detox 20.12.1 → 20.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/Detox-android/com/wix/detox/{20.12.1/detox-20.12.1-javadoc.jar → 20.13.0/detox-20.13.0-javadoc.jar} +0 -0
  2. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.md5 +1 -0
  3. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha1 +1 -0
  4. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha256 +1 -0
  5. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-javadoc.jar.sha512 +1 -0
  6. package/Detox-android/com/wix/detox/{20.12.1/detox-20.12.1-sources.jar → 20.13.0/detox-20.13.0-sources.jar} +0 -0
  7. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.md5 +1 -0
  8. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha1 +1 -0
  9. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha256 +1 -0
  10. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0-sources.jar.sha512 +1 -0
  11. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar +0 -0
  12. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.md5 +1 -0
  13. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha1 +1 -0
  14. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha256 +1 -0
  15. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.aar.sha512 +1 -0
  16. package/Detox-android/com/wix/detox/{20.12.1/detox-20.12.1.pom → 20.13.0/detox-20.13.0.pom} +1 -7
  17. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.md5 +1 -0
  18. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha1 +1 -0
  19. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha256 +1 -0
  20. package/Detox-android/com/wix/detox/20.13.0/detox-20.13.0.pom.sha512 +1 -0
  21. package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
  22. package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
  23. package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
  24. package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
  25. package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
  26. package/Detox-ios-src.tbz +0 -0
  27. package/Detox-ios.tbz +0 -0
  28. package/android/detox/build.gradle +4 -3
  29. package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +2 -2
  30. package/android/detox/src/full/java/com/wix/detox/espresso/action/GetAttributesAction.kt +30 -31
  31. package/android/detox/src/full/java/com/wix/detox/espresso/common/MaterialSliderHelper.kt +21 -0
  32. package/android/detox/src/full/java/com/wix/detox/espresso/common/{SliderHelper.kt → ReactSliderHelper.kt} +6 -5
  33. package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +2 -2
  34. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/MaterialSliderHelperTest.kt +33 -0
  35. package/android/detox/src/testFull/java/com/wix/detox/espresso/common/{SliderHelperTest.kt → ReactSliderHelperTest.kt} +3 -3
  36. package/internals.d.ts +10 -1
  37. package/local-cli/reset-lock-file.js +5 -9
  38. package/package.json +5 -6
  39. package/runners/jest/reporters/DetoxReporter.js +127 -9
  40. package/runners/jest/testEnvironment/index.js +5 -0
  41. package/src/DetoxWorker.js +5 -11
  42. package/src/artifacts/providers/index.js +3 -3
  43. package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +0 -17
  44. package/src/configuration/composeLoggerConfig.js +1 -0
  45. package/src/devices/allocation/DeviceAllocator.js +66 -20
  46. package/src/devices/allocation/DeviceList.js +44 -0
  47. package/src/devices/allocation/DeviceRegistry.js +189 -0
  48. package/src/devices/allocation/drivers/AllocationDriverBase.d.ts +15 -0
  49. package/src/devices/{common/drivers/android/tools → allocation/drivers/android}/FreeDeviceFinder.js +11 -10
  50. package/src/devices/allocation/drivers/android/attached/AttachedAndroidAllocDriver.js +22 -17
  51. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +97 -38
  52. package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +32 -45
  53. package/src/devices/allocation/drivers/android/emulator/FreeEmulatorFinder.js +1 -1
  54. package/src/devices/allocation/drivers/android/emulator/FreePortFinder.js +37 -0
  55. package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -3
  56. package/src/devices/allocation/drivers/android/genycloud/GenyAllocDriver.js +104 -32
  57. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceLauncher.js +40 -31
  58. package/src/devices/allocation/drivers/android/genycloud/GenyRegistry.js +121 -0
  59. package/src/devices/allocation/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +24 -0
  60. package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
  61. package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyInstance.js +83 -0
  62. package/src/devices/allocation/drivers/android/genycloud/services/dto/GenyRecipe.js +25 -0
  63. package/src/devices/allocation/drivers/ios/SimulatorAllocDriver.js +94 -51
  64. package/src/devices/allocation/drivers/ios/SimulatorLauncher.js +11 -7
  65. package/src/devices/allocation/drivers/ios/SimulatorQuery.js +24 -0
  66. package/src/devices/allocation/factories/android.js +29 -35
  67. package/src/devices/allocation/factories/ios.js +7 -5
  68. package/src/devices/common/drivers/DeviceCookie.d.ts +12 -0
  69. package/src/devices/common/drivers/android/cookies.d.ts +11 -0
  70. package/src/devices/common/drivers/android/emulator/exec/EmulatorExec.js +17 -5
  71. package/src/devices/common/drivers/android/exec/ADB.js +1 -0
  72. package/src/devices/common/drivers/ios/cookies.d.ts +9 -0
  73. package/src/devices/cookies/index.js +0 -6
  74. package/src/devices/runtime/drivers/android/genycloud/GenyCloudDriver.js +7 -6
  75. package/src/devices/runtime/factories/android.js +3 -11
  76. package/src/devices/runtime/factories/ios.js +3 -2
  77. package/src/{servicelocator → devices/servicelocator}/android/emulatorServiceLocator.js +1 -1
  78. package/src/devices/servicelocator/android/genycloudServiceLocator.js +17 -0
  79. package/src/devices/servicelocator/android/index.js +23 -0
  80. package/src/{validation → devices/validation}/EnvironmentValidatorBase.js +1 -0
  81. package/src/{validation → devices/validation}/android/GenycloudEnvValidator.js +2 -2
  82. package/src/{validation → devices/validation}/factories/index.js +1 -1
  83. package/src/{validation → devices/validation}/ios/IosSimulatorEnvValidator.js +2 -2
  84. package/src/environmentFactory.js +1 -11
  85. package/src/ipc/IPCClient.js +22 -1
  86. package/src/ipc/IPCServer.js +40 -1
  87. package/src/ipc/SessionState.js +1 -0
  88. package/src/logger/DetoxLogger.js +2 -2
  89. package/src/realms/DetoxContext.js +8 -0
  90. package/src/realms/DetoxInternalsFacade.js +1 -0
  91. package/src/realms/DetoxPrimaryContext.js +48 -42
  92. package/src/realms/DetoxSecondaryContext.js +27 -0
  93. package/src/realms/symbols.js +6 -0
  94. package/src/utils/PIDService.js +27 -0
  95. package/src/utils/environment.js +8 -15
  96. package/src/utils/errorUtils.js +3 -3
  97. package/tsconfig.json +5 -3
  98. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-javadoc.jar.md5 +0 -1
  99. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-javadoc.jar.sha1 +0 -1
  100. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-javadoc.jar.sha256 +0 -1
  101. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-javadoc.jar.sha512 +0 -1
  102. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-sources.jar.md5 +0 -1
  103. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-sources.jar.sha1 +0 -1
  104. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-sources.jar.sha256 +0 -1
  105. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1-sources.jar.sha512 +0 -1
  106. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.aar +0 -0
  107. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.aar.md5 +0 -1
  108. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.aar.sha1 +0 -1
  109. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.aar.sha256 +0 -1
  110. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.aar.sha512 +0 -1
  111. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.pom.md5 +0 -1
  112. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.pom.sha1 +0 -1
  113. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.pom.sha256 +0 -1
  114. package/Detox-android/com/wix/detox/20.12.1/detox-20.12.1.pom.sha512 +0 -1
  115. package/src/devices/DeviceRegistry.js +0 -176
  116. package/src/devices/allocation/drivers/AllocationDriverBase.js +0 -30
  117. package/src/devices/allocation/drivers/android/attached/AttachedAndroidLauncher.js +0 -13
  118. package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +0 -72
  119. package/src/devices/allocation/drivers/android/genycloud/GenyDeviceRegistryFactory.js +0 -16
  120. package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +0 -65
  121. package/src/devices/common/drivers/DeviceAllocationHelper.js +0 -20
  122. package/src/devices/common/drivers/DeviceLauncher.js +0 -19
  123. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLifecycleService.js +0 -25
  124. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceLookupService.js +0 -38
  125. package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +0 -14
  126. package/src/devices/common/drivers/android/genycloud/services/dto/GenyInstance.js +0 -66
  127. package/src/devices/common/drivers/android/genycloud/services/dto/GenyRecipe.js +0 -13
  128. package/src/devices/cookies/AndroidDeviceCookie.js +0 -13
  129. package/src/devices/cookies/AndroidEmulatorCookie.js +0 -6
  130. package/src/devices/cookies/AttachedAndroidDeviceCookie.js +0 -12
  131. package/src/devices/cookies/DeviceCookie.js +0 -4
  132. package/src/devices/cookies/GenycloudEmulatorCookie.js +0 -20
  133. package/src/devices/cookies/IosCookie.js +0 -6
  134. package/src/devices/cookies/IosSimulatorCookie.js +0 -10
  135. package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +0 -71
  136. package/src/devices/lifecycle/factories/GenyGlobalLifecycleHandlerFactory.js +0 -18
  137. package/src/servicelocator/android/genycloudServiceLocator.js +0 -21
  138. package/src/servicelocator/android/index.js +0 -25
  139. package/src/servicelocator/ios.js +0 -7
  140. /package/src/devices/{common → allocation}/drivers/android/genycloud/exec/GenyCloudExec.js +0 -0
  141. /package/src/devices/{common → allocation}/drivers/android/genycloud/services/GenyAuthService.js +0 -0
@@ -0,0 +1 @@
1
+ 0709a8a30b2cc4c27244a2257ac28ed7
@@ -0,0 +1 @@
1
+ 08f017a03aa160bead65af9b208ea95857ac9697
@@ -0,0 +1 @@
1
+ 5cc49445c8f5440e5e5ed8d2d95e4827fb1ab4796d20e32ab30d7151da661ce7
@@ -0,0 +1 @@
1
+ 7360ab285d19450619f38c7da9985fda6514d382f903e87a2af9d4e0204a0250851c412a045da6ce04cc932e9addf7c131fd5147889975be20910e2fdc64e88f
@@ -0,0 +1 @@
1
+ 972fa81d6c5d9f0eb6edc63765bf01af
@@ -0,0 +1 @@
1
+ 1ea26448826d4701a7dce9d2c0c24355853ad9d7
@@ -0,0 +1 @@
1
+ 6b2f9a8186f2eef1075910eae28c189ac2030561520277e503e3a696f3c977e2
@@ -0,0 +1 @@
1
+ eae9264b4d57f78a80ecffae3c85e157a2cd1df1b2259c0edc93f5c22d305a004216c5e9e6b35a1415fab6ba14a4f6667acd2eac4d5c6ae5a7a410ee85ca2c7c
@@ -0,0 +1 @@
1
+ 0ff20c1510b97ba80b15a438ce65bddc
@@ -0,0 +1 @@
1
+ 449b07e6bb8435baef57e3d0839e68b5f7f85af5
@@ -0,0 +1 @@
1
+ c3347ddd7b4e4a94c60c55c079451ea219e050f7c69b8dbc7b59a453d2398e67
@@ -0,0 +1 @@
1
+ ebcf7f52b7e34a391174fc8850879e39a3e3f8f8ccfa0a417937680187461d5b41f7811933ca5ca088c554ae7a4e8d8cb2198375fdbb55680888aac561c71f64
@@ -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.12.1</version>
6
+ <version>20.13.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>
@@ -84,12 +84,6 @@
84
84
  <version>1.2.0</version>
85
85
  <scope>runtime</scope>
86
86
  </dependency>
87
- <dependency>
88
- <groupId>com.google.android.material</groupId>
89
- <artifactId>material</artifactId>
90
- <version>1.2.1</version>
91
- <scope>runtime</scope>
92
- </dependency>
93
87
  <dependency>
94
88
  <groupId>org.apache.commons</groupId>
95
89
  <artifactId>commons-lang3</artifactId>
@@ -0,0 +1 @@
1
+ 293aa59dd07a84b7a1bd7c4dc2bffe16
@@ -0,0 +1 @@
1
+ 144cef7278f92d8e7798cae134d8f93136492080
@@ -0,0 +1 @@
1
+ a1062bb5feb8cb7210de7f0e2c36d8a219f8d4065377c9ced13ae55d7eb13220
@@ -0,0 +1 @@
1
+ 216ecb00454a1e03ef9ab2a197b616c4d326ec6ef47fd08b83b22d57c2c9d4dc37725a3c4d19600874074b40918387cebd1be11d558270af4ab7e797af40607f
@@ -3,11 +3,11 @@
3
3
  <groupId>com.wix</groupId>
4
4
  <artifactId>detox</artifactId>
5
5
  <versioning>
6
- <latest>20.12.1</latest>
7
- <release>20.12.1</release>
6
+ <latest>20.13.0</latest>
7
+ <release>20.13.0</release>
8
8
  <versions>
9
- <version>20.12.1</version>
9
+ <version>20.13.0</version>
10
10
  </versions>
11
- <lastUpdated>20230919081610</lastUpdated>
11
+ <lastUpdated>20231002075250</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 1e3fc98a2197d7ff387e7c2bba133329
1
+ 253d464cc30a2d00e586eadca31d5952
@@ -1 +1 @@
1
- 0bd2298f41bb8578b4eb3bf4b744dbbec757a1ac
1
+ 1a402a8246b4532c9be982b61c2b4d3b3e6ab741
@@ -1 +1 @@
1
- 01991e2c36e2b46d6ee16a7de9a7bb11fdb5bb1e2f134bcd7e06a6b5f2f74fa8
1
+ 09104c2799b83cedb2f68628779529f7efb1e96b3e33c0ed8c814da6a5e19ef8
@@ -1 +1 @@
1
- 9c4f073180d321ea3a79f98c16155c2e55e0e2a53ea3052bda82a18a893d35af8e5a257b882f3dcbd723e0886ee3b874f92bdd2a102d06b80a8fb9090c480d2f
1
+ b1547a601cae891dc3f1a58b66c63e70670d9f3e512c50cb6d26d40568972b94cb2f28887c13ea8d04e2b75b57bba73f8ba4ad780b471009fed3cd4e42b469ae
package/Detox-ios-src.tbz CHANGED
Binary file
package/Detox-ios.tbz CHANGED
Binary file
@@ -126,9 +126,6 @@ dependencies {
126
126
 
127
127
  // Third-party/extension deps.
128
128
  dependencies {
129
- implementation("com.google.android.material:material:$_materialMinVersion") {
130
- because 'Material components are mentioned explicitly (e.g. Slider in get-attributes handler)'
131
- }
132
129
  implementation('org.apache.commons:commons-lang3:3.7') {
133
130
  because 'Needed by invoke. Warning: Upgrading to newer versions is not seamless.'
134
131
  }
@@ -150,6 +147,10 @@ dependencies {
150
147
  testImplementation 'org.apache.commons:commons-io:1.3.2'
151
148
  testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
152
149
  testImplementation 'org.robolectric:robolectric:4.4'
150
+
151
+ testImplementation("com.google.android.material:material:$_materialMinVersion") {
152
+ because 'Material components are mentioned explicitly (e.g. Slider in get-attributes handler)'
153
+ }
153
154
  }
154
155
 
155
156
  // Spek (https://spekframework.org/setup-android)
@@ -6,7 +6,7 @@ import androidx.test.espresso.UiController
6
6
  import androidx.test.espresso.ViewAction
7
7
  import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
8
8
  import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
9
- import com.wix.detox.espresso.common.SliderHelper
9
+ import com.wix.detox.espresso.common.ReactSliderHelper
10
10
  import org.hamcrest.Matcher
11
11
  import org.hamcrest.Matchers
12
12
 
@@ -16,7 +16,7 @@ class AdjustSliderToPositionAction(private val targetPositionPct: Double) : View
16
16
  Matchers.allOf( isDisplayed(), isAssignableFrom(AppCompatSeekBar::class.java) )
17
17
 
18
18
  override fun perform(uiController: UiController?, view: View) {
19
- val sliderHelper = SliderHelper.create(view)
19
+ val sliderHelper = ReactSliderHelper.create(view)
20
20
  sliderHelper.setProgressPct(targetPositionPct)
21
21
  }
22
22
  }
@@ -7,10 +7,10 @@ import android.widget.CheckBox
7
7
  import android.widget.ProgressBar
8
8
  import android.widget.TextView
9
9
  import androidx.test.espresso.UiController
10
- import com.google.android.material.slider.Slider
11
10
  import com.wix.detox.espresso.ViewActionWithResult
12
11
  import com.wix.detox.espresso.MultipleViewsAction
13
- import com.wix.detox.espresso.common.SliderHelper
12
+ import com.wix.detox.espresso.common.ReactSliderHelper
13
+ import com.wix.detox.espresso.common.MaterialSliderHelper
14
14
  import com.wix.detox.reactnative.ui.getAccessibilityLabel
15
15
  import org.hamcrest.Matcher
16
16
  import org.hamcrest.Matchers
@@ -18,23 +18,25 @@ import org.hamcrest.Matchers.allOf
18
18
  import org.hamcrest.Matchers.notNullValue
19
19
  import org.json.JSONObject
20
20
 
21
+ private interface AttributeExtractor {
22
+ fun extractAttributes(json: JSONObject, view: View)
23
+ }
24
+
21
25
  class GetAttributesAction() : ViewActionWithResult<JSONObject?>, MultipleViewsAction {
22
- private val commonAttributes = CommonAttributes()
23
- private val textViewAttributes = TextViewAttributes()
24
- private val checkBoxAttributes = CheckBoxAttributes()
25
- private val progressBarAttributes = ProgressBarAttributes()
26
- private val sliderAttributes = SliderAttributes()
26
+ private val attributeExtractors = listOf(
27
+ CommonAttributes(),
28
+ TextViewAttributes(),
29
+ CheckBoxAttributes(),
30
+ ProgressBarAttributes(),
31
+ MaterialSliderAttributes()
32
+ )
27
33
  private var result: JSONObject? = null
28
34
 
29
35
  override fun perform(uiController: UiController?, view: View?) {
30
36
  view!!
31
37
 
32
38
  val json = JSONObject()
33
- commonAttributes.get(json, view)
34
- textViewAttributes.get(json, view)
35
- checkBoxAttributes.get(json, view)
36
- progressBarAttributes.get(json, view)
37
- sliderAttributes.get(json, view)
39
+ attributeExtractors.forEach { it.extractAttributes(json, view) }
38
40
 
39
41
  result = json
40
42
  }
@@ -44,8 +46,8 @@ class GetAttributesAction() : ViewActionWithResult<JSONObject?>, MultipleViewsAc
44
46
  override fun getConstraints(): Matcher<View> = allOf(notNullValue(), Matchers.isA(View::class.java))
45
47
  }
46
48
 
47
- private class CommonAttributes {
48
- fun get(json: JSONObject, view: View) {
49
+ private class CommonAttributes : AttributeExtractor {
50
+ override fun extractAttributes(json: JSONObject, view: View) {
49
51
  getId(json, view)
50
52
  getVisibility(json, view)
51
53
  getAccessibilityLabel(json, view)
@@ -89,8 +91,8 @@ private class CommonAttributes {
89
91
  }
90
92
  }
91
93
 
92
- private class TextViewAttributes {
93
- fun get(json: JSONObject, view: View) {
94
+ private class TextViewAttributes : AttributeExtractor {
95
+ override fun extractAttributes(json: JSONObject, view: View) {
94
96
  if (view is TextView) {
95
97
  getText(json, view)
96
98
  getLength(json, view)
@@ -118,8 +120,8 @@ private class TextViewAttributes {
118
120
  }
119
121
  }
120
122
 
121
- private class CheckBoxAttributes {
122
- fun get(json: JSONObject, view: View) {
123
+ private class CheckBoxAttributes : AttributeExtractor {
124
+ override fun extractAttributes(json: JSONObject, view: View) {
123
125
  if (view is CheckBox) {
124
126
  getCheckboxValue(json, view)
125
127
  }
@@ -133,31 +135,28 @@ private class CheckBoxAttributes {
133
135
  * Note: this applies also to [androidx.appcompat.widget.AppCompatSeekBar], which
134
136
  * is anything RN-slider-ish.
135
137
  */
136
- private class ProgressBarAttributes {
137
- fun get(json: JSONObject, view: View) {
138
+ private class ProgressBarAttributes : AttributeExtractor {
139
+ override fun extractAttributes(json: JSONObject, view: View) {
138
140
  if (view is ProgressBar) {
139
- SliderHelper.maybeCreate(view)?.let {
140
- getRNSliderValue(json, it)
141
+ ReactSliderHelper.maybeCreate(view)?.let {
142
+ getReactSliderValue(json, it)
141
143
  } ?:
142
144
  getProgressBarValue(json, view)
143
145
  }
144
146
  }
145
147
 
146
- private fun getRNSliderValue(rootObject: JSONObject, sliderHelper: SliderHelper) {
147
- rootObject.put("value", sliderHelper.getCurrentProgressPct())
148
+ private fun getReactSliderValue(rootObject: JSONObject, reactSliderHelper: ReactSliderHelper) {
149
+ rootObject.put("value", reactSliderHelper.getCurrentProgressPct())
148
150
  }
149
151
 
150
152
  private fun getProgressBarValue(rootObject: JSONObject, view: ProgressBar) =
151
153
  rootObject.put("value", view.progress)
152
154
  }
153
155
 
154
- private class SliderAttributes {
155
- fun get(json: JSONObject, view: View) {
156
- if (view is Slider) {
157
- getSliderValue(json, view)
156
+ private class MaterialSliderAttributes : AttributeExtractor {
157
+ override fun extractAttributes(json: JSONObject, view: View) {
158
+ MaterialSliderHelper(view).getValueIfSlider()?.let {
159
+ json.put("value", it)
158
160
  }
159
161
  }
160
-
161
- private fun getSliderValue(rootObject: JSONObject, view: Slider) =
162
- rootObject.put("value", view.value)
163
162
  }
@@ -0,0 +1,21 @@
1
+ package com.wix.detox.espresso.common
2
+
3
+ import android.view.View
4
+ import com.wix.detox.espresso.action.common.ReflectUtils
5
+ import org.joor.Reflect
6
+
7
+ private const val CLASS_MATERIAL_SLIDER = "com.google.android.material.slider.Slider"
8
+
9
+ open class MaterialSliderHelper(protected val view: View) {
10
+ fun getValueIfSlider(): Float? {
11
+ if (!isSlider()) {
12
+ return null
13
+ }
14
+
15
+ return getValue()
16
+ }
17
+
18
+ private fun isSlider() = ReflectUtils.isAssignableFrom(view, CLASS_MATERIAL_SLIDER)
19
+
20
+ private fun getValue() = Reflect.on(view).call("getValue").get() as Float
21
+ }
@@ -11,8 +11,9 @@ import org.joor.Reflect
11
11
 
12
12
  private const val CLASS_REACT_SLIDER_LEGACY = "com.facebook.react.views.slider.ReactSlider"
13
13
  private const val CLASS_REACT_SLIDER_COMMUNITY = "com.reactnativecommunity.slider.ReactSlider"
14
+ private const val CLASS_REACT_SLIDER_COMMUNITY_MANAGER = "com.reactnativecommunity.slider.ReactSliderManager"
14
15
 
15
- abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
16
+ abstract class ReactSliderHelper(protected val slider: AppCompatSeekBar) {
16
17
  fun getCurrentProgressPct(): Double {
17
18
  val nativeProgress = slider.progress.toDouble()
18
19
  val nativeMax = slider.max
@@ -46,7 +47,7 @@ abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
46
47
  ?: throw DetoxIllegalStateException("Cannot handle this type of a seek-bar view (Class ${view.javaClass.canonicalName}). " +
47
48
  "Only React Native sliders are currently supported.")
48
49
 
49
- fun maybeCreate(view: View): SliderHelper? =
50
+ fun maybeCreate(view: View): ReactSliderHelper? =
50
51
  when {
51
52
  ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_LEGACY)
52
53
  -> LegacySliderHelper(view as ReactSlider)
@@ -58,7 +59,7 @@ abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
58
59
  }
59
60
  }
60
61
 
61
- private class LegacySliderHelper(slider: ReactSlider): SliderHelper(slider) {
62
+ private class LegacySliderHelper(slider: ReactSlider): ReactSliderHelper(slider) {
62
63
  override fun setProgressJS(valueJS: Double) {
63
64
  val reactSliderManager = com.facebook.react.views.slider.ReactSliderManager()
64
65
  reactSliderManager.updateProperties(slider as ReactSlider, buildStyles("value", valueJS))
@@ -67,9 +68,9 @@ private class LegacySliderHelper(slider: ReactSlider): SliderHelper(slider) {
67
68
  private fun buildStyles(vararg keysAndValues: Any) = ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues))
68
69
  }
69
70
 
70
- private class CommunitySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
71
+ private class CommunitySliderHelper(slider: AppCompatSeekBar): ReactSliderHelper(slider) {
71
72
  override fun setProgressJS(valueJS: Double) {
72
- val reactSliderManager = Class.forName("com.reactnativecommunity.slider.ReactSliderManager").newInstance()
73
+ val reactSliderManager = Class.forName(CLASS_REACT_SLIDER_COMMUNITY_MANAGER).newInstance()
73
74
  Reflect.on(reactSliderManager).call("setValue", slider, valueJS)
74
75
  }
75
76
  }
@@ -7,7 +7,7 @@ import androidx.appcompat.widget.AppCompatSeekBar
7
7
  import androidx.test.espresso.matcher.BoundedMatcher
8
8
  import androidx.test.espresso.matcher.ViewMatchers
9
9
  import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
10
- import com.wix.detox.espresso.common.SliderHelper
10
+ import com.wix.detox.espresso.common.ReactSliderHelper
11
11
  import org.hamcrest.*
12
12
  import org.hamcrest.Matchers.*
13
13
  import kotlin.math.abs
@@ -60,7 +60,7 @@ fun toHaveSliderPosition(expectedValuePct: Double, tolerance: Double): Matcher<V
60
60
  }
61
61
 
62
62
  override fun matchesSafely(view: AppCompatSeekBar): Boolean {
63
- val sliderHelper = SliderHelper.create(view)
63
+ val sliderHelper = ReactSliderHelper.create(view)
64
64
  val progressPct = sliderHelper.getCurrentProgressPct()
65
65
  return (abs(progressPct - expectedValuePct) <= tolerance)
66
66
  }
@@ -0,0 +1,33 @@
1
+ package com.wix.detox.espresso.common
2
+
3
+ import android.view.View
4
+ import com.google.android.material.slider.Slider
5
+ import org.assertj.core.api.Assertions.assertThat
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.robolectric.RobolectricTestRunner
11
+
12
+ @RunWith(RobolectricTestRunner::class)
13
+ class MaterialSliderHelperTest {
14
+ @Test
15
+ fun `should return value if view is a slider`() {
16
+ val slider: Slider = mock {
17
+ on { value } doReturn 0.2f
18
+ }
19
+
20
+ val uut = MaterialSliderHelper(slider)
21
+
22
+ assertThat(uut.getValueIfSlider()).isEqualTo(0.2f)
23
+ }
24
+
25
+ @Test
26
+ fun `should return null if view is not a slider`() {
27
+ val view: View = mock()
28
+
29
+ val uut = MaterialSliderHelper(view)
30
+
31
+ assertThat(uut.getValueIfSlider()).isNull()
32
+ }
33
+ }
@@ -15,14 +15,14 @@ import org.robolectric.RobolectricTestRunner
15
15
  * to avoid having to install the community slider under node_modules just for this.
16
16
  */
17
17
  @RunWith(RobolectricTestRunner::class)
18
- class SliderHelperTest {
18
+ class ReactSliderHelperTest {
19
19
  lateinit var slider: ReactSlider
20
- lateinit var uut: SliderHelper
20
+ lateinit var uut: ReactSliderHelper
21
21
 
22
22
  @Before
23
23
  fun setup() {
24
24
  slider = mock()
25
- uut = SliderHelper.create(slider)
25
+ uut = ReactSliderHelper.create(slider)
26
26
  }
27
27
 
28
28
  private fun givenNativeProgressTraits(current: Int, max: Int) {
package/internals.d.ts CHANGED
@@ -113,7 +113,11 @@ declare global {
113
113
  /** Test suite name */
114
114
  name: string;
115
115
  }): Promise<void>;
116
-
116
+ /**
117
+ * Workaround for Jest exiting abruptly in --bail mode.
118
+ * Makes sure that all workers and their test environments are properly torn down.
119
+ */
120
+ unsafe_conductEarlyTeardown(): Promise<void>;
117
121
  /**
118
122
  * Reports to Detox CLI about passed and failed test files.
119
123
  * The failed test files might be re-run again if
@@ -215,6 +219,11 @@ declare global {
215
219
  * Randomly generated ID for the entire Detox test session, including retries.
216
220
  */
217
221
  id: string;
222
+ /**
223
+ * Signalizes that the test session is being torn down.
224
+ * Experimental feature for Jest --bail mode.
225
+ */
226
+ unsafe_earlyTeardown?: boolean;
218
227
  /**
219
228
  * Results of test file executions. Primarily used for Detox CLI retry mechanism.
220
229
  */
@@ -1,16 +1,12 @@
1
1
  const { log } = require('../internals');
2
- const DeviceRegistry = require('../src/devices/DeviceRegistry');
3
- const { getDetoxLibraryRootPath } = require('../src/utils/environment');
4
-
2
+ const DeviceRegistry = require('../src/devices/allocation/DeviceRegistry');
5
3
 
6
4
  module.exports.command = 'reset-lock-file';
7
- module.exports.desc = 'Resets all Detox lock files. Useful when you need to run multiple `detox test` commands in parallel with --keepLockFile.';
5
+ module.exports.desc = 'Resets Detox lock file completely - all devices are marked as available after that.';
8
6
 
9
7
  module.exports.handler = async function resetLockFile() {
10
- await Promise.all([
11
- DeviceRegistry.forIOS().reset(),
12
- DeviceRegistry.forAndroid().reset(),
13
- ]);
8
+ const registry = new DeviceRegistry();
9
+ await registry.reset();
14
10
 
15
- log.info(`Cleaned lock files from: ${getDetoxLibraryRootPath()}`);
11
+ log.info(`Cleaned lock file at: ${registry.lockFilePath}`);
16
12
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "detox",
3
3
  "description": "E2E tests and automation for mobile",
4
- "version": "20.12.1",
4
+ "version": "20.13.0",
5
5
  "bin": {
6
6
  "detox": "local-cli/cli.js"
7
7
  },
@@ -137,9 +137,9 @@
137
137
  "src/artifacts/log",
138
138
  "src/artifacts/screenshot",
139
139
  "src/artifacts/video",
140
- "src/devices/allocation/drivers/AllocationDriverBase.js",
141
140
  "src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js",
142
141
  "src/devices/allocation/drivers/android/emulator/patchAvdSkinConfig.js",
142
+ "src/devices/allocation/.*AllocDriver.js",
143
143
  "src/devices/allocation/drivers/ios",
144
144
  "src/devices/allocation/factories",
145
145
  "src/devices/allocation/factories/drivers",
@@ -154,10 +154,9 @@
154
154
  "src/devices/runtime/drivers/ios",
155
155
  "src/devices/runtime/factories",
156
156
  "src/devices/runtime/factories/drivers",
157
+ "src/devices/validation/EnvironmentValidatorBase.js",
158
+ "src/devices/validation/factories",
157
159
  "src/matchers/factories",
158
- "src/validation/EnvironmentValidatorBase.js",
159
- "src/validation/factories",
160
- "src/validation/ios/IosSimulatorEnvValidator",
161
160
  "src/utils/appdatapath.js",
162
161
  "src/utils/debug.js",
163
162
  "src/utils/environment.js",
@@ -206,5 +205,5 @@
206
205
  "browserslist": [
207
206
  "node 14"
208
207
  ],
209
- "gitHead": "b489519a3166723194c83c5a43bd585bee1d9395"
208
+ "gitHead": "72e85a2fe078a2a721628255249410423fc5c1ac"
210
209
  }