detox 20.1.0-next-is-hittable-check.0 → 20.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar → 20.1.0/detox-20.1.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar → 20.1.0/detox-20.1.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom → 20.1.0/detox-20.1.0.pom} +1 -1
  17. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.1.0/detox-20.1.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/build.gradle +0 -1
  29. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
  30. package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
  31. package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
  32. package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
  33. package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
  34. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
  35. package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
  36. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
  37. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +2 -4
  38. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
  39. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
  40. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
  41. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +1 -6
  42. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
  43. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
  44. package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
  45. package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
  46. package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
  47. package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
  48. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
  49. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
  50. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
  51. package/index.d.ts +102 -18
  52. package/internals.d.ts +34 -9
  53. package/local-cli/cli.js +6 -3
  54. package/local-cli/init.js +1 -1
  55. package/local-cli/test.js +6 -6
  56. package/local-cli/testCommand/TestRunnerCommand.js +97 -94
  57. package/local-cli/testCommand/TestRunnerError.js +17 -0
  58. package/local-cli/testCommand/builder.js +0 -1
  59. package/local-cli/testCommand/middlewares.js +4 -13
  60. package/local-cli/testCommand/warnings.js +0 -3
  61. package/package.json +18 -15
  62. package/runners/deprecation.js +42 -44
  63. package/runners/jest/index.d.ts +60 -0
  64. package/runners/jest/index.js +3 -8
  65. package/runners/jest/reporters/DetoxReporter.js +21 -10
  66. package/runners/jest/testEnvironment/index.js +57 -41
  67. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
  68. package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
  69. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
  70. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  71. package/src/DetoxWorker.js +95 -49
  72. package/src/android/interactions/native.js +3 -2
  73. package/src/artifacts/ArtifactsManager.js +6 -6
  74. package/src/artifacts/utils/temporaryPath.js +32 -2
  75. package/src/client/actions/SyncStatusSchema.json +21 -0
  76. package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
  77. package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
  78. package/src/configuration/collectCliConfig.js +1 -12
  79. package/src/configuration/composeRunnerConfig.js +5 -4
  80. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
  81. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
  82. package/src/devices/common/drivers/android/exec/ADB.js +4 -0
  83. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
  84. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +4 -0
  85. package/src/devices/runtime/RuntimeDevice.js +3 -3
  86. package/src/errors/DetoxConfigErrorComposer.js +6 -1
  87. package/src/errors/DetoxError.js +5 -1
  88. package/src/ios/expectTwo.js +3 -2
  89. package/src/ipc/IPCClient.js +26 -17
  90. package/src/ipc/IPCServer.js +11 -3
  91. package/src/ipc/SessionState.js +11 -11
  92. package/src/logger/DetoxLogger.js +63 -43
  93. package/src/logger/index.js +1 -0
  94. package/src/logger/utils/BunyanLogger.js +50 -7
  95. package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
  96. package/src/logger/utils/DetoxLogFinalizer.js +166 -0
  97. package/src/logger/utils/MessageStack.js +17 -6
  98. package/src/logger/utils/ThreadDispatcher.js +5 -25
  99. package/src/logger/utils/customConsoleLogger.js +22 -5
  100. package/src/logger/utils/getMainCategory.js +5 -0
  101. package/src/logger/utils/sanitizeBunyanContext.js +3 -1
  102. package/src/logger/utils/streams/BunyanTransformer.js +72 -0
  103. package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
  104. package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
  105. package/src/logger/utils/streams/JSONLStringer.js +55 -0
  106. package/src/logger/utils/streams/index.js +7 -0
  107. package/src/logger/utils/streams/transformers.js +39 -0
  108. package/src/logger/utils/tracerLegacy.js +14 -25
  109. package/src/realms/DetoxContext.js +11 -7
  110. package/src/realms/DetoxInternalsFacade.js +0 -6
  111. package/src/realms/DetoxPrimaryContext.js +42 -87
  112. package/src/realms/DetoxSecondaryContext.js +8 -12
  113. package/src/utils/argparse.js +11 -0
  114. package/src/utils/logger.js +1 -1
  115. package/src/utils/pathUtils.js +11 -0
  116. package/src/utils/shellUtils.js +17 -0
  117. package/src/utils/traceInvocationCall.js +21 -0
  118. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.md5 +0 -1
  119. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha1 +0 -1
  120. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha256 +0 -1
  121. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha512 +0 -1
  122. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.md5 +0 -1
  123. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha1 +0 -1
  124. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha256 +0 -1
  125. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha512 +0 -1
  126. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar +0 -0
  127. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.md5 +0 -1
  128. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha1 +0 -1
  129. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha256 +0 -1
  130. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha512 +0 -1
  131. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.md5 +0 -1
  132. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha1 +0 -1
  133. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha256 +0 -1
  134. package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha512 +0 -1
  135. package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
  136. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
  137. package/local-cli/build.test.js +0 -104
  138. package/local-cli/run-server.test.js +0 -23
  139. package/local-cli/test.test.js +0 -569
  140. package/runners/jest/deprecation.js +0 -25
  141. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
  142. package/src/configuration/utils/warnings.js +0 -12
  143. package/src/logger/utils/streamUtils.js +0 -240
  144. package/src/utils/trace.js +0 -3
@@ -0,0 +1 @@
1
+ ea6186058d129e19888773c331920f40
@@ -0,0 +1 @@
1
+ c345c57a09f415daef9a23832141b5af2e18647e
@@ -0,0 +1 @@
1
+ de444279abdbbef76d881b8130460cf395410b1076c87fc63e249167138ce04a
@@ -0,0 +1 @@
1
+ a336b4f6dfcf0681162be31e004aa9f407876c27ed27d08e1f5261e351782b57e96fcd419a35acd0c45292c5ba11705b595d5f751c2fd548025161c9189ab7ef
@@ -0,0 +1 @@
1
+ d1cc2d23f8f9f2b0a4bc726bbb62bfe8
@@ -0,0 +1 @@
1
+ 0dfff4938eb6cdcbad7c459e00e03e5f74cf63e2
@@ -0,0 +1 @@
1
+ 57d1a4ca0a22818cacb3fc0612ef95d2f2e2619975c678a96360c58564667d01
@@ -0,0 +1 @@
1
+ c3aa7640f8f4d7fe4515fd64f6bf5dd2d086125b50e355fb7b7267c2973a992f159ab5723ffce5d52c90ced2c2e899692fa503804ebec6a28ecf9520c7fb4253
@@ -0,0 +1 @@
1
+ 9f4287a9139d94b1eb35aef80da68b65
@@ -0,0 +1 @@
1
+ dfa1ae19ebfa0add0b2392b3287e5885bd492768
@@ -0,0 +1 @@
1
+ a0f706c4d9f8a2c9b33603874ac9c107ad50e4f74177c98f84cd28b2cfe305ec
@@ -0,0 +1 @@
1
+ 7c5616e2dff6896bccaa3b98bbd0eb4085cfc2493ef4e0f3a6a75d4f6623059ab5ce912d80881eda8daa85f6d94aeecdc4661648f335523eb8e2e90cb47d40ae
@@ -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.1.0-next-is-hittable-check.0</version>
6
+ <version>20.1.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
+ 707f23a53e4df7c923928f8ee9d9532b
@@ -0,0 +1 @@
1
+ 314e61210f92969bb0b274cbe3e0dac1f04c0bdc
@@ -0,0 +1 @@
1
+ 65a2960ffce341d2c351849d7d164f6fee2164dee2d3ca6963094444c28e15e5
@@ -0,0 +1 @@
1
+ 8542c39f3f0b79257898244daaf665d4bca3f445833cbac16c11ba8a858928e38bae73227c2996f12c2ffa744ce350e00e96636a1ff212dfaa6730d6274bb559
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.1.0-next-is-hittable-check.0</latest>
7
- <release>20.1.0-next-is-hittable-check.0</release>
6
+ <latest>20.1.0</latest>
7
+ <release>20.1.0</release>
8
8
  <versions>
9
- <version>20.1.0-next-is-hittable-check.0</version>
9
+ <version>20.1.0</version>
10
10
  </versions>
11
- <lastUpdated>20221027091848</lastUpdated>
11
+ <lastUpdated>20221212153534</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 6abc81d3b72724caa7b05b479ec9cda4
1
+ b02bbab8a120f411b8c9e07c75d6c54b
@@ -1 +1 @@
1
- e5c15d3ad5f2372b8c9131eb4f9c431c34b534d6
1
+ 2e0d0ea05c62fd6d2bbe0cdb43a2efb6315e8c29
@@ -1 +1 @@
1
- 2bef8053b1c66b74321c2f2cc0c6f74bf2d3af4205804b5bab79e8417fc6d186
1
+ 6bd3e259aefe68a101c55de5de010ad3a84cc3f30116c87cf35a668264329310
@@ -1 +1 @@
1
- 347e4a189b393cf31f1b553b141f05e398c686487df11b8ba665395f05065aca3f9c87068c2b9c0dc078c3e09ca0dd7163144de81ae4031c199011a55cec03a1
1
+ c14e8fe0813c1b8f97b59b54f76c28fe1d1b3293908d5226b2c584a902a7a247c5fcc33aad5295b13729b83c415f29699da133dc9127d138f3be5f0be3ddff8b
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
@@ -37,7 +37,6 @@ allprojects {
37
37
  mavenLocal()
38
38
  mavenCentral()
39
39
  google()
40
- jcenter()
41
40
  maven {
42
41
  url "$projectDir/../../node_modules/react-native/android"
43
42
  }
@@ -5,16 +5,16 @@ import android.util.Log
5
5
  import androidx.test.espresso.Espresso
6
6
  import com.wix.detox.common.DetoxLog.Companion.LOG_TAG
7
7
  import com.wix.detox.espresso.UiAutomatorHelper
8
- import com.wix.detox.espresso.registry.IRStatusInquirer
8
+ import com.wix.detox.espresso.registry.BusyResourcesInquirer
9
9
  import com.wix.detox.reactnative.ReactNativeExtension
10
10
 
11
11
  class TestEngineFacade {
12
- fun awaitIdle(): Unit? = Espresso.onIdle() {
12
+ fun awaitIdle(): Unit? = Espresso.onIdle {
13
13
  Log.i(LOG_TAG, "Wait is over: App is now idle!")
14
14
  null
15
15
  }
16
16
  fun syncIdle() = UiAutomatorHelper.espressoSync() // TODO Check whether this can be replaced with #awaitIdle()
17
- fun getBusyIdlingResources() = IRStatusInquirer.INSTANCE.getAllBusyResources()
17
+ fun getAllBusyResources() = BusyResourcesInquirer.INSTANCE.getAllBusyResources()
18
18
 
19
19
  // TODO Refactor RN related stuff away
20
20
  fun reloadReactNative(appContext: Context) = ReactNativeExtension.reloadReactNative(appContext)
@@ -1,96 +1,28 @@
1
1
  package com.wix.detox.adapters.server
2
2
 
3
- import androidx.test.espresso.IdlingResource
4
3
  import com.wix.detox.TestEngineFacade
5
- import com.wix.detox.reactnative.idlingresources.DescriptiveIdlingResource
4
+ import com.wix.detox.inquiry.DetoxBusyResource
6
5
 
7
6
  class QueryStatusActionHandler(
8
7
  private val outboundServerAdapter: OutboundServerAdapter,
9
8
  private val testEngineFacade: TestEngineFacade
10
- )
11
- : DetoxActionHandler {
9
+ ) : DetoxActionHandler {
12
10
 
13
11
  override fun handle(params: String, messageId: Long) {
14
- val data = mutableMapOf<String, Any?>()
15
- data["status"] = formatStatus(testEngineFacade.getBusyIdlingResources())
16
-
12
+ val busyResources = testEngineFacade.getAllBusyResources()
13
+ val data = mapOf<String, Any?>(
14
+ "status" to formatStatus(busyResources)
15
+ )
17
16
  outboundServerAdapter.sendMessage("currentStatusResult", data, messageId)
18
17
  }
19
18
 
20
- private fun formatStatus(busyResources: List<IdlingResource>): Map<String, Any> {
19
+ private fun formatStatus(busyResources: List<DetoxBusyResource>): Map<String, Any> =
21
20
  if (busyResources.isEmpty()) {
22
- return mapOf("app_status" to "idle")
23
- }
24
-
25
- val status = mutableMapOf<String, Any>()
26
- status["app_status"] = "busy"
27
- status["busy_resources"] = busyResources.map{ formatResource(it) }
28
-
29
- return status
30
- }
31
-
32
- private fun formatResource(resource: IdlingResource): Map<String, Any> {
33
- if (resource is DescriptiveIdlingResource) {
34
- return resource.getDescription().json()
35
- }
36
-
37
- if (resource.javaClass.name.contains("LooperIdlingResource")) {
38
- return formatLooperResourceFromName(resource.name)
39
- }
40
-
41
- return mapOf<String, Any>(
42
- "name" to "unknown",
43
- "description" to mapOf<String, Any>(
44
- "identifier" to resource.name
21
+ mapOf("app_status" to "idle")
22
+ } else {
23
+ mapOf(
24
+ "app_status" to "busy",
25
+ "busy_resources" to busyResources.map { it.getDescription().json() }
45
26
  )
46
- )
47
- }
48
-
49
- private fun formatLooperResourceFromName(resourceName: String): Map<String, Any> {
50
- return when {
51
- isJSCodeExecution(resourceName) -> {
52
- formatLooperResource(
53
- "\"${resourceName}\" (JS Thread)",
54
- "JavaScript code"
55
- )
56
- }
57
- isNativeCodeExecution(resourceName) -> {
58
- formatLooperResource(
59
- "\"${resourceName}\" (Native Modules Thread)",
60
- "native module calls"
61
- )
62
- }
63
- else -> {
64
- formatLooperResource(
65
- "\"${resourceName}\""
66
- )
67
- }
68
27
  }
69
- }
70
-
71
- /**
72
- * @see URL https://reactnative.dev/docs/profiling
73
- */
74
- private fun isJSCodeExecution(looperName: String): Boolean {
75
- return looperName.contains("mqt_js")
76
- }
77
-
78
- private fun formatLooperResource(thread: String, executionType: String? = null): Map<String, Any> {
79
- return mapOf<String, Any>(
80
- "name" to "looper",
81
- "description" to
82
- mutableMapOf<String, Any>(
83
- "thread" to thread
84
- ).apply {
85
- if (executionType != null) put("execution_type", executionType)
86
- }
87
- )
88
- }
89
-
90
- /**
91
- * @see URL https://reactnative.dev/docs/profiling
92
- */
93
- private fun isNativeCodeExecution(looperName: String): Boolean {
94
- return looperName.contains("mqt_native")
95
- }
96
28
  }
@@ -0,0 +1,16 @@
1
+ package com.wix.detox.espresso.common
2
+
3
+ import com.wix.detox.espresso.action.common.utils.getUiController
4
+ import org.joor.Reflect
5
+
6
+ private const val FIELD_ASYNC_IDLE = "asyncIdle"
7
+ private const val FIELD_COMPAT_IDLE = "compatIdle"
8
+ private const val METHOD_IS_IDLE_NOW = "isIdleNow"
9
+
10
+ class UiControllerImplReflected {
11
+ fun isAsyncIdleNow(): Boolean =
12
+ Reflect.on(getUiController()).field(FIELD_ASYNC_IDLE).call(METHOD_IS_IDLE_NOW).get()
13
+
14
+ fun isCompatIdleNow(): Boolean =
15
+ Reflect.on(getUiController()).field(FIELD_COMPAT_IDLE).call(METHOD_IS_IDLE_NOW).get()
16
+ }
@@ -0,0 +1,8 @@
1
+ package com.wix.detox.espresso.idlingresources
2
+
3
+ import androidx.test.espresso.IdlingResource
4
+
5
+ interface DescriptiveIdlingResource: IdlingResource {
6
+ fun getDebugName(): String
7
+ fun getBusyHint(): Map<String, Any>? = null
8
+ }
@@ -0,0 +1,48 @@
1
+ package com.wix.detox.espresso.registry
2
+
3
+ import androidx.test.espresso.Espresso
4
+ import androidx.test.espresso.base.IdlingResourceRegistry
5
+ import com.wix.detox.common.UIThread
6
+ import com.wix.detox.espresso.common.UiControllerImplReflected
7
+ import com.wix.detox.inquiry.DetoxBusyResource
8
+ import com.wix.detox.inquiry.DetoxBusyResource.BusyAsyncTasks
9
+ import com.wix.detox.inquiry.DetoxBusyResource.BusyIdlingResource
10
+ import org.joor.Reflect
11
+ import java.util.concurrent.Callable
12
+
13
+ // TODO Better to split inquiry to two separate classes running under the single `UIThread.postFirstSync()` we have here.
14
+ class BusyResourcesInquirer(
15
+ private val registry: IdlingResourceRegistry,
16
+ private val uiControllerImplReflected: UiControllerImplReflected
17
+ ) {
18
+ fun getAllBusyResources(): List<DetoxBusyResource> {
19
+ return UIThread.postFirstSync(Callable<List<DetoxBusyResource>> {
20
+ mutableListOf<DetoxBusyResource>().apply {
21
+ addAll(getBusyIdlingResources())
22
+ addAll(getAsyncTasksResource()?.let { listOf(it) } ?: emptyList())
23
+ }
24
+ })
25
+ }
26
+
27
+ private fun getBusyIdlingResources(): List<BusyIdlingResource> =
28
+ registry.resources
29
+ .filter { !it.isIdleNow }
30
+ .map { BusyIdlingResource(it) }
31
+
32
+ private fun getAsyncTasksResource(): BusyAsyncTasks? {
33
+ // Mind the implicit optimization:
34
+ // Don't inspect both resources if not necessary (async-tasks is not idle).
35
+ if (uiControllerImplReflected.isAsyncIdleNow() &&
36
+ uiControllerImplReflected.isCompatIdleNow()) {
37
+ return null
38
+ }
39
+ return BusyAsyncTasks
40
+ }
41
+
42
+ companion object {
43
+ val INSTANCE = BusyResourcesInquirer(getRegistryDefault(), UiControllerImplReflected())
44
+ }
45
+ }
46
+
47
+ private fun getRegistryDefault() =
48
+ Reflect.on(Espresso::class.java).get<IdlingResourceRegistry>("baseRegistry")
@@ -0,0 +1,92 @@
1
+ package com.wix.detox.inquiry
2
+
3
+ import androidx.test.espresso.IdlingResource
4
+ import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource
5
+
6
+ sealed class DetoxBusyResource {
7
+ abstract fun getDescription(): DetoxBusyResourceDescription
8
+
9
+ class BusyIdlingResource(val resource: IdlingResource): DetoxBusyResource() {
10
+ override fun getDescription() =
11
+ when {
12
+ (resource is DescriptiveIdlingResource) ->
13
+ getIRDescription(resource)
14
+
15
+ (resource.javaClass.name.contains("LooperIdlingResource")) ->
16
+ getLooperResourceDescriptionByName(resource.name)
17
+
18
+ else ->
19
+ getUnspecifiedResourceDescription(resource)
20
+ }
21
+
22
+ private fun getIRDescription(resource: DescriptiveIdlingResource) =
23
+ DetoxBusyResourceDescription.Builder()
24
+ .name(resource.getDebugName())
25
+ .apply {
26
+ resource.getBusyHint()?.let {
27
+ it.forEach { hint -> addDescription(hint.key, hint.value) }
28
+ }
29
+ }
30
+ .build()
31
+
32
+ private fun getLooperResourceDescriptionByName(resourceName: String) =
33
+ when {
34
+ isJSCodeExecution(resourceName) -> {
35
+ getLooperResourceDesc(
36
+ thread = "\"${resourceName}\" (JS Thread)",
37
+ executionType = "JavaScript code"
38
+ )
39
+ }
40
+ isNativeCodeExecution(resourceName) -> {
41
+ getLooperResourceDesc(
42
+ thread = "\"${resourceName}\" (Native Modules Thread)",
43
+ executionType = "native module calls"
44
+ )
45
+ }
46
+ else -> {
47
+ getLooperResourceDesc(
48
+ thread = "\"${resourceName}\""
49
+ )
50
+ }
51
+ }
52
+
53
+ private fun getUnspecifiedResourceDescription(resource: IdlingResource) =
54
+ DetoxBusyResourceDescription.Builder()
55
+ .name("unknown")
56
+ .addDescription("identifier", resource.name)
57
+ .build()
58
+
59
+ /**
60
+ * @see URL https://reactnative.dev/docs/profiling
61
+ */
62
+ private fun isJSCodeExecution(looperName: String): Boolean {
63
+ return looperName.contains("mqt_js")
64
+ }
65
+
66
+ private fun getLooperResourceDesc(thread: String, executionType: String? = null) =
67
+ DetoxBusyResourceDescription.Builder()
68
+ .name("looper")
69
+ .addDescription("thread", thread)
70
+ .apply {
71
+ executionType?.let { addDescription("execution_type", executionType) }
72
+ }
73
+ .build()
74
+
75
+ /**
76
+ * @see URL https://reactnative.dev/docs/profiling
77
+ */
78
+ private fun isNativeCodeExecution(looperName: String): Boolean {
79
+ return looperName.contains("mqt_native")
80
+ }
81
+
82
+ }
83
+
84
+ object BusyAsyncTasks: DetoxBusyResource() {
85
+ override fun getDescription() =
86
+ DetoxBusyResourceDescription.Builder()
87
+ .name("bg")
88
+ .addDescription("reason", "native async-tasks")
89
+ .build()
90
+
91
+ }
92
+ }
@@ -1,17 +1,17 @@
1
- package com.wix.detox.reactnative.idlingresources
1
+ package com.wix.detox.inquiry
2
2
 
3
- class IdlingResourceDescription private constructor(
3
+ class DetoxBusyResourceDescription private constructor(
4
4
  private val name: String,
5
5
  private val description: Map<String, Any>) {
6
6
 
7
- fun json() =
7
+ fun json(): Map<String, Any> =
8
8
  mutableMapOf<String, Any>("name" to name)
9
9
  .apply {
10
10
  if (description.isNotEmpty()) put("description", description)
11
- }.toMap()
11
+ }
12
12
 
13
13
  override fun equals(other: Any?) =
14
- (other is IdlingResourceDescription && other.json() == this.json())
14
+ (other is DetoxBusyResourceDescription && other.json() == this.json())
15
15
 
16
16
  override fun hashCode(): Int =
17
17
  (31 * name.hashCode() + description.hashCode())
@@ -21,6 +21,6 @@ class IdlingResourceDescription private constructor(
21
21
  var description: MutableMap<String, Any> = mutableMapOf()) {
22
22
  fun name(value: String) = apply { name = value }
23
23
  fun addDescription(key: String, value: Any) = apply { description[key] = value }
24
- fun build() = IdlingResourceDescription(name, description)
24
+ fun build() = DetoxBusyResourceDescription(name, description)
25
25
  }
26
26
  }
@@ -3,13 +3,17 @@ package com.wix.detox.reactnative.idlingresources;
3
3
  import android.util.Log;
4
4
  import android.view.Choreographer;
5
5
 
6
+ import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource;
6
7
  import com.wix.detox.reactnative.ReactNativeInfo;
7
8
 
8
- import org.jetbrains.annotations.NotNull;
9
9
  import org.joor.Reflect;
10
10
  import org.joor.ReflectException;
11
11
 
12
+ import java.util.HashMap;
13
+ import java.util.Map;
14
+
12
15
  import androidx.annotation.NonNull;
16
+ import androidx.annotation.Nullable;
13
17
 
14
18
  /**
15
19
  * Created by simonracz on 25/08/2017.
@@ -51,6 +55,10 @@ public class AnimatedModuleIdlingResource implements DescriptiveIdlingResource,
51
55
 
52
56
  private final static String METHOD_HAS_ACTIVE_ANIMATIONS = "hasActiveAnimations";
53
57
 
58
+ private final static Map<String, Object> busyHint = new HashMap<String, Object>() {{
59
+ put("reason", "Animations running on screen");
60
+ }};
61
+
54
62
  private ResourceCallback callback = null;
55
63
  private Object reactContext = null;
56
64
 
@@ -63,13 +71,16 @@ public class AnimatedModuleIdlingResource implements DescriptiveIdlingResource,
63
71
  return AnimatedModuleIdlingResource.class.getName();
64
72
  }
65
73
 
66
- @NotNull
74
+ @NonNull
75
+ @Override
76
+ public String getDebugName() {
77
+ return "ui";
78
+ }
79
+
80
+ @Nullable
67
81
  @Override
68
- public IdlingResourceDescription getDescription() {
69
- return new IdlingResourceDescription.Builder()
70
- .name("ui")
71
- .addDescription("reason", "Animations running on screen")
72
- .build();
82
+ public Map<String, Object> getBusyHint() {
83
+ return busyHint;
73
84
  }
74
85
 
75
86
  @Override
@@ -4,6 +4,7 @@ import android.util.Log
4
4
  import androidx.test.espresso.IdlingResource
5
5
  import com.facebook.react.bridge.NativeModule
6
6
  import com.facebook.react.bridge.ReactContext
7
+ import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource
7
8
  import com.wix.detox.reactnative.helpers.RNHelpers
8
9
  import org.joor.Reflect
9
10
  import java.util.concurrent.Executor
@@ -50,10 +51,7 @@ open class AsyncStorageIdlingResource
50
51
  }
51
52
 
52
53
  override fun getName(): String = javaClass.name
53
-
54
- override fun getDescription(): IdlingResourceDescription {
55
- return IdlingResourceDescription.Builder().name("io").build()
56
- }
54
+ override fun getDebugName() = "io"
57
55
 
58
56
  override fun isIdleNow(): Boolean =
59
57
  checkIdle().also { idle ->
@@ -5,12 +5,12 @@ import android.util.Log;
5
5
  import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
6
6
  import com.facebook.react.bridge.ReactContext;
7
7
 
8
- import org.jetbrains.annotations.NotNull;
9
-
10
- import java.util.HashMap;
11
8
  import java.util.Map;
12
9
  import java.util.concurrent.atomic.AtomicBoolean;
13
10
 
11
+ import androidx.annotation.NonNull;
12
+ import androidx.annotation.Nullable;
13
+
14
14
  /**
15
15
  * Created by simonracz on 01/06/2017.
16
16
  */
@@ -42,10 +42,10 @@ public class BridgeIdlingResource extends DetoxBaseIdlingResource implements Not
42
42
  return BridgeIdlingResource.class.getName();
43
43
  }
44
44
 
45
- @NotNull
45
+ @NonNull
46
46
  @Override
47
- public IdlingResourceDescription getDescription() {
48
- return new IdlingResourceDescription.Builder().name("bridge").build();
47
+ public String getDebugName() {
48
+ return "bridge";
49
49
  }
50
50
 
51
51
  @Override
@@ -85,4 +85,10 @@ public class BridgeIdlingResource extends DetoxBaseIdlingResource implements Not
85
85
  callback.onTransitionToIdle();
86
86
  }
87
87
  }
88
+
89
+ @Nullable
90
+ @Override
91
+ public Map<String, Object> getBusyHint() {
92
+ return null;
93
+ }
88
94
  }
@@ -1,5 +1,7 @@
1
1
  package com.wix.detox.reactnative.idlingresources;
2
2
 
3
+ import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource;
4
+
3
5
  import java.util.concurrent.atomic.AtomicBoolean;
4
6
 
5
7
  public abstract class DetoxBaseIdlingResource implements DescriptiveIdlingResource {
@@ -5,16 +5,17 @@ import android.view.Choreographer;
5
5
 
6
6
  import com.facebook.react.bridge.ReactContext;
7
7
 
8
- import org.jetbrains.annotations.NotNull;
9
-
10
8
  import java.util.ArrayList;
9
+ import java.util.HashMap;
11
10
  import java.util.HashSet;
12
11
  import java.util.List;
12
+ import java.util.Map;
13
13
  import java.util.Set;
14
14
  import java.util.regex.Pattern;
15
15
  import java.util.regex.PatternSyntaxException;
16
16
 
17
17
  import androidx.annotation.NonNull;
18
+ import androidx.annotation.Nullable;
18
19
  import okhttp3.Call;
19
20
  import okhttp3.Dispatcher;
20
21
 
@@ -67,13 +68,18 @@ public class NetworkIdlingResource extends DetoxBaseIdlingResource implements Ch
67
68
  return NetworkIdlingResource.class.getName();
68
69
  }
69
70
 
70
- @NotNull
71
+ @NonNull
72
+ @Override
73
+ public String getDebugName() {
74
+ return "network";
75
+ }
76
+
77
+ @Nullable
71
78
  @Override
72
- public synchronized IdlingResourceDescription getDescription() {
73
- return new IdlingResourceDescription.Builder()
74
- .name("network")
75
- .addDescription("urls", new ArrayList<>(busyResources))
76
- .build();
79
+ public synchronized Map<String, Object> getBusyHint() {
80
+ return new HashMap<String, Object>() {{
81
+ put("urls", new ArrayList<>(busyResources));
82
+ }};
77
83
  }
78
84
 
79
85
  @Override
@@ -2,9 +2,7 @@ package com.wix.detox.reactnative.idlingresources.timers
2
2
 
3
3
  import android.view.Choreographer
4
4
  import androidx.test.espresso.IdlingResource
5
-
6
5
  import com.wix.detox.reactnative.idlingresources.DetoxBaseIdlingResource
7
- import com.wix.detox.reactnative.idlingresources.IdlingResourceDescription
8
6
 
9
7
  class TimersIdlingResource @JvmOverloads constructor(
10
8
  private val interrogationStrategy: IdleInterrogationStrategy,
@@ -14,10 +12,7 @@ class TimersIdlingResource @JvmOverloads constructor(
14
12
  private var callback: IdlingResource.ResourceCallback? = null
15
13
 
16
14
  override fun getName(): String = this.javaClass.name
17
-
18
- override fun getDescription(): IdlingResourceDescription {
19
- return IdlingResourceDescription.Builder().name("timers").build();
20
- }
15
+ override fun getDebugName(): String = "timers"
21
16
 
22
17
  override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) {
23
18
  this.callback = callback