detox 20.14.0-smoke.0 → 20.14.0
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/{20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar → 20.14.0/detox-20.14.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar → 20.14.0/detox-20.14.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.14.0-smoke.0/detox-20.14.0-smoke.0.pom → 20.14.0/detox-20.14.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.14.0/detox-20.14.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/android/detox/build.gradle +8 -4
- package/android/detox/src/full/java/com/wix/detox/Detox.java +1 -7
- package/android/detox/src/full/java/com/wix/detox/DetoxMain.kt +55 -72
- package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxActionHandlers.kt +0 -15
- package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxActionsDispatcher.kt +16 -6
- package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxServerAdapter.kt +0 -2
- package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +4 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +0 -14
- package/android/detox/src/full/java/com/wix/invoke/types/Invocation.java +2 -2
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/MotionEvents.kt +60 -4
- package/android/detox/src/testFull/java/com/wix/invoke/JsonParserTest.java +23 -7
- package/android/detox/src/testFull/resources/targetInvocationEspressoWebDetoxScript.json +47 -0
- package/detox.d.ts +1830 -0
- package/globals.d.ts +23 -0
- package/index.d.ts +2 -1838
- package/internals.d.ts +2 -1
- package/jest.config.js +108 -0
- package/local-cli/testCommand/TestRunnerCommand.js +26 -3
- package/local-cli/utils/interruptListeners.js +15 -0
- package/package.json +3 -99
- 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 +7 -1
- package/src/android/core/WebElement.js +24 -6
- package/src/android/espressoapi/web/WebElement.js +1 -4
- package/src/configuration/composeRunnerConfig.js +3 -1
- package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +3 -5
- package/src/devices/allocation/factories/ios.js +1 -4
- package/src/devices/common/drivers/android/tools/instrumentationArgs.js +7 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +5 -4
- package/src/devices/runtime/factories/ios.js +0 -2
- package/src/ipc/IPCClient.js +2 -2
- package/src/ipc/IPCServer.js +5 -3
- package/src/realms/DetoxContext.js +1 -1
- package/src/realms/DetoxPrimaryContext.js +2 -2
- package/src/realms/DetoxSecondaryContext.js +2 -2
- package/src/utils/assertIsFunction.js +35 -0
- package/src/utils/isArrowFunction.js +24 -0
- package/tsconfig.json +3 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha512 +0 -1
- package/runners/jest/reporters/DetoxReporter.js +0 -154
- package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +0 -25
package/.eslintignore
CHANGED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
6f56fccb91a86713ebb2fc576e82039d
|
@@ -0,0 +1 @@
|
|
1
|
+
754176c710b6e4f1af667773e37a399e4786e6d4
|
@@ -0,0 +1 @@
|
|
1
|
+
cc50c16a411723ac745bd01f103038e1af06a9fe172ec4da1918793bc8765a04
|
@@ -0,0 +1 @@
|
|
1
|
+
d8617e60a2de84c1e3d3c5acb2fd1ea1516fc39cd2295d0f22222aac3eb6200387875af5ec4f87865790e81db4ef4d4431ca00c98e54f517f4c6ecb7d41eaa70
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
d051bf6a91bb21da6571b1638b9c82f5
|
@@ -0,0 +1 @@
|
|
1
|
+
1c97086b846b030e12672ddb950e52509ccb66f1
|
@@ -0,0 +1 @@
|
|
1
|
+
1b8af7d65897ae117b45f3ea6f616a8063fe5310870fcf90dee93cd59ec25db0
|
@@ -0,0 +1 @@
|
|
1
|
+
a0dcbf7873645878aa25df38c28122e268ea938cab81d8027e85551218550dcd3a893ec48cd88af45c3ccdf64b1989d74fab2a4b166f0fed8e5d7bc16ec3ee0f
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
5802af204da6a4e44339eb5b544e816d
|
@@ -0,0 +1 @@
|
|
1
|
+
530bd1ee5be0479b9d48b33722b521ef408d82b7
|
@@ -0,0 +1 @@
|
|
1
|
+
4efd5d50625590c576c69a3a722d8df776fa213cff6e1fa254ec429d4db6fb58
|
@@ -0,0 +1 @@
|
|
1
|
+
19b779508bf7d9059f23fd638114bb817eee061bf018fcf793b451f63b3c5d8519e20f85fceffa61863d59244f168692d1e4e8d861be979200a2130c4486b9e8
|
@@ -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.14.0
|
6
|
+
<version>20.14.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>
|
@@ -0,0 +1 @@
|
|
1
|
+
0c5222ee7674b2cc7b96555b70e3467a
|
@@ -0,0 +1 @@
|
|
1
|
+
f9edd0e97cf8f517117ecda80c7750c1f29fcef4
|
@@ -0,0 +1 @@
|
|
1
|
+
37d489ab6d0fdfb0393fa08ecf63f86143475e3024419044d4c2079d88e61622
|
@@ -0,0 +1 @@
|
|
1
|
+
a7b182129f8993dbda457ccdd2264815de9d8bc2c0a1e32803f69078d622f4a6b0c246776c053327111f6b531201e1e108d9d326e4cfea0dba0aba277d738293
|
@@ -3,11 +3,11 @@
|
|
3
3
|
<groupId>com.wix</groupId>
|
4
4
|
<artifactId>detox</artifactId>
|
5
5
|
<versioning>
|
6
|
-
<latest>20.14.0
|
7
|
-
<release>20.14.0
|
6
|
+
<latest>20.14.0</latest>
|
7
|
+
<release>20.14.0</release>
|
8
8
|
<versions>
|
9
|
-
<version>20.14.0
|
9
|
+
<version>20.14.0</version>
|
10
10
|
</versions>
|
11
|
-
<lastUpdated>
|
11
|
+
<lastUpdated>20231210163331</lastUpdated>
|
12
12
|
</versioning>
|
13
13
|
</metadata>
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ced231901009d2c029e5aede431056b4
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
13075663f209c8921a22e79c588761ed4cdfd63b
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
c7f90237e91df79c7e1eaf2d36b21fe321c122f629adcac834d94f3e72c2743a
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
5f1fa89ed8dcde704cfcb08fec6fa7126f9356d1ff215bc0a1a1444884ea49e9d7c7a2bae523d72b78b5e9080681b9bcecb6e5afb2e202beb27e43f8562e6d19
|
package/Detox-ios-src.tbz
CHANGED
Binary file
|
package/Detox-ios.tbz
CHANGED
Binary file
|
@@ -21,8 +21,12 @@ def _rnNativeArtifact = rnInfo.isRN71OrHigher
|
|
21
21
|
: 'com.facebook.react:react-native:+'
|
22
22
|
|
23
23
|
android {
|
24
|
-
|
25
|
-
|
24
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
|
25
|
+
if (agpVersion >= 7) {
|
26
|
+
namespace "com.wix.detox"
|
27
|
+
}
|
28
|
+
compileSdk _compileSdkVersion
|
29
|
+
buildToolsVersion = _buildToolsVersion
|
26
30
|
|
27
31
|
defaultConfig {
|
28
32
|
minSdkVersion _minSdkVersion
|
@@ -33,7 +37,7 @@ android {
|
|
33
37
|
consumerProguardFiles 'proguard-rules.pro'
|
34
38
|
}
|
35
39
|
|
36
|
-
flavorDimensions 'detox'
|
40
|
+
flavorDimensions = ['detox']
|
37
41
|
productFlavors {
|
38
42
|
full {
|
39
43
|
dimension 'detox'
|
@@ -48,7 +52,7 @@ android {
|
|
48
52
|
unitTests.returnDefaultValues = true
|
49
53
|
unitTests.all { t ->
|
50
54
|
reports {
|
51
|
-
html.
|
55
|
+
html.required = true
|
52
56
|
}
|
53
57
|
testLogging {
|
54
58
|
events "passed", "skipped", "failed", "standardOut", "standardError"
|
@@ -123,13 +123,7 @@ public final class Detox {
|
|
123
123
|
DetoxConfig.CONFIG.apply();
|
124
124
|
|
125
125
|
sActivityLaunchHelper = new ActivityLaunchHelper(activityTestRule);
|
126
|
-
|
127
|
-
try {
|
128
|
-
DetoxMain.run(context, sActivityLaunchHelper);
|
129
|
-
} catch (Exception e) {
|
130
|
-
Thread.currentThread().interrupt();
|
131
|
-
throw new RuntimeException("Detox got interrupted prematurely", e);
|
132
|
-
}
|
126
|
+
DetoxMain.run(context, sActivityLaunchHelper);
|
133
127
|
}
|
134
128
|
|
135
129
|
public static void launchMainActivity() {
|
@@ -2,53 +2,63 @@ package com.wix.detox
|
|
2
2
|
|
3
3
|
import android.content.Context
|
4
4
|
import android.util.Log
|
5
|
-
import com.wix.detox.adapters.server
|
6
|
-
import com.wix.detox.adapters.server.DetoxActionHandler
|
7
|
-
import com.wix.detox.adapters.server.DetoxActionsDispatcher
|
8
|
-
import com.wix.detox.adapters.server.DetoxServerAdapter
|
9
|
-
import com.wix.detox.adapters.server.DetoxServerInfo
|
10
|
-
import com.wix.detox.adapters.server.InstrumentsEventsActionsHandler
|
11
|
-
import com.wix.detox.adapters.server.InstrumentsRecordingStateActionHandler
|
12
|
-
import com.wix.detox.adapters.server.InvokeActionHandler
|
13
|
-
import com.wix.detox.adapters.server.OutboundServerAdapter
|
14
|
-
import com.wix.detox.adapters.server.PrematureReadyHandler
|
15
|
-
import com.wix.detox.adapters.server.QueryStatusActionHandler
|
16
|
-
import com.wix.detox.adapters.server.ReactNativeReloadActionHandler
|
17
|
-
import com.wix.detox.adapters.server.ReadyActionHandler
|
5
|
+
import com.wix.detox.adapters.server.*
|
18
6
|
import com.wix.detox.common.DetoxLog
|
19
7
|
import com.wix.detox.espresso.UiControllerSpy
|
20
8
|
import com.wix.detox.instruments.DetoxInstrumentsManager
|
21
9
|
import com.wix.detox.reactnative.ReactNativeExtension
|
22
10
|
import com.wix.invoke.MethodInvocation
|
11
|
+
import java.util.concurrent.CountDownLatch
|
23
12
|
|
24
|
-
private const val INIT_ACTION = "_init"
|
25
|
-
private const val IS_READY_ACTION = "isReady"
|
26
13
|
private const val TERMINATION_ACTION = "_terminate"
|
27
14
|
|
28
15
|
object DetoxMain {
|
16
|
+
private val handshakeLock = CountDownLatch(1)
|
17
|
+
|
29
18
|
@JvmStatic
|
30
19
|
fun run(rnHostHolder: Context, activityLaunchHelper: ActivityLaunchHelper) {
|
31
20
|
val detoxServerInfo = DetoxServerInfo()
|
32
21
|
val testEngineFacade = TestEngineFacade()
|
33
22
|
val actionsDispatcher = DetoxActionsDispatcher()
|
34
|
-
val
|
23
|
+
val serverAdapter = DetoxServerAdapter(actionsDispatcher, detoxServerInfo, TERMINATION_ACTION)
|
24
|
+
|
25
|
+
initCrashHandler(serverAdapter)
|
26
|
+
initANRListener(serverAdapter)
|
27
|
+
initEspresso()
|
28
|
+
initReactNative()
|
29
|
+
|
30
|
+
setupActionHandlers(actionsDispatcher, serverAdapter, testEngineFacade, rnHostHolder)
|
31
|
+
serverAdapter.connect()
|
35
32
|
|
36
|
-
|
37
|
-
actionsDispatcher.dispatchAction(INIT_ACTION, "", 0)
|
33
|
+
launchActivityOnCue(rnHostHolder, activityLaunchHelper)
|
38
34
|
actionsDispatcher.join()
|
39
35
|
}
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
/**
|
38
|
+
* Launch the tested activity "on cue", namely, right after a connection is established and the handshake
|
39
|
+
* completes successfully.
|
40
|
+
*
|
41
|
+
* This has to be synchronized so that an `isReady` isn't handled *before* the activity is launched (albeit not fully
|
42
|
+
* initialized - all native modules and everything) and a react context is available.
|
43
|
+
*
|
44
|
+
* As a better alternative, it would make sense to execute this as a simple action from within the actions
|
45
|
+
* dispatcher (i.e. handler of `loginSuccess`), in which case, no inter-thread locking would be required
|
46
|
+
* thanks to the usage of Handlers. However, in this type of a solution, errors / crashes would be reported
|
47
|
+
* not by instrumentation itself, but based on the `AppWillTerminateWithError` message; In it's own, it is a good
|
48
|
+
* thing, but for a reason we're not sure of yet, it is ignored by the test runner at this point in the flow.
|
49
|
+
*/
|
50
|
+
@Synchronized
|
51
|
+
private fun launchActivityOnCue(rnHostHolder: Context, activityLaunchHelper: ActivityLaunchHelper) {
|
52
|
+
awaitHandshake()
|
53
|
+
launchActivity(rnHostHolder, activityLaunchHelper)
|
54
|
+
}
|
46
55
|
|
47
|
-
|
56
|
+
private fun awaitHandshake() {
|
57
|
+
handshakeLock.await()
|
48
58
|
}
|
49
59
|
|
50
|
-
private fun
|
51
|
-
|
60
|
+
private fun onLoginSuccess() {
|
61
|
+
handshakeLock.countDown()
|
52
62
|
}
|
53
63
|
|
54
64
|
private fun doTeardown(serverAdapter: DetoxServerAdapter, actionsDispatcher: DetoxActionsDispatcher, testEngineFacade: TestEngineFacade) {
|
@@ -58,50 +68,28 @@ object DetoxMain {
|
|
58
68
|
actionsDispatcher.teardown()
|
59
69
|
}
|
60
70
|
|
61
|
-
private fun
|
71
|
+
private fun setupActionHandlers(actionsDispatcher: DetoxActionsDispatcher, serverAdapter: DetoxServerAdapter, testEngineFacade: TestEngineFacade, rnHostHolder: Context) {
|
72
|
+
class SynchronizedActionHandler(private val actionHandler: DetoxActionHandler): DetoxActionHandler {
|
73
|
+
override fun handle(params: String, messageId: Long) {
|
74
|
+
synchronized(this@DetoxMain) {
|
75
|
+
actionHandler.handle(params, messageId)
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
62
80
|
// Primary actions
|
63
81
|
with(actionsDispatcher) {
|
64
|
-
|
65
|
-
val rnReloadHandler = ReactNativeReloadActionHandler(rnHostHolder, serverAdapter, testEngineFacade)
|
66
|
-
|
67
|
-
associateActionHandler(
|
68
|
-
|
69
|
-
|
70
|
-
this@DetoxMain.doInit(serverAdapter)
|
71
|
-
}
|
72
|
-
})
|
73
|
-
associateActionHandler(IS_READY_ACTION, prematureIsReadyHandler!!)
|
74
|
-
|
75
|
-
associateActionHandler("loginSuccess", object: DetoxActionHandler {
|
76
|
-
override fun handle(params: String, messageId: Long) {
|
77
|
-
synchronized(this@DetoxMain) {
|
78
|
-
this@DetoxMain.onConnected(activityLaunchHelper, rnHostHolder)
|
79
|
-
associateActionHandler(IS_READY_ACTION, ReadyActionHandler(serverAdapter, testEngineFacade))
|
80
|
-
|
81
|
-
prematureIsReadyHandler?.let {
|
82
|
-
if (it.isActionPending) {
|
83
|
-
actionsDispatcher.dispatchAction(IS_READY_ACTION, it.params!!, it.messageId!!)
|
84
|
-
}
|
85
|
-
prematureIsReadyHandler = null
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
})
|
90
|
-
associateActionHandler("reactNativeReload", object: DetoxActionHandler {
|
91
|
-
override fun handle(params: String, messageId: Long) =
|
92
|
-
synchronized(this@DetoxMain) {
|
93
|
-
rnReloadHandler.handle(params, messageId)
|
94
|
-
}
|
95
|
-
})
|
82
|
+
val readyHandler = SynchronizedActionHandler( ReadyActionHandler(serverAdapter, testEngineFacade) )
|
83
|
+
val rnReloadHandler = SynchronizedActionHandler( ReactNativeReloadActionHandler(rnHostHolder, serverAdapter, testEngineFacade) )
|
84
|
+
|
85
|
+
associateActionHandler("loginSuccess", ::onLoginSuccess)
|
86
|
+
associateActionHandler("isReady", readyHandler)
|
87
|
+
associateActionHandler("reactNativeReload", rnReloadHandler)
|
96
88
|
associateActionHandler("invoke", InvokeActionHandler(MethodInvocation(), serverAdapter))
|
97
89
|
associateActionHandler("cleanup", CleanupActionHandler(serverAdapter, testEngineFacade) {
|
98
90
|
dispatchAction(TERMINATION_ACTION, "", 0)
|
99
91
|
})
|
100
|
-
associateActionHandler(TERMINATION_ACTION,
|
101
|
-
override fun handle(params: String, messageId: Long) {
|
102
|
-
this@DetoxMain.doTeardown(serverAdapter, actionsDispatcher, testEngineFacade)
|
103
|
-
}
|
104
|
-
})
|
92
|
+
associateActionHandler(TERMINATION_ACTION) { -> doTeardown(serverAdapter, actionsDispatcher, testEngineFacade) }
|
105
93
|
|
106
94
|
if (DetoxInstrumentsManager.supports()) {
|
107
95
|
val instrumentsManager = DetoxInstrumentsManager(rnHostHolder)
|
@@ -112,13 +100,8 @@ object DetoxMain {
|
|
112
100
|
|
113
101
|
// Secondary actions
|
114
102
|
with(actionsDispatcher) {
|
115
|
-
val queryStatusHandler = QueryStatusActionHandler(serverAdapter, testEngineFacade)
|
116
|
-
|
117
|
-
override fun handle(params: String, messageId: Long) =
|
118
|
-
synchronized(this@DetoxMain) {
|
119
|
-
queryStatusHandler.handle(params, messageId)
|
120
|
-
}
|
121
|
-
}, false)
|
103
|
+
val queryStatusHandler = SynchronizedActionHandler( QueryStatusActionHandler(serverAdapter, testEngineFacade) )
|
104
|
+
associateSecondaryActionHandler("currentStatus", queryStatusHandler)
|
122
105
|
}
|
123
106
|
}
|
124
107
|
|
@@ -138,7 +121,7 @@ object DetoxMain {
|
|
138
121
|
ReactNativeExtension.initIfNeeded()
|
139
122
|
}
|
140
123
|
|
141
|
-
private fun
|
124
|
+
private fun launchActivity(rnHostHolder: Context, activityLaunchHelper: ActivityLaunchHelper) {
|
142
125
|
Log.i(DetoxLog.LOG_TAG, "Launching the tested activity!")
|
143
126
|
activityLaunchHelper.launchActivityUnderTest()
|
144
127
|
ReactNativeExtension.waitForRNBootstrap(rnHostHolder)
|
@@ -3,7 +3,6 @@ package com.wix.detox.adapters.server
|
|
3
3
|
import android.content.Context
|
4
4
|
import android.util.Log
|
5
5
|
import com.wix.detox.TestEngineFacade
|
6
|
-
import com.wix.detox.common.DetoxLog
|
7
6
|
import com.wix.detox.common.extractRootCause
|
8
7
|
import com.wix.detox.instruments.DetoxInstrumentsException
|
9
8
|
import com.wix.detox.instruments.DetoxInstrumentsManager
|
@@ -28,20 +27,6 @@ class ReadyActionHandler(
|
|
28
27
|
}
|
29
28
|
}
|
30
29
|
|
31
|
-
class PrematureReadyHandler(): DetoxActionHandler {
|
32
|
-
var isActionPending = false
|
33
|
-
var params: String? = null
|
34
|
-
var messageId: Long? = null
|
35
|
-
|
36
|
-
override fun handle(params: String, messageId: Long) {
|
37
|
-
Log.i(DetoxLog.LOG_TAG, "Got a premature ready action, saving for later...")
|
38
|
-
|
39
|
-
this.isActionPending = true
|
40
|
-
this.params = params
|
41
|
-
this.messageId = messageId
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
30
|
open class ReactNativeReloadActionHandler(
|
46
31
|
private val appContext: Context,
|
47
32
|
private val outboundServerAdapter: OutboundServerAdapter,
|
@@ -11,11 +11,18 @@ class DetoxActionsDispatcher {
|
|
11
11
|
private val primaryExec = ActionsExecutor("detox.primary")
|
12
12
|
private val secondaryExec = ActionsExecutor("detox.secondary")
|
13
13
|
|
14
|
-
fun associateActionHandler(type: String, actionHandler: DetoxActionHandler
|
15
|
-
|
16
|
-
|
14
|
+
fun associateActionHandler(type: String, actionHandler: DetoxActionHandler) =
|
15
|
+
associateActionHandler(type, actionHandler, true)
|
16
|
+
|
17
|
+
fun associateActionHandler(type: String, handlerFunc: () -> Unit) {
|
18
|
+
associateActionHandler(type, object: DetoxActionHandler {
|
19
|
+
override fun handle(params: String, messageId: Long) = handlerFunc()
|
20
|
+
})
|
17
21
|
}
|
18
22
|
|
23
|
+
fun associateSecondaryActionHandler(type: String, actionHandler: DetoxActionHandler) =
|
24
|
+
associateActionHandler(type, actionHandler, false)
|
25
|
+
|
19
26
|
fun dispatchAction(type: String, params: String, messageId: Long) {
|
20
27
|
(primaryExec.executeAction(type, params, messageId) ||
|
21
28
|
secondaryExec.executeAction(type, params, messageId))
|
@@ -33,6 +40,11 @@ class DetoxActionsDispatcher {
|
|
33
40
|
primaryExec.join()
|
34
41
|
secondaryExec.join()
|
35
42
|
}
|
43
|
+
|
44
|
+
private fun associateActionHandler(type: String, actionHandler: DetoxActionHandler, isPrimary: Boolean = true) {
|
45
|
+
val actionsExecutor = (if (isPrimary) primaryExec else secondaryExec)
|
46
|
+
actionsExecutor.associateHandler(type, actionHandler)
|
47
|
+
}
|
36
48
|
}
|
37
49
|
|
38
50
|
private class ActionsExecutor(name: String) {
|
@@ -74,7 +86,5 @@ private class ActionsExecutor(name: String) {
|
|
74
86
|
handler.looper.quit()
|
75
87
|
}
|
76
88
|
|
77
|
-
fun join()
|
78
|
-
thread.join()
|
79
|
-
}
|
89
|
+
fun join() = thread.join()
|
80
90
|
}
|
@@ -10,7 +10,6 @@ interface OutboundServerAdapter {
|
|
10
10
|
class DetoxServerAdapter(
|
11
11
|
private val actionsDispatcher: DetoxActionsDispatcher,
|
12
12
|
private val detoxServerInfo: DetoxServerInfo,
|
13
|
-
private val readyActionType: String,
|
14
13
|
private val terminationActionType: String)
|
15
14
|
: WebSocketClient.WSEventsHandler, OutboundServerAdapter {
|
16
15
|
|
@@ -27,7 +26,6 @@ class DetoxServerAdapter(
|
|
27
26
|
|
28
27
|
override fun onConnect() {
|
29
28
|
Log.i(DetoxLog.LOG_TAG, "Connected to server!")
|
30
|
-
actionsDispatcher.dispatchAction(readyActionType, "", -1000L)
|
31
29
|
}
|
32
30
|
|
33
31
|
override fun onClosed() {
|
@@ -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() {
|
@@ -36,7 +36,6 @@ object ReactNativeExtension {
|
|
36
36
|
val reactContext = awaitNewReactNativeContext(it, null)
|
37
37
|
|
38
38
|
enableOrDisableSynchronization(reactContext)
|
39
|
-
hackRN50WaitForReady()
|
40
39
|
}
|
41
40
|
}
|
42
41
|
|
@@ -66,7 +65,6 @@ object ReactNativeExtension {
|
|
66
65
|
val reactContext = awaitNewReactNativeContext(it, previousReactContext)
|
67
66
|
|
68
67
|
enableOrDisableSynchronization(reactContext, networkSyncEnabled)
|
69
|
-
hackRN50WaitForReady()
|
70
68
|
}
|
71
69
|
}
|
72
70
|
|
@@ -152,18 +150,6 @@ object ReactNativeExtension {
|
|
152
150
|
}
|
153
151
|
}
|
154
152
|
|
155
|
-
private fun hackRN50WaitForReady() {
|
156
|
-
if (ReactNativeInfo.rnVersion().minor in 50..62) {
|
157
|
-
try {
|
158
|
-
//TODO- Temp hack to make Detox usable for RN>=50 till we find a better sync solution.
|
159
|
-
Thread.sleep(1000)
|
160
|
-
} catch (e: InterruptedException) {
|
161
|
-
e.printStackTrace()
|
162
|
-
}
|
163
|
-
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
153
|
private fun clearIdlingResources() {
|
168
154
|
rnIdlingResources?.unregisterAll()
|
169
155
|
rnIdlingResources = null
|
@@ -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 {
|
@@ -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)
|