detox 20.28.0 → 20.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/Detox-android/com/wix/detox/{20.28.0/detox-20.28.0-sources.jar → 20.30.0/detox-20.30.0-sources.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0-sources.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar +0 -0
  7. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.aar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/{20.28.0/detox-20.28.0.pom → 20.30.0/detox-20.30.0.pom} +2 -2
  12. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.30.0/detox-20.30.0.pom.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  17. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  18. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  19. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  20. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  21. package/Detox-ios-framework.tbz +0 -0
  22. package/Detox-ios-src.tbz +0 -0
  23. package/Detox-ios-xcuitest.tbz +0 -0
  24. package/android/build.gradle +5 -5
  25. package/android/detox/proguard-rules-app.pro +3 -0
  26. package/android/detox/src/full/java/com/wix/detox/espresso/EspressoDetox.java +1 -1
  27. package/android/detox/src/full/java/com/wix/detox/espresso/web/DetoxWebAtomMatcher.java +3 -3
  28. package/android/detox/src/full/java/com/wix/detox/espresso/web/WebElement.java +0 -1
  29. package/android/detox/src/full/java/com/wix/detox/espresso/web/WebViewElement.java +33 -8
  30. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +6 -11
  31. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeInfo.kt +4 -11
  32. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxIdlingResource.kt +42 -0
  33. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/ReactNativeIdlingResources.kt +145 -0
  34. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/animations/AnimatedModuleIdlingResource.kt +61 -0
  35. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/bridge/BridgeIdlingResource.kt +72 -0
  36. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/factory/DetoxIdlingResourceFactory.kt +32 -0
  37. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/factory/IdlingResourcesName.kt +10 -0
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/factory/LooperName.kt +6 -0
  39. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/looper/MQThreadsReflector.kt +47 -0
  40. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/network/NetworkIdlingResource.kt +105 -0
  41. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/{NetworkingModuleReflected.kt → network/NetworkingModuleReflected.kt} +1 -1
  42. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/{AsyncStorageIdlingResource.kt → storage/AsyncStorageIdlingResource.kt} +33 -35
  43. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/{SerialExecutorReflected.kt → storage/SerialExecutorReflected.kt} +1 -1
  44. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +21 -19
  45. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +19 -27
  46. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +5 -17
  47. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceTest.kt +248 -0
  48. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -1
  49. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/SerialExecutorReflectedSpec.kt +1 -0
  50. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceTest.kt +212 -0
  51. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  52. package/android/rninfo.gradle +31 -24
  53. package/android/settings.gradle +11 -6
  54. package/package.json +11 -8
  55. package/scripts/postinstall.js +2 -2
  56. package/scripts/updateGradle.js +41 -8
  57. package/src/DetoxWorker.js +11 -6
  58. package/src/copilot/DetoxCopilot.js +3 -15
  59. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0-sources.jar.md5 +0 -1
  60. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0-sources.jar.sha1 +0 -1
  61. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0-sources.jar.sha256 +0 -1
  62. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0-sources.jar.sha512 +0 -1
  63. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.aar +0 -0
  64. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.aar.md5 +0 -1
  65. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.aar.sha1 +0 -1
  66. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.aar.sha256 +0 -1
  67. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.aar.sha512 +0 -1
  68. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.pom.md5 +0 -1
  69. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.pom.sha1 +0 -1
  70. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.pom.sha256 +0 -1
  71. package/Detox-android/com/wix/detox/20.28.0/detox-20.28.0.pom.sha512 +0 -1
  72. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0-sources.jar +0 -0
  73. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0-sources.jar.md5 +0 -1
  74. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0-sources.jar.sha1 +0 -1
  75. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0-sources.jar.sha256 +0 -1
  76. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0-sources.jar.sha512 +0 -1
  77. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.aar +0 -0
  78. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.aar.md5 +0 -1
  79. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.aar.sha1 +0 -1
  80. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.aar.sha256 +0 -1
  81. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.aar.sha512 +0 -1
  82. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.pom +0 -100
  83. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.pom.md5 +0 -1
  84. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.pom.sha1 +0 -1
  85. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.pom.sha256 +0 -1
  86. package/Detox-android/com/wix/detox-legacy/20.28.0/detox-legacy-20.28.0.pom.sha512 +0 -1
  87. package/Detox-android/com/wix/detox-legacy/maven-metadata.xml +0 -13
  88. package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.md5 +0 -1
  89. package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.sha1 +0 -1
  90. package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.sha256 +0 -1
  91. package/Detox-android/com/wix/detox-legacy/maven-metadata.xml.sha512 +0 -1
  92. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +0 -229
  93. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +0 -215
  94. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +0 -94
  95. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +0 -29
  96. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +0 -134
  97. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +0 -23
  98. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +0 -16
  99. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +0 -71
  100. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +0 -227
  101. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +0 -47
  102. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +0 -189
@@ -6,6 +6,12 @@ const rnMinor = require('../src/utils/rn-consts/rn-consts').rnVersion.minor;
6
6
  function getGradleVersionByRNVersion() {
7
7
  switch (rnMinor) {
8
8
  default:
9
+ return '8.10.2';
10
+ case '75':
11
+ return '8.8';
12
+ case '74':
13
+ return '8.6';
14
+ case '73':
9
15
  return '8.3';
10
16
  case '72':
11
17
  return '8.0';
@@ -17,19 +23,46 @@ function getGradleVersionByRNVersion() {
17
23
  /**
18
24
  * Update the Gradle wrapper to the version that matches the React Native version.
19
25
  */
20
- function setGradleVersionByRNVersion() {
21
- const gradleVersion = getGradleVersionByRNVersion();
22
- updateGradleWrapperSync(gradleVersion);
26
+ function patchGradleByRNVersion() {
27
+ updateGradleWrapperSync();
28
+ patchSettingsGradle();
29
+ }
30
+
31
+ /**
32
+ * In RN75 and above the settings.gradle file should contain the following lines. We can't wrap them in 'if' statement
33
+ * because they should be the first line in the settings file. This patch could be safely removed after dropping support
34
+ * for RN74.
35
+ */
36
+ function patchSettingsGradle() {
37
+ if (parseInt(rnMinor) >= 75) {
38
+ return;
39
+ }
40
+
41
+ const settingsGradlePath = path.join(process.cwd(), 'android', 'settings.gradle');
42
+ console.log(`Patching settings.gradle. File: ${settingsGradlePath}`);
43
+
44
+ try {
45
+ let data = fs.readFileSync(settingsGradlePath, 'utf8');
46
+ const blockRegex = /\/\/ RN75\+_BLOCK_START[\s\S]*?\/\/ RN75\+_BLOCK_END/g;
47
+
48
+ // Replace the block with an empty string
49
+ const updatedData = data.replace(blockRegex, '');
50
+
51
+ fs.writeFileSync(settingsGradlePath, updatedData, 'utf8');
52
+ console.log('settings.gradle patched successfully.');
53
+ } catch (err) {
54
+ console.error('Error:', err);
55
+ }
23
56
  }
24
57
 
25
58
  /**
26
59
  * Update the Gradle wrapper to the specified version.
27
- *
28
- * @param {string} newVersion - the new Gradle wrapper version
29
60
  */
30
- function updateGradleWrapperSync(newVersion) {
61
+ function updateGradleWrapperSync() {
62
+ const newVersion = getGradleVersionByRNVersion();
63
+
31
64
  const gradleWrapperPath = path.join(process.cwd(), 'android', 'gradle', 'wrapper', 'gradle-wrapper.properties');
32
- console.log(`Updating Gradle wrapper to version${newVersion}. File: ${gradleWrapperPath}`);
65
+ console.log(`Updating Gradle wrapper to version$ {newVersion}. File: ${gradleWrapperPath}`);
33
66
 
34
67
  try {
35
68
  let data = fs.readFileSync(gradleWrapperPath, 'utf8');
@@ -43,5 +76,5 @@ function updateGradleWrapperSync(newVersion) {
43
76
  }
44
77
 
45
78
  module.exports = {
46
- setGradleVersionByRNVersion
79
+ patchGradleByRNVersion: patchGradleByRNVersion
47
80
  };
@@ -1,4 +1,5 @@
1
1
  const CAF = require('caf');
2
+ const copilot = require('detox-copilot').default;
2
3
  const _ = require('lodash');
3
4
 
4
5
  const Client = require('./client/Client');
@@ -62,7 +63,7 @@ class DetoxWorker {
62
63
  /** @type {Detox.SystemFacade} */
63
64
  this.system = null;
64
65
  /** @type {Detox.DetoxCopilotFacade} */
65
- this.copilot = null;
66
+ this.copilot = new DetoxCopilot();
66
67
 
67
68
  this._deviceCookie = null;
68
69
 
@@ -126,8 +127,6 @@ class DetoxWorker {
126
127
  runtimeDeviceFactory,
127
128
  } = environmentFactory.createFactories(deviceConfig);
128
129
 
129
- this.copilot = new DetoxCopilot();
130
-
131
130
  const envValidator = envValidatorFactory.createValidator();
132
131
  yield envValidator.validate();
133
132
 
@@ -226,9 +225,10 @@ class DetoxWorker {
226
225
  yield this._artifactsManager.onRunDescribeStart(...args);
227
226
  };
228
227
 
229
- onTestStart = function* (_signal, testSummary) {
230
- // Copilot is reset before each test to ensure a clean state
231
- this.copilot.resetIfNeeded();
228
+ onTestStart = function* (_signal, testSummary){
229
+ if (copilot.isInitialized()) {
230
+ copilot.start();
231
+ }
232
232
 
233
233
  this._validateTestSummary('beforeEach', testSummary);
234
234
 
@@ -257,6 +257,11 @@ class DetoxWorker {
257
257
  pendingRequests: testSummary.timedOut,
258
258
  testName: testSummary.fullName,
259
259
  });
260
+
261
+ if (copilot.isInitialized()) {
262
+ // In case of failure, pass false to copilot, so temporary cache is not saved
263
+ copilot.end(testSummary.status === 'passed');
264
+ }
260
265
  };
261
266
 
262
267
  onRunDescribeFinish = function* (_signal, ...args) {
@@ -2,27 +2,15 @@ const copilot = require('detox-copilot').default;
2
2
 
3
3
  const detoxCopilotFrameworkDriver = require('./detoxCopilotFrameworkDriver');
4
4
 
5
+ /**
6
+ * @typedef {Object} Detox.DetoxCopilotFacade
7
+ */
5
8
  class DetoxCopilot {
6
- constructor() {
7
- this.isInitialized = false;
8
- }
9
-
10
9
  init(promptHandler) {
11
10
  copilot.init({
12
11
  frameworkDriver: detoxCopilotFrameworkDriver,
13
12
  promptHandler: promptHandler
14
13
  });
15
-
16
- this.isInitialized = true;
17
- }
18
-
19
- resetIfNeeded() {
20
- if (!this.isInitialized) {
21
- // Copilot is not initialized, nothing to reset
22
- return;
23
- }
24
-
25
- copilot.reset();
26
14
  }
27
15
 
28
16
  perform(...steps) {
@@ -1 +0,0 @@
1
- 5f9c61888ac541880ca966b9cf54f996
@@ -1 +0,0 @@
1
- 905d3c70363af1ef378373c1337b2a02fb085847
@@ -1 +0,0 @@
1
- 9da6d1b24a67e2c3f54e4f85b76d2f308df4f4783a2ead715cacae4078d54198
@@ -1 +0,0 @@
1
- 488ca79bd9330a788fe0659818e9256d06908d3c9ff765ddf9ee41e253b78dbbb0db1409f794532019fa39ca3395c8a27396398cbe56d203989afb258c31f1b8
@@ -1 +0,0 @@
1
- 2d6e006f6dc0428fd9be3efb971433cf
@@ -1 +0,0 @@
1
- 7e71f1e0bd4e0beea5f2c8db164c560255332a30
@@ -1 +0,0 @@
1
- d0d12c5ecb2c4d760332b168a9237aa1948ac10ea1736a4b75067de6ebaaf6cb
@@ -1 +0,0 @@
1
- 1ebe46cd76b0bcfdcab9fc6b1a863b257da71ee05bac63f538fab1351f55ba858d97b81aba1d040d5db74c9e27508b12dbeb6ae2e6c09ef469a184516fc82c00
@@ -1 +0,0 @@
1
- 72dd9fb9e071a00dfb6b7731da5a8268
@@ -1 +0,0 @@
1
- 5ea89a7c06c7d3e3ebee78b290422c25471ffccf
@@ -1 +0,0 @@
1
- 48839af705f5ce69be3f8075367e012c822f2cb9b4d5d66d1466c718f7adecd4
@@ -1 +0,0 @@
1
- 01b1f663413f39c8f25e81f70669ddce75f2f332f154c531cb5289a646d25e3cc80120580202da5bc3cf1e4fd865a61b0551126be9da37b61eeec6f75fc2b9cf
@@ -1 +0,0 @@
1
- d01d2e826e3b99f843a7e444d309d6d2
@@ -1 +0,0 @@
1
- 3cf94f158d84d98241e421c64cc5c06142fbf4c0
@@ -1 +0,0 @@
1
- cb302fd2cd81b8ba3a03115ab529d073bb8f223af0088e89e22af90120117412
@@ -1 +0,0 @@
1
- 37109f12c35e795d76f25a7c462c143dcedbbd0cb66bdde25364f237754da179307e87b73fae67e5432b7724903abe485c5105ac5667a7f6f26806b6c5229d88
@@ -1 +0,0 @@
1
- f3e0e6447e243a7a93b9425d8ca2c34d
@@ -1 +0,0 @@
1
- 135215a6c872a80b0020ecface42fd07fde6e8a2
@@ -1 +0,0 @@
1
- 67f6e9df85d01f17887b135aa64b3db8b10afce941b70314fa1cc15580699102
@@ -1 +0,0 @@
1
- a71be556721d9c7b600914bcbeaff171d0d959a3dbb816d4467c8f52caa5703d9b241c0a76c13e4010c57036fff63b0c157eb126c58a96fe593ef1a71dcd3778
@@ -1,100 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
- <modelVersion>4.0.0</modelVersion>
4
- <groupId>com.wix</groupId>
5
- <artifactId>detox-legacy</artifactId>
6
- <version>20.28.0</version>
7
- <packaging>aar</packaging>
8
- <name>Detox</name>
9
- <description>Gray box end-to-end testing and automation library for mobile apps</description>
10
- <url>https://github.com/wix/Detox</url>
11
- <licenses>
12
- <license>
13
- <name>The MIT License</name>
14
- <url>https://github.com/wix/Detox/blob/master/LICENSE</url>
15
- </license>
16
- </licenses>
17
- <developers>
18
- <developer>
19
- <name>WixMobile</name>
20
- <email>mobile1@wix.com</email>
21
- </developer>
22
- <developer>
23
- <name>d4vidi</name>
24
- <email>amitd@wix.com</email>
25
- </developer>
26
- </developers>
27
- <scm>
28
- <connection>scm:git:git://github.com/wix/detox.git</connection>
29
- <developerConnection>scm:git:git@github.com/wix/detox.git</developerConnection>
30
- <url>https://github.com/wix/detox</url>
31
- </scm>
32
- <dependencies>
33
- <dependency>
34
- <groupId>org.jetbrains.kotlin</groupId>
35
- <artifactId>kotlin-stdlib-jdk8</artifactId>
36
- <version>1.8.0</version>
37
- <scope>compile</scope>
38
- </dependency>
39
- <dependency>
40
- <groupId>androidx.test.espresso</groupId>
41
- <artifactId>espresso-core</artifactId>
42
- <version>3.6.1</version>
43
- <scope>compile</scope>
44
- </dependency>
45
- <dependency>
46
- <groupId>androidx.test.espresso</groupId>
47
- <artifactId>espresso-web</artifactId>
48
- <version>3.6.1</version>
49
- <scope>compile</scope>
50
- </dependency>
51
- <dependency>
52
- <groupId>androidx.test.espresso</groupId>
53
- <artifactId>espresso-contrib</artifactId>
54
- <version>3.6.1</version>
55
- <scope>compile</scope>
56
- <exclusions>
57
- <exclusion>
58
- <groupId>org.checkerframework</groupId>
59
- <artifactId>checker</artifactId>
60
- </exclusion>
61
- </exclusions>
62
- </dependency>
63
- <dependency>
64
- <groupId>org.hamcrest</groupId>
65
- <artifactId>hamcrest</artifactId>
66
- <version>2.2</version>
67
- <scope>compile</scope>
68
- </dependency>
69
- <dependency>
70
- <groupId>androidx.test</groupId>
71
- <artifactId>rules</artifactId>
72
- <version>1.6.1</version>
73
- <scope>compile</scope>
74
- </dependency>
75
- <dependency>
76
- <groupId>androidx.test.ext</groupId>
77
- <artifactId>junit</artifactId>
78
- <version>1.2.1</version>
79
- <scope>compile</scope>
80
- </dependency>
81
- <dependency>
82
- <groupId>androidx.test.uiautomator</groupId>
83
- <artifactId>uiautomator</artifactId>
84
- <version>2.2.0</version>
85
- <scope>compile</scope>
86
- </dependency>
87
- <dependency>
88
- <groupId>org.apache.commons</groupId>
89
- <artifactId>commons-lang3</artifactId>
90
- <version>3.7</version>
91
- <scope>runtime</scope>
92
- </dependency>
93
- <dependency>
94
- <groupId>com.github.anrwatchdog</groupId>
95
- <artifactId>anrwatchdog</artifactId>
96
- <version>1.4.0</version>
97
- <scope>runtime</scope>
98
- </dependency>
99
- </dependencies>
100
- </project>
@@ -1 +0,0 @@
1
- 2c9a5efdc4cc9949403de29543d189c3
@@ -1 +0,0 @@
1
- dd1b295394376809aa40565060e7f0068758476d
@@ -1 +0,0 @@
1
- 28a059a24a50d3e94b75af039c1aee8dd403bb862525cce01876a4a188313eb1
@@ -1 +0,0 @@
1
- 252cf3d47cd05805ab38367c8b33793b5b7e210a5f7f88717b1439127f168181bd5b3a05fa020c4c444aad0dfb6ad81547a7bc05ce6dc5f8043aff2eea3096f1
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <metadata>
3
- <groupId>com.wix</groupId>
4
- <artifactId>detox-legacy</artifactId>
5
- <versioning>
6
- <latest>20.28.0</latest>
7
- <release>20.28.0</release>
8
- <versions>
9
- <version>20.28.0</version>
10
- </versions>
11
- <lastUpdated>20241114182808</lastUpdated>
12
- </versioning>
13
- </metadata>
@@ -1 +0,0 @@
1
- dbb9351f570b2e9f79cd97583cda0e41
@@ -1 +0,0 @@
1
- e043135169acc282528cb1990f80ae8be7fd89b2
@@ -1 +0,0 @@
1
- 723c473ca26e2ced79ca5d707aa4e96f068d3bb86577a66d54ae5c41231127f2
@@ -1 +0,0 @@
1
- 5061e8696bf7b07237dd2b8fc02f65054eaaa87884723ca0f706b3b1de63e153e636db8077c6fdfd29ad8d0ca67433ff6a327bf6ffaddf040e671a2cafb4106e
@@ -1,229 +0,0 @@
1
- package com.wix.detox.reactnative
2
-
3
- import android.os.Looper
4
- import android.util.Log
5
- import androidx.test.espresso.Espresso
6
- import androidx.test.espresso.IdlingRegistry
7
- import androidx.test.espresso.base.IdlingResourceRegistry
8
- import com.facebook.react.bridge.ReactContext
9
- import com.wix.detox.LaunchArgs
10
- import com.wix.detox.reactnative.idlingresources.*
11
- import com.wix.detox.reactnative.idlingresources.timers.TimersIdlingResource
12
- import com.wix.detox.reactnative.idlingresources.timers.getInterrogationStrategy
13
- import com.wix.detox.reactnative.idlingresources.uimodule.UIModuleIdlingResource
14
- import org.joor.Reflect
15
- import org.joor.ReflectException
16
-
17
- private const val LOG_TAG = "DetoxRNIdleRes"
18
-
19
- private class MQThreadsReflector(private val reactContext: ReactContext) {
20
- fun getQueue(queueName: String): MQThreadReflected? {
21
- try {
22
- val queue = Reflect.on(reactContext).field(queueName).get() as Any?
23
- return MQThreadReflected(queue, queueName)
24
- } catch (e: ReflectException) {
25
- Log.e(LOG_TAG, "Could not find queue: $queueName", e)
26
- }
27
- return null
28
- }
29
- }
30
-
31
- private class MQThreadReflected(private val queue: Any?, private val queueName: String) {
32
- fun getLooper(): Looper? {
33
- try {
34
- if (queue != null) {
35
- return Reflect.on(queue).call(METHOD_GET_LOOPER).get()
36
- }
37
- } catch (e: ReflectException) {
38
- Log.e(LOG_TAG, "Could not find looper for queue: $queueName", e)
39
- }
40
- return null
41
- }
42
-
43
- companion object {
44
- const val METHOD_GET_LOOPER = "getLooper"
45
- }
46
- }
47
-
48
- class ReactNativeIdlingResources constructor(
49
- private val reactContext: ReactContext,
50
- private var launchArgs: LaunchArgs,
51
- internal var networkSyncEnabled: Boolean = true
52
- ) {
53
- companion object {
54
- private const val FIELD_NATIVE_MODULES_MSG_QUEUE = "mNativeModulesMessageQueueThread"
55
- private const val FIELD_JS_MSG_QUEUE = "mJSMessageQueueThread"
56
- }
57
-
58
- private var timersIdlingResource: TimersIdlingResource? = null
59
- private var asyncStorageIdlingResource: AsyncStorageIdlingResource? = null
60
- private var legacyAsyncStorageIdlingResource: AsyncStorageIdlingResource? = null
61
- private var rnBridgeIdlingResource: BridgeIdlingResource? = null
62
- private var uiModuleIdlingResource: UIModuleIdlingResource? = null
63
- private var animIdlingResource: AnimatedModuleIdlingResource? = null
64
- private var networkIdlingResource: NetworkIdlingResource? = null
65
-
66
- fun registerAll() {
67
- Log.i(LOG_TAG, "Setting up Espresso Idling Resources for React Native")
68
- unregisterAll()
69
-
70
- setupUrlBlacklist()
71
- setupMQThreadsInterrogators()
72
- syncIdlingResources()
73
- setupCustomRNIdlingResources()
74
- syncIdlingResources()
75
- }
76
-
77
- fun unregisterAll() {
78
- unregisterMQThreadsInterrogators()
79
- unregisterCustomRNIdlingResources()
80
- }
81
-
82
- fun setNetworkSynchronization(enable: Boolean) {
83
- if (networkSyncEnabled == enable) {
84
- return
85
- }
86
-
87
- if (enable) {
88
- setupNetworkIdlingResource()
89
- } else {
90
- removeNetworkIdlingResource()
91
- }
92
- networkSyncEnabled = enable
93
- }
94
-
95
- fun pauseNetworkSynchronization() = networkIdlingResource?.pause()
96
- fun resumeNetworkSynchronization() {
97
- if (networkSyncEnabled) {
98
- networkIdlingResource?.resume()
99
- }
100
- }
101
-
102
- fun pauseRNTimersIdlingResource() = timersIdlingResource?.pause()
103
- fun resumeRNTimersIdlingResource() = timersIdlingResource?.resume()
104
- fun pauseUIIdlingResource() = uiModuleIdlingResource?.pause()
105
- fun resumeUIIdlingResource() = uiModuleIdlingResource?.resume()
106
-
107
- fun setBlacklistUrls(urlList: String) {
108
- setIldingResourceBlacklist(urlList)
109
- }
110
-
111
- private fun setIldingResourceBlacklist(urlList: String) {
112
- val urlArray = toFormattedUrlArray(urlList)
113
- NetworkIdlingResource.setURLBlacklist(urlArray)
114
- }
115
-
116
- private fun setupMQThreadsInterrogators() {
117
- if (IdlingRegistry.getInstance().loopers.isEmpty()) {
118
- val mqThreadsReflector = MQThreadsReflector(reactContext)
119
- val mqJS = mqThreadsReflector.getQueue(FIELD_JS_MSG_QUEUE)?.getLooper()
120
- val mqNativeModules =
121
- mqThreadsReflector.getQueue(FIELD_NATIVE_MODULES_MSG_QUEUE)?.getLooper()
122
-
123
- IdlingRegistry.getInstance().apply {
124
- registerLooperAsIdlingResource(mqJS)
125
- registerLooperAsIdlingResource(mqNativeModules)
126
- }
127
- }
128
- }
129
-
130
- private fun setupUrlBlacklist() {
131
- if (launchArgs.hasURLBlacklist()) {
132
- val blacklistUrls = launchArgs.urlBlacklist
133
- setIldingResourceBlacklist(blacklistUrls)
134
- }
135
- }
136
-
137
- private fun setupCustomRNIdlingResources() {
138
- rnBridgeIdlingResource = BridgeIdlingResource(reactContext)
139
- timersIdlingResource = TimersIdlingResource(getInterrogationStrategy(reactContext)!!)
140
- uiModuleIdlingResource = UIModuleIdlingResource(reactContext)
141
- animIdlingResource = AnimatedModuleIdlingResource(reactContext)
142
-
143
- IdlingRegistry.getInstance()
144
- .register(
145
- timersIdlingResource,
146
- rnBridgeIdlingResource,
147
- uiModuleIdlingResource,
148
- animIdlingResource)
149
-
150
- if (networkSyncEnabled) {
151
- setupNetworkIdlingResource()
152
- }
153
- setupAsyncStorageIdlingResource()
154
- }
155
-
156
- private fun syncIdlingResources() {
157
- IdlingRegistry.getInstance().apply {
158
- val irr: IdlingResourceRegistry =
159
- Reflect.on(Espresso::class.java).field("baseRegistry").get()
160
- irr.sync(this.resources, this.loopers)
161
- }
162
- }
163
-
164
- private fun unregisterMQThreadsInterrogators() {
165
- val idlingResourceInstance = IdlingRegistry.getInstance()
166
- val loopersField = Reflect.on(idlingResourceInstance).field("loopers")
167
- loopersField.get<MutableSet<Any>>().clear()
168
- }
169
-
170
- private fun unregisterCustomRNIdlingResources() {
171
- IdlingRegistry.getInstance()
172
- .unregister(
173
- timersIdlingResource,
174
- rnBridgeIdlingResource,
175
- uiModuleIdlingResource,
176
- animIdlingResource
177
- )
178
- rnBridgeIdlingResource?.onDetach()
179
-
180
- removeNetworkIdlingResource()
181
- removeAsyncStorageIdlingResource()
182
- }
183
-
184
- private fun setupAsyncStorageIdlingResource() {
185
- asyncStorageIdlingResource =
186
- AsyncStorageIdlingResource.createIfNeeded(reactContext, false)?.also {
187
- IdlingRegistry.getInstance().register(it)
188
- }
189
-
190
- legacyAsyncStorageIdlingResource =
191
- AsyncStorageIdlingResource.createIfNeeded(reactContext, true)?.also {
192
- IdlingRegistry.getInstance().register(it)
193
- }
194
- }
195
-
196
- private fun removeAsyncStorageIdlingResource() {
197
- asyncStorageIdlingResource?.also {
198
- IdlingRegistry.getInstance().unregister(it)
199
- }
200
-
201
- legacyAsyncStorageIdlingResource?.also {
202
- IdlingRegistry.getInstance().unregister(it)
203
- }
204
- }
205
-
206
- private fun setupNetworkIdlingResource() {
207
- try {
208
- networkIdlingResource = NetworkIdlingResource(reactContext)
209
- IdlingRegistry.getInstance().register(networkIdlingResource)
210
- } catch (e: ReflectException) {
211
- Log.e(LOG_TAG, "Can't set up Networking Module listener", e)
212
- }
213
- }
214
-
215
- private fun removeNetworkIdlingResource() {
216
- networkIdlingResource?.let {
217
- it.pause()
218
- IdlingRegistry.getInstance().unregister(it)
219
- networkIdlingResource = null
220
- }
221
- }
222
-
223
- private fun toFormattedUrlArray(urlList: String): List<String> {
224
- var formattedUrls = urlList
225
- formattedUrls = formattedUrls.replace(Regex("""[()"]"""), "")
226
- formattedUrls = formattedUrls.trim()
227
- return formattedUrls.split(',')
228
- }
229
- }