detox 20.12.2 → 20.14.0-smoke.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.12.2/detox-20.12.2-javadoc.jar → 20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.12.2/detox-20.12.2-sources.jar → 20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.12.2/detox-20.12.2.pom → 20.14.0-smoke.0/detox-20.14.0-smoke.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/android/detox/src/full/java/com/wix/detox/ActivityLaunchHelper.kt +76 -0
- package/android/detox/src/full/java/com/wix/detox/Detox.java +8 -64
- package/android/detox/src/full/java/com/wix/detox/DetoxMain.kt +58 -16
- package/android/detox/src/full/java/com/wix/detox/LaunchIntentsFactory.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxActionHandlers.kt +15 -4
- package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxServerInfo.kt +4 -2
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactMarkersLogger.kt +44 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +28 -21
- package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +0 -3
- package/local-cli/reset-lock-file.js +5 -9
- package/package.json +5 -6
- package/runners/jest/testEnvironment/index.js +1 -1
- package/src/DetoxWorker.js +5 -11
- package/src/android/espressoapi/Detox.js +0 -11
- package/src/artifacts/providers/index.js +3 -3
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +0 -17
- package/src/configuration/composeLoggerConfig.js +1 -0
- package/src/devices/allocation/DeviceAllocator.js +66 -20
- package/src/devices/allocation/DeviceList.js +44 -0
- package/src/devices/allocation/DeviceRegistry.js +189 -0
- package/src/devices/allocation/drivers/AllocationDriverBase.d.ts +15 -0
- package/src/devices/{common/drivers/android/tools → allocation/drivers/android}/FreeDeviceFinder.js +11 -10
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +22 -17
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +97 -38
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +32 -45
- package/src/devices/allocation/drivers/android/emulator/FreeEmulatorFinder.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/FreePortFinder.js +37 -0
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -3
- package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +104 -32
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceLauncher.js +40 -31
- package/src/devices/allocation/drivers/android/genycloud/GenyRegistry.js +121 -0
- package/src/devices/allocation/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +24 -0
- package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyInstance.js +83 -0
- package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyRecipe.js +25 -0
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +94 -51
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +11 -7
- package/src/devices/allocation/drivers/ios/SimulatorQuery.js +24 -0
- package/src/devices/allocation/factories/android.js +29 -35
- package/src/devices/allocation/factories/ios.js +7 -5
- package/src/devices/common/drivers/DeviceCookie.d.ts +12 -0
- package/src/devices/common/drivers/android/cookies.d.ts +11 -0
- package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +17 -5
- package/src/devices/common/drivers/android/exec/ADB.js +1 -0
- package/src/devices/common/drivers/ios/cookies.d.ts +9 -0
- package/src/devices/cookies/index.js +0 -6
- package/src/devices/runtime/drivers/android/genycloud/GenyCloudDriver.js +7 -6
- package/src/devices/runtime/factories/android.js +3 -11
- package/src/devices/runtime/factories/ios.js +3 -2
- package/src/{servicelocator → devices/servicelocator}/android/emulatorServiceLocator.js +1 -1
- package/src/devices/servicelocator/android/genycloudServiceLocator.js +17 -0
- package/src/devices/servicelocator/android/index.js +23 -0
- package/src/{validation → devices/validation}/EnvironmentValidatorBase.js +1 -0
- package/src/{validation → devices/validation}/android/GenycloudEnvValidator.js +2 -2
- package/src/{validation → devices/validation}/factories/index.js +1 -1
- package/src/{validation → devices/validation}/ios/IosSimulatorEnvValidator.js +2 -2
- package/src/environmentFactory.js +1 -11
- package/src/ipc/IPCClient.js +17 -1
- package/src/ipc/IPCServer.js +27 -1
- package/src/logger/DetoxLogger.js +2 -2
- package/src/realms/DetoxContext.js +6 -0
- package/src/realms/DetoxPrimaryContext.js +42 -42
- package/src/realms/DetoxSecondaryContext.js +19 -0
- package/src/realms/symbols.js +4 -0
- package/src/utils/PIDService.js +27 -0
- package/src/utils/environment.js +8 -15
- package/src/utils/errorUtils.js +2 -2
- package/tsconfig.json +5 -3
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.aar +0 -0
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.12.2/detox-20.12.2.pom.sha512 +0 -1
- package/src/devices/DeviceRegistry.js +0 -176
- package/src/devices/allocation/drivers/AllocationDriverBase.js +0 -30
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidLauncher.js +0 -13
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +0 -72
- package/src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory.js +0 -16
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +0 -65
- package/src/devices/common/drivers/DeviceAllocationHelper.js +0 -20
- package/src/devices/common/drivers/DeviceLauncher.js +0 -19
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +0 -25
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLookupService.js +0 -38
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +0 -14
- package/src/devices/common/drivers/android/genycloud/services/dto/GenyInstance.js +0 -66
- package/src/devices/common/drivers/android/genycloud/services/dto/GenyRecipe.js +0 -13
- package/src/devices/cookies/AndroidDeviceCookie.js +0 -13
- package/src/devices/cookies/AndroidEmulatorCookie.js +0 -6
- package/src/devices/cookies/AttachedAndroidDeviceCookie.js +0 -12
- package/src/devices/cookies/DeviceCookie.js +0 -4
- package/src/devices/cookies/GenycloudEmulatorCookie.js +0 -20
- package/src/devices/cookies/IosCookie.js +0 -6
- package/src/devices/cookies/IosSimulatorCookie.js +0 -10
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +0 -71
- package/src/devices/lifecycle/factories/GenyGlobalLifecycleHandlerFactory.js +0 -18
- package/src/servicelocator/android/genycloudServiceLocator.js +0 -21
- package/src/servicelocator/android/index.js +0 -25
- package/src/servicelocator/ios.js +0 -7
- /package/src/devices/{common → allocation}/drivers/android/genycloud/exec/GenyCloudExec.js +0 -0
- /package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyAuthService.js +0 -0
@@ -2,16 +2,18 @@
|
|
2
2
|
const DeviceAllocatorFactory = require('./base');
|
3
3
|
|
4
4
|
class IosSimulator extends DeviceAllocatorFactory {
|
5
|
-
_createDriver({ eventEmitter }) {
|
6
|
-
const
|
7
|
-
const applesimutils =
|
8
|
-
|
5
|
+
_createDriver({ detoxConfig, detoxSession, eventEmitter }) {
|
6
|
+
const AppleSimUtils = require('../../../devices/common/drivers/ios/tools/AppleSimUtils');
|
7
|
+
const applesimutils = new AppleSimUtils();
|
8
|
+
|
9
|
+
const DeviceRegistry = require('../../../devices/allocation/DeviceRegistry');
|
10
|
+
const deviceRegistry = new DeviceRegistry({ sessionId: detoxSession.id });
|
9
11
|
|
10
12
|
const SimulatorLauncher = require('../drivers/ios/SimulatorLauncher');
|
11
13
|
const simulatorLauncher = new SimulatorLauncher({ applesimutils, eventEmitter });
|
12
14
|
|
13
15
|
const SimulatorAllocDriver = require('../drivers/ios/SimulatorAllocDriver');
|
14
|
-
return new SimulatorAllocDriver({ deviceRegistry, applesimutils, simulatorLauncher });
|
16
|
+
return new SimulatorAllocDriver({ detoxConfig, deviceRegistry, applesimutils, simulatorLauncher });
|
15
17
|
}
|
16
18
|
}
|
17
19
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/* eslint-disable import/no-unresolved,node/no-missing-import,node/no-unsupported-features/es-syntax */
|
2
|
+
|
3
|
+
/**
|
4
|
+
* A serializable object that represents a device.
|
5
|
+
*/
|
6
|
+
export interface DeviceCookie {
|
7
|
+
/** The device's unique identifier. */
|
8
|
+
id: string;
|
9
|
+
/** The display name of the device. */
|
10
|
+
name?: string;
|
11
|
+
}
|
12
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/* eslint-disable import/no-unresolved,node/no-missing-import,node/no-unsupported-features/es-syntax */
|
2
|
+
import GenyInstance from '../../../allocation/drivers/android/genycloud/services/dto/GenyInstance';
|
3
|
+
import { DeviceCookie } from '../DeviceCookie';
|
4
|
+
|
5
|
+
interface AndroidDeviceCookie extends DeviceCookie {
|
6
|
+
adbName: string;
|
7
|
+
}
|
8
|
+
|
9
|
+
interface GenycloudEmulatorCookie extends AndroidDeviceCookie {
|
10
|
+
instance: GenyInstance;
|
11
|
+
}
|
@@ -32,19 +32,31 @@ class QueryVersionCommand extends ExecCommand {
|
|
32
32
|
}
|
33
33
|
|
34
34
|
class LaunchCommand extends ExecCommand {
|
35
|
-
constructor(
|
35
|
+
constructor(options) {
|
36
36
|
super();
|
37
37
|
this._options = options;
|
38
|
-
this._args = this._getEmulatorArgs(
|
39
|
-
|
38
|
+
this._args = this._getEmulatorArgs();
|
39
|
+
}
|
40
|
+
|
41
|
+
get adbName() {
|
42
|
+
return this._options.adbName;
|
43
|
+
}
|
44
|
+
|
45
|
+
get avdName() {
|
46
|
+
return this._options.avdName;
|
47
|
+
}
|
48
|
+
|
49
|
+
get port() {
|
50
|
+
return this._options.port;
|
40
51
|
}
|
41
52
|
|
42
53
|
_getArgs() {
|
43
54
|
return this._args;
|
44
55
|
}
|
45
56
|
|
46
|
-
_getEmulatorArgs(
|
57
|
+
_getEmulatorArgs() {
|
47
58
|
const {
|
59
|
+
avdName,
|
48
60
|
bootArgs,
|
49
61
|
gpuMode = this._getDefaultGPUMode(),
|
50
62
|
headless,
|
@@ -64,7 +76,7 @@ class LaunchCommand extends ExecCommand {
|
|
64
76
|
port ? '-port' : '',
|
65
77
|
port ? `${port}` : '',
|
66
78
|
...deviceBootArgs,
|
67
|
-
`@${
|
79
|
+
`@${avdName}`
|
68
80
|
]);
|
69
81
|
|
70
82
|
return emulatorArgs;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/* eslint-disable import/no-unresolved,node/no-missing-import,node/no-unsupported-features/es-syntax */
|
2
|
+
import { DeviceCookie } from '../DeviceCookie';
|
3
|
+
|
4
|
+
interface IosSimulatorCookie extends DeviceCookie {
|
5
|
+
udid: string;
|
6
|
+
type?: string;
|
7
|
+
bootArgs?: string;
|
8
|
+
headless?: boolean;
|
9
|
+
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
IosSimulatorCookie: require('./IosSimulatorCookie'),
|
3
|
-
AttachedAndroidDeviceCookie: require('./AttachedAndroidDeviceCookie'),
|
4
|
-
AndroidEmulatorCookie: require('./AndroidEmulatorCookie'),
|
5
|
-
GenycloudEmulatorCookie: require('./GenycloudEmulatorCookie'),
|
6
|
-
};
|
@@ -8,21 +8,22 @@ const AndroidDriver = require('../AndroidDriver');
|
|
8
8
|
|
9
9
|
/**
|
10
10
|
* @typedef GenycloudDriverProps
|
11
|
-
* @property
|
11
|
+
* @property adbName { GenyInstance } The DTO associated with the cloud instance
|
12
12
|
*/
|
13
13
|
|
14
14
|
class GenyCloudDriver extends AndroidDriver {
|
15
15
|
/**
|
16
16
|
* @param deps { GenycloudDriverDeps }
|
17
|
-
* @param props {
|
17
|
+
* @param props { GenycloudEmulatorCookie }
|
18
18
|
*/
|
19
|
-
constructor(deps, {
|
20
|
-
super(deps, { adbName
|
21
|
-
|
19
|
+
constructor(deps, { adbName, name }) {
|
20
|
+
super(deps, { adbName });
|
21
|
+
|
22
|
+
this._instanceName = name;
|
22
23
|
}
|
23
24
|
|
24
25
|
getDeviceName() {
|
25
|
-
return this.
|
26
|
+
return this._instanceName;
|
26
27
|
}
|
27
28
|
|
28
29
|
async setLocation(lat, lon) {
|
@@ -3,7 +3,7 @@ const RuntimeDeviceFactory = require('./base');
|
|
3
3
|
|
4
4
|
class RuntimeDriverFactoryAndroid extends RuntimeDeviceFactory {
|
5
5
|
_createDriverDependencies(commonDeps) {
|
6
|
-
const serviceLocator = require('
|
6
|
+
const serviceLocator = require('../../servicelocator/android');
|
7
7
|
const adb = serviceLocator.adb;
|
8
8
|
const aapt = serviceLocator.aapt;
|
9
9
|
const apkValidator = serviceLocator.apkValidator;
|
@@ -43,23 +43,15 @@ class AndroidEmulator extends RuntimeDriverFactoryAndroid {
|
|
43
43
|
|
44
44
|
class AndroidAttached extends RuntimeDriverFactoryAndroid {
|
45
45
|
_createDriver(deviceCookie, deps, configs) {
|
46
|
-
const props = {
|
47
|
-
adbName: deviceCookie.adbName,
|
48
|
-
};
|
49
|
-
|
50
46
|
const { AttachedAndroidRuntimeDriver } = require('../drivers');
|
51
|
-
return new AttachedAndroidRuntimeDriver(deps,
|
47
|
+
return new AttachedAndroidRuntimeDriver(deps, deviceCookie);
|
52
48
|
}
|
53
49
|
}
|
54
50
|
|
55
51
|
class Genycloud extends RuntimeDriverFactoryAndroid {
|
56
52
|
_createDriver(deviceCookie, deps, configs) {
|
57
|
-
const props = {
|
58
|
-
instance: deviceCookie.instance,
|
59
|
-
};
|
60
|
-
|
61
53
|
const { GenycloudRuntimeDriver } = require('../drivers');
|
62
|
-
return new GenycloudRuntimeDriver(deps,
|
54
|
+
return new GenycloudRuntimeDriver(deps, deviceCookie);
|
63
55
|
}
|
64
56
|
}
|
65
57
|
|
@@ -2,10 +2,11 @@ const RuntimeDeviceFactory = require('./base');
|
|
2
2
|
|
3
3
|
class RuntimeDriverFactoryIos extends RuntimeDeviceFactory {
|
4
4
|
_createDriverDependencies(commonDeps) {
|
5
|
-
const serviceLocator = require('../../../servicelocator/ios');
|
6
|
-
const applesimutils = serviceLocator.appleSimUtils;
|
7
5
|
const { eventEmitter } = commonDeps;
|
8
6
|
|
7
|
+
const AppleSimUtils = require('../../../devices/common/drivers/ios/tools/AppleSimUtils');
|
8
|
+
const applesimutils = new AppleSimUtils();
|
9
|
+
|
9
10
|
const SimulatorLauncher = require('../../allocation/drivers/ios/SimulatorLauncher');
|
10
11
|
return {
|
11
12
|
...commonDeps,
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class GenycloudServiceLocator {
|
2
|
+
constructor() {
|
3
|
+
this._exec = null;
|
4
|
+
}
|
5
|
+
|
6
|
+
// Note: important to keep lazy because of implicit validations that are sensitive (inside environment, in particular).
|
7
|
+
get exec() {
|
8
|
+
if (!this._exec) {
|
9
|
+
const Exec = require('../../allocation/drivers/android/genycloud/exec/GenyCloudExec');
|
10
|
+
const environment = require('../../../utils/environment');
|
11
|
+
this._exec = new Exec(environment.getGmsaasPath());
|
12
|
+
}
|
13
|
+
return this._exec;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
module.exports = new GenycloudServiceLocator();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const AndroidDevicePathBuilder = require('../../../artifacts/utils/AndroidDevicePathBuilder');
|
2
|
+
const AAPT = require('../../common/drivers/android/exec/AAPT');
|
3
|
+
const ADB = require('../../common/drivers/android/exec/ADB');
|
4
|
+
const ApkValidator = require('../../common/drivers/android/tools/ApkValidator');
|
5
|
+
const { TempFileTransfer } = require('../../common/drivers/android/tools/TempFileTransfer');
|
6
|
+
|
7
|
+
const AndroidServiceLocator = {
|
8
|
+
get emulator() {
|
9
|
+
return require('./emulatorServiceLocator');
|
10
|
+
},
|
11
|
+
|
12
|
+
get genycloud() {
|
13
|
+
return require('./genycloudServiceLocator');
|
14
|
+
},
|
15
|
+
};
|
16
|
+
|
17
|
+
AndroidServiceLocator.adb = new ADB();
|
18
|
+
AndroidServiceLocator.aapt = new AAPT();
|
19
|
+
AndroidServiceLocator.apkValidator = new ApkValidator(AndroidServiceLocator.aapt);
|
20
|
+
AndroidServiceLocator.fileTransfer = new TempFileTransfer(AndroidServiceLocator.adb);
|
21
|
+
AndroidServiceLocator.devicePathBuilder = new AndroidDevicePathBuilder();
|
22
|
+
|
23
|
+
module.exports = AndroidServiceLocator;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
// @ts-nocheck
|
2
2
|
const semver = require('semver');
|
3
3
|
|
4
|
-
const DetoxRuntimeError = require('
|
5
|
-
const environment = require('
|
4
|
+
const { DetoxRuntimeError } = require('../../../errors');
|
5
|
+
const environment = require('../../../utils/environment');
|
6
6
|
const EnvironmentValidatorBase = require('../EnvironmentValidatorBase');
|
7
7
|
|
8
8
|
const MIN_GMSAAS_VERSION = '1.6.0';
|
@@ -7,7 +7,7 @@ class Genycloud extends EnvValidatorFactory {
|
|
7
7
|
const serviceLocator = require('../../servicelocator/android');
|
8
8
|
const exec = serviceLocator.genycloud.exec;
|
9
9
|
|
10
|
-
const GenyAuthService = require('../../
|
10
|
+
const GenyAuthService = require('../../allocation/drivers/android/genycloud/services/GenyAuthService');
|
11
11
|
const authService = new GenyAuthService(exec);
|
12
12
|
|
13
13
|
const GenycloudEnvValidator = require('../android/GenycloudEnvValidator');
|
@@ -1,7 +1,7 @@
|
|
1
1
|
const fs = require('fs');
|
2
2
|
|
3
|
-
const DetoxRuntimeError = require('
|
4
|
-
const environment = require('
|
3
|
+
const DetoxRuntimeError = require('../../../errors/DetoxRuntimeError');
|
4
|
+
const environment = require('../../../utils/environment');
|
5
5
|
const EnvironmentValidatorBase = require('../EnvironmentValidatorBase');
|
6
6
|
|
7
7
|
class IosSimulatorEnvValidator extends EnvironmentValidatorBase {
|
@@ -2,9 +2,9 @@
|
|
2
2
|
const artifactsManagerFactories = require('./artifacts/factories');
|
3
3
|
const deviceAllocationFactories = require('./devices/allocation/factories');
|
4
4
|
const runtimeDeviceFactories = require('./devices/runtime/factories');
|
5
|
+
const envValidationFactories = require('./devices/validation/factories');
|
5
6
|
const matchersFactories = require('./matchers/factories');
|
6
7
|
const resolveModuleFromPath = require('./utils/resolveModuleFromPath');
|
7
|
-
const envValidationFactories = require('./validation/factories');
|
8
8
|
|
9
9
|
function validateConfig(deviceConfig) {
|
10
10
|
const classes = _getFactoryClasses(deviceConfig);
|
@@ -36,15 +36,6 @@ function createFactories(deviceConfig) {
|
|
36
36
|
return _getExternalModuleFactories(deviceConfig);
|
37
37
|
}
|
38
38
|
|
39
|
-
function createGlobalLifecycleHandler(deviceConfig) {
|
40
|
-
if (deviceConfig.type === 'android.genycloud') {
|
41
|
-
const FactoryClass = require('./devices/lifecycle/factories/GenyGlobalLifecycleHandlerFactory');
|
42
|
-
const factory = new FactoryClass();
|
43
|
-
return factory.createHandler();
|
44
|
-
}
|
45
|
-
return null;
|
46
|
-
}
|
47
|
-
|
48
39
|
function _getFactoryClasses(deviceConfig) {
|
49
40
|
let envValidatorFactoryClass;
|
50
41
|
let artifactsManagerFactoryClass;
|
@@ -115,5 +106,4 @@ function _getExternalModuleFactories(deviceConfig) {
|
|
115
106
|
module.exports = {
|
116
107
|
validateConfig,
|
117
108
|
createFactories,
|
118
|
-
createGlobalLifecycleHandler,
|
119
109
|
};
|
package/src/ipc/IPCClient.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
const { IPC } = require('node-ipc');
|
2
2
|
|
3
3
|
const { DetoxInternalError } = require('../errors');
|
4
|
-
const { serializeObjectWithError } = require('../utils/errorUtils');
|
4
|
+
const { serializeObjectWithError, deserializeObjectWithError } = require('../utils/errorUtils');
|
5
5
|
|
6
6
|
class IPCClient {
|
7
7
|
constructor({ id, logger, sessionState }) {
|
@@ -60,6 +60,22 @@ class IPCClient {
|
|
60
60
|
this._sessionState.patch(sessionState);
|
61
61
|
}
|
62
62
|
|
63
|
+
async allocateDevice() {
|
64
|
+
const { deviceCookie, error } = deserializeObjectWithError(await this._emit('allocateDevice', {}));
|
65
|
+
if (error) {
|
66
|
+
throw error;
|
67
|
+
}
|
68
|
+
|
69
|
+
return deviceCookie;
|
70
|
+
}
|
71
|
+
|
72
|
+
async deallocateDevice(deviceCookie) {
|
73
|
+
const { error } = deserializeObjectWithError(await this._emit('deallocateDevice', { deviceCookie }));
|
74
|
+
if (error) {
|
75
|
+
throw error;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
63
79
|
/**
|
64
80
|
* @param {DetoxInternals.DetoxTestFileReport[]} testResults
|
65
81
|
*/
|
package/src/ipc/IPCServer.js
CHANGED
@@ -8,11 +8,15 @@ class IPCServer {
|
|
8
8
|
* @param {object} options
|
9
9
|
* @param {import('./SessionState')} options.sessionState
|
10
10
|
* @param {Detox.Logger} options.logger
|
11
|
+
* @param {object} options.callbacks
|
12
|
+
* @param {() => Promise<any>} options.callbacks.onAllocateDevice
|
13
|
+
* @param {(cookie: any) => Promise<void>} options.callbacks.onDeallocateDevice
|
11
14
|
*/
|
12
|
-
constructor({ sessionState, logger }) {
|
15
|
+
constructor({ sessionState, logger, callbacks }) {
|
13
16
|
this._sessionState = sessionState;
|
14
17
|
this._logger = logger.child({ cat: 'ipc,ipc-server' });
|
15
18
|
this._ipc = null;
|
19
|
+
this._callbacks = callbacks;
|
16
20
|
this._workers = new Set();
|
17
21
|
this._contexts = new Set();
|
18
22
|
}
|
@@ -42,6 +46,8 @@ class IPCServer {
|
|
42
46
|
this._ipc.server.on('registerContext', this.onRegisterContext.bind(this));
|
43
47
|
this._ipc.server.on('registerWorker', this.onRegisterWorker.bind(this));
|
44
48
|
this._ipc.server.on('reportTestResults', this.onReportTestResults.bind(this));
|
49
|
+
this._ipc.server.on('allocateDevice', this.onAllocateDevice.bind(this));
|
50
|
+
this._ipc.server.on('deallocateDevice', this.onDeallocateDevice.bind(this));
|
45
51
|
this._ipc.server.start();
|
46
52
|
});
|
47
53
|
}
|
@@ -96,6 +102,26 @@ class IPCServer {
|
|
96
102
|
this._ipc.server.broadcast('sessionStateUpdate', newState);
|
97
103
|
}
|
98
104
|
|
105
|
+
async onAllocateDevice(_payload, socket) {
|
106
|
+
let deviceCookie;
|
107
|
+
|
108
|
+
try {
|
109
|
+
deviceCookie = await this._callbacks.onAllocateDevice();
|
110
|
+
this._ipc.server.emit(socket, 'allocateDeviceDone', { deviceCookie });
|
111
|
+
} catch (error) {
|
112
|
+
this._ipc.server.emit(socket, 'allocateDeviceDone', serializeObjectWithError({ error }));
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
async onDeallocateDevice({ deviceCookie }, socket) {
|
117
|
+
try {
|
118
|
+
await this._callbacks.onDeallocateDevice(deviceCookie);
|
119
|
+
this._ipc.server.emit(socket, 'deallocateDeviceDone', {});
|
120
|
+
} catch (error) {
|
121
|
+
this._ipc.server.emit(socket, 'deallocateDeviceDone', serializeObjectWithError({ error }));
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
99
125
|
onReportTestResults({ testResults }, socket = null) {
|
100
126
|
const merged = uniqBy([
|
101
127
|
...testResults.map(r => serializeObjectWithError(r, 'testExecError')),
|
@@ -249,7 +249,7 @@ class DetoxLogger {
|
|
249
249
|
_complete(level, maybeContext, maybeMessage, maybeAction) {
|
250
250
|
const action = typeof maybeContext !== 'string' ? maybeAction : maybeMessage;
|
251
251
|
const args = maybeAction === action ? [maybeContext, maybeMessage] : [maybeContext];
|
252
|
-
const { context, msg } = this._parseArgs(
|
252
|
+
const { context, msg } = this._parseArgs({ ph: 'B' }, args);
|
253
253
|
const end = (ctx) => this[level].end({
|
254
254
|
id: context.id,
|
255
255
|
cat: context.cat,
|
@@ -257,7 +257,7 @@ class DetoxLogger {
|
|
257
257
|
});
|
258
258
|
|
259
259
|
let result;
|
260
|
-
this._beginInternal(level,
|
260
|
+
this._beginInternal(level, context, msg);
|
261
261
|
try {
|
262
262
|
result = typeof action === 'function'
|
263
263
|
? action()
|
@@ -151,6 +151,12 @@ class DetoxContext {
|
|
151
151
|
await this[$worker].init();
|
152
152
|
}
|
153
153
|
|
154
|
+
/** @abstract */
|
155
|
+
async [symbols.allocateDevice]() {}
|
156
|
+
|
157
|
+
/** @abstract */
|
158
|
+
async [symbols.deallocateDevice]() {}
|
159
|
+
|
154
160
|
async [symbols.uninstallWorker]() {
|
155
161
|
try {
|
156
162
|
if (this[$worker]) {
|
@@ -16,15 +16,14 @@ const symbols = require('./symbols');
|
|
16
16
|
const { $logFinalizer, $restoreSessionState, $sessionState, $worker } = DetoxContext.protected;
|
17
17
|
|
18
18
|
//#region Private symbols
|
19
|
-
const _globalLifecycleHandler = Symbol('globalLifecycleHandler');
|
20
19
|
const _ipcServer = Symbol('ipcServer');
|
21
|
-
const _resetLockFile = Symbol('resetLockFile');
|
22
20
|
const _wss = Symbol('wss');
|
23
21
|
const _dirty = Symbol('dirty');
|
24
22
|
const _emergencyTeardown = Symbol('emergencyTeardown');
|
25
23
|
const _lifecycleLogger = Symbol('lifecycleLogger');
|
26
24
|
const _sessionFile = Symbol('sessionFile');
|
27
25
|
const _logFinalError = Symbol('logFinalError');
|
26
|
+
const _deviceAllocator = Symbol('deviceAllocator');
|
28
27
|
//#endregion
|
29
28
|
|
30
29
|
class DetoxPrimaryContext extends DetoxContext {
|
@@ -33,7 +32,8 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
33
32
|
|
34
33
|
this[_dirty] = false;
|
35
34
|
this[_wss] = null;
|
36
|
-
this[
|
35
|
+
this[_deviceAllocator] = null;
|
36
|
+
|
37
37
|
/** Path to file where the initial session object is serialized */
|
38
38
|
this[_sessionFile] = '';
|
39
39
|
/**
|
@@ -85,7 +85,6 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
85
85
|
const detoxConfig = await this[symbols.resolveConfig](opts);
|
86
86
|
|
87
87
|
const {
|
88
|
-
behavior: behaviorConfig,
|
89
88
|
device: deviceConfig,
|
90
89
|
logger: loggerConfig,
|
91
90
|
session: sessionConfig
|
@@ -102,20 +101,23 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
102
101
|
this[_ipcServer] = new IPCServer({
|
103
102
|
sessionState: this[$sessionState],
|
104
103
|
logger: this[symbols.logger],
|
104
|
+
callbacks: {
|
105
|
+
onAllocateDevice: this[symbols.allocateDevice].bind(this),
|
106
|
+
onDeallocateDevice: this[symbols.deallocateDevice].bind(this),
|
107
|
+
},
|
105
108
|
});
|
106
109
|
|
107
110
|
await this[_ipcServer].init();
|
108
111
|
|
109
112
|
const environmentFactory = require('../environmentFactory');
|
110
|
-
this[_globalLifecycleHandler] = await environmentFactory.createGlobalLifecycleHandler(deviceConfig);
|
111
113
|
|
112
|
-
|
113
|
-
|
114
|
-
|
114
|
+
const { deviceAllocatorFactory } = environmentFactory.createFactories(deviceConfig);
|
115
|
+
this[_deviceAllocator] = deviceAllocatorFactory.createDeviceAllocator({
|
116
|
+
detoxConfig,
|
117
|
+
detoxSession: this[$sessionState],
|
118
|
+
});
|
115
119
|
|
116
|
-
|
117
|
-
await this[_resetLockFile]();
|
118
|
-
}
|
120
|
+
await this[_deviceAllocator].init();
|
119
121
|
|
120
122
|
// TODO: Detox-server creation ought to be delegated to a generator/factory.
|
121
123
|
const DetoxServer = require('../server/DetoxServer');
|
@@ -159,6 +161,29 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
159
161
|
await super[symbols.installWorker]({ ...opts, workerId });
|
160
162
|
}
|
161
163
|
|
164
|
+
/** @override */
|
165
|
+
async [symbols.allocateDevice]() {
|
166
|
+
const { device } = this[$sessionState].detoxConfig;
|
167
|
+
const deviceCookie = await this[_deviceAllocator].allocate(device);
|
168
|
+
|
169
|
+
try {
|
170
|
+
return await this[_deviceAllocator].postAllocate(deviceCookie);
|
171
|
+
} catch (e) {
|
172
|
+
try {
|
173
|
+
await this[_deviceAllocator].free(deviceCookie, { shutdown: true });
|
174
|
+
} catch (e2) {
|
175
|
+
this[symbols.logger].error({ cat: 'device', err: e2 }, `Failed to free ${deviceCookie.name || deviceCookie.id} after a failed allocation`);
|
176
|
+
}
|
177
|
+
|
178
|
+
throw e;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
/** @override */
|
183
|
+
async [symbols.deallocateDevice](cookie) {
|
184
|
+
await this[_deviceAllocator].free(cookie);
|
185
|
+
}
|
186
|
+
|
162
187
|
/** @override */
|
163
188
|
async [symbols.cleanup]() {
|
164
189
|
try {
|
@@ -166,9 +191,9 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
166
191
|
await this[symbols.uninstallWorker]();
|
167
192
|
}
|
168
193
|
} finally {
|
169
|
-
if (this[
|
170
|
-
await this[
|
171
|
-
this[
|
194
|
+
if (this[_deviceAllocator]) {
|
195
|
+
await this[_deviceAllocator].cleanup();
|
196
|
+
this[_deviceAllocator] = null;
|
172
197
|
}
|
173
198
|
|
174
199
|
if (this[_wss]) {
|
@@ -202,9 +227,9 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
202
227
|
return;
|
203
228
|
}
|
204
229
|
|
205
|
-
if (this[
|
206
|
-
this[
|
207
|
-
this[
|
230
|
+
if (this[_deviceAllocator]) {
|
231
|
+
this[_deviceAllocator].emergencyCleanup();
|
232
|
+
this[_deviceAllocator] = null;
|
208
233
|
}
|
209
234
|
|
210
235
|
if (this[_wss]) {
|
@@ -247,31 +272,6 @@ class DetoxPrimaryContext extends DetoxContext {
|
|
247
272
|
});
|
248
273
|
}
|
249
274
|
//#endregion
|
250
|
-
|
251
|
-
//#region Private members
|
252
|
-
async[_resetLockFile]() {
|
253
|
-
const DeviceRegistry = require('../devices/DeviceRegistry');
|
254
|
-
|
255
|
-
const deviceType = this[symbols.config].device.type;
|
256
|
-
|
257
|
-
switch (deviceType) {
|
258
|
-
case 'ios.none':
|
259
|
-
case 'ios.simulator':
|
260
|
-
await DeviceRegistry.forIOS().reset();
|
261
|
-
break;
|
262
|
-
case 'android.attached':
|
263
|
-
case 'android.emulator':
|
264
|
-
case 'android.genycloud':
|
265
|
-
await DeviceRegistry.forAndroid().reset();
|
266
|
-
break;
|
267
|
-
}
|
268
|
-
|
269
|
-
if (deviceType === 'android.genycloud') {
|
270
|
-
const GenyDeviceRegistryFactory = require('../devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory');
|
271
|
-
await GenyDeviceRegistryFactory.forGlobalShutdown().reset();
|
272
|
-
}
|
273
|
-
}
|
274
|
-
//#endregion
|
275
275
|
}
|
276
276
|
|
277
277
|
module.exports = DetoxPrimaryContext;
|
@@ -62,6 +62,25 @@ class DetoxSecondaryContext extends DetoxContext {
|
|
62
62
|
}
|
63
63
|
}
|
64
64
|
|
65
|
+
/** @override */
|
66
|
+
async [symbols.allocateDevice]() {
|
67
|
+
if (this[_ipcClient]) {
|
68
|
+
const deviceCookie = await this[_ipcClient].allocateDevice();
|
69
|
+
return deviceCookie;
|
70
|
+
} else {
|
71
|
+
throw new DetoxInternalError('Detected an attempt to allocate a device using a non-initialized context.');
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
/** @override */
|
76
|
+
async [symbols.deallocateDevice](deviceCookie) {
|
77
|
+
if (this[_ipcClient]) {
|
78
|
+
await this[_ipcClient].deallocateDevice(deviceCookie);
|
79
|
+
} else {
|
80
|
+
throw new DetoxInternalError('Detected an attempt to allocate a device using a non-initialized context.');
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
65
84
|
/** @override */
|
66
85
|
async [symbols.cleanup]() {
|
67
86
|
try {
|
package/src/realms/symbols.js
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
* readonly getStatus: unique symbol;
|
6
6
|
* readonly init: unique symbol;
|
7
7
|
* readonly installWorker: unique symbol;
|
8
|
+
* readonly allocateDevice: unique symbol;
|
9
|
+
* readonly deallocateDevice: unique symbol;
|
8
10
|
* readonly logger: unique symbol;
|
9
11
|
* readonly onHookFailure: unique symbol;
|
10
12
|
* readonly onRunDescribeFinish: unique symbol;
|
@@ -34,6 +36,8 @@ module.exports = {
|
|
34
36
|
//#region IPC
|
35
37
|
reportTestResults: Symbol('reportTestResults'),
|
36
38
|
conductEarlyTeardown: Symbol('conductEarlyTeardown'),
|
39
|
+
allocateDevice: Symbol('allocateDevice'),
|
40
|
+
deallocateDevice: Symbol('deallocateDevice'),
|
37
41
|
//#endregion
|
38
42
|
|
39
43
|
//#region Main
|