detox 21.0.0-rc.5 → 21.0.0-rc.7
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar → 21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar → 21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{21.0.0-rc.5/detox-21.0.0-rc.5.pom → 21.0.0-rc.7/detox-21.0.0-rc.7.pom} +1 -7
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.7/detox-21.0.0-rc.7.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 +1 -1
- package/android/detox/build.gradle +13 -8
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAssertion.java +44 -25
- package/android/detox/src/full/java/com/wix/detox/espresso/EspressoDetox.java +6 -7
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +2 -2
- package/android/detox/src/full/java/com/wix/detox/espresso/action/GetAttributesAction.kt +34 -35
- package/android/detox/src/full/java/com/wix/detox/espresso/common/MaterialSliderHelper.kt +21 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/common/{SliderHelper.kt → ReactSliderHelper.kt} +6 -5
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +2 -2
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/MultipleViewsActionPerformer.kt +43 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/SingleViewActionPerformer.kt +19 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/performer/ViewActionPerformer.kt +24 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +4 -4
- package/android/detox/src/full/java/com/wix/invoke/types/Invocation.java +7 -6
- package/android/detox/src/main/java/com/wix/detox/espresso/MultipleViewsAction.kt +4 -0
- package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +0 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/ViewActionWithResult.kt +2 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/MotionEvents.kt +60 -4
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +6 -5
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/MaterialSliderHelperTest.kt +33 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/{SliderHelperTest.kt → ReactSliderHelperTest.kt} +3 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/performer/ViewActionPerformerSpec.kt +37 -0
- package/android/detox/src/testFull/java/com/wix/invoke/JsonParserTest.java +23 -7
- package/android/detox/src/testFull/resources/targetInvocationEspressoWebDetoxScript.json +47 -0
- package/android/rninfo.gradle +3 -3
- package/detox.d.ts +1830 -0
- package/globals.d.ts +23 -0
- package/index.d.ts +2 -1823
- package/internals.d.ts +11 -1
- package/jest.config.js +108 -0
- package/local-cli/reset-lock-file.js +5 -9
- package/local-cli/testCommand/TestRunnerCommand.js +26 -3
- package/local-cli/utils/interruptListeners.js +15 -0
- package/package.json +2 -100
- package/runners/jest/reporter.js +21 -1
- package/runners/jest/reporters/DetoxIPCReporter.js +34 -0
- package/runners/jest/reporters/DetoxReporterDispatcher.js +144 -0
- package/runners/jest/reporters/DetoxSummaryReporter.js +16 -0
- package/runners/jest/reporters/DetoxVerboseReporter.js +16 -0
- package/runners/jest/reporters/index.js +6 -0
- package/runners/jest/testEnvironment/index.js +11 -0
- package/src/DetoxWorker.js +5 -11
- package/src/android/core/NativeElement.js +26 -29
- package/src/android/core/WebElement.js +24 -6
- package/src/android/espressoapi/DetoxAssertion.js +16 -14
- package/src/android/espressoapi/EspressoDetox.js +9 -2
- package/src/android/espressoapi/web/WebElement.js +1 -4
- package/src/android/interactions/native.js +2 -3
- package/src/artifacts/providers/index.js +3 -3
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +0 -17
- package/src/configuration/composeLoggerConfig.js +1 -0
- package/src/configuration/composeRunnerConfig.js +3 -1
- package/src/devices/allocation/DeviceAllocator.js +66 -20
- package/src/devices/allocation/DeviceList.js +44 -0
- package/src/devices/allocation/DeviceRegistry.js +189 -0
- package/src/devices/allocation/drivers/AllocationDriverBase.d.ts +15 -0
- package/src/devices/{common/drivers/android/tools → allocation/drivers/android}/FreeDeviceFinder.js +11 -10
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +22 -17
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +97 -38
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +32 -45
- package/src/devices/allocation/drivers/android/emulator/FreeEmulatorFinder.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/FreePortFinder.js +37 -0
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -3
- package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +104 -32
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceLauncher.js +40 -31
- package/src/devices/allocation/drivers/android/genycloud/GenyRegistry.js +121 -0
- package/src/devices/allocation/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +24 -0
- package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyInstance.js +83 -0
- package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyRecipe.js +25 -0
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +95 -54
- package/src/devices/allocation/drivers/ios/SimulatorQuery.js +24 -0
- package/src/devices/allocation/factories/android.js +29 -35
- package/src/devices/allocation/factories/ios.js +6 -7
- package/src/devices/common/drivers/DeviceCookie.d.ts +12 -0
- package/src/devices/common/drivers/android/cookies.d.ts +11 -0
- package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +17 -5
- package/src/devices/common/drivers/android/exec/ADB.js +1 -0
- package/src/devices/common/drivers/android/tools/instrumentationArgs.js +7 -1
- package/src/devices/common/drivers/ios/cookies.d.ts +9 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +3 -1
- package/src/devices/cookies/index.js +0 -6
- package/src/devices/runtime/drivers/android/genycloud/GenyCloudDriver.js +7 -6
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +5 -4
- package/src/devices/runtime/drivers/ios/XCUITestUtils.js +18 -7
- package/src/devices/runtime/factories/android.js +3 -11
- package/src/devices/runtime/factories/ios.js +3 -4
- package/src/{servicelocator → devices/servicelocator}/android/emulatorServiceLocator.js +1 -1
- package/src/devices/servicelocator/android/genycloudServiceLocator.js +17 -0
- package/src/devices/servicelocator/android/index.js +23 -0
- package/src/{validation → devices/validation}/EnvironmentValidatorBase.js +1 -0
- package/src/{validation → devices/validation}/android/GenycloudEnvValidator.js +2 -2
- package/src/{validation → devices/validation}/factories/index.js +1 -1
- package/src/{validation → devices/validation}/ios/IosSimulatorEnvValidator.js +2 -2
- package/src/environmentFactory.js +1 -11
- package/src/ios/web.js +21 -5
- package/src/ipc/IPCClient.js +22 -1
- package/src/ipc/IPCServer.js +42 -1
- package/src/ipc/SessionState.js +1 -0
- package/src/logger/DetoxLogger.js +2 -2
- package/src/realms/DetoxContext.js +8 -0
- package/src/realms/DetoxInternalsFacade.js +1 -0
- package/src/realms/DetoxPrimaryContext.js +48 -42
- package/src/realms/DetoxSecondaryContext.js +27 -0
- package/src/realms/symbols.js +6 -0
- package/src/utils/PIDService.js +27 -0
- package/src/utils/assertIsFunction.js +35 -0
- package/src/utils/environment.js +8 -15
- package/src/utils/errorUtils.js +3 -3
- package/src/utils/isArrowFunction.js +24 -0
- package/tsconfig.json +8 -3
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar +0 -0
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/21.0.0-rc.5/detox-21.0.0-rc.5.pom.sha512 +0 -1
- package/runners/jest/reporters/DetoxReporter.js +0 -36
- package/src/devices/DeviceRegistry.js +0 -176
- package/src/devices/allocation/drivers/AllocationDriverBase.js +0 -30
- package/src/devices/allocation/drivers/android/attached/AttachedAndroidLauncher.js +0 -13
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +0 -72
- package/src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory.js +0 -16
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +0 -65
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +0 -21
- package/src/devices/common/drivers/DeviceAllocationHelper.js +0 -20
- package/src/devices/common/drivers/DeviceLauncher.js +0 -19
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +0 -25
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLookupService.js +0 -38
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +0 -14
- package/src/devices/common/drivers/android/genycloud/services/dto/GenyInstance.js +0 -66
- package/src/devices/common/drivers/android/genycloud/services/dto/GenyRecipe.js +0 -13
- package/src/devices/cookies/AndroidDeviceCookie.js +0 -13
- package/src/devices/cookies/AndroidEmulatorCookie.js +0 -6
- package/src/devices/cookies/AttachedAndroidDeviceCookie.js +0 -12
- package/src/devices/cookies/DeviceCookie.js +0 -4
- package/src/devices/cookies/GenycloudEmulatorCookie.js +0 -20
- package/src/devices/cookies/IosCookie.js +0 -6
- package/src/devices/cookies/IosSimulatorCookie.js +0 -10
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +0 -71
- package/src/devices/lifecycle/factories/GenyGlobalLifecycleHandlerFactory.js +0 -18
- package/src/servicelocator/android/genycloudServiceLocator.js +0 -21
- package/src/servicelocator/android/index.js +0 -25
- package/src/servicelocator/ios.js +0 -7
- /package/src/devices/{common → allocation}/drivers/android/genycloud/exec/GenyCloudExec.js +0 -0
- /package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyAuthService.js +0 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
package com.wix.detox.espresso.performer
|
2
|
+
|
3
|
+
import com.wix.detox.espresso.MultipleViewsAction
|
4
|
+
|
5
|
+
import android.view.View
|
6
|
+
import androidx.test.espresso.Espresso.onView
|
7
|
+
import androidx.test.espresso.NoMatchingViewException
|
8
|
+
import androidx.test.espresso.ViewAction
|
9
|
+
import org.hamcrest.Matcher
|
10
|
+
|
11
|
+
interface ViewActionPerformer {
|
12
|
+
fun performOn(matcher: Matcher<View>): Any?
|
13
|
+
|
14
|
+
companion object {
|
15
|
+
@JvmStatic
|
16
|
+
fun forAction(action: ViewAction): ViewActionPerformer {
|
17
|
+
return if (action is MultipleViewsAction) {
|
18
|
+
MultipleViewsActionPerformer(action)
|
19
|
+
} else {
|
20
|
+
SingleViewActionPerformer(action)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
@@ -62,12 +62,12 @@ public class WebElement {
|
|
62
62
|
return getWebViewInteraction().withElement(get()).perform(DriverAtoms.getText()).get();
|
63
63
|
}
|
64
64
|
|
65
|
-
public
|
66
|
-
return getWebViewInteraction().withElement(get()).perform(new SimpleAtom(script)).get();
|
65
|
+
public Object runScript(String script) {
|
66
|
+
return getWebViewInteraction().withElement(get()).perform(new SimpleAtom(script)).get().getValue();
|
67
67
|
}
|
68
68
|
|
69
|
-
public
|
70
|
-
return getWebViewInteraction().withElement(get()).perform(Atoms.scriptWithArgs(script, args)).get();
|
69
|
+
public Object runScriptWithArgs(String script, final ArrayList<Object> args) {
|
70
|
+
return getWebViewInteraction().withElement(get()).perform(Atoms.scriptWithArgs(script, args)).get().getValue();
|
71
71
|
}
|
72
72
|
|
73
73
|
public String getCurrentUrl() {
|
@@ -68,9 +68,9 @@ public class Invocation {
|
|
68
68
|
argument = args.get(i);
|
69
69
|
} else if(args.get(i).getClass() == JSONArray.class) {
|
70
70
|
JSONArray jsonArray = (JSONArray) args.get(i);
|
71
|
-
List<
|
71
|
+
List<Object> list = new ArrayList<>();
|
72
72
|
for (int j = 0; j < jsonArray.length(); j++) {
|
73
|
-
list.add(jsonArray.
|
73
|
+
list.add(jsonArray.get(j));
|
74
74
|
}
|
75
75
|
argument = list;
|
76
76
|
} else {
|
@@ -92,9 +92,9 @@ public class Invocation {
|
|
92
92
|
} else if (type.equals("boolean")) {
|
93
93
|
argument = jsonArgument.optBoolean("value");
|
94
94
|
} else if (type.equals("Invocation")) {
|
95
|
-
argument = new Invocation(jsonArgument.optJSONObject("value"));
|
95
|
+
argument = new Invocation(jsonArgument.optJSONObject("value"));
|
96
96
|
} else {
|
97
|
-
throw new RuntimeException("Unhandled arg type" + type);
|
97
|
+
throw new RuntimeException("Unhandled arg type " + type);
|
98
98
|
}
|
99
99
|
}
|
100
100
|
}
|
@@ -105,6 +105,8 @@ public class Invocation {
|
|
105
105
|
}
|
106
106
|
|
107
107
|
public void setArgs(Object[] args) {
|
108
|
+
JsonParser parser = new JsonParser();
|
109
|
+
|
108
110
|
for (int i = 0; i < args.length; i++) {
|
109
111
|
Object argument = args[i];
|
110
112
|
if (argument instanceof HashMap && !((HashMap) argument).isEmpty()) {
|
@@ -125,10 +127,9 @@ public class Invocation {
|
|
125
127
|
} else if (type.equals("boolean")) {
|
126
128
|
argument = ((Boolean) value).booleanValue();
|
127
129
|
} else if (type.equals("Invocation")) {
|
128
|
-
JsonParser parser = new JsonParser();
|
129
130
|
argument = parser.parse((String)value);
|
130
131
|
} else {
|
131
|
-
throw new RuntimeException("Unhandled arg type" + type);
|
132
|
+
throw new RuntimeException("Unhandled arg type " + type);
|
132
133
|
}
|
133
134
|
|
134
135
|
args[i] = argument;
|
@@ -9,8 +9,37 @@ import androidx.test.espresso.action.MotionEvents
|
|
9
9
|
private val PRECISION = floatArrayOf(16f, 16f)
|
10
10
|
|
11
11
|
class MotionEvents {
|
12
|
-
fun obtainMoveEvent(downEvent: MotionEvent, eventTime: Long, x: Float, y: Float): MotionEvent
|
13
|
-
|
12
|
+
fun obtainMoveEvent(downEvent: MotionEvent, eventTime: Long, x: Float, y: Float): MotionEvent {
|
13
|
+
val pointerProperties = MotionEvent.PointerProperties().apply {
|
14
|
+
clear()
|
15
|
+
id = 0
|
16
|
+
toolType = MotionEvent.TOOL_TYPE_UNKNOWN
|
17
|
+
}
|
18
|
+
val pointerCoords = MotionEvent.PointerCoords().apply {
|
19
|
+
clear()
|
20
|
+
this.x = x
|
21
|
+
this.y = y
|
22
|
+
this.pressure = 0f
|
23
|
+
this.size = 1f
|
24
|
+
}
|
25
|
+
|
26
|
+
return MotionEvent.obtain(
|
27
|
+
downEvent.downTime,
|
28
|
+
eventTime,
|
29
|
+
MotionEvent.ACTION_MOVE,
|
30
|
+
1, // pointerCounts
|
31
|
+
arrayOf(pointerProperties),
|
32
|
+
arrayOf(pointerCoords),
|
33
|
+
0, // metaState
|
34
|
+
downEvent.buttonState,
|
35
|
+
downEvent.xPrecision,
|
36
|
+
downEvent.yPrecision,
|
37
|
+
0, // deviceId
|
38
|
+
0, // edgeFlags
|
39
|
+
downEvent.source,
|
40
|
+
0
|
41
|
+
)
|
42
|
+
}
|
14
43
|
|
15
44
|
fun obtainDownEvent(x: Float, y: Float, precision: FloatArray = PRECISION)
|
16
45
|
= obtainDownEvent(x, y, precision, null)
|
@@ -46,8 +75,35 @@ class MotionEvents {
|
|
46
75
|
0)
|
47
76
|
}
|
48
77
|
|
49
|
-
fun obtainUpEvent(downEvent: MotionEvent, eventTime: Long, x: Float, y: Float): MotionEvent
|
50
|
-
|
78
|
+
fun obtainUpEvent(downEvent: MotionEvent, eventTime: Long, x: Float, y: Float): MotionEvent {
|
79
|
+
val pointerProperties = MotionEvent.PointerProperties().apply {
|
80
|
+
id = 0
|
81
|
+
toolType = MotionEvent.TOOL_TYPE_UNKNOWN
|
82
|
+
}
|
83
|
+
val pointerCoords = MotionEvent.PointerCoords().apply {
|
84
|
+
clear()
|
85
|
+
this.x = x
|
86
|
+
this.y = y
|
87
|
+
this.pressure = 0f
|
88
|
+
this.size = 1f
|
89
|
+
}
|
90
|
+
return MotionEvent.obtain(
|
91
|
+
downEvent.downTime,
|
92
|
+
eventTime,
|
93
|
+
MotionEvent.ACTION_UP,
|
94
|
+
1, // pointerCounts
|
95
|
+
arrayOf(pointerProperties),
|
96
|
+
arrayOf(pointerCoords),
|
97
|
+
0, // metaState
|
98
|
+
downEvent.buttonState,
|
99
|
+
downEvent.xPrecision,
|
100
|
+
downEvent.yPrecision,
|
101
|
+
0, // deviceId
|
102
|
+
0, // edgeFlags
|
103
|
+
downEvent.source,
|
104
|
+
0
|
105
|
+
)
|
106
|
+
}
|
51
107
|
|
52
108
|
fun sendDownAsync(uiController: UiController, x: Float, y: Float, precision: FloatArray = PRECISION): MotionEvent {
|
53
109
|
val downEvent = obtainDownEvent(x, y, precision, null)
|
package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt
CHANGED
@@ -37,7 +37,7 @@ class GetAttributesActionTest {
|
|
37
37
|
|
38
38
|
private fun perform(v: View = view): JSONObject {
|
39
39
|
uut.perform(null, v)
|
40
|
-
return
|
40
|
+
return uut.getResult()!!
|
41
41
|
}
|
42
42
|
|
43
43
|
@Test
|
@@ -135,10 +135,10 @@ class GetAttributesActionTest {
|
|
135
135
|
}
|
136
136
|
|
137
137
|
val resultJson = perform()
|
138
|
-
assertThat(resultJson.opt("alpha")).isEqualTo(0.
|
138
|
+
assertThat(resultJson.opt("alpha")).isEqualTo(0.42f)
|
139
139
|
assertThat(resultJson.opt("width")).isEqualTo(123)
|
140
140
|
assertThat(resultJson.opt("height")).isEqualTo(456)
|
141
|
-
assertThat(resultJson.opt("elevation")).isEqualTo(0.
|
141
|
+
assertThat(resultJson.opt("elevation")).isEqualTo(0.314f)
|
142
142
|
}
|
143
143
|
|
144
144
|
@Test
|
@@ -208,7 +208,8 @@ class GetAttributesActionTest {
|
|
208
208
|
}
|
209
209
|
|
210
210
|
val resultJson = perform(slider)
|
211
|
-
|
211
|
+
android.util.Log.i("TESTS", "should return material-Slider state through value attribute: "+ resultJson)
|
212
|
+
assertThat(resultJson.opt("value")).isEqualTo(0.42f)
|
212
213
|
}
|
213
214
|
|
214
215
|
@Test
|
@@ -221,7 +222,7 @@ class GetAttributesActionTest {
|
|
221
222
|
|
222
223
|
val resultJson = perform(textView)
|
223
224
|
assertThat(resultJson.opt("text")).isEqualTo("mock-text")
|
224
|
-
assertThat(resultJson.opt("textSize")).isEqualTo(
|
225
|
+
assertThat(resultJson.opt("textSize")).isEqualTo(24f)
|
225
226
|
assertThat(resultJson.opt("length")).isEqualTo(111)
|
226
227
|
}
|
227
228
|
|
package/android/detox/src/testFull/java/com/wix/detox/espresso/common/MaterialSliderHelperTest.kt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
package com.wix.detox.espresso.common
|
2
|
+
|
3
|
+
import android.view.View
|
4
|
+
import com.google.android.material.slider.Slider
|
5
|
+
import org.assertj.core.api.Assertions.assertThat
|
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.robolectric.RobolectricTestRunner
|
11
|
+
|
12
|
+
@RunWith(RobolectricTestRunner::class)
|
13
|
+
class MaterialSliderHelperTest {
|
14
|
+
@Test
|
15
|
+
fun `should return value if view is a slider`() {
|
16
|
+
val slider: Slider = mock {
|
17
|
+
on { value } doReturn 0.2f
|
18
|
+
}
|
19
|
+
|
20
|
+
val uut = MaterialSliderHelper(slider)
|
21
|
+
|
22
|
+
assertThat(uut.getValueIfSlider()).isEqualTo(0.2f)
|
23
|
+
}
|
24
|
+
|
25
|
+
@Test
|
26
|
+
fun `should return null if view is not a slider`() {
|
27
|
+
val view: View = mock()
|
28
|
+
|
29
|
+
val uut = MaterialSliderHelper(view)
|
30
|
+
|
31
|
+
assertThat(uut.getValueIfSlider()).isNull()
|
32
|
+
}
|
33
|
+
}
|
@@ -15,14 +15,14 @@ import org.robolectric.RobolectricTestRunner
|
|
15
15
|
* to avoid having to install the community slider under node_modules just for this.
|
16
16
|
*/
|
17
17
|
@RunWith(RobolectricTestRunner::class)
|
18
|
-
class
|
18
|
+
class ReactSliderHelperTest {
|
19
19
|
lateinit var slider: ReactSlider
|
20
|
-
lateinit var uut:
|
20
|
+
lateinit var uut: ReactSliderHelper
|
21
21
|
|
22
22
|
@Before
|
23
23
|
fun setup() {
|
24
24
|
slider = mock()
|
25
|
-
uut =
|
25
|
+
uut = ReactSliderHelper.create(slider)
|
26
26
|
}
|
27
27
|
|
28
28
|
private fun givenNativeProgressTraits(current: Int, max: Int) {
|
package/android/detox/src/testFull/java/com/wix/detox/espresso/performer/ViewActionPerformerSpec.kt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
package com.wix.detox.espresso.performer
|
2
|
+
|
3
|
+
import org.spekframework.spek2.Spek
|
4
|
+
import org.spekframework.spek2.style.specification.describe
|
5
|
+
import androidx.test.espresso.ViewAction
|
6
|
+
import com.wix.detox.espresso.MultipleViewsAction
|
7
|
+
import org.hamcrest.Matcher
|
8
|
+
import org.mockito.Mockito.*
|
9
|
+
import org.mockito.kotlin.mock
|
10
|
+
|
11
|
+
object ViewActionPerformerSpec : Spek({
|
12
|
+
|
13
|
+
describe("ViewActionPerformer") {
|
14
|
+
context("forAction") {
|
15
|
+
context("given a regular ViewAction") {
|
16
|
+
val action = mock(ViewAction::class.java)
|
17
|
+
|
18
|
+
it("should return a SingleViewActionPerformer") {
|
19
|
+
val performer = ViewActionPerformer.forAction(action)
|
20
|
+
assert(performer is SingleViewActionPerformer)
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
context("given a MultipleViewsAction") {
|
25
|
+
val multipleViewsAction: ViewAction = mock(
|
26
|
+
ViewAction::class.java,
|
27
|
+
withSettings().extraInterfaces(MultipleViewsAction::class.java)
|
28
|
+
)
|
29
|
+
|
30
|
+
it("should return a MultipleViewsActionPerformer") {
|
31
|
+
val performer = ViewActionPerformer.forAction(multipleViewsAction)
|
32
|
+
assert(performer is MultipleViewsActionPerformer)
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
})
|
@@ -7,6 +7,7 @@ import com.wix.invoke.types.ClassTarget;
|
|
7
7
|
import com.wix.invoke.types.Invocation;
|
8
8
|
import com.wix.invoke.types.InvocationTarget;
|
9
9
|
|
10
|
+
import org.json.JSONArray;
|
10
11
|
import org.json.JSONException;
|
11
12
|
import org.json.JSONObject;
|
12
13
|
import org.junit.Test;
|
@@ -21,20 +22,20 @@ public class JsonParserTest {
|
|
21
22
|
@Test
|
22
23
|
public void targetClassStaticMethodNoParams() {
|
23
24
|
Invocation invocation = new Invocation(new ClassTarget("java.lang.System"), "lineSeparator");
|
24
|
-
assertThat(parse("targetClassStaticMethodNoParams.json")).
|
25
|
+
assertThat(parse("targetClassStaticMethodNoParams.json")).usingRecursiveComparison().isEqualTo(invocation);
|
25
26
|
}
|
26
27
|
|
27
28
|
@Test
|
28
29
|
public void parseTargetClassStaticMethodOneParam() {
|
29
30
|
Invocation invocation = new Invocation(new ClassTarget("java.lang.String"), "valueOf", 1.0f);
|
30
|
-
assertThat(parse("targetClassStaticMethodOneParam.json")).
|
31
|
+
assertThat(parse("targetClassStaticMethodOneParam.json")).usingRecursiveComparison().isEqualTo(invocation);
|
31
32
|
}
|
32
33
|
|
33
34
|
@Test
|
34
35
|
public void targetInvocationMethodOfClassStaticMethodOneParam() {
|
35
36
|
Invocation innerInvocation = new Invocation(new ClassTarget("java.lang.String"), "valueOf", 1.0f);
|
36
37
|
Invocation outerInvocation = new Invocation(new InvocationTarget(innerInvocation), "length");
|
37
|
-
assertThat(parse("targetInvocationMethodOfClassStaticMethodOneParam.json")).
|
38
|
+
assertThat(parse("targetInvocationMethodOfClassStaticMethodOneParam.json")).usingRecursiveComparison().isEqualTo(outerInvocation);
|
38
39
|
}
|
39
40
|
|
40
41
|
@Test
|
@@ -46,7 +47,7 @@ public class JsonParserTest {
|
|
46
47
|
Invocation perform = new Invocation(new InvocationTarget(onView), "perform", click);
|
47
48
|
|
48
49
|
|
49
|
-
assertThat(parse("targetInvocationEspresso.json")).
|
50
|
+
assertThat(parse("targetInvocationEspresso.json")).usingRecursiveComparison().isEqualTo(perform);
|
50
51
|
}
|
51
52
|
|
52
53
|
|
@@ -59,7 +60,7 @@ public class JsonParserTest {
|
|
59
60
|
Invocation click = new Invocation(new ClassTarget("android.support.test.espresso.action.ViewActions"), "click");
|
60
61
|
Invocation perform = new Invocation(new ClassTarget("com.wix.detox.espresso.EspressoDetox"), "perform", onView, click);
|
61
62
|
|
62
|
-
assertThat(parse("targetInvocationEspressoDetox.json")).
|
63
|
+
assertThat(parse("targetInvocationEspressoDetox.json")).usingRecursiveComparison().isEqualTo(perform);
|
63
64
|
}
|
64
65
|
|
65
66
|
@Test
|
@@ -73,12 +74,27 @@ public class JsonParserTest {
|
|
73
74
|
assertThat(parse("targetInvocationEspressoWebDetox.json")).usingRecursiveComparison().isEqualTo(tap);
|
74
75
|
}
|
75
76
|
|
77
|
+
@Test
|
78
|
+
public void fromJsonTargetInvocationEspressoWebDetoxScript() throws JSONException {
|
79
|
+
Invocation getWebView = new Invocation(new ClassTarget("com.wix.detox.espresso.web.EspressoWebDetox"), "getWebView");
|
80
|
+
Invocation matcher = new Invocation(new ClassTarget("com.wix.detox.espresso.web.DetoxWebAtomMatcher"), "matcherForId", "textInput");
|
81
|
+
Invocation element = new Invocation(new InvocationTarget(getWebView), "element", matcher, 0);
|
82
|
+
|
83
|
+
String script = "function(el,arg1){}";
|
84
|
+
ArrayList<Object> scriptArguments = new ArrayList<>();
|
85
|
+
JSONArray arg1 = new JSONArray("[{ \"b\": true, \"n\": 1, \"s\": \"1\" }]");
|
86
|
+
scriptArguments.add(arg1);
|
87
|
+
|
88
|
+
Invocation runScriptWithArgs = new Invocation(new InvocationTarget(element), "runScriptWithArgs", script, scriptArguments);
|
89
|
+
assertThat(parse("targetInvocationEspressoWebDetoxScript.json")).usingRecursiveComparison().isEqualTo(runScriptWithArgs);
|
90
|
+
}
|
91
|
+
|
76
92
|
@Test
|
77
93
|
public void fromJsonTargetInvocationWithListParams() {
|
78
94
|
ArrayList<String> params = new ArrayList<>();
|
79
95
|
params.add(".*10.0.2.2.*");
|
80
96
|
Invocation test = new Invocation(new ClassTarget("com.wix.detox.espresso.EspressoDetox"), "setURLBlacklist", params);
|
81
|
-
assertThat(parse("fromJsonTargetInvocationWithListParams.json")).
|
97
|
+
assertThat(parse("fromJsonTargetInvocationWithListParams.json")).usingRecursiveComparison().isEqualTo(test);
|
82
98
|
}
|
83
99
|
|
84
100
|
public Invocation parseString(String jsonString) {
|
@@ -95,4 +111,4 @@ public class JsonParserTest {
|
|
95
111
|
String jsonString = TestUtils.jsonFileToString(filePath);
|
96
112
|
return parseString(jsonString);
|
97
113
|
}
|
98
|
-
}
|
114
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
{
|
2
|
+
"target":{
|
3
|
+
"type":"Invocation",
|
4
|
+
"value":{
|
5
|
+
"target":{
|
6
|
+
"type":"Invocation",
|
7
|
+
"value":{
|
8
|
+
"target":{
|
9
|
+
"type":"Class",
|
10
|
+
"value":"com.wix.detox.espresso.web.EspressoWebDetox"
|
11
|
+
},
|
12
|
+
"method":"getWebView",
|
13
|
+
"args":[
|
14
|
+
|
15
|
+
]
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"method":"element",
|
19
|
+
"args":[
|
20
|
+
{
|
21
|
+
"type":"Invocation",
|
22
|
+
"value":{
|
23
|
+
"target":{
|
24
|
+
"type":"Class",
|
25
|
+
"value":"com.wix.detox.espresso.web.DetoxWebAtomMatcher"
|
26
|
+
},
|
27
|
+
"method":"matcherForId",
|
28
|
+
"args":[
|
29
|
+
"textInput"
|
30
|
+
]
|
31
|
+
}
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"type":"Integer",
|
35
|
+
"value":0
|
36
|
+
}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
},
|
40
|
+
"method": "runScriptWithArgs",
|
41
|
+
"args": [
|
42
|
+
"function(el,arg1){}",
|
43
|
+
[
|
44
|
+
[{ "b": true, "n": 1, "s": "1" }]
|
45
|
+
]
|
46
|
+
]
|
47
|
+
}
|
package/android/rninfo.gradle
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import groovy.json.JsonSlurper
|
2
2
|
|
3
|
-
def rnVersion = getRNVersion()
|
3
|
+
def rnVersion = getRNVersion(project.rootDir)
|
4
4
|
def rnMajorVer = getMajorVersion(rnVersion)
|
5
5
|
println "[$project] RNInfo: detected React Native version: $rnVersion (major=$rnMajorVer)"
|
6
6
|
|
@@ -12,9 +12,9 @@ project.ext.rnInfo = [
|
|
12
12
|
isRN71OrHigher: rnMajorVer >= 71,
|
13
13
|
]
|
14
14
|
|
15
|
-
private static def getRNVersion() {
|
15
|
+
private static def getRNVersion(workingDir) {
|
16
16
|
def jsonSlurper = new JsonSlurper()
|
17
|
-
Map<String, Object> packageJSON = jsonSlurper.parse(new File(
|
17
|
+
Map<String, Object> packageJSON = jsonSlurper.parse(new File("$workingDir/../node_modules/react-native/package.json"))
|
18
18
|
String rnVersion = packageJSON.get('version')
|
19
19
|
return rnVersion
|
20
20
|
}
|