detox 21.0.0-breaking.new-global-lifecycle.0 → 21.0.1-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +2 -7
- package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar → 21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar → 21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom → 21.0.1-rc.0/detox-21.0.1-rc.0.pom} +22 -10
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.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-framework.tbz +0 -0
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios-xcuitest.tbz +0 -0
- package/README.md +1 -1
- package/android/build.gradle +13 -8
- package/android/detox/build.gradle +24 -13
- package/android/detox/proguard-rules-app.pro +6 -0
- package/android/detox/proguard-rules.pro +3 -0
- package/android/detox/publish-pom.gradle +5 -1
- package/android/detox/publishing.gradle +35 -33
- package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +4 -4
- package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
- package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +3 -1
- package/android/detox/src/full/java/com/wix/detox/common/UIExtensions.kt +28 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +37 -3
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +11 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +22 -0
- package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +17 -4
- package/android/detox/src/full/java/com/wix/detox/espresso/action/RNDetoxAccessibilityAction.kt +46 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +75 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +24 -28
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/WithAccessibilityLabelMatcher.kt +23 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
- package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
- package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResourceDescription.kt +26 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +54 -8
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +3 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +43 -34
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +2 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +13 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/ui/UIExtensions.kt +37 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/utils/RNUtils.kt +6 -0
- package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +4 -1
- package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +2 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +10 -0
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
- package/android/detox/src/testFull/java/com/wix/detox/UTHelpers.kt +12 -0
- package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
- package/android/detox/src/testFull/java/com/wix/detox/common/UIExtensionsTest.kt +107 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +22 -9
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +39 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/ViewAtIndexMatcherSpec.kt +1 -2
- package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
- package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
- package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
- package/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/android/gradlew +181 -107
- package/index.d.ts +239 -83
- package/index.js +12 -1
- package/internals.d.ts +219 -45
- package/internals.js +10 -3
- package/local-cli/build-framework-cache.js +1 -1
- package/local-cli/build-xcuitest-cache.js +16 -0
- package/local-cli/build.js +2 -2
- package/local-cli/clean-framework-cache.js +1 -1
- package/local-cli/clean-xcuitest-cache.js +19 -0
- package/local-cli/cli.js +13 -7
- package/local-cli/init.js +61 -21
- package/local-cli/rebuild-framework-cache.js +4 -4
- package/local-cli/rebuild-xcuitest-cache.js +21 -0
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/run-server.js +12 -1
- package/local-cli/start.js +49 -0
- package/local-cli/startCommand/AppStartCommand.js +65 -0
- package/local-cli/templates/jest.js +13 -10
- package/local-cli/test.js +14 -8
- package/local-cli/testCommand/TestRunnerCommand.js +126 -77
- package/local-cli/testCommand/TestRunnerError.js +13 -0
- package/local-cli/testCommand/builder.js +5 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/local-cli/utils/cliErrorHandling.js +15 -0
- package/local-cli/utils/jestInternals.js +4 -1
- package/package.json +46 -26
- package/runners/deprecation.js +42 -44
- package/runners/jest/globalSetup.js +1 -1
- package/runners/jest/globalTeardown.js +1 -1
- package/runners/jest/index.d.ts +61 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/reporters/DetoxReporter.js +33 -2
- package/runners/jest/testEnvironment/index.js +119 -68
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +97 -51
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +15 -17
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +3 -7
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/scripts/build_framework.ios.sh +26 -60
- package/scripts/build_local_framework.ios.sh +62 -0
- package/scripts/build_local_xcuitest.ios.sh +53 -0
- package/scripts/build_xcuitest.ios.sh +23 -0
- package/scripts/pack_ios.sh +14 -5
- package/scripts/postinstall.js +10 -4
- package/src/DetoxWorker.js +112 -64
- package/src/android/actions/native.js +16 -0
- package/src/android/core/NativeElement.js +72 -20
- package/src/android/core/NativeExpect.js +28 -9
- package/src/android/core/NativeMatcher.js +31 -10
- package/src/android/core/NativeWaitFor.js +8 -0
- package/src/android/espressoapi/DetoxAction.js +37 -0
- package/src/android/espressoapi/DetoxMatcher.js +24 -0
- package/src/android/espressoapi/EspressoDetox.js +1 -1
- package/src/android/espressoapi/web/WebElement.js +1 -1
- package/src/android/interactions/native.js +25 -18
- package/src/android/matchers/index.js +2 -2
- package/src/android/matchers/native.js +10 -3
- package/src/artifacts/ArtifactsManager.js +14 -47
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/android/ADBLogcatRecording.js +11 -28
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +2 -2
- package/src/artifacts/templates/plugin/TwoSnapshotsPerTestPlugin.js +2 -1
- package/src/artifacts/templates/plugin/WholeTestRecorderPlugin.js +3 -2
- package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
- package/src/artifacts/utils/temporaryPath.js +47 -8
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +11 -19
- package/src/client/Client.js +35 -3
- package/src/client/actions/SyncStatusSchema.json +21 -0
- package/src/client/actions/actions.js +38 -0
- package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
- package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
- package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
- package/src/configuration/collectCliConfig.js +3 -13
- package/src/configuration/composeAppsConfig.js +5 -1
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +20 -10
- package/src/configuration/composeRunnerConfig.js +62 -9
- package/src/configuration/index.js +14 -9
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/devices/allocation/DeviceAllocator.js +15 -2
- package/src/devices/allocation/drivers/AllocationDriverBase.js +10 -2
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +10 -1
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +28 -29
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +6 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +4 -17
- package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +27 -18
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +12 -7
- package/src/devices/allocation/factories/base.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +9 -0
- package/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js +1 -1
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
- package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/AppInstallHelper.js +4 -4
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/{FileXfer.js → FileTransfer.js} +2 -2
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
- package/src/devices/common/drivers/android/tools/TempFileTransfer.js +14 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +21 -4
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +24 -12
- package/src/devices/runtime/drivers/DeviceDriverBase.js +2 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +17 -8
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +42 -2
- package/src/devices/runtime/drivers/ios/XCUITestUtils.js +209 -0
- package/src/devices/runtime/drivers/ios/allowNetworkPermissionsXCUITest.scpt +14 -0
- package/src/devices/runtime/factories/android.js +6 -5
- package/src/devices/runtime/factories/base.js +3 -2
- package/src/errors/DetoxConfigErrorComposer.js +18 -3
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +199 -78
- package/src/ipc/IPCClient.js +36 -27
- package/src/ipc/IPCServer.js +40 -21
- package/src/ipc/SessionState.js +60 -0
- package/src/logger/DetoxLogger.js +287 -154
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +105 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +37 -0
- package/src/logger/utils/DetoxLogFinalizer.js +166 -0
- package/src/logger/utils/MessageStack.js +35 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +23 -6
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxContext.js +83 -66
- package/src/realms/DetoxInternalsFacade.js +9 -13
- package/src/realms/DetoxPrimaryContext.js +117 -74
- package/src/realms/DetoxSecondaryContext.js +32 -35
- package/src/{symbols.js → realms/symbols.js} +16 -22
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +9 -6
- package/src/server/DetoxSessionManager.js +2 -1
- package/src/server/handlers/AnonymousConnectionHandler.js +1 -0
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/servicelocator/android/index.js +2 -2
- package/src/utils/ExclusiveLockfile.js +1 -0
- package/src/utils/Timer.js +59 -36
- package/src/utils/argparse.js +11 -27
- package/src/utils/childProcess/exec.js +4 -2
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/dateUtils.js +5 -0
- package/src/utils/environment.js +55 -16
- package/src/utils/errorUtils.js +24 -3
- package/src/utils/invocationTraceDescriptions.js +44 -0
- package/src/utils/isPromise.js +8 -1
- package/src/utils/logger.js +2 -2
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/src/validation/ios/IosSimulatorEnvValidator.js +7 -4
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- package/Detox-ios.tbz +0 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +0 -20
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
- package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -36
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +0 -59
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
- package/local-cli/build.test.js +0 -104
- package/local-cli/run-server.test.js +0 -23
- package/local-cli/test.test.js +0 -515
- package/runners/jest/deprecation.js +0 -25
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
- package/scripts/build_universal_framework.sh +0 -14
- package/scripts/build_universal_framework_legacy.sh +0 -76
- package/scripts/build_universal_framework_modern.sh +0 -28
- package/src/configuration/utils/warnings.js +0 -12
- package/src/devices/common/drivers/android/tools/TempFileXfer.js +0 -16
- package/src/ipc/state.js +0 -76
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/logger/TraceThreadDispatcher.js +0 -52
- package/src/realms/index.js +0 -10
- package/src/utils/ChromeTracingExporter.js +0 -53
- package/src/utils/streamUtils.js +0 -214
- package/src/utils/trace.js +0 -19
package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt
CHANGED
@@ -4,7 +4,9 @@ import android.view.View
|
|
4
4
|
import android.widget.CheckBox
|
5
5
|
import android.widget.ProgressBar
|
6
6
|
import android.widget.TextView
|
7
|
+
import com.facebook.react.views.slider.ReactSlider
|
7
8
|
import com.google.android.material.slider.Slider
|
9
|
+
import com.wix.detox.reactnative.ui.getAccessibilityLabel
|
8
10
|
import org.assertj.core.api.Assertions.assertThat
|
9
11
|
import org.json.JSONObject
|
10
12
|
import org.junit.Before
|
@@ -31,7 +33,7 @@ class GetAttributesActionTest {
|
|
31
33
|
private fun givenNoViewTag() = givenViewTag(null)
|
32
34
|
private fun givenVisibility(value: Int) { whenever(view.visibility).doReturn(value) }
|
33
35
|
private fun givenVisibilityRectAvailability(value: Boolean) { whenever(view.getLocalVisibleRect(any())).doReturn(value) }
|
34
|
-
private fun
|
36
|
+
private fun givenAccessibilityLabel(value: String) { whenever(view.getAccessibilityLabel()).doReturn(value) }
|
35
37
|
|
36
38
|
private fun perform(v: View = view): JSONObject {
|
37
39
|
uut.perform(null, v)
|
@@ -109,16 +111,16 @@ class GetAttributesActionTest {
|
|
109
111
|
}
|
110
112
|
|
111
113
|
@Test
|
112
|
-
fun `should return label according to
|
113
|
-
val
|
114
|
-
|
114
|
+
fun `should return label according to accessibilityLabel extension`() {
|
115
|
+
val accessibilityLabel = "label-mock"
|
116
|
+
givenAccessibilityLabel(accessibilityLabel)
|
115
117
|
|
116
118
|
val resultJson = perform()
|
117
|
-
assertThat(resultJson.opt("label")).isEqualTo(
|
119
|
+
assertThat(resultJson.opt("label")).isEqualTo(accessibilityLabel)
|
118
120
|
}
|
119
121
|
|
120
122
|
@Test
|
121
|
-
fun `should not return label if
|
123
|
+
fun `should not return label if accessibility label is not available`() {
|
122
124
|
val resultJson = perform()
|
123
125
|
assertThat(resultJson.opt("label")).isNull()
|
124
126
|
}
|
@@ -179,7 +181,7 @@ class GetAttributesActionTest {
|
|
179
181
|
}
|
180
182
|
|
181
183
|
@Test
|
182
|
-
fun `should return ProgressBar
|
184
|
+
fun `should return raw ProgressBar or SeekBar 'progress' via value attribute`() {
|
183
185
|
val progressBar: ProgressBar = mock {
|
184
186
|
on { progress } doReturn 42
|
185
187
|
}
|
@@ -189,7 +191,18 @@ class GetAttributesActionTest {
|
|
189
191
|
}
|
190
192
|
|
191
193
|
@Test
|
192
|
-
fun `should return Slider
|
194
|
+
fun `should return RN-Slider via value attribute`() {
|
195
|
+
val progressBar: ReactSlider = mock {
|
196
|
+
on { max } doReturn 100
|
197
|
+
on { progress } doReturn 50
|
198
|
+
}
|
199
|
+
|
200
|
+
val resultJson = perform(progressBar)
|
201
|
+
assertThat(resultJson.opt("value")).isEqualTo(0.5)
|
202
|
+
}
|
203
|
+
|
204
|
+
@Test
|
205
|
+
fun `should return material-Slider state through value attribute`() {
|
193
206
|
val slider: Slider = mock {
|
194
207
|
on { value } doReturn 0.42f
|
195
208
|
}
|
@@ -225,7 +238,7 @@ class GetAttributesActionTest {
|
|
225
238
|
}
|
226
239
|
|
227
240
|
@Test
|
228
|
-
fun `should return text hint via
|
241
|
+
fun `should return text hint via 'placeholder' attribute, if applicable`() {
|
229
242
|
val textViewWithHint: TextView = mock {
|
230
243
|
on { hint } doReturn "hint-text-mock"
|
231
244
|
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
package com.wix.detox.espresso.common
|
2
|
+
|
3
|
+
import com.facebook.react.views.slider.ReactSlider
|
4
|
+
import org.assertj.core.api.Assertions.assertThat
|
5
|
+
import org.junit.Before
|
6
|
+
import org.junit.Test
|
7
|
+
import org.junit.runner.RunWith
|
8
|
+
import org.mockito.kotlin.doReturn
|
9
|
+
import org.mockito.kotlin.mock
|
10
|
+
import org.mockito.kotlin.whenever
|
11
|
+
import org.robolectric.RobolectricTestRunner
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Note: This only tests against the react *legacy* (non-community) slider in order
|
15
|
+
* to avoid having to install the community slider under node_modules just for this.
|
16
|
+
*/
|
17
|
+
@RunWith(RobolectricTestRunner::class)
|
18
|
+
class SliderHelperTest {
|
19
|
+
lateinit var slider: ReactSlider
|
20
|
+
lateinit var uut: SliderHelper
|
21
|
+
|
22
|
+
@Before
|
23
|
+
fun setup() {
|
24
|
+
slider = mock()
|
25
|
+
uut = SliderHelper.create(slider)
|
26
|
+
}
|
27
|
+
|
28
|
+
private fun givenNativeProgressTraits(current: Int, max: Int) {
|
29
|
+
whenever(slider.progress).doReturn(current)
|
30
|
+
whenever(slider.max).doReturn(max)
|
31
|
+
}
|
32
|
+
|
33
|
+
@Test
|
34
|
+
fun `should properly calculate current progress, in percentage`() {
|
35
|
+
givenNativeProgressTraits(current = 20, max = 100)
|
36
|
+
|
37
|
+
assertThat(uut.getCurrentProgressPct()).isEqualTo(0.2)
|
38
|
+
}
|
39
|
+
}
|
package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/ViewAtIndexMatcherSpec.kt
CHANGED
@@ -3,7 +3,6 @@ package com.wix.detox.espresso.matcher
|
|
3
3
|
import android.view.View
|
4
4
|
import org.hamcrest.Description
|
5
5
|
import org.hamcrest.Matcher
|
6
|
-
import org.hamcrest.Matchers
|
7
6
|
import org.mockito.kotlin.mock
|
8
7
|
import org.mockito.kotlin.verify
|
9
8
|
import org.mockito.kotlin.whenever
|
@@ -28,7 +27,7 @@ object ViewAtIndexMatcherSpec: Spek({
|
|
28
27
|
uut.describeTo(description)
|
29
28
|
verify(description).appendText("View at index #0, of those matching MATCHER(innerMatcher description)")
|
30
29
|
}
|
31
|
-
|
30
|
+
|
32
31
|
it("should append a valid description for index≥0") {
|
33
32
|
val uut = ViewAtIndexMatcher(7, innerMatcher)
|
34
33
|
uut.describeTo(description)
|
@@ -4,6 +4,8 @@ import android.os.Looper
|
|
4
4
|
import androidx.test.espresso.IdlingResource
|
5
5
|
import androidx.test.espresso.base.IdlingResourceRegistry
|
6
6
|
import com.wix.detox.UTHelpers
|
7
|
+
import com.wix.detox.espresso.common.UiControllerImplReflected
|
8
|
+
import com.wix.detox.inquiry.DetoxBusyResource
|
7
9
|
import org.assertj.core.api.Assertions.assertThat
|
8
10
|
import org.junit.Before
|
9
11
|
import org.junit.Test
|
@@ -21,10 +23,11 @@ import java.util.concurrent.Executors
|
|
21
23
|
// Fixes: Hangs in UIThread.postFirstSync inside IRStatusInquirer.getAllBusyResources when upgrading robolectric 4.3.x -> 4.4
|
22
24
|
// See http://robolectric.org/blog/2019/06/04/paused-looper/ (coming from https://github.com/robolectric/robolectric/releases/tag/robolectric-4.4)
|
23
25
|
@LooperMode(LooperMode.Mode.LEGACY)
|
24
|
-
class
|
26
|
+
class BusyResourcesInquirerTest {
|
25
27
|
|
26
28
|
lateinit var registry: IdlingResourceRegistry
|
27
|
-
lateinit var
|
29
|
+
lateinit var uiController: UiControllerImplReflected
|
30
|
+
lateinit var uut: BusyResourcesInquirer
|
28
31
|
|
29
32
|
private fun anIdleResource() = mock<IdlingResource> {
|
30
33
|
on { isIdleNow } doReturn true
|
@@ -38,10 +41,22 @@ class IRStatusInquirerTest {
|
|
38
41
|
whenever(registry.resources).doReturn(resources.asList())
|
39
42
|
}
|
40
43
|
|
44
|
+
private fun givenRunningAsyncTasks() {
|
45
|
+
whenever(uiController.isAsyncIdleNow()).doReturn(false)
|
46
|
+
}
|
47
|
+
|
48
|
+
private fun givenRunningCompatAsyncTasks() {
|
49
|
+
whenever(uiController.isCompatIdleNow()).doReturn(false)
|
50
|
+
}
|
51
|
+
|
41
52
|
@Before
|
42
53
|
fun setup() {
|
43
54
|
registry = mock()
|
44
|
-
|
55
|
+
uiController = mock() {
|
56
|
+
on { isAsyncIdleNow() } doReturn true
|
57
|
+
on { isCompatIdleNow() } doReturn true
|
58
|
+
}
|
59
|
+
uut = BusyResourcesInquirer(registry, uiController)
|
45
60
|
}
|
46
61
|
|
47
62
|
@Test
|
@@ -51,13 +66,33 @@ class IRStatusInquirerTest {
|
|
51
66
|
}
|
52
67
|
|
53
68
|
@Test
|
54
|
-
fun `should return busy resources if there are some`() {
|
69
|
+
fun `should return busy resources if there are some IR ones`() {
|
55
70
|
val resourceIdle = anIdleResource()
|
56
71
|
val resourceBusy = aBusyResource()
|
57
72
|
givenIdlingResources(resourceIdle, resourceBusy)
|
58
73
|
|
59
74
|
val result = uut.getAllBusyResources()
|
60
|
-
assertThat(result).isEqualTo(
|
75
|
+
assertThat(result.size).isEqualTo(1)
|
76
|
+
assertThat(result[0] is DetoxBusyResource.BusyIdlingResource)
|
77
|
+
assertThat((result[0] as DetoxBusyResource.BusyIdlingResource).resource).isEqualTo(resourceBusy)
|
78
|
+
}
|
79
|
+
|
80
|
+
@Test
|
81
|
+
fun `should return the async-task busy resource if some async-tasks are running`() {
|
82
|
+
givenRunningAsyncTasks()
|
83
|
+
|
84
|
+
val result = uut.getAllBusyResources()
|
85
|
+
assertThat(result.size).isEqualTo(1)
|
86
|
+
assertThat(result[0] is DetoxBusyResource.BusyAsyncTasks)
|
87
|
+
}
|
88
|
+
|
89
|
+
@Test
|
90
|
+
fun `should return the async-task busy resource if some legacy async-tasks are running`() {
|
91
|
+
givenRunningCompatAsyncTasks()
|
92
|
+
|
93
|
+
val result = uut.getAllBusyResources()
|
94
|
+
assertThat(result.size).isEqualTo(1)
|
95
|
+
assertThat(result[0] is DetoxBusyResource.BusyAsyncTasks)
|
61
96
|
}
|
62
97
|
|
63
98
|
@Test
|
@@ -79,13 +114,17 @@ class IRStatusInquirerTest {
|
|
79
114
|
}
|
80
115
|
givenIdlingResources(resource)
|
81
116
|
|
82
|
-
var result: List<
|
117
|
+
var result: List<DetoxBusyResource>? = null
|
83
118
|
executor.execute {
|
84
119
|
result = uut.getAllBusyResources()
|
85
120
|
}
|
86
121
|
Thread.sleep(100L) // Give time for the unit to actually post on the main thread (as it's suppose to...)
|
87
122
|
Robolectric.flushForegroundThreadScheduler()
|
88
123
|
UTHelpers.yieldToOtherThreads(executor)
|
89
|
-
|
124
|
+
|
125
|
+
assertThat(result).isNotNull
|
126
|
+
assertThat(result!!.size).isEqualTo(1)
|
127
|
+
assertThat(result!![0] is DetoxBusyResource.BusyIdlingResource)
|
128
|
+
assertThat((result!![0] as DetoxBusyResource.BusyIdlingResource).resource).isEqualTo(resource)
|
90
129
|
}
|
91
130
|
}
|
@@ -1,16 +1,16 @@
|
|
1
|
-
package com.wix.detox.
|
1
|
+
package com.wix.detox.inquiry
|
2
2
|
|
3
3
|
import org.assertj.core.api.Assertions
|
4
4
|
import org.spekframework.spek2.Spek
|
5
5
|
import org.spekframework.spek2.style.specification.describe
|
6
6
|
|
7
|
-
class
|
7
|
+
class DetoxBusyResourceDescriptionSpec: Spek({
|
8
8
|
describe("Idling Resource Description Builder") {
|
9
|
-
lateinit var description:
|
9
|
+
lateinit var description: DetoxBusyResourceDescription
|
10
10
|
lateinit var expectedJSON: Map<String, Any>
|
11
11
|
|
12
12
|
it("should build with given description") {
|
13
|
-
description =
|
13
|
+
description = DetoxBusyResourceDescription.Builder()
|
14
14
|
.name("foo")
|
15
15
|
.addDescription("bar", "baz")
|
16
16
|
.addDescription("qux", "quux")
|
@@ -24,14 +24,14 @@ class IdlingResourceDescriptionSpec: Spek({
|
|
24
24
|
}
|
25
25
|
|
26
26
|
it("should build without description") {
|
27
|
-
description =
|
27
|
+
description = DetoxBusyResourceDescription.Builder().name("foo").build()
|
28
28
|
|
29
29
|
expectedJSON = mapOf("name" to "foo")
|
30
30
|
Assertions.assertThat(description.json()).isEqualTo(expectedJSON)
|
31
31
|
}
|
32
32
|
|
33
33
|
it("should build without name") {
|
34
|
-
description =
|
34
|
+
description = DetoxBusyResourceDescription.Builder()
|
35
35
|
.addDescription("bar", "baz")
|
36
36
|
.addDescription("qux", "quux")
|
37
37
|
.build()
|
@@ -0,0 +1,134 @@
|
|
1
|
+
package com.wix.detox.inquiry
|
2
|
+
|
3
|
+
import androidx.test.espresso.IdlingResource
|
4
|
+
import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource
|
5
|
+
import org.assertj.core.api.Assertions.assertThat
|
6
|
+
import org.mockito.kotlin.doReturn
|
7
|
+
import org.mockito.kotlin.mock
|
8
|
+
import org.spekframework.spek2.Spek
|
9
|
+
import org.spekframework.spek2.style.specification.describe
|
10
|
+
|
11
|
+
class DetoxBusyResourceSpec: Spek({
|
12
|
+
describe("Detox busy resource") {
|
13
|
+
data class TestCase<in T: IdlingResource>(
|
14
|
+
val caseTitle: String,
|
15
|
+
val idlingResource: IdlingResource,
|
16
|
+
val expectedDescription: DetoxBusyResourceDescription
|
17
|
+
)
|
18
|
+
|
19
|
+
describe("given a descriptive idling resource") {
|
20
|
+
val mockedDebugName = "mock:debug-name"
|
21
|
+
|
22
|
+
fun aDescriptiveIdlingResource(busyHint: Map<String, Any>?): DescriptiveIdlingResource =
|
23
|
+
mock() {
|
24
|
+
on { getDebugName() }.doReturn(mockedDebugName)
|
25
|
+
on { getBusyHint() }.doReturn(busyHint)
|
26
|
+
}
|
27
|
+
|
28
|
+
listOf(
|
29
|
+
TestCase<IdlingResource>(
|
30
|
+
caseTitle = "should return a description based on debug-name and busy-hint",
|
31
|
+
idlingResource = aDescriptiveIdlingResource(mapOf("mocked" to "hint", "mocked2" to "hint2")),
|
32
|
+
expectedDescription = DetoxBusyResourceDescription.Builder()
|
33
|
+
.name(mockedDebugName)
|
34
|
+
.addDescription("mocked", "hint")
|
35
|
+
.addDescription("mocked2", "hint2")
|
36
|
+
.build()
|
37
|
+
),
|
38
|
+
TestCase(
|
39
|
+
caseTitle = "should return a description even without a busy-hint",
|
40
|
+
idlingResource = aDescriptiveIdlingResource(busyHint = null),
|
41
|
+
expectedDescription = DetoxBusyResourceDescription.Builder()
|
42
|
+
.name(mockedDebugName)
|
43
|
+
.build()
|
44
|
+
),
|
45
|
+
).forEach { (caseTitle, idlingResource, expectedDescription) ->
|
46
|
+
it(caseTitle) {
|
47
|
+
val uut = DetoxBusyResource.BusyIdlingResource(idlingResource)
|
48
|
+
|
49
|
+
assertThat(uut.resource).isEqualTo(idlingResource)
|
50
|
+
assertThat(uut.getDescription()).isEqualTo(expectedDescription)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
describe("given a looper idling resource") {
|
56
|
+
|
57
|
+
abstract class LooperIdlingResource: IdlingResource {}
|
58
|
+
|
59
|
+
fun aLooperIdlingResourceMock(resourceName: String): LooperIdlingResource =
|
60
|
+
mock() {
|
61
|
+
on { name }.doReturn(resourceName)
|
62
|
+
}
|
63
|
+
|
64
|
+
listOf(
|
65
|
+
TestCase<LooperIdlingResource>(
|
66
|
+
caseTitle = "should return a tailored description for the js-thread looper",
|
67
|
+
idlingResource = aLooperIdlingResourceMock("mqt_js"),
|
68
|
+
expectedDescription = DetoxBusyResourceDescription.Builder()
|
69
|
+
.name("looper")
|
70
|
+
.addDescription("thread", "\"mqt_js\" (JS Thread)")
|
71
|
+
.addDescription("execution_type", "JavaScript code")
|
72
|
+
.build(),
|
73
|
+
),
|
74
|
+
TestCase<LooperIdlingResource>(
|
75
|
+
caseTitle = "should return a tailored description for native-modules thread",
|
76
|
+
idlingResource = aLooperIdlingResourceMock("mqt_native"),
|
77
|
+
expectedDescription = DetoxBusyResourceDescription.Builder()
|
78
|
+
.name("looper")
|
79
|
+
.addDescription("thread", "\"mqt_native\" (Native Modules Thread)")
|
80
|
+
.addDescription("execution_type", "native module calls")
|
81
|
+
.build()
|
82
|
+
),
|
83
|
+
TestCase<LooperIdlingResource>(
|
84
|
+
caseTitle = "should return a default description for unspecified looper-threads",
|
85
|
+
idlingResource = aLooperIdlingResourceMock("unmapped"),
|
86
|
+
expectedDescription = DetoxBusyResourceDescription.Builder()
|
87
|
+
.name("looper")
|
88
|
+
.addDescription("thread", "\"unmapped\"")
|
89
|
+
.build(),
|
90
|
+
),
|
91
|
+
).forEach { (caseTitle, idlingResource, expectedDescription) ->
|
92
|
+
it(caseTitle) {
|
93
|
+
val uut = DetoxBusyResource.BusyIdlingResource(idlingResource)
|
94
|
+
|
95
|
+
assertThat(uut.resource).isEqualTo(idlingResource)
|
96
|
+
assertThat(uut.getDescription()).isEqualTo(expectedDescription)
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
describe("given a generic idling resource") {
|
102
|
+
val mockedResourceName = "mock:resource-name"
|
103
|
+
|
104
|
+
listOf(
|
105
|
+
TestCase<IdlingResource>(
|
106
|
+
caseTitle = "should return a generic description for a generic idling resource",
|
107
|
+
idlingResource = mock { on { name}.doReturn(mockedResourceName) },
|
108
|
+
expectedDescription = DetoxBusyResourceDescription.Builder()
|
109
|
+
.name("unknown")
|
110
|
+
.addDescription("identifier", mockedResourceName)
|
111
|
+
.build()
|
112
|
+
)
|
113
|
+
).forEach { (caseTitle, idlingResource, expectedDescription) ->
|
114
|
+
it (caseTitle) {
|
115
|
+
val uut = DetoxBusyResource.BusyIdlingResource(idlingResource)
|
116
|
+
|
117
|
+
assertThat(uut.resource).isEqualTo(idlingResource)
|
118
|
+
assertThat(uut.getDescription()).isEqualTo(expectedDescription)
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
describe("busy async-task(s) description") {
|
124
|
+
it("should return a general description") {
|
125
|
+
val expectedDescription = DetoxBusyResourceDescription.Builder()
|
126
|
+
.name("bg")
|
127
|
+
.addDescription("reason", "native async-tasks")
|
128
|
+
.build()
|
129
|
+
|
130
|
+
assertThat(DetoxBusyResource.BusyAsyncTasks.getDescription()).isEqualTo(expectedDescription)
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
})
|
@@ -61,6 +61,10 @@ class AsyncStorageIdlingResourceSpec: Spek({
|
|
61
61
|
assertThat(uut.name).isEqualTo("com.wix.detox.reactnative.idlingresources.AsyncStorageIdlingResource")
|
62
62
|
}
|
63
63
|
|
64
|
+
it("should have a debug-name") {
|
65
|
+
assertThat(uut.getDebugName()).isEqualTo("io")
|
66
|
+
}
|
67
|
+
|
64
68
|
describe("idle-checking") {
|
65
69
|
it("should be idle") {
|
66
70
|
givenIdleSExecutor()
|
@@ -71,11 +75,6 @@ class AsyncStorageIdlingResourceSpec: Spek({
|
|
71
75
|
givenAnActiveTask()
|
72
76
|
givenNoPendingTasks()
|
73
77
|
assertThat(uut.isIdleNow).isFalse()
|
74
|
-
|
75
|
-
val expectedDescription = IdlingResourceDescription.Builder()
|
76
|
-
.name("io")
|
77
|
-
.build()
|
78
|
-
assertThat(uut.getDescription()).isEqualTo(expectedDescription)
|
79
78
|
}
|
80
79
|
|
81
80
|
it("should be busy if executor has pending tasks") {
|
@@ -0,0 +1,61 @@
|
|
1
|
+
package com.wix.detox.reactnative.idlingresources
|
2
|
+
|
3
|
+
import com.wix.detox.UTHelpers.yieldToOtherThreads
|
4
|
+
import org.assertj.core.api.Assertions.assertThat
|
5
|
+
|
6
|
+
import okhttp3.Dispatcher
|
7
|
+
import org.junit.Before
|
8
|
+
import org.junit.Test
|
9
|
+
import org.junit.runner.RunWith
|
10
|
+
import org.robolectric.RobolectricTestRunner
|
11
|
+
import java.util.concurrent.Executors
|
12
|
+
|
13
|
+
@RunWith(RobolectricTestRunner::class)
|
14
|
+
class NetworkIdlingResourcesTest {
|
15
|
+
lateinit var dispatcher: Dispatcher
|
16
|
+
lateinit var uut: NetworkIdlingResource
|
17
|
+
|
18
|
+
@Before
|
19
|
+
fun setup() {
|
20
|
+
dispatcher = Dispatcher()
|
21
|
+
uut = NetworkIdlingResource(dispatcher)
|
22
|
+
}
|
23
|
+
|
24
|
+
// Note: Ideally, we should test that the list of busy resources is protected,
|
25
|
+
// rather than testing thread-safety as a whole.
|
26
|
+
@Test
|
27
|
+
fun `should return the descriptive data a thread-safe way`() {
|
28
|
+
val localExecutor = Executors.newSingleThreadExecutor()
|
29
|
+
var busyHint: Map<String, Any>? = null
|
30
|
+
|
31
|
+
synchronized(uut) {
|
32
|
+
localExecutor.submit {
|
33
|
+
busyHint = uut.getBusyHint()
|
34
|
+
}
|
35
|
+
|
36
|
+
yieldToOtherThreads(localExecutor)
|
37
|
+
assertThat(busyHint).isNull()
|
38
|
+
}
|
39
|
+
yieldToOtherThreads(localExecutor)
|
40
|
+
assertThat(busyHint).isNotNull
|
41
|
+
}
|
42
|
+
|
43
|
+
// Note: Ideally, we should test that the list of busy resources is protected,
|
44
|
+
// rather than testing thread-safety as a whole.
|
45
|
+
@Test
|
46
|
+
fun `should check for idle in a thread-safe way`() {
|
47
|
+
val localExecutor = Executors.newSingleThreadExecutor()
|
48
|
+
var idle = false
|
49
|
+
|
50
|
+
synchronized(uut) {
|
51
|
+
localExecutor.submit {
|
52
|
+
idle = uut.isIdleNow
|
53
|
+
}
|
54
|
+
|
55
|
+
yieldToOtherThreads(localExecutor)
|
56
|
+
assertThat(idle).isFalse
|
57
|
+
}
|
58
|
+
yieldToOtherThreads(localExecutor)
|
59
|
+
assertThat(idle).isTrue
|
60
|
+
}
|
61
|
+
}
|
@@ -5,22 +5,14 @@ import org.assertj.core.api.Assertions.assertThat
|
|
5
5
|
import org.mockito.kotlin.*
|
6
6
|
import org.spekframework.spek2.Spek
|
7
7
|
import org.spekframework.spek2.style.specification.describe
|
8
|
+
import com.facebook.react.modules.core.TimingModule
|
8
9
|
|
9
10
|
private const val BUSY_INTERVAL_MS = 1500L
|
10
11
|
|
11
|
-
abstract class TimingModuleStub: NativeModule {
|
12
|
-
abstract fun hasActiveTimersInRange(rangeMs: Long): Boolean
|
13
|
-
|
14
|
-
override fun onCatalystInstanceDestroy() {}
|
15
|
-
override fun getName(): String = "TimersNativeModuleStub"
|
16
|
-
override fun canOverrideExistingModule() = false
|
17
|
-
override fun initialize() {}
|
18
|
-
}
|
19
|
-
|
20
12
|
object DelegatedIdleInterrogationStrategySpec : Spek({
|
21
|
-
describe("
|
13
|
+
describe("Timers idle-interrogation strategy") {
|
22
14
|
|
23
|
-
lateinit var timingModule:
|
15
|
+
lateinit var timingModule: TimingModule
|
24
16
|
|
25
17
|
beforeEachTest {
|
26
18
|
timingModule = mock()
|
@@ -2,7 +2,6 @@ package com.wix.detox.reactnative.idlingresources.timers
|
|
2
2
|
|
3
3
|
import android.view.Choreographer
|
4
4
|
import androidx.test.espresso.IdlingResource
|
5
|
-
import com.wix.detox.reactnative.idlingresources.IdlingResourceDescription
|
6
5
|
import org.assertj.core.api.Assertions
|
7
6
|
import org.mockito.kotlin.*
|
8
7
|
import org.spekframework.spek2.Spek
|
@@ -41,6 +40,10 @@ object TimersIdlingResourceSpec : Spek({
|
|
41
40
|
getChoreographerCallback().doFrame(0L)
|
42
41
|
}
|
43
42
|
|
43
|
+
it("should return a debug-name") {
|
44
|
+
Assertions.assertThat(uut().getDebugName()).isEqualTo("timers")
|
45
|
+
}
|
46
|
+
|
44
47
|
it("should be idle if strategy says so") {
|
45
48
|
givenIdleStrategy()
|
46
49
|
Assertions.assertThat(uut().isIdleNow).isTrue()
|
@@ -49,11 +52,6 @@ object TimersIdlingResourceSpec : Spek({
|
|
49
52
|
it("should be busy if strategy says so") {
|
50
53
|
givenBusyStrategy()
|
51
54
|
Assertions.assertThat(uut().isIdleNow).isFalse()
|
52
|
-
|
53
|
-
val expectedDescription = IdlingResourceDescription.Builder()
|
54
|
-
.name("timers")
|
55
|
-
.build()
|
56
|
-
Assertions.assertThat(uut().getDescription()).isEqualTo(expectedDescription)
|
57
55
|
}
|
58
56
|
|
59
57
|
it("should transition to idle if found idle by strategy") {
|
@@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME
|
|
3
3
|
distributionPath=wrapper/dists
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
5
5
|
zipStorePath=wrapper/dists
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
6
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
|
7
|
+
|