detox 21.0.0-breaking.new-global-lifecycle.0 → 21.0.1-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. package/.eslintrc.js +2 -7
  2. package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar → 21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar} +0 -0
  3. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.md5 +1 -0
  4. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha1 +1 -0
  5. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha256 +1 -0
  6. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-javadoc.jar.sha512 +1 -0
  7. package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar → 21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar} +0 -0
  8. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.md5 +1 -0
  9. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha1 +1 -0
  10. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha256 +1 -0
  11. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0-sources.jar.sha512 +1 -0
  12. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar +0 -0
  13. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.md5 +1 -0
  14. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha1 +1 -0
  15. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha256 +1 -0
  16. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.aar.sha512 +1 -0
  17. package/Detox-android/com/wix/detox/{21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom → 21.0.1-rc.0/detox-21.0.1-rc.0.pom} +22 -10
  18. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.md5 +1 -0
  19. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha1 +1 -0
  20. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha256 +1 -0
  21. package/Detox-android/com/wix/detox/21.0.1-rc.0/detox-21.0.1-rc.0.pom.sha512 +1 -0
  22. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  26. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  27. package/Detox-ios-framework.tbz +0 -0
  28. package/Detox-ios-src.tbz +0 -0
  29. package/Detox-ios-xcuitest.tbz +0 -0
  30. package/README.md +1 -1
  31. package/android/build.gradle +13 -8
  32. package/android/detox/build.gradle +24 -13
  33. package/android/detox/proguard-rules-app.pro +6 -0
  34. package/android/detox/proguard-rules.pro +3 -0
  35. package/android/detox/publish-pom.gradle +5 -1
  36. package/android/detox/publishing.gradle +35 -33
  37. package/android/detox/src/full/java/com/wix/detox/DetoxCrashHandler.kt +1 -1
  38. package/android/detox/src/full/java/com/wix/detox/LaunchArgs.java +9 -0
  39. package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +4 -4
  40. package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
  41. package/android/detox/src/full/java/com/wix/detox/adapters/server/WebSocketClient.java +3 -1
  42. package/android/detox/src/full/java/com/wix/detox/common/UIExtensions.kt +28 -0
  43. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +37 -3
  44. package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +11 -1
  45. package/android/detox/src/full/java/com/wix/detox/espresso/UiAutomatorHelper.java +1 -1
  46. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +22 -0
  47. package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +17 -4
  48. package/android/detox/src/full/java/com/wix/detox/espresso/action/RNDetoxAccessibilityAction.kt +46 -0
  49. package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +75 -0
  50. package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
  51. package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
  52. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +24 -28
  53. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/WithAccessibilityLabelMatcher.kt +23 -0
  54. package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
  55. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
  56. package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResourceDescription.kt +26 -0
  57. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeExtension.kt +15 -2
  58. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeIdlingResources.kt +43 -38
  59. package/android/detox/src/full/java/com/wix/detox/reactnative/ReactNativeLoadingMonitor.kt +54 -8
  60. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
  61. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +3 -4
  62. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
  63. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
  64. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +43 -34
  65. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategy.kt +7 -27
  66. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/IdleInterrogationStrategy.kt +1 -11
  67. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +2 -6
  68. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/RN66Workaround.kt +13 -4
  69. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
  70. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
  71. package/android/detox/src/full/java/com/wix/detox/reactnative/ui/UIExtensions.kt +37 -0
  72. package/android/detox/src/full/java/com/wix/detox/reactnative/utils/RNUtils.kt +6 -0
  73. package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +4 -1
  74. package/android/detox/src/main/java/com/wix/detox/common/TextFileReader.kt +1 -1
  75. package/android/detox/src/main/java/com/wix/detox/espresso/UiControllerSpy.kt +2 -1
  76. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +10 -0
  77. package/android/detox/src/main/java/com/wix/detox/espresso/action/common/utils/UiControllerUtils.kt +1 -1
  78. package/android/detox/src/testFull/java/com/wix/detox/UTHelpers.kt +12 -0
  79. package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
  80. package/android/detox/src/testFull/java/com/wix/detox/common/UIExtensionsTest.kt +107 -0
  81. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/DetoxMultiTapSpec.kt +4 -3
  82. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +22 -9
  83. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +39 -0
  84. package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/ViewAtIndexMatcherSpec.kt +1 -2
  85. package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
  86. package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
  87. package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
  88. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
  89. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +61 -0
  90. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DelegatedIdleInterrogationStrategySpec.kt +3 -11
  91. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
  92. package/android/gradle/wrapper/gradle-wrapper.properties +2 -1
  93. package/android/gradlew +181 -107
  94. package/index.d.ts +239 -83
  95. package/index.js +12 -1
  96. package/internals.d.ts +219 -45
  97. package/internals.js +10 -3
  98. package/local-cli/build-framework-cache.js +1 -1
  99. package/local-cli/build-xcuitest-cache.js +16 -0
  100. package/local-cli/build.js +2 -2
  101. package/local-cli/clean-framework-cache.js +1 -1
  102. package/local-cli/clean-xcuitest-cache.js +19 -0
  103. package/local-cli/cli.js +13 -7
  104. package/local-cli/init.js +61 -21
  105. package/local-cli/rebuild-framework-cache.js +4 -4
  106. package/local-cli/rebuild-xcuitest-cache.js +21 -0
  107. package/local-cli/reset-lock-file.js +16 -0
  108. package/local-cli/run-server.js +12 -1
  109. package/local-cli/start.js +49 -0
  110. package/local-cli/startCommand/AppStartCommand.js +65 -0
  111. package/local-cli/templates/jest.js +13 -10
  112. package/local-cli/test.js +14 -8
  113. package/local-cli/testCommand/TestRunnerCommand.js +126 -77
  114. package/local-cli/testCommand/TestRunnerError.js +13 -0
  115. package/local-cli/testCommand/builder.js +5 -1
  116. package/local-cli/testCommand/middlewares.js +4 -13
  117. package/local-cli/testCommand/warnings.js +0 -3
  118. package/local-cli/utils/cliErrorHandling.js +15 -0
  119. package/local-cli/utils/jestInternals.js +4 -1
  120. package/package.json +46 -26
  121. package/runners/deprecation.js +42 -44
  122. package/runners/jest/globalSetup.js +1 -1
  123. package/runners/jest/globalTeardown.js +1 -1
  124. package/runners/jest/index.d.ts +61 -0
  125. package/runners/jest/index.js +3 -8
  126. package/runners/jest/reporters/DetoxReporter.js +33 -2
  127. package/runners/jest/testEnvironment/index.js +119 -68
  128. package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +97 -51
  129. package/runners/jest/testEnvironment/listeners/DetoxPlatformFilterListener.js +1 -1
  130. package/runners/jest/testEnvironment/listeners/SpecReporter.js +15 -17
  131. package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +3 -7
  132. package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
  133. package/scripts/build_framework.ios.sh +26 -60
  134. package/scripts/build_local_framework.ios.sh +62 -0
  135. package/scripts/build_local_xcuitest.ios.sh +53 -0
  136. package/scripts/build_xcuitest.ios.sh +23 -0
  137. package/scripts/pack_ios.sh +14 -5
  138. package/scripts/postinstall.js +10 -4
  139. package/src/DetoxWorker.js +112 -64
  140. package/src/android/actions/native.js +16 -0
  141. package/src/android/core/NativeElement.js +72 -20
  142. package/src/android/core/NativeExpect.js +28 -9
  143. package/src/android/core/NativeMatcher.js +31 -10
  144. package/src/android/core/NativeWaitFor.js +8 -0
  145. package/src/android/espressoapi/DetoxAction.js +37 -0
  146. package/src/android/espressoapi/DetoxMatcher.js +24 -0
  147. package/src/android/espressoapi/EspressoDetox.js +1 -1
  148. package/src/android/espressoapi/web/WebElement.js +1 -1
  149. package/src/android/interactions/native.js +25 -18
  150. package/src/android/matchers/index.js +2 -2
  151. package/src/android/matchers/native.js +10 -3
  152. package/src/artifacts/ArtifactsManager.js +14 -47
  153. package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
  154. package/src/artifacts/log/android/ADBLogcatRecording.js +11 -28
  155. package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
  156. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
  157. package/src/artifacts/templates/artifact/Artifact.js +1 -1
  158. package/src/artifacts/templates/plugin/ArtifactPlugin.js +2 -2
  159. package/src/artifacts/templates/plugin/TwoSnapshotsPerTestPlugin.js +2 -1
  160. package/src/artifacts/templates/plugin/WholeTestRecorderPlugin.js +3 -2
  161. package/src/artifacts/timeline/TimelineContextTypes.js +7 -0
  162. package/src/artifacts/utils/temporaryPath.js +47 -8
  163. package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
  164. package/src/client/AsyncWebSocket.js +11 -19
  165. package/src/client/Client.js +35 -3
  166. package/src/client/actions/SyncStatusSchema.json +21 -0
  167. package/src/client/actions/actions.js +38 -0
  168. package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
  169. package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
  170. package/src/client/actions/formatters/sync-resources/NetworkFormatter.js +1 -1
  171. package/src/configuration/collectCliConfig.js +3 -13
  172. package/src/configuration/composeAppsConfig.js +5 -1
  173. package/src/configuration/composeDeviceConfig.js +1 -1
  174. package/src/configuration/composeLoggerConfig.js +20 -10
  175. package/src/configuration/composeRunnerConfig.js +62 -9
  176. package/src/configuration/index.js +14 -9
  177. package/src/configuration/loadExternalConfig.js +1 -1
  178. package/src/devices/allocation/DeviceAllocator.js +15 -2
  179. package/src/devices/allocation/drivers/AllocationDriverBase.js +10 -2
  180. package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +10 -1
  181. package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +5 -5
  182. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +28 -29
  183. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
  184. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +6 -5
  185. package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
  186. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +4 -17
  187. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +27 -18
  188. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
  189. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +12 -7
  190. package/src/devices/allocation/factories/base.js +1 -1
  191. package/src/devices/common/drivers/android/exec/ADB.js +9 -0
  192. package/src/devices/common/drivers/android/genycloud/exec/GenyCloudExec.js +1 -1
  193. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
  194. package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  195. package/src/devices/common/drivers/android/tools/AppInstallHelper.js +4 -4
  196. package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
  197. package/src/devices/common/drivers/android/tools/{FileXfer.js → FileTransfer.js} +2 -2
  198. package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
  199. package/src/devices/common/drivers/android/tools/MonitoredInstrumentation.js +1 -1
  200. package/src/devices/common/drivers/android/tools/TempFileTransfer.js +14 -0
  201. package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +21 -4
  202. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +13 -15
  203. package/src/devices/runtime/RuntimeDevice.js +24 -12
  204. package/src/devices/runtime/drivers/DeviceDriverBase.js +2 -1
  205. package/src/devices/runtime/drivers/android/AndroidDriver.js +17 -8
  206. package/src/devices/runtime/drivers/ios/SimulatorDriver.js +42 -2
  207. package/src/devices/runtime/drivers/ios/XCUITestUtils.js +209 -0
  208. package/src/devices/runtime/drivers/ios/allowNetworkPermissionsXCUITest.scpt +14 -0
  209. package/src/devices/runtime/factories/android.js +6 -5
  210. package/src/devices/runtime/factories/base.js +3 -2
  211. package/src/errors/DetoxConfigErrorComposer.js +18 -3
  212. package/src/errors/DetoxError.js +5 -1
  213. package/src/ios/expectTwo.js +199 -78
  214. package/src/ipc/IPCClient.js +36 -27
  215. package/src/ipc/IPCServer.js +40 -21
  216. package/src/ipc/SessionState.js +60 -0
  217. package/src/logger/DetoxLogger.js +287 -154
  218. package/src/logger/index.js +5 -0
  219. package/src/logger/utils/BunyanLogger.js +105 -0
  220. package/src/logger/utils/CategoryThreadDispatcher.js +37 -0
  221. package/src/logger/utils/DetoxLogFinalizer.js +166 -0
  222. package/src/logger/utils/MessageStack.js +35 -0
  223. package/src/logger/utils/ThreadDispatcher.js +61 -0
  224. package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +23 -6
  225. package/src/logger/utils/getMainCategory.js +5 -0
  226. package/src/logger/utils/sanitizeBunyanContext.js +30 -0
  227. package/src/logger/utils/streams/BunyanTransformer.js +72 -0
  228. package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
  229. package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
  230. package/src/logger/utils/streams/JSONLStringer.js +55 -0
  231. package/src/logger/utils/streams/index.js +7 -0
  232. package/src/logger/utils/streams/transformers.js +39 -0
  233. package/src/logger/utils/tracerLegacy.js +37 -0
  234. package/src/realms/DetoxContext.js +83 -66
  235. package/src/realms/DetoxInternalsFacade.js +9 -13
  236. package/src/realms/DetoxPrimaryContext.js +117 -74
  237. package/src/realms/DetoxSecondaryContext.js +32 -35
  238. package/src/{symbols.js → realms/symbols.js} +16 -22
  239. package/src/server/DetoxConnection.js +18 -23
  240. package/src/server/DetoxServer.js +7 -10
  241. package/src/server/DetoxSession.js +9 -6
  242. package/src/server/DetoxSessionManager.js +2 -1
  243. package/src/server/handlers/AnonymousConnectionHandler.js +1 -0
  244. package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
  245. package/src/servicelocator/android/index.js +2 -2
  246. package/src/utils/ExclusiveLockfile.js +1 -0
  247. package/src/utils/Timer.js +59 -36
  248. package/src/utils/argparse.js +11 -27
  249. package/src/utils/childProcess/exec.js +4 -2
  250. package/src/utils/childProcess/spawn.js +1 -1
  251. package/src/utils/dateUtils.js +5 -0
  252. package/src/utils/environment.js +55 -16
  253. package/src/utils/errorUtils.js +24 -3
  254. package/src/utils/invocationTraceDescriptions.js +44 -0
  255. package/src/utils/isPromise.js +8 -1
  256. package/src/utils/logger.js +2 -2
  257. package/src/utils/pathUtils.js +11 -0
  258. package/src/utils/shellUtils.js +17 -0
  259. package/src/utils/traceInvocationCall.js +21 -0
  260. package/src/utils/traceMethods.js +15 -0
  261. package/src/validation/ios/IosSimulatorEnvValidator.js +7 -4
  262. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
  263. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
  264. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
  265. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
  266. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
  267. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
  268. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
  269. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
  270. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar +0 -0
  271. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.md5 +0 -1
  272. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha1 +0 -1
  273. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha256 +0 -1
  274. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.aar.sha512 +0 -1
  275. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.md5 +0 -1
  276. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
  277. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
  278. package/Detox-android/com/wix/detox/21.0.0-breaking.new-global-lifecycle.0/detox-21.0.0-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
  279. package/Detox-ios.tbz +0 -0
  280. package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
  281. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
  282. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/IdlingResourceDescription.kt +0 -20
  283. package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategy.kt +0 -84
  284. package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -36
  285. package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +0 -59
  286. package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/DefaultIdleInterrogationStrategySpec.kt +0 -115
  287. package/local-cli/build.test.js +0 -104
  288. package/local-cli/run-server.test.js +0 -23
  289. package/local-cli/test.test.js +0 -515
  290. package/runners/jest/deprecation.js +0 -25
  291. package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
  292. package/scripts/build_universal_framework.sh +0 -14
  293. package/scripts/build_universal_framework_legacy.sh +0 -76
  294. package/scripts/build_universal_framework_modern.sh +0 -28
  295. package/src/configuration/utils/warnings.js +0 -12
  296. package/src/devices/common/drivers/android/tools/TempFileXfer.js +0 -16
  297. package/src/ipc/state.js +0 -76
  298. package/src/logger/DetoxTraceEventBuilder.js +0 -21
  299. package/src/logger/DetoxTracer.js +0 -133
  300. package/src/logger/TraceThreadDispatcher.js +0 -52
  301. package/src/realms/index.js +0 -10
  302. package/src/utils/ChromeTracingExporter.js +0 -53
  303. package/src/utils/streamUtils.js +0 -214
  304. package/src/utils/trace.js +0 -19
@@ -4,7 +4,9 @@ import android.view.View
4
4
  import android.widget.CheckBox
5
5
  import android.widget.ProgressBar
6
6
  import android.widget.TextView
7
+ import com.facebook.react.views.slider.ReactSlider
7
8
  import com.google.android.material.slider.Slider
9
+ import com.wix.detox.reactnative.ui.getAccessibilityLabel
8
10
  import org.assertj.core.api.Assertions.assertThat
9
11
  import org.json.JSONObject
10
12
  import org.junit.Before
@@ -31,7 +33,7 @@ class GetAttributesActionTest {
31
33
  private fun givenNoViewTag() = givenViewTag(null)
32
34
  private fun givenVisibility(value: Int) { whenever(view.visibility).doReturn(value) }
33
35
  private fun givenVisibilityRectAvailability(value: Boolean) { whenever(view.getLocalVisibleRect(any())).doReturn(value) }
34
- private fun givenContentDescription(value: String) { whenever(view.contentDescription).doReturn(value) }
36
+ private fun givenAccessibilityLabel(value: String) { whenever(view.getAccessibilityLabel()).doReturn(value) }
35
37
 
36
38
  private fun perform(v: View = view): JSONObject {
37
39
  uut.perform(null, v)
@@ -109,16 +111,16 @@ class GetAttributesActionTest {
109
111
  }
110
112
 
111
113
  @Test
112
- fun `should return label according to content-description`() {
113
- val contentDescription = "content-description-mock"
114
- givenContentDescription(contentDescription)
114
+ fun `should return label according to accessibilityLabel extension`() {
115
+ val accessibilityLabel = "label-mock"
116
+ givenAccessibilityLabel(accessibilityLabel)
115
117
 
116
118
  val resultJson = perform()
117
- assertThat(resultJson.opt("label")).isEqualTo(contentDescription)
119
+ assertThat(resultJson.opt("label")).isEqualTo(accessibilityLabel)
118
120
  }
119
121
 
120
122
  @Test
121
- fun `should not return label if content description no set`() {
123
+ fun `should not return label if accessibility label is not available`() {
122
124
  val resultJson = perform()
123
125
  assertThat(resultJson.opt("label")).isNull()
124
126
  }
@@ -179,7 +181,7 @@ class GetAttributesActionTest {
179
181
  }
180
182
 
181
183
  @Test
182
- fun `should return ProgressBar (or SeekBar) "progress" via value attribute`() {
184
+ fun `should return raw ProgressBar or SeekBar 'progress' via value attribute`() {
183
185
  val progressBar: ProgressBar = mock {
184
186
  on { progress } doReturn 42
185
187
  }
@@ -189,7 +191,18 @@ class GetAttributesActionTest {
189
191
  }
190
192
 
191
193
  @Test
192
- fun `should return Slider state through value attribute`() {
194
+ fun `should return RN-Slider via value attribute`() {
195
+ val progressBar: ReactSlider = mock {
196
+ on { max } doReturn 100
197
+ on { progress } doReturn 50
198
+ }
199
+
200
+ val resultJson = perform(progressBar)
201
+ assertThat(resultJson.opt("value")).isEqualTo(0.5)
202
+ }
203
+
204
+ @Test
205
+ fun `should return material-Slider state through value attribute`() {
193
206
  val slider: Slider = mock {
194
207
  on { value } doReturn 0.42f
195
208
  }
@@ -225,7 +238,7 @@ class GetAttributesActionTest {
225
238
  }
226
239
 
227
240
  @Test
228
- fun `should return text hint via "placeholder" attribute, if applicable`() {
241
+ fun `should return text hint via 'placeholder' attribute, if applicable`() {
229
242
  val textViewWithHint: TextView = mock {
230
243
  on { hint } doReturn "hint-text-mock"
231
244
  }
@@ -0,0 +1,39 @@
1
+ package com.wix.detox.espresso.common
2
+
3
+ import com.facebook.react.views.slider.ReactSlider
4
+ import org.assertj.core.api.Assertions.assertThat
5
+ import org.junit.Before
6
+ import org.junit.Test
7
+ import org.junit.runner.RunWith
8
+ import org.mockito.kotlin.doReturn
9
+ import org.mockito.kotlin.mock
10
+ import org.mockito.kotlin.whenever
11
+ import org.robolectric.RobolectricTestRunner
12
+
13
+ /**
14
+ * Note: This only tests against the react *legacy* (non-community) slider in order
15
+ * to avoid having to install the community slider under node_modules just for this.
16
+ */
17
+ @RunWith(RobolectricTestRunner::class)
18
+ class SliderHelperTest {
19
+ lateinit var slider: ReactSlider
20
+ lateinit var uut: SliderHelper
21
+
22
+ @Before
23
+ fun setup() {
24
+ slider = mock()
25
+ uut = SliderHelper.create(slider)
26
+ }
27
+
28
+ private fun givenNativeProgressTraits(current: Int, max: Int) {
29
+ whenever(slider.progress).doReturn(current)
30
+ whenever(slider.max).doReturn(max)
31
+ }
32
+
33
+ @Test
34
+ fun `should properly calculate current progress, in percentage`() {
35
+ givenNativeProgressTraits(current = 20, max = 100)
36
+
37
+ assertThat(uut.getCurrentProgressPct()).isEqualTo(0.2)
38
+ }
39
+ }
@@ -3,7 +3,6 @@ package com.wix.detox.espresso.matcher
3
3
  import android.view.View
4
4
  import org.hamcrest.Description
5
5
  import org.hamcrest.Matcher
6
- import org.hamcrest.Matchers
7
6
  import org.mockito.kotlin.mock
8
7
  import org.mockito.kotlin.verify
9
8
  import org.mockito.kotlin.whenever
@@ -28,7 +27,7 @@ object ViewAtIndexMatcherSpec: Spek({
28
27
  uut.describeTo(description)
29
28
  verify(description).appendText("View at index #0, of those matching MATCHER(innerMatcher description)")
30
29
  }
31
-
30
+
32
31
  it("should append a valid description for index≥0") {
33
32
  val uut = ViewAtIndexMatcher(7, innerMatcher)
34
33
  uut.describeTo(description)
@@ -4,6 +4,8 @@ import android.os.Looper
4
4
  import androidx.test.espresso.IdlingResource
5
5
  import androidx.test.espresso.base.IdlingResourceRegistry
6
6
  import com.wix.detox.UTHelpers
7
+ import com.wix.detox.espresso.common.UiControllerImplReflected
8
+ import com.wix.detox.inquiry.DetoxBusyResource
7
9
  import org.assertj.core.api.Assertions.assertThat
8
10
  import org.junit.Before
9
11
  import org.junit.Test
@@ -21,10 +23,11 @@ import java.util.concurrent.Executors
21
23
  // Fixes: Hangs in UIThread.postFirstSync inside IRStatusInquirer.getAllBusyResources when upgrading robolectric 4.3.x -> 4.4
22
24
  // See http://robolectric.org/blog/2019/06/04/paused-looper/ (coming from https://github.com/robolectric/robolectric/releases/tag/robolectric-4.4)
23
25
  @LooperMode(LooperMode.Mode.LEGACY)
24
- class IRStatusInquirerTest {
26
+ class BusyResourcesInquirerTest {
25
27
 
26
28
  lateinit var registry: IdlingResourceRegistry
27
- lateinit var uut: IRStatusInquirer
29
+ lateinit var uiController: UiControllerImplReflected
30
+ lateinit var uut: BusyResourcesInquirer
28
31
 
29
32
  private fun anIdleResource() = mock<IdlingResource> {
30
33
  on { isIdleNow } doReturn true
@@ -38,10 +41,22 @@ class IRStatusInquirerTest {
38
41
  whenever(registry.resources).doReturn(resources.asList())
39
42
  }
40
43
 
44
+ private fun givenRunningAsyncTasks() {
45
+ whenever(uiController.isAsyncIdleNow()).doReturn(false)
46
+ }
47
+
48
+ private fun givenRunningCompatAsyncTasks() {
49
+ whenever(uiController.isCompatIdleNow()).doReturn(false)
50
+ }
51
+
41
52
  @Before
42
53
  fun setup() {
43
54
  registry = mock()
44
- uut = IRStatusInquirer(registry)
55
+ uiController = mock() {
56
+ on { isAsyncIdleNow() } doReturn true
57
+ on { isCompatIdleNow() } doReturn true
58
+ }
59
+ uut = BusyResourcesInquirer(registry, uiController)
45
60
  }
46
61
 
47
62
  @Test
@@ -51,13 +66,33 @@ class IRStatusInquirerTest {
51
66
  }
52
67
 
53
68
  @Test
54
- fun `should return busy resources if there are some`() {
69
+ fun `should return busy resources if there are some IR ones`() {
55
70
  val resourceIdle = anIdleResource()
56
71
  val resourceBusy = aBusyResource()
57
72
  givenIdlingResources(resourceIdle, resourceBusy)
58
73
 
59
74
  val result = uut.getAllBusyResources()
60
- assertThat(result).isEqualTo(arrayListOf(resourceBusy))
75
+ assertThat(result.size).isEqualTo(1)
76
+ assertThat(result[0] is DetoxBusyResource.BusyIdlingResource)
77
+ assertThat((result[0] as DetoxBusyResource.BusyIdlingResource).resource).isEqualTo(resourceBusy)
78
+ }
79
+
80
+ @Test
81
+ fun `should return the async-task busy resource if some async-tasks are running`() {
82
+ givenRunningAsyncTasks()
83
+
84
+ val result = uut.getAllBusyResources()
85
+ assertThat(result.size).isEqualTo(1)
86
+ assertThat(result[0] is DetoxBusyResource.BusyAsyncTasks)
87
+ }
88
+
89
+ @Test
90
+ fun `should return the async-task busy resource if some legacy async-tasks are running`() {
91
+ givenRunningCompatAsyncTasks()
92
+
93
+ val result = uut.getAllBusyResources()
94
+ assertThat(result.size).isEqualTo(1)
95
+ assertThat(result[0] is DetoxBusyResource.BusyAsyncTasks)
61
96
  }
62
97
 
63
98
  @Test
@@ -79,13 +114,17 @@ class IRStatusInquirerTest {
79
114
  }
80
115
  givenIdlingResources(resource)
81
116
 
82
- var result: List<IdlingResource>? = null
117
+ var result: List<DetoxBusyResource>? = null
83
118
  executor.execute {
84
119
  result = uut.getAllBusyResources()
85
120
  }
86
121
  Thread.sleep(100L) // Give time for the unit to actually post on the main thread (as it's suppose to...)
87
122
  Robolectric.flushForegroundThreadScheduler()
88
123
  UTHelpers.yieldToOtherThreads(executor)
89
- assertThat(result).isEqualTo(arrayListOf(resource)) // Assert (2)
124
+
125
+ assertThat(result).isNotNull
126
+ assertThat(result!!.size).isEqualTo(1)
127
+ assertThat(result!![0] is DetoxBusyResource.BusyIdlingResource)
128
+ assertThat((result!![0] as DetoxBusyResource.BusyIdlingResource).resource).isEqualTo(resource)
90
129
  }
91
130
  }
@@ -1,16 +1,16 @@
1
- package com.wix.detox.reactnative.idlingresources
1
+ package com.wix.detox.inquiry
2
2
 
3
3
  import org.assertj.core.api.Assertions
4
4
  import org.spekframework.spek2.Spek
5
5
  import org.spekframework.spek2.style.specification.describe
6
6
 
7
- class IdlingResourceDescriptionSpec: Spek({
7
+ class DetoxBusyResourceDescriptionSpec: Spek({
8
8
  describe("Idling Resource Description Builder") {
9
- lateinit var description: IdlingResourceDescription
9
+ lateinit var description: DetoxBusyResourceDescription
10
10
  lateinit var expectedJSON: Map<String, Any>
11
11
 
12
12
  it("should build with given description") {
13
- description = IdlingResourceDescription.Builder()
13
+ description = DetoxBusyResourceDescription.Builder()
14
14
  .name("foo")
15
15
  .addDescription("bar", "baz")
16
16
  .addDescription("qux", "quux")
@@ -24,14 +24,14 @@ class IdlingResourceDescriptionSpec: Spek({
24
24
  }
25
25
 
26
26
  it("should build without description") {
27
- description = IdlingResourceDescription.Builder().name("foo").build()
27
+ description = DetoxBusyResourceDescription.Builder().name("foo").build()
28
28
 
29
29
  expectedJSON = mapOf("name" to "foo")
30
30
  Assertions.assertThat(description.json()).isEqualTo(expectedJSON)
31
31
  }
32
32
 
33
33
  it("should build without name") {
34
- description = IdlingResourceDescription.Builder()
34
+ description = DetoxBusyResourceDescription.Builder()
35
35
  .addDescription("bar", "baz")
36
36
  .addDescription("qux", "quux")
37
37
  .build()
@@ -0,0 +1,134 @@
1
+ package com.wix.detox.inquiry
2
+
3
+ import androidx.test.espresso.IdlingResource
4
+ import com.wix.detox.espresso.idlingresources.DescriptiveIdlingResource
5
+ import org.assertj.core.api.Assertions.assertThat
6
+ import org.mockito.kotlin.doReturn
7
+ import org.mockito.kotlin.mock
8
+ import org.spekframework.spek2.Spek
9
+ import org.spekframework.spek2.style.specification.describe
10
+
11
+ class DetoxBusyResourceSpec: Spek({
12
+ describe("Detox busy resource") {
13
+ data class TestCase<in T: IdlingResource>(
14
+ val caseTitle: String,
15
+ val idlingResource: IdlingResource,
16
+ val expectedDescription: DetoxBusyResourceDescription
17
+ )
18
+
19
+ describe("given a descriptive idling resource") {
20
+ val mockedDebugName = "mock:debug-name"
21
+
22
+ fun aDescriptiveIdlingResource(busyHint: Map<String, Any>?): DescriptiveIdlingResource =
23
+ mock() {
24
+ on { getDebugName() }.doReturn(mockedDebugName)
25
+ on { getBusyHint() }.doReturn(busyHint)
26
+ }
27
+
28
+ listOf(
29
+ TestCase<IdlingResource>(
30
+ caseTitle = "should return a description based on debug-name and busy-hint",
31
+ idlingResource = aDescriptiveIdlingResource(mapOf("mocked" to "hint", "mocked2" to "hint2")),
32
+ expectedDescription = DetoxBusyResourceDescription.Builder()
33
+ .name(mockedDebugName)
34
+ .addDescription("mocked", "hint")
35
+ .addDescription("mocked2", "hint2")
36
+ .build()
37
+ ),
38
+ TestCase(
39
+ caseTitle = "should return a description even without a busy-hint",
40
+ idlingResource = aDescriptiveIdlingResource(busyHint = null),
41
+ expectedDescription = DetoxBusyResourceDescription.Builder()
42
+ .name(mockedDebugName)
43
+ .build()
44
+ ),
45
+ ).forEach { (caseTitle, idlingResource, expectedDescription) ->
46
+ it(caseTitle) {
47
+ val uut = DetoxBusyResource.BusyIdlingResource(idlingResource)
48
+
49
+ assertThat(uut.resource).isEqualTo(idlingResource)
50
+ assertThat(uut.getDescription()).isEqualTo(expectedDescription)
51
+ }
52
+ }
53
+ }
54
+
55
+ describe("given a looper idling resource") {
56
+
57
+ abstract class LooperIdlingResource: IdlingResource {}
58
+
59
+ fun aLooperIdlingResourceMock(resourceName: String): LooperIdlingResource =
60
+ mock() {
61
+ on { name }.doReturn(resourceName)
62
+ }
63
+
64
+ listOf(
65
+ TestCase<LooperIdlingResource>(
66
+ caseTitle = "should return a tailored description for the js-thread looper",
67
+ idlingResource = aLooperIdlingResourceMock("mqt_js"),
68
+ expectedDescription = DetoxBusyResourceDescription.Builder()
69
+ .name("looper")
70
+ .addDescription("thread", "\"mqt_js\" (JS Thread)")
71
+ .addDescription("execution_type", "JavaScript code")
72
+ .build(),
73
+ ),
74
+ TestCase<LooperIdlingResource>(
75
+ caseTitle = "should return a tailored description for native-modules thread",
76
+ idlingResource = aLooperIdlingResourceMock("mqt_native"),
77
+ expectedDescription = DetoxBusyResourceDescription.Builder()
78
+ .name("looper")
79
+ .addDescription("thread", "\"mqt_native\" (Native Modules Thread)")
80
+ .addDescription("execution_type", "native module calls")
81
+ .build()
82
+ ),
83
+ TestCase<LooperIdlingResource>(
84
+ caseTitle = "should return a default description for unspecified looper-threads",
85
+ idlingResource = aLooperIdlingResourceMock("unmapped"),
86
+ expectedDescription = DetoxBusyResourceDescription.Builder()
87
+ .name("looper")
88
+ .addDescription("thread", "\"unmapped\"")
89
+ .build(),
90
+ ),
91
+ ).forEach { (caseTitle, idlingResource, expectedDescription) ->
92
+ it(caseTitle) {
93
+ val uut = DetoxBusyResource.BusyIdlingResource(idlingResource)
94
+
95
+ assertThat(uut.resource).isEqualTo(idlingResource)
96
+ assertThat(uut.getDescription()).isEqualTo(expectedDescription)
97
+ }
98
+ }
99
+ }
100
+
101
+ describe("given a generic idling resource") {
102
+ val mockedResourceName = "mock:resource-name"
103
+
104
+ listOf(
105
+ TestCase<IdlingResource>(
106
+ caseTitle = "should return a generic description for a generic idling resource",
107
+ idlingResource = mock { on { name}.doReturn(mockedResourceName) },
108
+ expectedDescription = DetoxBusyResourceDescription.Builder()
109
+ .name("unknown")
110
+ .addDescription("identifier", mockedResourceName)
111
+ .build()
112
+ )
113
+ ).forEach { (caseTitle, idlingResource, expectedDescription) ->
114
+ it (caseTitle) {
115
+ val uut = DetoxBusyResource.BusyIdlingResource(idlingResource)
116
+
117
+ assertThat(uut.resource).isEqualTo(idlingResource)
118
+ assertThat(uut.getDescription()).isEqualTo(expectedDescription)
119
+ }
120
+ }
121
+ }
122
+
123
+ describe("busy async-task(s) description") {
124
+ it("should return a general description") {
125
+ val expectedDescription = DetoxBusyResourceDescription.Builder()
126
+ .name("bg")
127
+ .addDescription("reason", "native async-tasks")
128
+ .build()
129
+
130
+ assertThat(DetoxBusyResource.BusyAsyncTasks.getDescription()).isEqualTo(expectedDescription)
131
+ }
132
+ }
133
+ }
134
+ })
@@ -61,6 +61,10 @@ class AsyncStorageIdlingResourceSpec: Spek({
61
61
  assertThat(uut.name).isEqualTo("com.wix.detox.reactnative.idlingresources.AsyncStorageIdlingResource")
62
62
  }
63
63
 
64
+ it("should have a debug-name") {
65
+ assertThat(uut.getDebugName()).isEqualTo("io")
66
+ }
67
+
64
68
  describe("idle-checking") {
65
69
  it("should be idle") {
66
70
  givenIdleSExecutor()
@@ -71,11 +75,6 @@ class AsyncStorageIdlingResourceSpec: Spek({
71
75
  givenAnActiveTask()
72
76
  givenNoPendingTasks()
73
77
  assertThat(uut.isIdleNow).isFalse()
74
-
75
- val expectedDescription = IdlingResourceDescription.Builder()
76
- .name("io")
77
- .build()
78
- assertThat(uut.getDescription()).isEqualTo(expectedDescription)
79
78
  }
80
79
 
81
80
  it("should be busy if executor has pending tasks") {
@@ -0,0 +1,61 @@
1
+ package com.wix.detox.reactnative.idlingresources
2
+
3
+ import com.wix.detox.UTHelpers.yieldToOtherThreads
4
+ import org.assertj.core.api.Assertions.assertThat
5
+
6
+ import okhttp3.Dispatcher
7
+ import org.junit.Before
8
+ import org.junit.Test
9
+ import org.junit.runner.RunWith
10
+ import org.robolectric.RobolectricTestRunner
11
+ import java.util.concurrent.Executors
12
+
13
+ @RunWith(RobolectricTestRunner::class)
14
+ class NetworkIdlingResourcesTest {
15
+ lateinit var dispatcher: Dispatcher
16
+ lateinit var uut: NetworkIdlingResource
17
+
18
+ @Before
19
+ fun setup() {
20
+ dispatcher = Dispatcher()
21
+ uut = NetworkIdlingResource(dispatcher)
22
+ }
23
+
24
+ // Note: Ideally, we should test that the list of busy resources is protected,
25
+ // rather than testing thread-safety as a whole.
26
+ @Test
27
+ fun `should return the descriptive data a thread-safe way`() {
28
+ val localExecutor = Executors.newSingleThreadExecutor()
29
+ var busyHint: Map<String, Any>? = null
30
+
31
+ synchronized(uut) {
32
+ localExecutor.submit {
33
+ busyHint = uut.getBusyHint()
34
+ }
35
+
36
+ yieldToOtherThreads(localExecutor)
37
+ assertThat(busyHint).isNull()
38
+ }
39
+ yieldToOtherThreads(localExecutor)
40
+ assertThat(busyHint).isNotNull
41
+ }
42
+
43
+ // Note: Ideally, we should test that the list of busy resources is protected,
44
+ // rather than testing thread-safety as a whole.
45
+ @Test
46
+ fun `should check for idle in a thread-safe way`() {
47
+ val localExecutor = Executors.newSingleThreadExecutor()
48
+ var idle = false
49
+
50
+ synchronized(uut) {
51
+ localExecutor.submit {
52
+ idle = uut.isIdleNow
53
+ }
54
+
55
+ yieldToOtherThreads(localExecutor)
56
+ assertThat(idle).isFalse
57
+ }
58
+ yieldToOtherThreads(localExecutor)
59
+ assertThat(idle).isTrue
60
+ }
61
+ }
@@ -5,22 +5,14 @@ import org.assertj.core.api.Assertions.assertThat
5
5
  import org.mockito.kotlin.*
6
6
  import org.spekframework.spek2.Spek
7
7
  import org.spekframework.spek2.style.specification.describe
8
+ import com.facebook.react.modules.core.TimingModule
8
9
 
9
10
  private const val BUSY_INTERVAL_MS = 1500L
10
11
 
11
- abstract class TimingModuleStub: NativeModule {
12
- abstract fun hasActiveTimersInRange(rangeMs: Long): Boolean
13
-
14
- override fun onCatalystInstanceDestroy() {}
15
- override fun getName(): String = "TimersNativeModuleStub"
16
- override fun canOverrideExistingModule() = false
17
- override fun initialize() {}
18
- }
19
-
20
12
  object DelegatedIdleInterrogationStrategySpec : Spek({
21
- describe("RN62+ timers idle-interrogation strategy") {
13
+ describe("Timers idle-interrogation strategy") {
22
14
 
23
- lateinit var timingModule: TimingModuleStub
15
+ lateinit var timingModule: TimingModule
24
16
 
25
17
  beforeEachTest {
26
18
  timingModule = mock()
@@ -2,7 +2,6 @@ package com.wix.detox.reactnative.idlingresources.timers
2
2
 
3
3
  import android.view.Choreographer
4
4
  import androidx.test.espresso.IdlingResource
5
- import com.wix.detox.reactnative.idlingresources.IdlingResourceDescription
6
5
  import org.assertj.core.api.Assertions
7
6
  import org.mockito.kotlin.*
8
7
  import org.spekframework.spek2.Spek
@@ -41,6 +40,10 @@ object TimersIdlingResourceSpec : Spek({
41
40
  getChoreographerCallback().doFrame(0L)
42
41
  }
43
42
 
43
+ it("should return a debug-name") {
44
+ Assertions.assertThat(uut().getDebugName()).isEqualTo("timers")
45
+ }
46
+
44
47
  it("should be idle if strategy says so") {
45
48
  givenIdleStrategy()
46
49
  Assertions.assertThat(uut().isIdleNow).isTrue()
@@ -49,11 +52,6 @@ object TimersIdlingResourceSpec : Spek({
49
52
  it("should be busy if strategy says so") {
50
53
  givenBusyStrategy()
51
54
  Assertions.assertThat(uut().isIdleNow).isFalse()
52
-
53
- val expectedDescription = IdlingResourceDescription.Builder()
54
- .name("timers")
55
- .build()
56
- Assertions.assertThat(uut().getDescription()).isEqualTo(expectedDescription)
57
55
  }
58
56
 
59
57
  it("should transition to idle if found idle by strategy") {
@@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
7
+