detox 21.0.0-rc.0 → 21.0.0-rc.10
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +3 -0
- package/.eslintrc.js +1 -40
- package/Detox-android/com/wix/detox/{21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar → 21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar → 21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.0/detox-21.0.0-rc.0.pom → 21.0.0-rc.10/detox-21.0.0-rc.10.pom} +1 -7
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.10/detox-21.0.0-rc.10.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-framework.tbz +0 -0
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios-xcuitest.tbz +0 -0
- package/android/build.gradle +20 -10
- package/android/detox/build.gradle +24 -12
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAssertion.java +44 -25
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +12 -12
- package/android/detox/src/full/java/com/wix/detox/espresso/EspressoDetox.java +6 -7
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +2 -2
- package/android/detox/src/full/java/com/wix/detox/espresso/action/GetAttributesAction.kt +34 -35
- package/android/detox/src/full/java/com/wix/detox/espresso/common/MaterialSliderHelper.kt +21 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/common/{SliderHelper.kt → ReactSliderHelper.kt} +7 -6
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/RegexMatcher.kt +56 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +18 -6
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/MultipleViewsActionPerformer.kt +43 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/SingleViewActionPerformer.kt +19 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/ViewActionPerformer.kt +24 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +4 -4
- package/android/detox/src/full/java/com/wix/invoke/types/Invocation.java +7 -6
- package/android/detox/src/main/java/com/wix/detox/espresso/MultipleViewsAction.kt +4 -0
- package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +0 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/ViewActionWithResult.kt +2 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/MotionEvents.kt +60 -4
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +6 -5
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/MaterialSliderHelperTest.kt +33 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/{SliderHelperTest.kt → ReactSliderHelperTest.kt} +3 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/RegexMatcherTest.kt +52 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/performer/ViewActionPerformerSpec.kt +37 -0
- package/android/detox/src/testFull/java/com/wix/invoke/JsonParserTest.java +23 -7
- package/android/detox/src/testFull/resources/targetInvocationEspressoWebDetoxScript.json +47 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/rninfo.gradle +25 -0
- package/android/settings.gradle +2 -1
- package/detox.d.ts +1840 -0
- package/globals.d.ts +23 -0
- package/index.d.ts +2 -1789
- package/internals.d.ts +11 -1
- package/jest.config.js +108 -0
- package/local-cli/reset-lock-file.js +5 -9
- package/local-cli/startCommand/AppStartCommand.js +4 -1
- package/local-cli/testCommand/TestRunnerCommand.js +26 -3
- package/local-cli/utils/interruptListeners.js +15 -0
- package/package.json +15 -108
- package/runners/jest/reporter.js +21 -1
- package/runners/jest/reporters/DetoxIPCReporter.js +34 -0
- package/runners/jest/reporters/DetoxReporterDispatcher.js +144 -0
- package/runners/jest/reporters/DetoxSummaryReporter.js +16 -0
- package/runners/jest/reporters/DetoxVerboseReporter.js +16 -0
- package/runners/jest/reporters/index.js +6 -0
- package/runners/jest/testEnvironment/index.js +11 -0
- package/src/DetoxWorker.js +5 -11
- package/src/android/core/NativeElement.js +26 -29
- package/src/android/core/WebElement.js +24 -6
- package/src/android/espressoapi/DetoxAssertion.js +16 -14
- package/src/android/espressoapi/DetoxMatcher.js +24 -8
- package/src/android/espressoapi/EspressoDetox.js +9 -2
- package/src/android/espressoapi/web/WebElement.js +1 -4
- package/src/android/interactions/native.js +2 -3
- package/src/android/matchers/index.js +4 -0
- package/src/android/matchers/native.js +9 -4
- package/src/android/matchers/web.js +26 -1
- 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/configuration/composeRunnerConfig.js +3 -1
- 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 +95 -54
- 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 +6 -7
- 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/android/tools/instrumentationArgs.js +7 -1
- package/src/devices/common/drivers/ios/cookies.d.ts +9 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +3 -1
- package/src/devices/cookies/index.js +0 -6
- package/src/devices/runtime/drivers/android/genycloud/GenyCloudDriver.js +7 -6
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +9 -24
- package/src/devices/runtime/drivers/ios/XCUITestUtils.js +33 -19
- package/src/devices/runtime/factories/android.js +3 -11
- package/src/devices/runtime/factories/ios.js +3 -4
- 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/invoke.js +0 -2
- package/src/ios/expectTwo.js +28 -11
- package/src/ios/web.js +302 -0
- package/src/ipc/IPCClient.js +22 -1
- package/src/ipc/IPCServer.js +42 -1
- package/src/ipc/SessionState.js +1 -0
- package/src/logger/DetoxLogger.js +2 -2
- package/src/realms/DetoxContext.js +8 -0
- package/src/realms/DetoxInternalsFacade.js +1 -0
- package/src/realms/DetoxPrimaryContext.js +49 -44
- package/src/realms/DetoxSecondaryContext.js +27 -0
- package/src/realms/symbols.js +6 -0
- package/src/utils/PIDService.js +27 -0
- package/src/utils/assertIsFunction.js +35 -0
- package/src/utils/environment.js +8 -15
- package/src/utils/errorUtils.js +3 -3
- package/src/utils/invocationTraceDescriptions.js +16 -0
- package/src/utils/isArrowFunction.js +24 -0
- package/src/utils/isRegExp.js +7 -0
- package/tsconfig.json +8 -3
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.0/detox-21.0.0-rc.0.pom.sha512 +0 -1
- package/runners/jest/reporters/DetoxReporter.js +0 -36
- 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/allocation/drivers/ios/SimulatorLauncher.js +0 -21
- 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/invoke/EarlGrey.js +0 -8
- 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
@@ -1,65 +0,0 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const logger = require('../../../../../utils/logger').child({ cat: 'device' });
|
3
|
-
const DeviceAllocationHelper = require('../../../../common/drivers/DeviceAllocationHelper');
|
4
|
-
|
5
|
-
const { ALLOCATE_DEVICE_LOG_EVT } = DeviceAllocationHelper;
|
6
|
-
|
7
|
-
class AllocationResult {
|
8
|
-
constructor(instance, isNew) {
|
9
|
-
this.instance = instance;
|
10
|
-
this.isNew = isNew;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
class GenyInstanceAllocationHelper extends DeviceAllocationHelper {
|
15
|
-
constructor({ deviceRegistry, instanceLookupService, instanceLifecycleService }) {
|
16
|
-
super(deviceRegistry, logger);
|
17
|
-
|
18
|
-
this._instanceLookupService = instanceLookupService;
|
19
|
-
this._instanceLifecycleService = instanceLifecycleService;
|
20
|
-
}
|
21
|
-
|
22
|
-
/**
|
23
|
-
* @param recipe { GenyRecipe }
|
24
|
-
* @return { Promise<AllocationResult> }
|
25
|
-
*/
|
26
|
-
async allocateDevice(recipe) {
|
27
|
-
this._logAllocationAttempt(recipe);
|
28
|
-
|
29
|
-
const allocationResult = await this._doSynchronizedAllocation(recipe);
|
30
|
-
this._logAllocationResult(recipe, allocationResult.instance);
|
31
|
-
|
32
|
-
return allocationResult;
|
33
|
-
}
|
34
|
-
|
35
|
-
async deallocateDevice(instanceUUID) {
|
36
|
-
await this._deviceRegistry.disposeDevice(instanceUUID);
|
37
|
-
}
|
38
|
-
|
39
|
-
/**
|
40
|
-
* @param recipe { GenyRecipe }
|
41
|
-
* @return {Promise<{AllocationResult}>}
|
42
|
-
* @private
|
43
|
-
*/
|
44
|
-
async _doSynchronizedAllocation(recipe) {
|
45
|
-
let instance = null;
|
46
|
-
let isNew = false;
|
47
|
-
|
48
|
-
await this._deviceRegistry.allocateDevice(async () => {
|
49
|
-
instance = await this._instanceLookupService.findFreeInstance();
|
50
|
-
if (!instance) {
|
51
|
-
instance = await this._instanceLifecycleService.createInstance(recipe.uuid);
|
52
|
-
isNew = true;
|
53
|
-
}
|
54
|
-
return instance.uuid;
|
55
|
-
});
|
56
|
-
|
57
|
-
return new AllocationResult(instance, isNew);
|
58
|
-
}
|
59
|
-
|
60
|
-
_logAllocationResult(deviceQuery, deviceHandle) {
|
61
|
-
logger.info({ event: ALLOCATE_DEVICE_LOG_EVT }, `Allocating Genymotion-Cloud instance ${deviceHandle.name} for testing. To access it via a browser, go to: https://cloud.geny.io/instance/${deviceHandle.uuid}`);
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
module.exports = GenyInstanceAllocationHelper;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
const DeviceLauncher = require('../../../common/drivers/DeviceLauncher');
|
2
|
-
|
3
|
-
class SimulatorLauncher extends DeviceLauncher {
|
4
|
-
constructor({ applesimutils, eventEmitter }) {
|
5
|
-
super(eventEmitter);
|
6
|
-
this._applesimutils = applesimutils;
|
7
|
-
}
|
8
|
-
|
9
|
-
async launch(udid, type, bootArgs, headless) {
|
10
|
-
const coldBoot = await this._applesimutils.boot(udid, bootArgs, headless);
|
11
|
-
await this._notifyBootEvent(udid, type, coldBoot, headless);
|
12
|
-
}
|
13
|
-
|
14
|
-
async shutdown(udid) {
|
15
|
-
await this._notifyPreShutdown(udid);
|
16
|
-
await this._applesimutils.shutdown(udid);
|
17
|
-
await this._notifyShutdownCompleted(udid);
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
module.exports = SimulatorLauncher;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
const ALLOCATE_DEVICE_LOG_EVT = 'ALLOCATE_DEVICE';
|
2
|
-
|
3
|
-
class DeviceAllocationHelper {
|
4
|
-
constructor(deviceRegistry, logger) {
|
5
|
-
this._deviceRegistry = deviceRegistry;
|
6
|
-
this._logger = logger;
|
7
|
-
}
|
8
|
-
|
9
|
-
_logAllocationAttempt(deviceQuery) {
|
10
|
-
this._logger.debug({ event: ALLOCATE_DEVICE_LOG_EVT }, `Trying to allocate a device based on "${deviceQuery}"`);
|
11
|
-
}
|
12
|
-
|
13
|
-
_logAllocationResult(deviceQuery, deviceHandle) {
|
14
|
-
this._logger.debug({ event: ALLOCATE_DEVICE_LOG_EVT }, `Settled on ${deviceHandle}`);
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
DeviceAllocationHelper.ALLOCATE_DEVICE_LOG_EVT = ALLOCATE_DEVICE_LOG_EVT;
|
19
|
-
|
20
|
-
module.exports = DeviceAllocationHelper;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class DeviceLauncher {
|
2
|
-
constructor(eventEmitter) {
|
3
|
-
this._eventEmitter = eventEmitter;
|
4
|
-
}
|
5
|
-
|
6
|
-
async _notifyPreShutdown(deviceId) {
|
7
|
-
return this._eventEmitter.emit('beforeShutdownDevice', { deviceId });
|
8
|
-
}
|
9
|
-
|
10
|
-
async _notifyShutdownCompleted(deviceId) {
|
11
|
-
return this._eventEmitter.emit('shutdownDevice', { deviceId });
|
12
|
-
}
|
13
|
-
|
14
|
-
async _notifyBootEvent(deviceId, type, coldBoot, headless) {
|
15
|
-
return this._eventEmitter.emit('bootDevice', { deviceId, type, coldBoot, headless });
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
module.exports = DeviceLauncher;
|
package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLifecycleService.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
const Instance = require('./dto/GenyInstance');
|
2
|
-
|
3
|
-
class GenyInstanceLifecycleService {
|
4
|
-
constructor(genyCloudExec, instanceNaming) {
|
5
|
-
this.genyCloudExec = genyCloudExec;
|
6
|
-
this.instanceNaming = instanceNaming;
|
7
|
-
}
|
8
|
-
|
9
|
-
async createInstance(recipeUUID) {
|
10
|
-
const result = await this.genyCloudExec.startInstance(recipeUUID, this.instanceNaming.generateName());
|
11
|
-
return new Instance(result.instance);
|
12
|
-
}
|
13
|
-
|
14
|
-
async adbConnectInstance(instanceUUID) {
|
15
|
-
const result = (await this.genyCloudExec.adbConnect(instanceUUID));
|
16
|
-
return new Instance(result.instance);
|
17
|
-
}
|
18
|
-
|
19
|
-
async deleteInstance(instanceUUID) {
|
20
|
-
const result = await this.genyCloudExec.stopInstance(instanceUUID);
|
21
|
-
return new Instance(result.instance);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
module.exports = GenyInstanceLifecycleService;
|
@@ -1,38 +0,0 @@
|
|
1
|
-
const Instance = require('./dto/GenyInstance');
|
2
|
-
|
3
|
-
class GenyInstanceLookupService {
|
4
|
-
constructor(genyCloudExec, instanceNaming, genyCloudDeviceRegistry) {
|
5
|
-
this.genyCloudExec = genyCloudExec;
|
6
|
-
this.instanceNaming = instanceNaming;
|
7
|
-
this.deviceRegistry = genyCloudDeviceRegistry;
|
8
|
-
}
|
9
|
-
|
10
|
-
async findFreeInstance() {
|
11
|
-
const freeInstances = await this._getRelevantInstances();
|
12
|
-
return (freeInstances[0] || null);
|
13
|
-
}
|
14
|
-
|
15
|
-
async getInstance(instanceUUID) {
|
16
|
-
const { instance } = await this.genyCloudExec.getInstance(instanceUUID);
|
17
|
-
return new Instance(instance);
|
18
|
-
}
|
19
|
-
|
20
|
-
async _getRelevantInstances() {
|
21
|
-
const takenInstances = this.deviceRegistry.getRegisteredDevices();
|
22
|
-
const isRelevant = (instance) =>
|
23
|
-
(instance.isOnline() || instance.isInitializing()) &&
|
24
|
-
this.instanceNaming.isFamilial(instance.name) &&
|
25
|
-
!takenInstances.includes(instance.uuid);
|
26
|
-
|
27
|
-
const instances = await this._getAllInstances();
|
28
|
-
return instances.filter(isRelevant);
|
29
|
-
}
|
30
|
-
|
31
|
-
async _getAllInstances() {
|
32
|
-
return (await this.genyCloudExec.getInstances())
|
33
|
-
.instances
|
34
|
-
.map((rawInstance) => new Instance(rawInstance));
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
module.exports = GenyInstanceLookupService;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
const internals = () => require('../../../../../../../internals');
|
2
|
-
|
3
|
-
class GenyInstanceNaming {
|
4
|
-
generateName() {
|
5
|
-
const { session, worker } = internals();
|
6
|
-
return `Detox.${session.id}.${worker.id}`;
|
7
|
-
}
|
8
|
-
|
9
|
-
isFamilial(name) {
|
10
|
-
return name === this.generateName();
|
11
|
-
}
|
12
|
-
}
|
13
|
-
|
14
|
-
module.exports = GenyInstanceNaming;
|
@@ -1,66 +0,0 @@
|
|
1
|
-
const Recipe = require('./GenyRecipe');
|
2
|
-
|
3
|
-
const STATE_ONLINE = 'ONLINE';
|
4
|
-
const STATE_CREATING = 'CREATING';
|
5
|
-
const STATE_BOOTING = 'BOOTING';
|
6
|
-
const STATE_STARTING = 'STARTING';
|
7
|
-
const initStates = new Set([
|
8
|
-
STATE_CREATING,
|
9
|
-
STATE_BOOTING,
|
10
|
-
STATE_STARTING,
|
11
|
-
]);
|
12
|
-
|
13
|
-
class GenyInstance {
|
14
|
-
constructor(rawInstance) {
|
15
|
-
this.uuid = rawInstance.uuid;
|
16
|
-
this.name = rawInstance.name;
|
17
|
-
|
18
|
-
/**
|
19
|
-
* According to Genymotion's API docs, state is an enum with these possible values (description is not official):
|
20
|
-
* - "CREATING": Handling instance creation request
|
21
|
-
* - "STARTING": Instance created but not yet available for usage
|
22
|
-
* - "BOOTING": Instance created & started; Android OS is not booting
|
23
|
-
* - "ONLINE": Instance is ready for action
|
24
|
-
* - "RECYCLED": Instance has been automatically shut down due an idle timeout
|
25
|
-
* - "STOPPING": Instance is being shut-down
|
26
|
-
*
|
27
|
-
* Additional states: "OFFLINE", "SAVING", "SAVED", "DELETING", "ERROR", "REVOKED", "EXPIRED".
|
28
|
-
*/
|
29
|
-
this.state = rawInstance.state;
|
30
|
-
this.adb = {
|
31
|
-
name: rawInstance.adb_serial,
|
32
|
-
port: rawInstance.adb_serial_port,
|
33
|
-
};
|
34
|
-
this.recipe = new Recipe(rawInstance.recipe);
|
35
|
-
}
|
36
|
-
|
37
|
-
isAdbConnected() {
|
38
|
-
return this.adb.name !== '0.0.0.0';
|
39
|
-
}
|
40
|
-
|
41
|
-
isOnline() {
|
42
|
-
return this.state === STATE_ONLINE;
|
43
|
-
}
|
44
|
-
|
45
|
-
isInitializing() {
|
46
|
-
return initStates.has(this.state);
|
47
|
-
}
|
48
|
-
|
49
|
-
get recipeName() {
|
50
|
-
return this.recipe.name;
|
51
|
-
}
|
52
|
-
|
53
|
-
get recipeUUID() {
|
54
|
-
return this.recipe.uuid;
|
55
|
-
}
|
56
|
-
|
57
|
-
get adbName() {
|
58
|
-
return this.adb.name;
|
59
|
-
}
|
60
|
-
|
61
|
-
toString() {
|
62
|
-
return `GenyCloud:${this.name} (${this.uuid} ${this.adbName})`;
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
module.exports = GenyInstance;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class GenyRecipe {
|
2
|
-
constructor(rawRecipe) {
|
3
|
-
this.uuid = rawRecipe.uuid;
|
4
|
-
this.name = rawRecipe.name || 'Anonymous GMSaaS Recipe';
|
5
|
-
this._description = (rawRecipe.name ? `${this.name} (${this.uuid})` : `Recipe of ${this.uuid}`);
|
6
|
-
}
|
7
|
-
|
8
|
-
toString() {
|
9
|
-
return this._description;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
module.exports = GenyRecipe;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
const DeviceCookie = require('./DeviceCookie');
|
2
|
-
|
3
|
-
class AndroidDeviceCookie extends DeviceCookie {
|
4
|
-
/**
|
5
|
-
* @param adbName { String }
|
6
|
-
*/
|
7
|
-
constructor(adbName) {
|
8
|
-
super();
|
9
|
-
this.adbName = adbName;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
module.exports = AndroidDeviceCookie;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
const AndroidDeviceCookie = require('./AndroidDeviceCookie');
|
2
|
-
|
3
|
-
class AttachedAndroidDeviceCookie extends AndroidDeviceCookie {
|
4
|
-
/**
|
5
|
-
* @param adbName { String }
|
6
|
-
*/
|
7
|
-
constructor(adbName) {
|
8
|
-
super(adbName);
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
module.exports = AttachedAndroidDeviceCookie;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
// @ts-nocheck
|
2
|
-
const AndroidDeviceCookie = require('./AndroidDeviceCookie');
|
3
|
-
|
4
|
-
class GenycloudEmulatorCookie extends AndroidDeviceCookie {
|
5
|
-
/**
|
6
|
-
* @param instance { GenyInstance }
|
7
|
-
*/
|
8
|
-
constructor(instance) {
|
9
|
-
super();
|
10
|
-
this.instance = instance;
|
11
|
-
}
|
12
|
-
|
13
|
-
get adbName() {
|
14
|
-
return this.instance.adbName;
|
15
|
-
}
|
16
|
-
|
17
|
-
set adbName(value) {}
|
18
|
-
}
|
19
|
-
|
20
|
-
module.exports = GenycloudEmulatorCookie;
|
@@ -1,71 +0,0 @@
|
|
1
|
-
const logger = require('../../utils/logger').child({ cat: 'device' });
|
2
|
-
|
3
|
-
const cleanupLogData = {
|
4
|
-
event: 'GENYCLOUD_TEARDOWN',
|
5
|
-
};
|
6
|
-
|
7
|
-
class GenyGlobalLifecycleHandler {
|
8
|
-
constructor({ deviceCleanupRegistry, instanceLifecycleService }) {
|
9
|
-
/** @private */
|
10
|
-
this._deviceCleanupRegistry = deviceCleanupRegistry;
|
11
|
-
/** @private */
|
12
|
-
this._instanceLifecycleService = instanceLifecycleService;
|
13
|
-
}
|
14
|
-
|
15
|
-
async globalInit() {}
|
16
|
-
|
17
|
-
emergencyCleanup() {
|
18
|
-
const { rawDevices } = this._deviceCleanupRegistry.readRegisteredDevicesUNSAFE();
|
19
|
-
const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
|
20
|
-
if (instanceHandles.length) {
|
21
|
-
reportGlobalCleanupSummary(instanceHandles);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
async globalCleanup() {
|
26
|
-
const { rawDevices } = await this._deviceCleanupRegistry.readRegisteredDevices();
|
27
|
-
const instanceHandles = rawDevicesToInstanceHandles(rawDevices);
|
28
|
-
if (instanceHandles.length) {
|
29
|
-
await doSafeCleanup(this._instanceLifecycleService, instanceHandles);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
async function doSafeCleanup(instanceLifecycleService, instanceHandles) {
|
35
|
-
logger.info(cleanupLogData, 'Initiating Genymotion SaaS instances teardown...');
|
36
|
-
|
37
|
-
const deletionLeaks = [];
|
38
|
-
const killPromises = instanceHandles.map((instanceHandle) =>
|
39
|
-
instanceLifecycleService.deleteInstance(instanceHandle.uuid)
|
40
|
-
.catch((error) => deletionLeaks.push({ ...instanceHandle, error })));
|
41
|
-
|
42
|
-
await Promise.all(killPromises);
|
43
|
-
reportGlobalCleanupSummary(deletionLeaks);
|
44
|
-
}
|
45
|
-
|
46
|
-
function reportGlobalCleanupSummary(deletionLeaks) {
|
47
|
-
if (deletionLeaks.length) {
|
48
|
-
logger.warn(cleanupLogData, 'WARNING! Detected a Genymotion SaaS instance leakage, for the following instances:');
|
49
|
-
|
50
|
-
deletionLeaks.forEach(({ uuid, name, error }) => {
|
51
|
-
logger.warn(cleanupLogData, [
|
52
|
-
`Instance ${name} (${uuid})${error ? `: ${error}` : ''}`,
|
53
|
-
` Kill it by visiting https://cloud.geny.io/instance/${uuid}, or by running:`,
|
54
|
-
` gmsaas instances stop ${uuid}`,
|
55
|
-
].join('\n'));
|
56
|
-
});
|
57
|
-
|
58
|
-
logger.info(cleanupLogData, 'Instances teardown completed with warnings');
|
59
|
-
} else {
|
60
|
-
logger.info(cleanupLogData, 'Instances teardown completed successfully');
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
function rawDevicesToInstanceHandles(rawDevices) {
|
65
|
-
return rawDevices.map((rawDevice) => ({
|
66
|
-
uuid: rawDevice.id,
|
67
|
-
name: rawDevice.data.name,
|
68
|
-
}));
|
69
|
-
}
|
70
|
-
|
71
|
-
module.exports = GenyGlobalLifecycleHandler;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class GenyGlobalLifecycleHandlerFactory {
|
2
|
-
/**
|
3
|
-
* @returns { GenyGlobalLifecycleHandler }
|
4
|
-
*/
|
5
|
-
createHandler() {
|
6
|
-
const serviceLocator = require('../../../servicelocator/android');
|
7
|
-
const deviceCleanupRegistry = serviceLocator.genycloud.cleanupDeviceRegistry;
|
8
|
-
const exec = serviceLocator.genycloud.exec;
|
9
|
-
|
10
|
-
const InstanceLifecycleService = require('../../common/drivers/android/genycloud/services/GenyInstanceLifecycleService');
|
11
|
-
const instanceLifecycleService = new InstanceLifecycleService(exec, null);
|
12
|
-
|
13
|
-
const GenyGlobalLifecycleHandler = require('../GenyGlobalLifecycleHandler');
|
14
|
-
return new GenyGlobalLifecycleHandler({ deviceCleanupRegistry, instanceLifecycleService });
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
module.exports = GenyGlobalLifecycleHandlerFactory;
|
package/src/invoke/EarlGrey.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
const GenyDeviceRegistryFactory = require('../../devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory');
|
2
|
-
|
3
|
-
class GenycloudServiceLocator {
|
4
|
-
constructor() {
|
5
|
-
this._exec = null;
|
6
|
-
this.runtimeDeviceRegistry = GenyDeviceRegistryFactory.forRuntime();
|
7
|
-
this.cleanupDeviceRegistry = GenyDeviceRegistryFactory.forGlobalShutdown();
|
8
|
-
}
|
9
|
-
|
10
|
-
// Note: important to keep lazy because of implicit validations that are sensitive (inside environment, in particular).
|
11
|
-
get exec() {
|
12
|
-
if (!this._exec) {
|
13
|
-
const Exec = require('../../devices/common/drivers/android/genycloud/exec/GenyCloudExec');
|
14
|
-
const environment = require('../../utils/environment');
|
15
|
-
this._exec = new Exec(environment.getGmsaasPath());
|
16
|
-
}
|
17
|
-
return this._exec;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
module.exports = new GenycloudServiceLocator();
|
@@ -1,25 +0,0 @@
|
|
1
|
-
const AndroidDevicePathBuilder = require('../../artifacts/utils/AndroidDevicePathBuilder');
|
2
|
-
const DeviceRegistry = require('../../devices/DeviceRegistry');
|
3
|
-
const AAPT = require('../../devices/common/drivers/android/exec/AAPT');
|
4
|
-
const ADB = require('../../devices/common/drivers/android/exec/ADB');
|
5
|
-
const ApkValidator = require('../../devices/common/drivers/android/tools/ApkValidator');
|
6
|
-
const { TempFileTransfer } = require('../../devices/common/drivers/android/tools/TempFileTransfer');
|
7
|
-
|
8
|
-
const AndroidServiceLocator = {
|
9
|
-
get emulator() {
|
10
|
-
return require('./emulatorServiceLocator');
|
11
|
-
},
|
12
|
-
|
13
|
-
get genycloud() {
|
14
|
-
return require('./genycloudServiceLocator');
|
15
|
-
},
|
16
|
-
};
|
17
|
-
|
18
|
-
AndroidServiceLocator.adb = new ADB();
|
19
|
-
AndroidServiceLocator.aapt = new AAPT();
|
20
|
-
AndroidServiceLocator.apkValidator = new ApkValidator(AndroidServiceLocator.aapt);
|
21
|
-
AndroidServiceLocator.fileTransfer = new TempFileTransfer(AndroidServiceLocator.adb);
|
22
|
-
AndroidServiceLocator.deviceRegistry = DeviceRegistry.forAndroid();
|
23
|
-
AndroidServiceLocator.devicePathBuilder = new AndroidDevicePathBuilder();
|
24
|
-
|
25
|
-
module.exports = AndroidServiceLocator;
|
File without changes
|
/package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyAuthService.js
RENAMED
File without changes
|