detox 20.0.0-breaking.new-global-lifecycle.0 → 20.0.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.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.0/detox-20.0.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar → 20.0.0/detox-20.0.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom → 20.0.0/detox-20.0.0.pom} +2 -8
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.0/detox-20.0.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/README.md +1 -1
- package/android/build.gradle +13 -8
- package/android/detox/build.gradle +14 -10
- 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 +1 -1
- package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +3 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +1 -3
- 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 +13 -1
- 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/matcher/ViewMatchers.kt +16 -23
- 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/IdlingResourceDescription.kt +19 -13
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +33 -30
- 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/uimodule/RN66Workaround.kt +13 -4
- 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/espresso/action/DetoxMultiTapSpec.kt +4 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +15 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +39 -0
- 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/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/android/gradlew +181 -107
- package/index.d.ts +198 -57
- package/internals.d.ts +220 -51
- package/local-cli/build.js +2 -2
- package/local-cli/build.test.js +14 -14
- package/local-cli/cli.js +8 -6
- package/local-cli/init.js +61 -21
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/reset-lock-file.js +16 -0
- package/local-cli/templates/jest.js +13 -10
- package/local-cli/test.js +14 -8
- package/local-cli/test.test.js +148 -61
- package/local-cli/testCommand/TestRunnerCommand.js +78 -71
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/local-cli/utils/jestInternals.js +4 -1
- package/package.json +22 -15
- 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 +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/index.test.js +13 -0
- package/runners/jest/reporters/DetoxReporter.js +33 -2
- package/runners/jest/testEnvironment/index.js +119 -69
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +94 -51
- package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +14 -16
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +2 -6
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -1
- package/src/DetoxWorker.js +107 -59
- package/src/android/core/NativeElement.js +56 -20
- package/src/android/core/NativeExpect.js +28 -9
- package/src/android/interactions/native.js +25 -18
- 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 +1 -1
- package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
- package/src/artifacts/utils/temporaryPath.js +18 -7
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +19 -2
- package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeAppsConfig.js +5 -1
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +19 -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 +3 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +4 -3
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +1 -0
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/common/drivers/android/exec/ADB.js +5 -0
- 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/EmulatorTelnet.js +1 -1
- 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/ios/tools/AppleSimUtils.js +29 -3
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
- package/src/devices/runtime/RuntimeDevice.js +19 -12
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +10 -2
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
- package/src/errors/DetoxConfigErrorComposer.js +18 -3
- package/src/ios/expectTwo.js +153 -67
- package/src/ipc/IPCClient.js +12 -12
- package/src/ipc/IPCServer.js +34 -17
- package/src/ipc/{state.js → SessionState.js} +26 -31
- package/src/logger/DetoxLogger.js +261 -157
- package/src/logger/index.js +5 -0
- package/src/logger/utils/BunyanLogger.js +76 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +36 -0
- package/src/logger/utils/DetoxLogFinalizer.js +140 -0
- package/src/logger/utils/MessageStack.js +24 -0
- package/src/logger/utils/ThreadDispatcher.js +61 -0
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +5 -4
- package/src/logger/utils/sanitizeBunyanContext.js +30 -0
- package/src/{utils → logger/utils}/streamUtils.js +51 -17
- package/src/logger/utils/tracerLegacy.js +37 -0
- package/src/realms/DetoxContext.js +78 -65
- package/src/realms/DetoxInternalsFacade.js +8 -12
- package/src/realms/DetoxPrimaryContext.js +106 -73
- package/src/realms/DetoxSecondaryContext.js +29 -31
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +16 -22
- package/src/utils/Timer.js +55 -38
- package/src/utils/argparse.js +11 -0
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/environment.js +30 -15
- package/src/utils/errorUtils.js +24 -3
- package/src/utils/invocationTraceDescriptions.js +43 -0
- package/src/utils/logger.js +1 -1
- package/src/utils/traceInvocationCall.js +21 -0
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.0-breaking.new-global-lifecycle.0/detox-20.0.0-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- 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/runners/jest/deprecation.js +0 -25
- package/src/configuration/utils/warnings.js +0 -12
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/logger/TraceThreadDispatcher.js +0 -52
- package/src/utils/ChromeTracingExporter.js +0 -53
- package/src/utils/trace.js +0 -19
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
1ea8e085ad2927f2802e2a80a1f74212
|
@@ -0,0 +1 @@
|
|
1
|
+
d9951fa46e203d7c6ba85d696efe583409a20ddd
|
@@ -0,0 +1 @@
|
|
1
|
+
7160a7f118631e4211a0967f3481e65b4d4792eeb9fd4826e39e3c6986888ab4
|
@@ -0,0 +1 @@
|
|
1
|
+
319382faac98faa9ca85eb2d766c509f34581ef2667d3218b1eda7db8409c1fd06322157cb088ff469b7310386b0c364201d453741ec7c28f48bc47caaac4209
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
8fdc200eb9b33208998c90508c592aa9
|
@@ -0,0 +1 @@
|
|
1
|
+
eda4c6da4c996a51bf89213ab37f77cdb16ebf15
|
@@ -0,0 +1 @@
|
|
1
|
+
df271aeed9256e2438c9662b580cffc7adcc0a5c89ec05dfbc2936eec2ffb709
|
@@ -0,0 +1 @@
|
|
1
|
+
9917c4b2f553c07f8be531335aed637a8461bd37e0aba7d294b9664c2444e9597f6e8ed1cda7e4f8908e2b70bd543253222a73726ad9fafac22c13ea264300da
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
3bdd1b42fa0f182255a47fcdda8f544c
|
@@ -0,0 +1 @@
|
|
1
|
+
457ae10d202b196ea92bade4a33ce2dbc2f8bb3f
|
@@ -0,0 +1 @@
|
|
1
|
+
52342d1b0d1fae681b2ea1e6f9ac6f6278299ed70d7867fd60b95d63eb7a9ec3
|
@@ -0,0 +1 @@
|
|
1
|
+
5dfa73d84d647fd870a2e915d9943c9502c967abfd89a834ef7dee50a2a77d5a8b0be7b13407a34a6b97cbc10e9ed6f5e608fe7366d5a3041e462e3322d5b10d
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
3
|
<modelVersion>4.0.0</modelVersion>
|
4
4
|
<groupId>com.wix</groupId>
|
5
5
|
<artifactId>detox</artifactId>
|
6
|
-
<version>20.0.0
|
6
|
+
<version>20.0.0</version>
|
7
7
|
<packaging>aar</packaging>
|
8
8
|
<name>Detox</name>
|
9
9
|
<description>Gray box end-to-end testing and automation library for mobile apps</description>
|
@@ -60,12 +60,6 @@
|
|
60
60
|
<version>2.2.0</version>
|
61
61
|
<scope>compile</scope>
|
62
62
|
</dependency>
|
63
|
-
<dependency>
|
64
|
-
<groupId>org.jetbrains.kotlin</groupId>
|
65
|
-
<artifactId>kotlin-android-extensions-runtime</artifactId>
|
66
|
-
<version>1.3.72</version>
|
67
|
-
<scope>runtime</scope>
|
68
|
-
</dependency>
|
69
63
|
<dependency>
|
70
64
|
<groupId>org.jetbrains.kotlin</groupId>
|
71
65
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
@@ -0,0 +1 @@
|
|
1
|
+
8c1ad3cbaa689c86d077d621e63c9c15
|
@@ -0,0 +1 @@
|
|
1
|
+
513d5656e068ef46cedb53c60e4a2a06c308e69f
|
@@ -0,0 +1 @@
|
|
1
|
+
01bdb63d3a4c85a313b66a5f44896cffc4ea6e6bb7a9e1664c3c07fa53902c3b
|
@@ -0,0 +1 @@
|
|
1
|
+
1dbdc2557991bc8ced1e6ca50225a29da3459bd115b39eadc1be598ca28db57f0914d775921d47336e0af5d219c1c5db67069afd5a16ec51c8dbe0e10d690963
|
@@ -3,11 +3,11 @@
|
|
3
3
|
<groupId>com.wix</groupId>
|
4
4
|
<artifactId>detox</artifactId>
|
5
5
|
<versioning>
|
6
|
-
<latest>20.0.0
|
7
|
-
<release>20.0.0
|
6
|
+
<latest>20.0.0</latest>
|
7
|
+
<release>20.0.0</release>
|
8
8
|
<versions>
|
9
|
-
<version>20.0.0
|
9
|
+
<version>20.0.0</version>
|
10
10
|
</versions>
|
11
|
-
<lastUpdated>
|
11
|
+
<lastUpdated>20221110185852</lastUpdated>
|
12
12
|
</versioning>
|
13
13
|
</metadata>
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
92d4bb195d57ff4f2ac27d501f95a1ce
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
e648e1e844e18e28412fa2e429c61712193b036c
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
402d4d9057a480e0cbbd2c1cce049071d9d5f282c164dd051ab7afed6b8f1fc0
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
df71178b84026b8e1970ddee3d1347a840c567a626ce4a1b81f37ea7667fa6b5b474b9ac32f16c25de4009abbe7a5b89341a49a3a9f44f5dbee78913e37f4fb4
|
package/Detox-ios-src.tbz
CHANGED
Binary file
|
package/Detox-ios.tbz
CHANGED
Binary file
|
package/README.md
CHANGED
package/android/build.gradle
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
buildscript {
|
2
2
|
ext {
|
3
3
|
isOfficialDetoxLib = true
|
4
|
-
kotlinVersion = '1.
|
4
|
+
kotlinVersion = '1.6.10' // Aligned with RN .69's version bump
|
5
5
|
dokkaVersion = '1.6.0'
|
6
|
-
buildToolsVersion = '
|
6
|
+
buildToolsVersion = '31.0.0'
|
7
7
|
compileSdkVersion = 31
|
8
8
|
targetSdkVersion = 31
|
9
9
|
minSdkVersion = 21
|
10
|
+
|
11
|
+
if (System.properties['os.arch'] == "aarch64") {
|
12
|
+
// For M1 Users we need to use the NDK 24 which added support for aarch64
|
13
|
+
ndkVersion = "24.0.8215888"
|
14
|
+
} else {
|
15
|
+
// Otherwise we default to the side-by-side NDK version from AGP.
|
16
|
+
ndkVersion = "21.4.7075529"
|
17
|
+
}
|
10
18
|
}
|
11
19
|
ext.detoxKotlinVersion = ext.kotlinVersion
|
12
20
|
|
@@ -15,14 +23,12 @@ buildscript {
|
|
15
23
|
google()
|
16
24
|
}
|
17
25
|
dependencies {
|
18
|
-
classpath 'com.android.tools.build:gradle:
|
26
|
+
classpath 'com.android.tools.build:gradle:7.1.1'
|
19
27
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
20
28
|
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1'
|
25
|
-
}
|
30
|
+
// Needed by Spek (https://spekframework.org/setup-android)
|
31
|
+
classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1'
|
26
32
|
}
|
27
33
|
}
|
28
34
|
|
@@ -31,7 +37,6 @@ allprojects {
|
|
31
37
|
mavenLocal()
|
32
38
|
mavenCentral()
|
33
39
|
google()
|
34
|
-
jcenter()
|
35
40
|
maven {
|
36
41
|
url "$projectDir/../../node_modules/react-native/android"
|
37
42
|
}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
apply plugin: 'com.android.library'
|
2
2
|
apply plugin: 'kotlin-android'
|
3
|
-
|
3
|
+
|
4
|
+
def _kotlinMinVersion = '1.2.0'
|
5
|
+
def _materialMinVersion = '1.2.1'
|
4
6
|
|
5
7
|
def _ext = rootProject.ext
|
6
8
|
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 31
|
7
9
|
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 31
|
8
|
-
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '
|
9
|
-
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion :
|
10
|
-
def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion :
|
10
|
+
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '31.0.0'
|
11
|
+
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 21
|
12
|
+
def _kotlinVersion = _ext.has('detoxKotlinVersion') ? _ext.detoxKotlinVersion : _kotlinMinVersion
|
11
13
|
def _kotlinStdlib = _ext.has('detoxKotlinStdlib') ? _ext.detoxKotlinStdlib : 'kotlin-stdlib-jdk8'
|
12
14
|
|
13
15
|
android {
|
@@ -75,7 +77,8 @@ android {
|
|
75
77
|
|
76
78
|
// Fundamental deps.
|
77
79
|
dependencies {
|
78
|
-
implementation "org.jetbrains.kotlin:$_kotlinStdlib:$
|
80
|
+
implementation "org.jetbrains.kotlin:$_kotlinStdlib:$_kotlinMinVersion"
|
81
|
+
//noinspection GradleDynamicVersion
|
79
82
|
compileOnly 'com.facebook.react:react-native:+'
|
80
83
|
}
|
81
84
|
|
@@ -108,7 +111,7 @@ dependencies {
|
|
108
111
|
|
109
112
|
// Third-party/extension deps.
|
110
113
|
dependencies {
|
111
|
-
implementation(
|
114
|
+
implementation("com.google.android.material:material:$_materialMinVersion") {
|
112
115
|
because 'Material components are mentioned explicitly (e.g. Slider in get-attributes handler)'
|
113
116
|
}
|
114
117
|
implementation('org.apache.commons:commons-lang3:3.7') {
|
@@ -121,11 +124,11 @@ dependencies {
|
|
121
124
|
|
122
125
|
// Unit-testing deps.
|
123
126
|
dependencies {
|
127
|
+
//noinspection GradleDynamicVersion
|
124
128
|
testImplementation 'com.facebook.react:react-native:+'
|
125
129
|
testImplementation 'org.json:json:20140107'
|
126
130
|
|
127
131
|
// https://github.com/spekframework/spek/issues/232#issuecomment-610732158
|
128
|
-
// testImplementation 'junit:junit:4.13.2'
|
129
132
|
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.6.0'
|
130
133
|
|
131
134
|
testImplementation 'org.assertj:assertj-core:3.16.1'
|
@@ -136,9 +139,9 @@ dependencies {
|
|
136
139
|
}
|
137
140
|
|
138
141
|
// Spek (https://spekframework.org/setup-android)
|
139
|
-
if (
|
140
|
-
|
141
|
-
|
142
|
+
if (rootProject.hasProperty('isOfficialDetoxLib') ||
|
143
|
+
rootProject.hasProperty('isOfficialDetoxApp')) {
|
144
|
+
|
142
145
|
apply plugin: 'de.mannodermaus.android-junit5'
|
143
146
|
|
144
147
|
android {
|
@@ -164,3 +167,4 @@ if (!rootProject.hasProperty('suppressUnitTests') &&
|
|
164
167
|
if (rootProject.hasProperty('isOfficialDetoxLib')) {
|
165
168
|
apply from: './publishing.gradle'
|
166
169
|
}
|
170
|
+
|
@@ -1,4 +1,5 @@
|
|
1
1
|
-keepattributes InnerClasses, Exceptions
|
2
|
+
|
2
3
|
-keep class com.facebook.react.modules.** { *; }
|
3
4
|
-keep class com.facebook.react.uimanager.** { *; }
|
4
5
|
-keep class com.facebook.react.animated.** { *; }
|
@@ -6,6 +7,11 @@
|
|
6
7
|
-keep class com.facebook.react.ReactNativeHost { *; }
|
7
8
|
-keep class com.facebook.react.ReactInstanceManager { *; }
|
8
9
|
-keep class com.facebook.react.ReactInstanceManager** { *; }
|
10
|
+
-keep class com.facebook.react.ReactInstanceEventListener { *; }
|
11
|
+
|
12
|
+
-keep class com.facebook.react.views.slider.** { *; }
|
13
|
+
-keep class com.google.android.material.slider.** { *; }
|
14
|
+
-keep class com.reactnativecommunity.slider.** { *; }
|
9
15
|
-keep class com.reactnativecommunity.asyncstorage.** { *; }
|
10
16
|
|
11
17
|
-keep class kotlin.jvm.** { *; }
|
@@ -4,8 +4,12 @@ project.ext.buildPomXmlDependencies = { pom, configurations ->
|
|
4
4
|
pom.withXml {
|
5
5
|
final rootNode = asNode().appendNode('dependencies')
|
6
6
|
addConfigurationDependencies(rootNode, configurations.api, 'compile')
|
7
|
-
addConfigurationDependencies(rootNode, configurations.compile, 'compile')
|
8
7
|
addConfigurationDependencies(rootNode, configurations.implementation, 'runtime')
|
8
|
+
|
9
|
+
// Legacy syntax
|
10
|
+
if (configurations.hasProperty('compile')) {
|
11
|
+
addConfigurationDependencies(rootNode, configurations.compile, 'compile')
|
12
|
+
}
|
9
13
|
}
|
10
14
|
}
|
11
15
|
|
@@ -18,6 +18,7 @@ def DEVELOPERS = [
|
|
18
18
|
String _versionName = System.getProperty('version')
|
19
19
|
String _flavour = System.getProperty('buildFlavour', PUB_FLAVOUR_FULL_DETOX)
|
20
20
|
Boolean _forceLocal = System.getProperty('forceLocal', 'false').toBoolean()
|
21
|
+
Boolean _forceSign = System.getProperty('forceSign', 'false').toBoolean()
|
21
22
|
|
22
23
|
String _mavenRepoUrl
|
23
24
|
Map _mavenCredentials
|
@@ -28,7 +29,7 @@ def _selectedVariant
|
|
28
29
|
def initLocalPublishing = {
|
29
30
|
_mavenRepoUrl = TARGET_LOCAL_DIR
|
30
31
|
_mavenCredentials = null
|
31
|
-
_shouldSignArtifacts =
|
32
|
+
_shouldSignArtifacts = _forceSign
|
32
33
|
}
|
33
34
|
|
34
35
|
def initMavenPublishing = {
|
@@ -71,10 +72,8 @@ def shouldPublishVariant = {
|
|
71
72
|
}
|
72
73
|
|
73
74
|
def declareArchive = { target ->
|
74
|
-
|
75
|
-
|
76
|
-
archives target
|
77
|
-
}
|
75
|
+
project.artifacts {
|
76
|
+
archives target
|
78
77
|
}
|
79
78
|
}
|
80
79
|
|
@@ -103,12 +102,12 @@ tasks.named("dokkaJavadoc") {
|
|
103
102
|
}
|
104
103
|
}
|
105
104
|
}
|
106
|
-
// Side note / TODO:
|
107
|
-
// Dokka outputs R and BuildConfig; currently, there's nothing to do about it, as issues such as
|
108
|
-
// this on - https://github.com/Kotlin/dokka/issues/419 are still open :-/
|
109
|
-
// We might want to revisit this in the future -- see if they've decided to export a custom classes
|
110
|
-
// suppression config var or something.
|
111
105
|
|
106
|
+
// Side note / TODO (revisit because dokka's 419 issue has been resolved, since):
|
107
|
+
// Dokka outputs R and BuildConfig; currently, there's nothing to do about it, as issues such as
|
108
|
+
// this on - https://github.com/Kotlin/dokka/issues/419 are still open :-/
|
109
|
+
// We might want to revisit this in the future -- see if they've decided to export a custom classes
|
110
|
+
// suppression config var or something.
|
112
111
|
task dokkaDocJar(type: Jar, dependsOn: dokkaJavadoc) {
|
113
112
|
from "$buildDir/dokkaDoc"
|
114
113
|
classifier = 'javadoc'
|
@@ -140,13 +139,15 @@ signing {
|
|
140
139
|
|
141
140
|
project.afterEvaluate {
|
142
141
|
project.tasks.all { Task task ->
|
143
|
-
android
|
144
|
-
|
145
|
-
|
146
|
-
task.
|
147
|
-
|
148
|
-
|
149
|
-
|
142
|
+
android {
|
143
|
+
libraryVariants.all { variant ->
|
144
|
+
String variantName = variant.name.capitalize()
|
145
|
+
if (task.name == "publishMaven${variantName}AarPublicationToMavenRepository".toString()) {
|
146
|
+
task.dependsOn "assemble${variantName}"
|
147
|
+
task.dependsOn project.tasks.signArchives
|
148
|
+
task.doFirst {
|
149
|
+
onPrePublish()
|
150
|
+
}
|
150
151
|
}
|
151
152
|
}
|
152
153
|
}
|
@@ -243,22 +244,23 @@ publishing {
|
|
243
244
|
}
|
244
245
|
}
|
245
246
|
|
246
|
-
// Register all artifacts we've previously registered as archives (i.e. .jar.asc's, .aar.asc's) as
|
247
|
-
// Note: this relies on preregistering the equivalent generator-tasks as archive artifacts
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
247
|
+
// Register all artifacts we've previously registered as signed archives (i.e. .jar.asc's, .aar.asc's) as publish-artifacts.
|
248
|
+
// Note: this relies on preregistering the equivalent generator-tasks as archive artifacts inside a project.artifacts { ... } clause.
|
249
|
+
if (_shouldSignArtifacts) {
|
250
|
+
project.tasks.signArchives.signatureFiles.each {
|
251
|
+
artifact(it) {
|
252
|
+
def matcherSrcDocs = (it.file =~ /-(sources|javadoc)\.jar\.asc$/)
|
253
|
+
def matcherAAR = (it.file =~ /\.aar\.asc$/)
|
254
|
+
if (matcherSrcDocs.find()) {
|
255
|
+
classifier = matcherSrcDocs.group(1)
|
256
|
+
extension = 'jar.asc'
|
257
|
+
} else if (matcherAAR.find()) {
|
258
|
+
classifier = null
|
259
|
+
extension = 'aar.asc'
|
260
|
+
} else {
|
261
|
+
classifier = null
|
262
|
+
extension = null
|
263
|
+
}
|
262
264
|
}
|
263
265
|
}
|
264
266
|
}
|
@@ -6,7 +6,7 @@ import com.wix.detox.adapters.server.OutboundServerAdapter
|
|
6
6
|
class DetoxCrashHandler(private val outboundServerAdapter: OutboundServerAdapter) {
|
7
7
|
fun attach() {
|
8
8
|
Thread.setDefaultUncaughtExceptionHandler { thread, exception ->
|
9
|
-
Log.e(LOG_TAG, "Crash detected!!! thread=${thread.name} (${thread.id})")
|
9
|
+
Log.e(LOG_TAG, "Crash detected!!! thread=${thread.name} (${thread.id})", exception)
|
10
10
|
|
11
11
|
val crashInfo = mapOf("errorDetails" to "@Thread ${thread.name}(${thread.id}):\n${Log.getStackTraceString(exception)}\nCheck device logs for full details!")
|
12
12
|
outboundServerAdapter.sendMessage(ACTION_NAME, crashInfo, MESSAGE_ID)
|
@@ -14,6 +14,7 @@ public class LaunchArgs {
|
|
14
14
|
private static final String DETOX_NOTIFICATION_PATH_ARG = "detoxUserNotificationDataURL";
|
15
15
|
private static final String DETOX_BLACKLIST_URLS_ARG = "detoxURLBlacklistRegex";
|
16
16
|
private static final String DETOX_URL_OVERRIDE_ARG = "detoxURLOverride";
|
17
|
+
private static final String DETOX_ENABLE_SYNCHRONIZATION = "detoxEnableSynchronization";
|
17
18
|
private static final List<String> RESERVED_INSTRUMENTATION_ARGS = Arrays.asList("class", "package", "func", "unit", "size", "perf", "debug", "log", "emma", "coverageFile");
|
18
19
|
|
19
20
|
public boolean hasNotificationPath() {
|
@@ -36,6 +37,14 @@ public class LaunchArgs {
|
|
36
37
|
return InstrumentationRegistry.getArguments().containsKey(DETOX_BLACKLIST_URLS_ARG);
|
37
38
|
}
|
38
39
|
|
40
|
+
public String getEnableSynchronization() {
|
41
|
+
return InstrumentationRegistry.getArguments().getString(DETOX_ENABLE_SYNCHRONIZATION);
|
42
|
+
}
|
43
|
+
|
44
|
+
public boolean hasEnableSynchronization() {
|
45
|
+
return InstrumentationRegistry.getArguments().containsKey(DETOX_ENABLE_SYNCHRONIZATION);
|
46
|
+
}
|
47
|
+
|
39
48
|
public String getUrlOverride() {
|
40
49
|
return InstrumentationRegistry.getArguments().getString(DETOX_URL_OVERRIDE_ARG);
|
41
50
|
}
|
@@ -10,7 +10,7 @@ import com.wix.detox.reactnative.ReactNativeExtension
|
|
10
10
|
|
11
11
|
class TestEngineFacade {
|
12
12
|
fun awaitIdle(): Unit? = Espresso.onIdle() {
|
13
|
-
Log.i(LOG_TAG, "Wait is over:
|
13
|
+
Log.i(LOG_TAG, "Wait is over: App is now idle!")
|
14
14
|
null
|
15
15
|
}
|
16
16
|
fun syncIdle() = UiAutomatorHelper.espressoSync() // TODO Check whether this can be replaced with #awaitIdle()
|
@@ -2,6 +2,8 @@ package com.wix.detox.adapters.server;
|
|
2
2
|
|
3
3
|
import android.util.Log;
|
4
4
|
|
5
|
+
import com.wix.detox.common.DetoxErrors;
|
6
|
+
|
5
7
|
import org.json.JSONException;
|
6
8
|
import org.json.JSONObject;
|
7
9
|
|
@@ -84,7 +86,7 @@ public class WebSocketClient {
|
|
84
86
|
wsEventsHandler.onAction(type, params.toString(), messageId);
|
85
87
|
}
|
86
88
|
} catch (JSONException e) {
|
87
|
-
|
89
|
+
throw new DetoxErrors.DetoxIllegalArgumentException(e);
|
88
90
|
}
|
89
91
|
}
|
90
92
|
|
@@ -2,7 +2,6 @@ package com.wix.detox.espresso;
|
|
2
2
|
|
3
3
|
import android.view.View;
|
4
4
|
|
5
|
-
import com.facebook.react.views.slider.ReactSliderManager;
|
6
5
|
import com.wix.detox.common.DetoxErrors.DetoxRuntimeException;
|
7
6
|
import com.wix.detox.common.DetoxErrors.StaleActionException;
|
8
7
|
import com.wix.detox.espresso.action.AdjustSliderToPositionAction;
|
@@ -151,8 +150,7 @@ public class DetoxAction {
|
|
151
150
|
}
|
152
151
|
|
153
152
|
public static ViewAction adjustSliderToPosition(final double newPosition) {
|
154
|
-
|
155
|
-
return new AdjustSliderToPositionAction(newPosition, reactSliderManager);
|
153
|
+
return new AdjustSliderToPositionAction(newPosition);
|
156
154
|
}
|
157
155
|
|
158
156
|
public static ViewAction takeViewScreenshot() {
|
@@ -5,7 +5,7 @@ import android.util.Log;
|
|
5
5
|
import android.view.Choreographer;
|
6
6
|
|
7
7
|
import com.wix.detox.common.UIThread;
|
8
|
-
import com.wix.detox.espresso.common.utils.UiControllerUtils;
|
8
|
+
import com.wix.detox.espresso.action.common.utils.UiControllerUtils;
|
9
9
|
|
10
10
|
import org.joor.Reflect;
|
11
11
|
import org.joor.ReflectException;
|
package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
package com.wix.detox.espresso.action
|
2
|
+
|
3
|
+
import android.view.View
|
4
|
+
import androidx.appcompat.widget.AppCompatSeekBar
|
5
|
+
import androidx.test.espresso.UiController
|
6
|
+
import androidx.test.espresso.ViewAction
|
7
|
+
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
|
8
|
+
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
9
|
+
import com.wix.detox.espresso.common.SliderHelper
|
10
|
+
import org.hamcrest.Matcher
|
11
|
+
import org.hamcrest.Matchers
|
12
|
+
|
13
|
+
class AdjustSliderToPositionAction(private val targetPositionPct: Double) : ViewAction {
|
14
|
+
override fun getDescription() = "adjustSliderToPosition"
|
15
|
+
override fun getConstraints(): Matcher<View?>? =
|
16
|
+
Matchers.allOf( isDisplayed(), isAssignableFrom(AppCompatSeekBar::class.java) )
|
17
|
+
|
18
|
+
override fun perform(uiController: UiController?, view: View) {
|
19
|
+
val sliderHelper = SliderHelper.create(view)
|
20
|
+
sliderHelper.setProgressPct(targetPositionPct)
|
21
|
+
}
|
22
|
+
}
|
package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt
RENAMED
@@ -9,6 +9,7 @@ import android.widget.TextView
|
|
9
9
|
import androidx.test.espresso.UiController
|
10
10
|
import com.google.android.material.slider.Slider
|
11
11
|
import com.wix.detox.espresso.ViewActionWithResult
|
12
|
+
import com.wix.detox.espresso.common.SliderHelper
|
12
13
|
import org.hamcrest.Matcher
|
13
14
|
import org.hamcrest.Matchers
|
14
15
|
import org.hamcrest.Matchers.allOf
|
@@ -127,13 +128,24 @@ private class CheckBoxAttributes {
|
|
127
128
|
rootObject.put("value", view.isChecked)
|
128
129
|
}
|
129
130
|
|
131
|
+
/**
|
132
|
+
* Note: this applies also to [androidx.appcompat.widget.AppCompatSeekBar], which
|
133
|
+
* is anything RN-slider-ish.
|
134
|
+
*/
|
130
135
|
private class ProgressBarAttributes {
|
131
136
|
fun get(json: JSONObject, view: View) {
|
132
137
|
if (view is ProgressBar) {
|
133
|
-
|
138
|
+
SliderHelper.maybeCreate(view)?.let {
|
139
|
+
getRNSliderValue(json, it)
|
140
|
+
} ?:
|
141
|
+
getProgressBarValue(json, view)
|
134
142
|
}
|
135
143
|
}
|
136
144
|
|
145
|
+
private fun getRNSliderValue(rootObject: JSONObject, sliderHelper: SliderHelper) {
|
146
|
+
rootObject.put("value", sliderHelper.getCurrentProgressPct())
|
147
|
+
}
|
148
|
+
|
137
149
|
private fun getProgressBarValue(rootObject: JSONObject, view: ProgressBar) =
|
138
150
|
rootObject.put("value", view.progress)
|
139
151
|
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
package com.wix.detox.espresso.common
|
2
|
+
|
3
|
+
import android.view.View
|
4
|
+
import androidx.appcompat.widget.AppCompatSeekBar
|
5
|
+
import com.facebook.react.bridge.JavaOnlyMap
|
6
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
7
|
+
import com.facebook.react.views.slider.ReactSlider
|
8
|
+
import com.wix.detox.common.DetoxErrors.DetoxIllegalStateException
|
9
|
+
import com.wix.detox.espresso.action.common.ReflectUtils
|
10
|
+
import org.joor.Reflect
|
11
|
+
|
12
|
+
private const val CLASS_REACT_SLIDER_LEGACY = "com.facebook.react.views.slider.ReactSlider"
|
13
|
+
private const val CLASS_REACT_SLIDER_COMMUNITY = "com.reactnativecommunity.slider.ReactSlider"
|
14
|
+
|
15
|
+
abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
|
16
|
+
fun getCurrentProgressPct(): Double {
|
17
|
+
val nativeProgress = slider.progress.toDouble()
|
18
|
+
val nativeMax = slider.max
|
19
|
+
return nativeProgress / nativeMax
|
20
|
+
}
|
21
|
+
|
22
|
+
// TODO Make this more testable (e.g. by delegating the set action away)
|
23
|
+
fun setProgressPct(valuePct: Double) {
|
24
|
+
val maxJSProgress = calcMaxJSProgress()
|
25
|
+
val valueJS = valuePct * maxJSProgress
|
26
|
+
setProgressJS(valueJS)
|
27
|
+
}
|
28
|
+
|
29
|
+
protected abstract fun setProgressJS(valueJS: Double)
|
30
|
+
|
31
|
+
private fun calcMaxJSProgress(): Double {
|
32
|
+
val nativeProgress = slider.progress.toDouble()
|
33
|
+
val nativeMax = slider.max
|
34
|
+
val toMaxFactor = nativeMax / nativeProgress
|
35
|
+
|
36
|
+
val jsProgress = getJSProgress()
|
37
|
+
return jsProgress * toMaxFactor
|
38
|
+
}
|
39
|
+
|
40
|
+
private fun getJSProgress(): Double =
|
41
|
+
Reflect.on(slider).call("toRealProgress", slider.progress).get() as Double
|
42
|
+
|
43
|
+
companion object {
|
44
|
+
fun create(view: View) =
|
45
|
+
maybeCreate(view)
|
46
|
+
?: throw DetoxIllegalStateException("Cannot handle this type of a seek-bar view (Class ${view.javaClass.canonicalName}). " +
|
47
|
+
"Only React Native sliders are currently supported.")
|
48
|
+
|
49
|
+
fun maybeCreate(view: View): SliderHelper? =
|
50
|
+
when {
|
51
|
+
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_LEGACY)
|
52
|
+
-> LegacySliderHelper(view as ReactSlider)
|
53
|
+
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_COMMUNITY)
|
54
|
+
-> CommunitySliderHelper(view as AppCompatSeekBar)
|
55
|
+
else
|
56
|
+
-> null
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
private class LegacySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
|
62
|
+
override fun setProgressJS(valueJS: Double) {
|
63
|
+
val reactSliderManager = com.facebook.react.views.slider.ReactSliderManager()
|
64
|
+
reactSliderManager.updateProperties(slider as ReactSlider, buildStyles("value", valueJS))
|
65
|
+
}
|
66
|
+
|
67
|
+
private fun buildStyles(vararg keysAndValues: Any) = ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues))
|
68
|
+
}
|
69
|
+
|
70
|
+
private class CommunitySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
|
71
|
+
override fun setProgressJS(valueJS: Double) {
|
72
|
+
val reactSliderManager = Class.forName("com.reactnativecommunity.slider.ReactSliderManager").newInstance()
|
73
|
+
Reflect.on(reactSliderManager).call("setValue", slider, valueJS)
|
74
|
+
}
|
75
|
+
}
|