detox 20.13.0 → 20.14.0-smoke.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0-javadoc.jar → 20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0-sources.jar → 20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.13.0/detox-20.13.0.pom → 20.14.0-smoke.0/detox-20.14.0-smoke.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.14.0-smoke.0/detox-20.14.0-smoke.0.pom.sha512 +1 -0
  21. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  22. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  26. package/Detox-ios-src.tbz +0 -0
  27. package/Detox-ios.tbz +0 -0
  28. package/android/detox/src/full/java/com/wix/detox/ActivityLaunchHelper.kt +76 -0
  29. package/android/detox/src/full/java/com/wix/detox/Detox.java +8 -64
  30. package/android/detox/src/full/java/com/wix/detox/DetoxMain.kt +58 -16
  31. package/android/detox/src/full/java/com/wix/detox/LaunchIntentsFactory.kt +1 -1
  32. package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxActionHandlers.kt +15 -4
  33. package/android/detox/src/full/java/com/wix/detox/adapters/server/DetoxServerInfo.kt +4 -2
  34. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactMarkersLogger.kt +44 -0
  35. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +28 -21
  36. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +0 -3
  37. package/package.json +2 -2
  38. package/src/android/espressoapi/Detox.js +0 -11
  39. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.md5 +0 -1
  40. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha1 +0 -1
  41. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha256 +0 -1
  42. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha512 +0 -1
  43. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.md5 +0 -1
  44. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha1 +0 -1
  45. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha256 +0 -1
  46. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha512 +0 -1
  47. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar +0 -0
  48. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.md5 +0 -1
  49. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha1 +0 -1
  50. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha256 +0 -1
  51. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha512 +0 -1
  52. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.md5 +0 -1
  53. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha1 +0 -1
  54. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha256 +0 -1
  55. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha512 +0 -1
@@ -0,0 +1 @@
1
+ 0c2bae26c123edf10cb62b77d5e5acdd
@@ -0,0 +1 @@
1
+ 96b7351396c83931de86925d213b5bc9d12a827d
@@ -0,0 +1 @@
1
+ dbe5afc9df9a7c857a961781ebd58be8cf1d82c39771819b6c801f36b44434d4
@@ -0,0 +1 @@
1
+ 8e4f2278448ac644826386e11b95b24f44037c1483f0bae0c1347dfc0a01783e058f9b229b5d9e217f8be08984ff0035a8a9a028503f672f2baff523d3dc037c
@@ -0,0 +1 @@
1
+ 4db28745d12fb52a9b94eefe7aef7c6d
@@ -0,0 +1 @@
1
+ 5101597e82e164ba10f7ecd0e15ee7a4316fdccc
@@ -0,0 +1 @@
1
+ e7bc12d7cbefc0831194c059a2b62166bfda3a63e9e34d212418eed88155462f
@@ -0,0 +1 @@
1
+ 6cc5ce462ef6068c314ffa8d8a06d6c091b819baa7d3d1b329bd6a907e3c7909db097fac66381b3833bbfcb3bd1226f5c1e511cad080b1e2a3a914ff91af6f61
@@ -0,0 +1 @@
1
+ b8569c6d3b296face8b6d34037e27b6e
@@ -0,0 +1 @@
1
+ fe831778fa7fbeffb2ccdbb15bf3200ec0e641b2
@@ -0,0 +1 @@
1
+ 305c99310501d83ad114e4357d1af6efccf8ff774ec5ad25a04f7d9921203225
@@ -0,0 +1 @@
1
+ f02ad136e06b87c385b1ec7d8d9ad27259cdd2f9eec6dae79eb79eb9e7e78614b55bbb33773da61990ea5e594b0dff92c8013f5d3687c9c04710916e95d70418
@@ -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.13.0</version>
6
+ <version>20.14.0-smoke.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
+ 84130ea1d35084f1db1652765a011da8
@@ -0,0 +1 @@
1
+ 0dc75a3ca7a62dadea9abdd8c20d8cade91ff0ad
@@ -0,0 +1 @@
1
+ cc11f65f610d8f9cc708b0295e6998ee7e819ae7dc34d9f54586790ee253d4b2
@@ -0,0 +1 @@
1
+ 592a6a8c132c98bb7e7cb531ec495cb83bd4bc004fd8388f361199359c293d10169e9af1a771efd9d79db0e9e65d2dd75cb3d4aa9b32909c01dc561368165ea0
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.13.0</latest>
7
- <release>20.13.0</release>
6
+ <latest>20.14.0-smoke.0</latest>
7
+ <release>20.14.0-smoke.0</release>
8
8
  <versions>
9
- <version>20.13.0</version>
9
+ <version>20.14.0-smoke.0</version>
10
10
  </versions>
11
- <lastUpdated>20231002075250</lastUpdated>
11
+ <lastUpdated>20231004101112</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 253d464cc30a2d00e586eadca31d5952
1
+ db9bf329cefd7a3174b46ce70f497a99
@@ -1 +1 @@
1
- 1a402a8246b4532c9be982b61c2b4d3b3e6ab741
1
+ 2166ac54d8a199afca7309e193e586480014f074
@@ -1 +1 @@
1
- 09104c2799b83cedb2f68628779529f7efb1e96b3e33c0ed8c814da6a5e19ef8
1
+ d872213b54196e083fdfac1b0f921ba338e96aa4d21e1971ac9f8e70cd20003c
@@ -1 +1 @@
1
- b1547a601cae891dc3f1a58b66c63e70670d9f3e512c50cb6d26d40568972b94cb2f28887c13ea8d04e2b75b57bba73f8ba4ad780b471009fed3cd4e42b469ae
1
+ 1ca24fd031e6a4bd8ac6197a4ff263b33a25a60b075291dac8ea33c8127623a8dbf65462f9e65d77ce493f1a2f07e09fbb5e9219e52e8ed457a3c293a86b118b
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
@@ -0,0 +1,76 @@
1
+ package com.wix.detox
2
+
3
+ import android.app.Instrumentation.ActivityMonitor
4
+ import android.content.Context
5
+ import android.content.Intent
6
+ import androidx.test.platform.app.InstrumentationRegistry
7
+ import androidx.test.rule.ActivityTestRule
8
+
9
+ class ActivityLaunchHelper(private val activityTestRule: ActivityTestRule<*>) {
10
+
11
+ private val launchArgs = LaunchArgs()
12
+ private val intentsFactory = LaunchIntentsFactory()
13
+
14
+ fun launchActivityUnderTest() {
15
+ val intent = extractInitialIntent()
16
+ activityTestRule.launchActivity(intent)
17
+ }
18
+
19
+ fun launchMainActivity() {
20
+ val activity = activityTestRule.activity
21
+ launchActivitySync(intentsFactory.activityLaunchIntent(activity))
22
+ }
23
+
24
+ fun startActivityFromUrl(url: String) {
25
+ launchActivitySync(intentsFactory.intentWithUrl(url, false))
26
+ }
27
+
28
+ fun startActivityFromNotification(dataFilePath: String) {
29
+ val notificationData = NotificationDataParser(dataFilePath!!).toBundle()
30
+ val intent = intentsFactory.intentWithNotificationData(appContext, notificationData, false)
31
+ launchActivitySync(intent)
32
+ }
33
+
34
+ private fun extractInitialIntent(): Intent =
35
+ if (launchArgs.hasUrlOverride()) {
36
+ intentsFactory.intentWithUrl(launchArgs.urlOverride, true)
37
+ } else if (launchArgs.hasNotificationPath()) {
38
+ val notificationData = NotificationDataParser(launchArgs.notificationPath).toBundle()
39
+ intentsFactory.intentWithNotificationData(appContext, notificationData, true)
40
+ } else {
41
+ intentsFactory.cleanIntent()
42
+ }.also {
43
+ it.putExtra(INTENT_LAUNCH_ARGS_KEY, launchArgs.asIntentBundle())
44
+ }
45
+
46
+ private fun launchActivitySync(intent: Intent) {
47
+ // Ideally, we would just call sActivityTestRule.launchActivity(intent) and get it over with.
48
+ // BUT!!! as it turns out, Espresso has an issue where doing this for an activity running in the background
49
+ // would have Espresso set up an ActivityMonitor which will spend its time waiting for the activity to load, *without
50
+ // ever being released*. It will finally fail after a 45 seconds timeout.
51
+ // Without going into full details, it seems that activity test rules were not meant to be used this way. However,
52
+ // the all-new ActivityScenario implementation introduced in androidx could probably support this (e.g. by using
53
+ // dedicated methods such as moveToState(), which give better control over the lifecycle).
54
+ // In any case, this is the core reason for this issue: https://github.com/wix/Detox/issues/1125
55
+ // What it forces us to do, then, is this -
56
+ // 1. Launch the activity by "ourselves" from the OS (i.e. using context.startActivity()).
57
+ // 2. Set up an activity monitor by ourselves -- such that it would block until the activity is ready.
58
+ // ^ Hence the code below.
59
+ val activity = activityTestRule.activity
60
+ val activityMonitor = ActivityMonitor(activity.javaClass.name, null, true)
61
+ activity.startActivity(intent)
62
+
63
+ InstrumentationRegistry.getInstrumentation().run {
64
+ addMonitor(activityMonitor)
65
+ waitForMonitorWithTimeout(activityMonitor, ACTIVITY_LAUNCH_TIMEOUT)
66
+ }
67
+ }
68
+
69
+ private val appContext: Context
70
+ get() = InstrumentationRegistry.getInstrumentation().targetContext.applicationContext
71
+
72
+ companion object {
73
+ private const val INTENT_LAUNCH_ARGS_KEY = "launchArgs"
74
+ private const val ACTIVITY_LAUNCH_TIMEOUT = 10000L
75
+ }
76
+ }
@@ -1,18 +1,13 @@
1
1
  package com.wix.detox;
2
2
 
3
- import android.app.Activity;
4
- import android.app.Instrumentation;
5
3
  import android.content.Context;
6
- import android.content.Intent;
7
- import android.os.Bundle;
8
-
9
- import com.wix.detox.config.DetoxConfig;
10
- import com.wix.detox.espresso.UiControllerSpy;
11
4
 
12
5
  import androidx.annotation.NonNull;
13
6
  import androidx.test.platform.app.InstrumentationRegistry;
14
7
  import androidx.test.rule.ActivityTestRule;
15
8
 
9
+ import com.wix.detox.config.DetoxConfig;
10
+
16
11
  /**
17
12
  * <p>Static class.</p>
18
13
  *
@@ -67,12 +62,7 @@ import androidx.test.rule.ActivityTestRule;
67
62
  * <p>If not set, then Detox tests are no ops. So it's safe to mix it with other tests.</p>
68
63
  */
69
64
  public final class Detox {
70
- private static final String INTENT_LAUNCH_ARGS_KEY = "launchArgs";
71
- private static final long ACTIVITY_LAUNCH_TIMEOUT = 10000L;
72
-
73
- private static final LaunchArgs sLaunchArgs = new LaunchArgs();
74
- private static final LaunchIntentsFactory sIntentsFactory = new LaunchIntentsFactory();
75
- private static ActivityTestRule sActivityTestRule;
65
+ private static ActivityLaunchHelper sActivityLaunchHelper;
76
66
 
77
67
  private Detox() {
78
68
  }
@@ -132,15 +122,10 @@ public final class Detox {
132
122
  DetoxConfig.CONFIG = detoxConfig;
133
123
  DetoxConfig.CONFIG.apply();
134
124
 
135
- sActivityTestRule = activityTestRule;
136
-
137
- UiControllerSpy.attachThroughProxy();
138
-
139
- Intent intent = extractInitialIntent();
140
- sActivityTestRule.launchActivity(intent);
125
+ sActivityLaunchHelper = new ActivityLaunchHelper(activityTestRule);
141
126
 
142
127
  try {
143
- DetoxMain.run(context);
128
+ DetoxMain.run(context, sActivityLaunchHelper);
144
129
  } catch (Exception e) {
145
130
  Thread.currentThread().interrupt();
146
131
  throw new RuntimeException("Detox got interrupted prematurely", e);
@@ -148,56 +133,15 @@ public final class Detox {
148
133
  }
149
134
 
150
135
  public static void launchMainActivity() {
151
- final Activity activity = sActivityTestRule.getActivity();
152
- launchActivitySync(sIntentsFactory.activityLaunchIntent(activity));
136
+ sActivityLaunchHelper.launchMainActivity();
153
137
  }
154
138
 
155
139
  public static void startActivityFromUrl(String url) {
156
- launchActivitySync(sIntentsFactory.intentWithUrl(url, false));
140
+ sActivityLaunchHelper.startActivityFromUrl(url);
157
141
  }
158
142
 
159
143
  public static void startActivityFromNotification(String dataFilePath) {
160
- Bundle notificationData = new NotificationDataParser(dataFilePath).toBundle();
161
- Intent intent = sIntentsFactory.intentWithNotificationData(getAppContext(), notificationData, false);
162
- launchActivitySync(intent);
163
- }
164
-
165
- private static Intent extractInitialIntent() {
166
- Intent intent;
167
-
168
- if (sLaunchArgs.hasUrlOverride()) {
169
- intent = sIntentsFactory.intentWithUrl(sLaunchArgs.getUrlOverride(), true);
170
- } else if (sLaunchArgs.hasNotificationPath()) {
171
- Bundle notificationData = new NotificationDataParser(sLaunchArgs.getNotificationPath()).toBundle();
172
- intent = sIntentsFactory.intentWithNotificationData(getAppContext(), notificationData, true);
173
- } else {
174
- intent = sIntentsFactory.cleanIntent();
175
- }
176
- intent.putExtra(INTENT_LAUNCH_ARGS_KEY, sLaunchArgs.asIntentBundle());
177
- return intent;
178
- }
179
-
180
- private static void launchActivitySync(Intent intent) {
181
- // Ideally, we would just call sActivityTestRule.launchActivity(intent) and get it over with.
182
- // BUT!!! as it turns out, Espresso has an issue where doing this for an activity running in the background
183
- // would have Espresso set up an ActivityMonitor which will spend its time waiting for the activity to load, *without
184
- // ever being released*. It will finally fail after a 45 seconds timeout.
185
- // Without going into full details, it seems that activity test rules were not meant to be used this way. However,
186
- // the all-new ActivityScenario implementation introduced in androidx could probably support this (e.g. by using
187
- // dedicated methods such as moveToState(), which give better control over the lifecycle).
188
- // In any case, this is the core reason for this issue: https://github.com/wix/Detox/issues/1125
189
- // What it forces us to do, then, is this -
190
- // 1. Launch the activity by "ourselves" from the OS (i.e. using context.startActivity()).
191
- // 2. Set up an activity monitor by ourselves -- such that it would block until the activity is ready.
192
- // ^ Hence the code below.
193
-
194
- final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
195
- final Activity activity = sActivityTestRule.getActivity();
196
- final Instrumentation.ActivityMonitor activityMonitor = new Instrumentation.ActivityMonitor(activity.getClass().getName(), null, true);
197
-
198
- activity.startActivity(intent);
199
- instrumentation.addMonitor(activityMonitor);
200
- instrumentation.waitForMonitorWithTimeout(activityMonitor, ACTIVITY_LAUNCH_TIMEOUT);
144
+ sActivityLaunchHelper.startActivityFromNotification(dataFilePath);
201
145
  }
202
146
 
203
147
  private static Context getAppContext() {
@@ -2,8 +2,21 @@ 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.common.DetoxLog.Companion.LOG_TAG
5
+ import com.wix.detox.adapters.server.CleanupActionHandler
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
18
+ import com.wix.detox.common.DetoxLog
19
+ import com.wix.detox.espresso.UiControllerSpy
7
20
  import com.wix.detox.instruments.DetoxInstrumentsManager
8
21
  import com.wix.detox.reactnative.ReactNativeExtension
9
22
  import com.wix.invoke.MethodInvocation
@@ -14,24 +27,28 @@ private const val TERMINATION_ACTION = "_terminate"
14
27
 
15
28
  object DetoxMain {
16
29
  @JvmStatic
17
- fun run(rnHostHolder: Context) {
30
+ fun run(rnHostHolder: Context, activityLaunchHelper: ActivityLaunchHelper) {
18
31
  val detoxServerInfo = DetoxServerInfo()
19
- Log.i(LOG_TAG, "Detox server connection details: $detoxServerInfo")
20
-
21
32
  val testEngineFacade = TestEngineFacade()
22
33
  val actionsDispatcher = DetoxActionsDispatcher()
23
34
  val externalAdapter = DetoxServerAdapter(actionsDispatcher, detoxServerInfo, IS_READY_ACTION, TERMINATION_ACTION)
24
- initActionHandlers(actionsDispatcher, externalAdapter, testEngineFacade, rnHostHolder)
35
+
36
+ initActionHandlers(activityLaunchHelper, actionsDispatcher, externalAdapter, testEngineFacade, rnHostHolder)
25
37
  actionsDispatcher.dispatchAction(INIT_ACTION, "", 0)
26
38
  actionsDispatcher.join()
27
39
  }
28
40
 
29
- private fun doInit(externalAdapter: DetoxServerAdapter, rnHostHolder: Context) {
30
- externalAdapter.connect()
31
-
41
+ private fun doInit(externalAdapter: DetoxServerAdapter) {
32
42
  initCrashHandler(externalAdapter)
33
43
  initANRListener(externalAdapter)
34
- initReactNativeIfNeeded(rnHostHolder)
44
+ initEspresso()
45
+ initReactNative()
46
+
47
+ externalAdapter.connect()
48
+ }
49
+
50
+ private fun onConnected(activityLaunchHelper: ActivityLaunchHelper, rnHostHolder: Context) {
51
+ launchApp(rnHostHolder, activityLaunchHelper)
35
52
  }
36
53
 
37
54
  private fun doTeardown(serverAdapter: DetoxServerAdapter, actionsDispatcher: DetoxActionsDispatcher, testEngineFacade: TestEngineFacade) {
@@ -41,20 +58,35 @@ object DetoxMain {
41
58
  actionsDispatcher.teardown()
42
59
  }
43
60
 
44
- private fun initActionHandlers(actionsDispatcher: DetoxActionsDispatcher, serverAdapter: DetoxServerAdapter, testEngineFacade: TestEngineFacade, rnHostHolder: Context) {
61
+ private fun initActionHandlers(activityLaunchHelper: ActivityLaunchHelper, actionsDispatcher: DetoxActionsDispatcher, serverAdapter: DetoxServerAdapter, testEngineFacade: TestEngineFacade, rnHostHolder: Context) {
45
62
  // Primary actions
46
63
  with(actionsDispatcher) {
64
+ var prematureIsReadyHandler: PrematureReadyHandler? = PrematureReadyHandler()
47
65
  val rnReloadHandler = ReactNativeReloadActionHandler(rnHostHolder, serverAdapter, testEngineFacade)
48
66
 
49
- associateActionHandler(INIT_ACTION, object : DetoxActionHandler {
67
+ associateActionHandler(INIT_ACTION, object: DetoxActionHandler {
50
68
  override fun handle(params: String, messageId: Long) =
51
69
  synchronized(this@DetoxMain) {
52
- this@DetoxMain.doInit(serverAdapter, rnHostHolder)
70
+ this@DetoxMain.doInit(serverAdapter)
53
71
  }
54
72
  })
55
- associateActionHandler(IS_READY_ACTION, ReadyActionHandler(serverAdapter, testEngineFacade))
73
+ associateActionHandler(IS_READY_ACTION, prematureIsReadyHandler!!)
56
74
 
57
- associateActionHandler("loginSuccess", ScarceActionHandler())
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
+ })
58
90
  associateActionHandler("reactNativeReload", object: DetoxActionHandler {
59
91
  override fun handle(params: String, messageId: Long) =
60
92
  synchronized(this@DetoxMain) {
@@ -98,7 +130,17 @@ object DetoxMain {
98
130
  DetoxANRHandler(outboundServerAdapter).attach()
99
131
  }
100
132
 
101
- private fun initReactNativeIfNeeded(rnHostHolder: Context) {
133
+ private fun initEspresso() {
134
+ UiControllerSpy.attachThroughProxy()
135
+ }
136
+
137
+ private fun initReactNative() {
138
+ ReactNativeExtension.initIfNeeded()
139
+ }
140
+
141
+ private fun launchApp(rnHostHolder: Context, activityLaunchHelper: ActivityLaunchHelper) {
142
+ Log.i(DetoxLog.LOG_TAG, "Launching the tested activity!")
143
+ activityLaunchHelper.launchActivityUnderTest()
102
144
  ReactNativeExtension.waitForRNBootstrap(rnHostHolder)
103
145
  }
104
146
  }
@@ -6,7 +6,7 @@ import android.content.Intent
6
6
  import android.net.Uri
7
7
  import android.os.Bundle
8
8
 
9
- internal class LaunchIntentsFactory {
9
+ class LaunchIntentsFactory {
10
10
 
11
11
  /**
12
12
  * Constructs an intent tightly associated with a specific activity.
@@ -3,6 +3,7 @@ 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
6
7
  import com.wix.detox.common.extractRootCause
7
8
  import com.wix.detox.instruments.DetoxInstrumentsException
8
9
  import com.wix.detox.instruments.DetoxInstrumentsManager
@@ -27,6 +28,20 @@ class ReadyActionHandler(
27
28
  }
28
29
  }
29
30
 
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
+
30
45
  open class ReactNativeReloadActionHandler(
31
46
  private val appContext: Context,
32
47
  private val outboundServerAdapter: OutboundServerAdapter,
@@ -152,7 +167,3 @@ class InstrumentsEventsActionsHandler(
152
167
  outboundServerAdapter.sendMessage("eventDone", emptyMap<String, Any>(), messageId)
153
168
  }
154
169
  }
155
-
156
- class ScarceActionHandler: DetoxActionHandler {
157
- override fun handle(params: String, messageId: Long) {}
158
- }
@@ -1,7 +1,9 @@
1
1
  package com.wix.detox.adapters.server
2
2
 
3
+ import android.util.Log
3
4
  import androidx.test.platform.app.InstrumentationRegistry
4
5
  import com.wix.detox.LaunchArgs
6
+ import com.wix.detox.common.DetoxLog
5
7
 
6
8
  private const val DEFAULT_URL = "ws://localhost:8099"
7
9
 
@@ -9,7 +11,7 @@ class DetoxServerInfo internal constructor(launchArgs: LaunchArgs = LaunchArgs()
9
11
  val serverUrl: String = launchArgs.detoxServerUrl ?: DEFAULT_URL
10
12
  val sessionId: String = launchArgs.detoxSessionId ?: InstrumentationRegistry.getInstrumentation().targetContext.applicationInfo.packageName
11
13
 
12
- override fun toString(): String {
13
- return "url=$serverUrl, sessionId=$sessionId"
14
+ init {
15
+ Log.i(DetoxLog.LOG_TAG, "Detox server connection details: url=$serverUrl, sessionId=$sessionId")
14
16
  }
15
17
  }
@@ -0,0 +1,44 @@
1
+ package com.wix.detox.reactnative
2
+
3
+ import android.util.Log
4
+ import com.facebook.react.bridge.ReactMarker
5
+ import com.facebook.react.bridge.ReactMarkerConstants
6
+ import com.facebook.react.bridge.ReactMarkerConstants.*
7
+
8
+ object ReactMarkersLogger : ReactMarker.MarkerListener {
9
+
10
+ fun attach() {
11
+ ReactMarker.addListener(this)
12
+ }
13
+
14
+ override fun logMarker(marker: ReactMarkerConstants, p1: String?, p2: Int) {
15
+ when {
16
+ marker == DOWNLOAD_START ||
17
+ marker == DOWNLOAD_END ||
18
+ marker == BUILD_REACT_INSTANCE_MANAGER_START ||
19
+ marker == BUILD_REACT_INSTANCE_MANAGER_END ||
20
+ marker == REACT_BRIDGE_LOADING_START ||
21
+ marker == REACT_BRIDGE_LOADING_END ||
22
+ marker == REACT_BRIDGELESS_LOADING_START ||
23
+ marker == REACT_BRIDGELESS_LOADING_END ||
24
+ marker == CREATE_MODULE_START ||
25
+ marker == CREATE_MODULE_END ||
26
+ marker == NATIVE_MODULE_SETUP_START ||
27
+ marker == NATIVE_MODULE_SETUP_END ||
28
+ marker == PRE_RUN_JS_BUNDLE_START ||
29
+ marker == RUN_JS_BUNDLE_START ||
30
+ marker == RUN_JS_BUNDLE_END ||
31
+ marker == CONTENT_APPEARED ||
32
+ marker == CREATE_CATALYST_INSTANCE_START ||
33
+ marker == CREATE_CATALYST_INSTANCE_END ||
34
+ marker == DESTROY_CATALYST_INSTANCE_START ||
35
+ marker == DESTROY_CATALYST_INSTANCE_END ||
36
+ marker == CREATE_REACT_CONTEXT_START ||
37
+ marker == CREATE_REACT_CONTEXT_END ||
38
+ marker == PROCESS_PACKAGES_START ||
39
+ marker == PROCESS_PACKAGES_END ||
40
+ false ->
41
+ Log.d("Detox.RNMarker", "$marker ($p1)")
42
+ }
43
+ }
44
+ }
@@ -14,6 +14,32 @@ private const val LOG_TAG = "DetoxRNExt"
14
14
  object ReactNativeExtension {
15
15
  private var rnIdlingResources: ReactNativeIdlingResources? = null
16
16
 
17
+ fun initIfNeeded() {
18
+ if (!ReactNativeInfo.isReactNativeApp()) {
19
+ return
20
+ }
21
+
22
+ ReactMarkersLogger.attach()
23
+ }
24
+
25
+ /**
26
+ * Wait for React-Native to finish loading (i.e. make RN context available).
27
+ *
28
+ * @param applicationContext The app context, implicitly assumed to be a [ReactApplication] instance.
29
+ */
30
+ fun waitForRNBootstrap(applicationContext: Context) {
31
+ if (!ReactNativeInfo.isReactNativeApp()) {
32
+ return
33
+ }
34
+
35
+ (applicationContext as ReactApplication).let {
36
+ val reactContext = awaitNewReactNativeContext(it, null)
37
+
38
+ enableOrDisableSynchronization(reactContext)
39
+ hackRN50WaitForReady()
40
+ }
41
+ }
42
+
17
43
  /**
18
44
  * Reloads the React Native context and thus all javascript code.
19
45
  *
@@ -40,26 +66,7 @@ object ReactNativeExtension {
40
66
  val reactContext = awaitNewReactNativeContext(it, previousReactContext)
41
67
 
42
68
  enableOrDisableSynchronization(reactContext, networkSyncEnabled)
43
- hackRN50OrHigherWaitForReady()
44
- }
45
- }
46
-
47
- /**
48
- * Wait for React-Native to finish loading (i.e. make RN context available).
49
- *
50
- * @param applicationContext The app context, implicitly assumed to be a [ReactApplication] instance.
51
- */
52
- @JvmStatic
53
- fun waitForRNBootstrap(applicationContext: Context) {
54
- if (!ReactNativeInfo.isReactNativeApp()) {
55
- return
56
- }
57
-
58
- (applicationContext as ReactApplication).let {
59
- val reactContext = awaitNewReactNativeContext(it, null)
60
-
61
- enableOrDisableSynchronization(reactContext)
62
- hackRN50OrHigherWaitForReady()
69
+ hackRN50WaitForReady()
63
70
  }
64
71
  }
65
72
 
@@ -145,7 +152,7 @@ object ReactNativeExtension {
145
152
  }
146
153
  }
147
154
 
148
- private fun hackRN50OrHigherWaitForReady() {
155
+ private fun hackRN50WaitForReady() {
149
156
  if (ReactNativeInfo.rnVersion().minor in 50..62) {
150
157
  try {
151
158
  //TODO- Temp hack to make Detox usable for RN>=50 till we find a better sync solution.
@@ -11,11 +11,8 @@ class UiControllerSpy: MethodsSpy("uiController") {
11
11
  fun eventInjectionsIterator(): Iterator<CallInfo?> = historyOf("injectMotionEvent").iterator()
12
12
 
13
13
  companion object {
14
- @JvmStatic
15
14
  val instance = UiControllerSpy()
16
15
 
17
- @JvmStatic
18
- @JvmOverloads
19
16
  fun attachThroughProxy(spy: UiControllerSpy = instance) {
20
17
  val eventsInjectorReflected = EventsInjectorReflected(getUiController())
21
18
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "detox",
3
3
  "description": "E2E tests and automation for mobile",
4
- "version": "20.13.0",
4
+ "version": "20.14.0-smoke.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -205,5 +205,5 @@
205
205
  "browserslist": [
206
206
  "node 14"
207
207
  ],
208
- "gitHead": "72e85a2fe078a2a721628255249410423fc5c1ac"
208
+ "gitHead": "e9ae9173b3e36e9926a74454aa20709ec71d4da8"
209
209
  }
@@ -58,17 +58,6 @@ class Detox {
58
58
  };
59
59
  }
60
60
 
61
- static extractInitialIntent() {
62
- return {
63
- target: {
64
- type: "Class",
65
- value: "com.wix.detox.Detox"
66
- },
67
- method: "extractInitialIntent",
68
- args: []
69
- };
70
- }
71
-
72
61
  static getAppContext() {
73
62
  return {
74
63
  target: {
@@ -1 +0,0 @@
1
- 0709a8a30b2cc4c27244a2257ac28ed7
@@ -1 +0,0 @@
1
- 08f017a03aa160bead65af9b208ea95857ac9697
@@ -1 +0,0 @@
1
- 5cc49445c8f5440e5e5ed8d2d95e4827fb1ab4796d20e32ab30d7151da661ce7
@@ -1 +0,0 @@
1
- 7360ab285d19450619f38c7da9985fda6514d382f903e87a2af9d4e0204a0250851c412a045da6ce04cc932e9addf7c131fd5147889975be20910e2fdc64e88f
@@ -1 +0,0 @@
1
- 972fa81d6c5d9f0eb6edc63765bf01af
@@ -1 +0,0 @@
1
- 1ea26448826d4701a7dce9d2c0c24355853ad9d7
@@ -1 +0,0 @@
1
- 6b2f9a8186f2eef1075910eae28c189ac2030561520277e503e3a696f3c977e2
@@ -1 +0,0 @@
1
- eae9264b4d57f78a80ecffae3c85e157a2cd1df1b2259c0edc93f5c22d305a004216c5e9e6b35a1415fab6ba14a4f6667acd2eac4d5c6ae5a7a410ee85ca2c7c
@@ -1 +0,0 @@
1
- 0ff20c1510b97ba80b15a438ce65bddc
@@ -1 +0,0 @@
1
- 449b07e6bb8435baef57e3d0839e68b5f7f85af5
@@ -1 +0,0 @@
1
- c3347ddd7b4e4a94c60c55c079451ea219e050f7c69b8dbc7b59a453d2398e67
@@ -1 +0,0 @@
1
- ebcf7f52b7e34a391174fc8850879e39a3e3f8f8ccfa0a417937680187461d5b41f7811933ca5ca088c554ae7a4e8d8cb2198375fdbb55680888aac561c71f64
@@ -1 +0,0 @@
1
- 293aa59dd07a84b7a1bd7c4dc2bffe16
@@ -1 +0,0 @@
1
- 144cef7278f92d8e7798cae134d8f93136492080
@@ -1 +0,0 @@
1
- a1062bb5feb8cb7210de7f0e2c36d8a219f8d4065377c9ced13ae55d7eb13220
@@ -1 +0,0 @@
1
- 216ecb00454a1e03ef9ab2a197b616c4d326ec6ef47fd08b83b22d57c2c9d4dc37725a3c4d19600874074b40918387cebd1be11d558270af4ab7e797af40607f