detox 20.27.7-smoke.0 → 20.31.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.27.7-smoke.0/detox-20.27.7-smoke.0-sources.jar → 20.30.0/detox-20.30.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.27.7-smoke.0/detox-20.27.7-smoke.0.pom → 20.30.0/detox-20.30.0.pom} +2 -2
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.30.0/detox-20.30.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/android/build.gradle +5 -5
- package/android/detox/proguard-rules-app.pro +3 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/EspressoDetox.java +54 -3
- package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +11 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/IsDisplayingAtLeastDetoxMatcher.kt +2 -2
- package/android/detox/src/full/java/com/wix/detox/espresso/web/DetoxWebAtomMatcher.java +4 -7
- package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +0 -5
- package/android/detox/src/full/java/com/wix/detox/espresso/web/WebViewElement.java +33 -8
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +6 -11
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeInfo.kt +4 -11
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxIdlingResource.kt +42 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/ReactNativeIdlingResources.kt +145 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/animations/AnimatedModuleIdlingResource.kt +61 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/bridge/BridgeIdlingResource.kt +72 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/factory/DetoxIdlingResourceFactory.kt +32 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/factory/IdlingResourcesName.kt +10 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/factory/LooperName.kt +6 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/looper/MQThreadsReflector.kt +47 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt +105 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/{NetworkingModuleReflected.kt → network/NetworkingModuleReflected.kt} +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/{AsyncStorageIdlingResource.kt → storage/AsyncStorageIdlingResource.kt} +33 -35
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/{SerialExecutorReflected.kt → storage/SerialExecutorReflected.kt} +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +21 -19
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +19 -27
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +5 -17
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceTest.kt +248 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -1
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/SerialExecutorReflectedSpec.kt +1 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceTest.kt +212 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/rninfo.gradle +31 -24
- package/android/settings.gradle +11 -6
- package/detox.d.ts +39 -0
- package/package.json +11 -8
- package/scripts/postinstall.js +2 -2
- package/scripts/updateGradle.js +41 -8
- package/src/DetoxWorker.js +11 -6
- package/src/android/espressoapi/EspressoDetox.js +83 -0
- package/src/copilot/DetoxCopilot.js +3 -15
- package/src/copilot/detoxCopilotFrameworkDriver.js +27 -15
- package/src/devices/runtime/RuntimeDevice.js +11 -0
- package/src/devices/runtime/drivers/DeviceDriverBase.js +8 -0
- package/src/devices/runtime/drivers/android/AndroidDriver.js +16 -0
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +35 -0
- package/src/utils/assertArgument.js +9 -0
- package/src/utils/invocationTraceDescriptions.js +1 -0
- package/src/utils/mapDeviceLongPressArguments.js +56 -0
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.27.7-smoke.0/detox-20.27.7-smoke.0.pom.sha512 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0-sources.jar +0 -0
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.aar +0 -0
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.pom +0 -100
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox-legacy/20.27.7-smoke.0/detox-legacy-20.27.7-smoke.0.pom.sha512 +0 -1
- package/Detox-android/com/wix/detox-legacy/maven-metadata.xml +0 -13
- package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.md5 +0 -1
- package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.sha1 +0 -1
- package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.sha256 +0 -1
- package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/web/DetoxDriverAtoms.java +0 -642
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +0 -229
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +0 -215
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +0 -94
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +0 -29
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +0 -134
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +0 -23
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +0 -16
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +0 -71
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +0 -227
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +0 -47
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +0 -189
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
3874ff4a56e24600a473d514e4e29e40
|
@@ -0,0 +1 @@
|
|
1
|
+
629c66f412e7b606503f31713eabd46fa55b618b
|
@@ -0,0 +1 @@
|
|
1
|
+
ca7005ce7e3de6a7fcd96d421742587ed196a0343d90e031501318d3fc3bf54a
|
@@ -0,0 +1 @@
|
|
1
|
+
033a223e6731b20be6db87a17bfcd4be7ff0833cc8686b66f63aa6ba74f2d05c4735715074fcc9834efe265f282823830102b7a5f808dca7865bd9956ec4b782
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
c5f3daffcbc4e0f545784d563efc793c
|
@@ -0,0 +1 @@
|
|
1
|
+
fd392c76debf7d9afdbfd9f7eb0c48766395bd82
|
@@ -0,0 +1 @@
|
|
1
|
+
f6623de89efe2e0b49241ef2c9ec3fee79cf3d84e7dbf5d2f00d762427a32cab
|
@@ -0,0 +1 @@
|
|
1
|
+
92906ac80969295c0ca21b3428801173fa48bb93ffc0ff2450f2d74af4a6c2b6c9afdcb07c49bd46f2bb791317b8dd43bd30ff5801839fa3c7deafd6c8348548
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<modelVersion>4.0.0</modelVersion>
|
4
4
|
<groupId>com.wix</groupId>
|
5
5
|
<artifactId>detox</artifactId>
|
6
|
-
<version>20.
|
6
|
+
<version>20.30.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>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
<dependency>
|
34
34
|
<groupId>org.jetbrains.kotlin</groupId>
|
35
35
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
36
|
-
<version>1.
|
36
|
+
<version>1.9.24</version>
|
37
37
|
<scope>compile</scope>
|
38
38
|
</dependency>
|
39
39
|
<dependency>
|
@@ -0,0 +1 @@
|
|
1
|
+
3c6dcd60dee4e0fc2d0224627831750b
|
@@ -0,0 +1 @@
|
|
1
|
+
de3d4cc5a268e3535f7dc4d9e11fd6bf5f91729c
|
@@ -0,0 +1 @@
|
|
1
|
+
463591b08b156e20021aa77adc93813045a82d3925156dc7f08e1aa092a5e3eb
|
@@ -0,0 +1 @@
|
|
1
|
+
ae13b47252859419d791e1f85f44b8abf97d2817a5ad5a7f7cba39172bd8f816b1fbff2a5b72da47875447d8a268c6dd56a9ffcdb04b4c6b98a4cab8485b8865
|
@@ -3,11 +3,11 @@
|
|
3
3
|
<groupId>com.wix</groupId>
|
4
4
|
<artifactId>detox</artifactId>
|
5
5
|
<versioning>
|
6
|
-
<latest>20.
|
7
|
-
<release>20.
|
6
|
+
<latest>20.30.0</latest>
|
7
|
+
<release>20.30.0</release>
|
8
8
|
<versions>
|
9
|
-
<version>20.
|
9
|
+
<version>20.30.0</version>
|
10
10
|
</versions>
|
11
|
-
<lastUpdated>
|
11
|
+
<lastUpdated>20241226125215</lastUpdated>
|
12
12
|
</versioning>
|
13
13
|
</metadata>
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ad324f05689fe3b7b826d7d867e84f37
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
70d396df4a41cca1caf0c5ba0e61dab492278a3e
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6351eb801890ff4733ba3c301fd62b8a296193a1bfd2397dbadc61c9c80796a9
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6c94d87a91120ce7745700afc1d1f6c53a4abfe8b9ee10111448dffed21bb204c15ff991e07b6fe63fbd4fed4d4d7030593c490f15cb223c97adb37bc8c5e306
|
package/Detox-ios-framework.tbz
CHANGED
Binary file
|
package/Detox-ios-src.tbz
CHANGED
Binary file
|
package/Detox-ios-xcuitest.tbz
CHANGED
Binary file
|
package/android/build.gradle
CHANGED
@@ -3,12 +3,12 @@ buildscript {
|
|
3
3
|
|
4
4
|
ext {
|
5
5
|
isOfficialDetoxLib = true
|
6
|
-
kotlinVersion = '1.
|
6
|
+
kotlinVersion = '1.9.24'
|
7
7
|
dokkaVersion = '1.9.10'
|
8
|
-
buildToolsVersion = '
|
9
|
-
compileSdkVersion =
|
10
|
-
targetSdkVersion =
|
11
|
-
minSdkVersion =
|
8
|
+
buildToolsVersion = '35.0.0'
|
9
|
+
compileSdkVersion = 35
|
10
|
+
targetSdkVersion = 35
|
11
|
+
minSdkVersion = 24
|
12
12
|
}
|
13
13
|
ext.detoxKotlinVersion = ext.kotlinVersion
|
14
14
|
|
@@ -8,6 +8,9 @@
|
|
8
8
|
-keep class com.facebook.react.ReactInstanceManager { *; }
|
9
9
|
-keep class com.facebook.react.ReactInstanceManager** { *; }
|
10
10
|
-keep class com.facebook.react.ReactInstanceEventListener { *; }
|
11
|
+
-keep class com.facebook.react.soloader.OpenSourceMergedSoMapping { *; }
|
12
|
+
-keep class com.facebook.soloader.SoLoader { *; }
|
13
|
+
-keep class com.facebook.soloader.ExternalSoMapping { *; }
|
11
14
|
|
12
15
|
-keep class com.facebook.react.views.slider.** { *; }
|
13
16
|
-keep class com.google.android.material.slider.** { *; }
|
@@ -13,7 +13,7 @@ import android.view.ViewGroup;
|
|
13
13
|
import com.facebook.react.ReactApplication;
|
14
14
|
import com.wix.detox.common.UIThread;
|
15
15
|
import com.wix.detox.reactnative.ReactNativeExtension;
|
16
|
-
import com.wix.detox.reactnative.idlingresources.NetworkIdlingResource;
|
16
|
+
import com.wix.detox.reactnative.idlingresources.network.NetworkIdlingResource;
|
17
17
|
|
18
18
|
import org.hamcrest.Matcher;
|
19
19
|
|
@@ -21,12 +21,11 @@ import java.util.ArrayList;
|
|
21
21
|
|
22
22
|
import androidx.test.espresso.UiController;
|
23
23
|
import androidx.test.espresso.ViewAction;
|
24
|
-
import androidx.test.espresso.ViewInteraction;
|
25
|
-
import androidx.test.espresso.NoMatchingViewException;
|
26
24
|
import androidx.test.platform.app.InstrumentationRegistry;
|
27
25
|
|
28
26
|
import static androidx.test.espresso.Espresso.onView;
|
29
27
|
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
|
28
|
+
import static com.wix.detox.espresso.UiAutomatorHelper.getStatusBarHeightDps;
|
30
29
|
|
31
30
|
/**
|
32
31
|
* Created by rotemm on 26/12/2016.
|
@@ -34,6 +33,10 @@ import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
|
|
34
33
|
public class EspressoDetox {
|
35
34
|
private static final String LOG_TAG = "detox";
|
36
35
|
|
36
|
+
private static int calculateAdjustedY(View view, Integer y, boolean shouldIgnoreStatusBar) {
|
37
|
+
return shouldIgnoreStatusBar ? y + getStatusBarHeightDps(view) : y;
|
38
|
+
}
|
39
|
+
|
37
40
|
public static Object perform(Matcher<View> matcher, ViewAction action) {
|
38
41
|
ViewActionPerformer performer = ViewActionPerformer.forAction(action);
|
39
42
|
return performer.performOn(matcher);
|
@@ -121,5 +124,53 @@ public class EspressoDetox {
|
|
121
124
|
}
|
122
125
|
});
|
123
126
|
}
|
127
|
+
|
128
|
+
public static void tap(Integer x, Integer y, boolean shouldIgnoreStatusBar) {
|
129
|
+
onView(isRoot()).perform(new ViewAction() {
|
130
|
+
@Override
|
131
|
+
public Matcher<View> getConstraints() {
|
132
|
+
return isRoot();
|
133
|
+
}
|
134
|
+
|
135
|
+
@Override
|
136
|
+
public String getDescription() {
|
137
|
+
return "tap on screen";
|
138
|
+
}
|
139
|
+
|
140
|
+
@Override
|
141
|
+
public void perform(UiController uiController, View view) {
|
142
|
+
int adjustedY = calculateAdjustedY(view, y, shouldIgnoreStatusBar);
|
143
|
+
ViewAction action = DetoxAction.tapAtLocation(x, adjustedY);
|
144
|
+
action.perform(uiController, view);
|
145
|
+
uiController.loopMainThreadUntilIdle();
|
146
|
+
}
|
147
|
+
});
|
148
|
+
}
|
149
|
+
|
150
|
+
public static void longPress(Integer x, Integer y, boolean shouldIgnoreStatusBar) {
|
151
|
+
longPress(x, y, null, shouldIgnoreStatusBar);
|
152
|
+
}
|
153
|
+
|
154
|
+
public static void longPress(Integer x, Integer y, Integer duration, boolean shouldIgnoreStatusBar) {
|
155
|
+
onView(isRoot()).perform(new ViewAction() {
|
156
|
+
@Override
|
157
|
+
public Matcher<View> getConstraints() {
|
158
|
+
return isRoot();
|
159
|
+
}
|
160
|
+
|
161
|
+
@Override
|
162
|
+
public String getDescription() {
|
163
|
+
return "long press on screen";
|
164
|
+
}
|
165
|
+
|
166
|
+
@Override
|
167
|
+
public void perform(UiController uiController, View view) {
|
168
|
+
int adjustedY = calculateAdjustedY(view, y, shouldIgnoreStatusBar);
|
169
|
+
ViewAction action = DetoxAction.longPress(x, adjustedY, duration);
|
170
|
+
action.perform(uiController, view);
|
171
|
+
uiController.loopMainThreadUntilIdle();
|
172
|
+
}
|
173
|
+
});
|
174
|
+
}
|
124
175
|
}
|
125
176
|
|
@@ -1,8 +1,13 @@
|
|
1
1
|
package com.wix.detox.espresso;
|
2
2
|
|
3
|
+
import android.annotation.SuppressLint;
|
4
|
+
import android.content.Context;
|
3
5
|
import android.os.Handler;
|
6
|
+
import android.util.DisplayMetrics;
|
4
7
|
import android.util.Log;
|
8
|
+
import android.util.TypedValue;
|
5
9
|
import android.view.Choreographer;
|
10
|
+
import android.view.View;
|
6
11
|
|
7
12
|
import com.wix.detox.common.UIThread;
|
8
13
|
import com.wix.detox.espresso.action.common.utils.UiControllerUtils;
|
@@ -111,4 +116,10 @@ public class UiAutomatorHelper {
|
|
111
116
|
}
|
112
117
|
}
|
113
118
|
|
119
|
+
@SuppressLint({"DiscouragedApi", "InternalInsetResource"})
|
120
|
+
public static int getStatusBarHeightDps(View view) {
|
121
|
+
Context context = view.getContext();
|
122
|
+
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
123
|
+
return (int) (context.getResources().getDimensionPixelSize(resourceId) / ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT));
|
124
|
+
}
|
114
125
|
}
|
@@ -120,7 +120,7 @@ class IsDisplayingAtLeastDetoxMatcher(private val areaPercentage: Int) : TypeSaf
|
|
120
120
|
.defaultDisplay
|
121
121
|
.getMetrics(m)
|
122
122
|
|
123
|
-
val statusBarHeight =
|
123
|
+
val statusBarHeight = getStatusBarHeightPixels(view)
|
124
124
|
val actionBarHeight = getActionBarHeight(view)
|
125
125
|
return Rect(0, 0, m.widthPixels, m.heightPixels - (statusBarHeight + actionBarHeight))
|
126
126
|
}
|
@@ -138,7 +138,7 @@ class IsDisplayingAtLeastDetoxMatcher(private val areaPercentage: Int) : TypeSaf
|
|
138
138
|
}
|
139
139
|
|
140
140
|
@SuppressLint("InternalInsetResource", "DiscouragedApi")
|
141
|
-
private fun
|
141
|
+
private fun getStatusBarHeightPixels(view: View): Int {
|
142
142
|
val resourceId = view.context.resources.getIdentifier("status_bar_height", "dimen", "android")
|
143
143
|
return if (resourceId > 0) view.context.resources.getDimensionPixelSize(resourceId) else 0
|
144
144
|
}
|
@@ -3,15 +3,12 @@ package com.wix.detox.espresso.web;
|
|
3
3
|
|
4
4
|
import static androidx.test.espresso.web.webdriver.DriverAtoms.findMultipleElements;
|
5
5
|
|
6
|
-
import static com.wix.detox.espresso.web.DetoxDriverAtoms.findMultipleElementsDetox;
|
7
|
-
|
8
6
|
import androidx.test.espresso.web.model.Atom;
|
9
7
|
import androidx.test.espresso.web.model.ElementReference;
|
10
8
|
import androidx.test.espresso.web.webdriver.Locator;
|
11
9
|
|
12
10
|
import java.util.List;
|
13
11
|
|
14
|
-
|
15
12
|
public class DetoxWebAtomMatcher {
|
16
13
|
|
17
14
|
private DetoxWebAtomMatcher() {
|
@@ -19,19 +16,19 @@ public class DetoxWebAtomMatcher {
|
|
19
16
|
}
|
20
17
|
|
21
18
|
public static Atom<List<ElementReference>> matcherForId(String id) {
|
22
|
-
return
|
19
|
+
return findMultipleElements(Locator.ID, id);
|
23
20
|
}
|
24
21
|
|
25
22
|
public static Atom<List<ElementReference>> matcherForClassName(String className) {
|
26
|
-
return
|
23
|
+
return findMultipleElements(Locator.CLASS_NAME, className);
|
27
24
|
}
|
28
25
|
|
29
26
|
public static Atom<List<ElementReference>> matcherForCssSelector(String cssSelector) {
|
30
|
-
return
|
27
|
+
return findMultipleElements(Locator.CSS_SELECTOR, cssSelector);
|
31
28
|
}
|
32
29
|
|
33
30
|
public static Atom<List<ElementReference>> matcherForName(String name) {
|
34
|
-
return
|
31
|
+
return findMultipleElements(Locator.NAME, name);
|
35
32
|
}
|
36
33
|
|
37
34
|
public static Atom<List<ElementReference>> matcherForXPath(String xpath) {
|
@@ -1,11 +1,8 @@
|
|
1
1
|
package com.wix.detox.espresso.web;
|
2
2
|
|
3
|
-
import android.util.Log;
|
4
|
-
|
5
3
|
import androidx.test.espresso.web.model.Atom;
|
6
4
|
import androidx.test.espresso.web.model.Atoms;
|
7
5
|
import androidx.test.espresso.web.model.ElementReference;
|
8
|
-
import androidx.test.espresso.web.model.Evaluation;
|
9
6
|
import androidx.test.espresso.web.model.SimpleAtom;
|
10
7
|
import androidx.test.espresso.web.sugar.Web;
|
11
8
|
import androidx.test.espresso.web.webdriver.DriverAtoms;
|
@@ -31,9 +28,7 @@ public class WebElement {
|
|
31
28
|
}
|
32
29
|
|
33
30
|
ElementReference get() {
|
34
|
-
long timestamp = System.currentTimeMillis();
|
35
31
|
List<ElementReference> elements = getWebViewInteraction().withTimeout(30, TimeUnit.SECONDS).perform(matcherAtom).get();
|
36
|
-
Log.d("WebElement", "Time taken to get element: " + (System.currentTimeMillis() - timestamp) + "ms");
|
37
32
|
|
38
33
|
if (elements == null || elements.size() == 0 || index >= elements.size()) {
|
39
34
|
throw new RuntimeException(String.format("element was not found at index: %d", index));
|
@@ -1,5 +1,7 @@
|
|
1
1
|
package com.wix.detox.espresso.web;
|
2
2
|
|
3
|
+
import static androidx.test.espresso.web.sugar.Web.onWebView;
|
4
|
+
|
3
5
|
import android.view.View;
|
4
6
|
import android.webkit.WebView;
|
5
7
|
|
@@ -7,24 +9,47 @@ import androidx.test.espresso.web.model.Atom;
|
|
7
9
|
import androidx.test.espresso.web.model.ElementReference;
|
8
10
|
import androidx.test.espresso.web.sugar.Web;
|
9
11
|
|
10
|
-
import org.hamcrest.
|
12
|
+
import org.hamcrest.Description;
|
11
13
|
import org.hamcrest.Matcher;
|
14
|
+
import org.hamcrest.TypeSafeMatcher;
|
12
15
|
|
13
16
|
import java.util.List;
|
14
17
|
|
15
18
|
import javax.annotation.Nullable;
|
16
19
|
|
17
|
-
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
18
|
-
import static androidx.test.espresso.web.sugar.Web.onWebView;
|
19
|
-
import static org.hamcrest.CoreMatchers.allOf;
|
20
|
-
|
21
20
|
public class WebViewElement {
|
22
21
|
|
23
|
-
final
|
22
|
+
private final static String WRAPPER_WEBVIEW_CLASS_NAME = "RNCWebViewWrapper";
|
23
|
+
|
24
24
|
final Web.WebInteraction<Void> webViewInteraction;
|
25
25
|
|
26
|
-
WebViewElement(@Nullable Matcher<View>
|
27
|
-
|
26
|
+
WebViewElement(@Nullable Matcher<View> userMatcher) {
|
27
|
+
Matcher<View> matcher = null;
|
28
|
+
|
29
|
+
if (userMatcher != null) {
|
30
|
+
matcher = new TypeSafeMatcher<>() {
|
31
|
+
|
32
|
+
@Override
|
33
|
+
protected boolean matchesSafely(View item) {
|
34
|
+
// Support for react-native-webview >= 13.0.0
|
35
|
+
if (item instanceof WebView && item.getParent().getClass().getSimpleName().equals(WRAPPER_WEBVIEW_CLASS_NAME)) {
|
36
|
+
return userMatcher.matches(item.getParent());
|
37
|
+
}
|
38
|
+
|
39
|
+
if (item.getClass().getSimpleName().equals("RNCWebViewWrapper")) {
|
40
|
+
// We never want to match the wrapper of the webview
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
|
44
|
+
return userMatcher.matches(item);
|
45
|
+
}
|
46
|
+
|
47
|
+
@Override
|
48
|
+
public void describeTo(Description description) {
|
49
|
+
userMatcher.describeTo(description);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
}
|
28
53
|
this.webViewInteraction = matcher != null ? onWebView(matcher) : onWebView();
|
29
54
|
}
|
30
55
|
|
@@ -8,6 +8,7 @@ import com.facebook.react.ReactApplication
|
|
8
8
|
import com.facebook.react.ReactInstanceManager
|
9
9
|
import com.facebook.react.bridge.ReactContext
|
10
10
|
import com.wix.detox.LaunchArgs
|
11
|
+
import com.wix.detox.reactnative.idlingresources.ReactNativeIdlingResources
|
11
12
|
|
12
13
|
private const val LOG_TAG = "DetoxRNExt"
|
13
14
|
|
@@ -56,7 +57,6 @@ object ReactNativeExtension {
|
|
56
57
|
Log.i(LOG_TAG, "Reloading React Native")
|
57
58
|
|
58
59
|
(applicationContext as ReactApplication).let {
|
59
|
-
val networkSyncEnabled = rnIdlingResources?.networkSyncEnabled ?: true
|
60
60
|
clearIdlingResources()
|
61
61
|
|
62
62
|
val previousReactContext = getCurrentReactContextSafe(it)
|
@@ -64,7 +64,7 @@ object ReactNativeExtension {
|
|
64
64
|
reloadReactNativeInBackground(it)
|
65
65
|
val reactContext = awaitNewReactNativeContext(it, previousReactContext)
|
66
66
|
|
67
|
-
enableOrDisableSynchronization(reactContext
|
67
|
+
enableOrDisableSynchronization(reactContext)
|
68
68
|
}
|
69
69
|
}
|
70
70
|
|
@@ -93,11 +93,6 @@ object ReactNativeExtension {
|
|
93
93
|
return null
|
94
94
|
}
|
95
95
|
|
96
|
-
@JvmStatic
|
97
|
-
fun setNetworkSynchronization(enable: Boolean) {
|
98
|
-
rnIdlingResources?.setNetworkSynchronization(enable)
|
99
|
-
}
|
100
|
-
|
101
96
|
@JvmStatic
|
102
97
|
fun toggleNetworkSynchronization(enable: Boolean) {
|
103
98
|
rnIdlingResources?.let {
|
@@ -129,11 +124,11 @@ object ReactNativeExtension {
|
|
129
124
|
return rnLoadingMonitor.getNewContext()!!
|
130
125
|
}
|
131
126
|
|
132
|
-
private fun enableOrDisableSynchronization(reactContext: ReactContext
|
127
|
+
private fun enableOrDisableSynchronization(reactContext: ReactContext) {
|
133
128
|
if (shouldDisableSynchronization()) {
|
134
129
|
clearAllSynchronization()
|
135
130
|
} else {
|
136
|
-
setupIdlingResources(reactContext
|
131
|
+
setupIdlingResources(reactContext)
|
137
132
|
}
|
138
133
|
}
|
139
134
|
|
@@ -142,10 +137,10 @@ object ReactNativeExtension {
|
|
142
137
|
return launchArgs.hasEnableSynchronization() && launchArgs.enableSynchronization.equals("0")
|
143
138
|
}
|
144
139
|
|
145
|
-
private fun setupIdlingResources(reactContext: ReactContext
|
140
|
+
private fun setupIdlingResources(reactContext: ReactContext) {
|
146
141
|
val launchArgs = LaunchArgs()
|
147
142
|
|
148
|
-
rnIdlingResources = ReactNativeIdlingResources(reactContext, launchArgs
|
143
|
+
rnIdlingResources = ReactNativeIdlingResources(reactContext, launchArgs).apply {
|
149
144
|
registerAll()
|
150
145
|
}
|
151
146
|
}
|
@@ -1,20 +1,13 @@
|
|
1
1
|
package com.wix.detox.reactnative
|
2
2
|
|
3
|
-
import
|
4
|
-
import java.util.Map
|
3
|
+
import com.facebook.react.modules.systeminfo.ReactNativeVersion
|
5
4
|
|
6
5
|
data class RNVersion(val major: Int, val minor: Int, val patch: Int)
|
7
6
|
|
8
7
|
object ReactNativeInfo {
|
9
|
-
private var rnVersion: RNVersion =
|
10
|
-
|
11
|
-
|
12
|
-
val versionMap: Map<String, Int> = Reflect.on(versionClass).field("VERSION").get()
|
13
|
-
RNVersion(versionMap.get("major")!!, versionMap.get("minor")!!, versionMap.get("patch")!!)
|
14
|
-
} catch (e: ClassNotFoundException) {
|
15
|
-
// ReactNativeVersion was introduced in RN50, default to latest previous version.
|
16
|
-
RNVersion(0, 49, 0)
|
17
|
-
}
|
8
|
+
private var rnVersion: RNVersion = ReactNativeVersion.VERSION.run {
|
9
|
+
RNVersion(get("major") as Int, get("minor") as Int, get("patch") as Int)
|
10
|
+
}
|
18
11
|
|
19
12
|
@JvmStatic
|
20
13
|
fun rnVersion() = rnVersion
|
package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxIdlingResource.kt
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
package com.wix.detox.reactnative.idlingresources
|
2
|
+
|
3
|
+
import androidx.test.espresso.IdlingResource
|
4
|
+
import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource
|
5
|
+
import java.util.concurrent.atomic.AtomicBoolean
|
6
|
+
|
7
|
+
abstract class DetoxIdlingResource : DescriptiveIdlingResource {
|
8
|
+
private var callback: IdlingResource.ResourceCallback? = null
|
9
|
+
private var paused: AtomicBoolean = AtomicBoolean(false)
|
10
|
+
|
11
|
+
fun pause() {
|
12
|
+
paused.set(true)
|
13
|
+
notifyIdle()
|
14
|
+
}
|
15
|
+
|
16
|
+
fun resume() {
|
17
|
+
paused.set(false)
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) {
|
22
|
+
this.callback = callback
|
23
|
+
}
|
24
|
+
|
25
|
+
final override fun isIdleNow(): Boolean {
|
26
|
+
if (paused.get()) {
|
27
|
+
return true
|
28
|
+
}
|
29
|
+
return checkIdle()
|
30
|
+
}
|
31
|
+
|
32
|
+
open fun onUnregistered() {
|
33
|
+
// no-op
|
34
|
+
}
|
35
|
+
|
36
|
+
protected abstract fun checkIdle(): Boolean
|
37
|
+
|
38
|
+
|
39
|
+
fun notifyIdle() {
|
40
|
+
callback?.onTransitionToIdle()
|
41
|
+
}
|
42
|
+
}
|