detox 19.6.7 → 19.7.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.
- package/Detox-android/com/wix/detox/{19.6.7/detox-19.6.7-javadoc.jar → 19.7.0/detox-19.7.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.6.7/detox-19.6.7-sources.jar → 19.7.0/detox-19.7.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar +0 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{19.6.7/detox-19.6.7.pom → 19.7.0/detox-19.7.0.pom} +1 -1
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/19.7.0/detox-19.7.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxAction.java +1 -3
- package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +22 -0
- package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt +13 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/common/SliderHelper.kt +75 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +16 -23
- package/android/detox/src/main/java/com/wix/detox/common/DetoxErrors.java +0 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/action/common/ReflectUtils.kt +10 -0
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt +15 -3
- package/android/detox/src/testFull/java/com/wix/detox/espresso/common/SliderHelperTest.kt +39 -0
- package/local-cli/utils/testCommandArgs.js +2 -2
- package/package.json +11 -4
- package/runners/jest/JestCircusEnvironment.js +3 -1
- package/runners/jest-circus/environment.js +2 -1
- package/runners/jest-circus/utils/assertJestCircus26.js +6 -4
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.aar +0 -0
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/19.6.7/detox-19.6.7.pom.sha512 +0 -1
- package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt +0 -36
- package/android/detox/src/testFull/java/com/wix/detox/espresso/action/AdjustSliderToPositionActionTest.kt +0 -59
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
79fdb56017f0147da0e0e4dd6f350b99
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
362d43b822bd19f2846daf501b926fe3a5c4a711
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
851b8010ef6d2e2c8aebdeb3f55a6b66e445b4fd3efd9aa6391ca582383d8f7d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
978250d24965a75710bf16dc7c4ea5e72972bf4a09181c0a7c59e3cadc299394a71c67e3b25bb55fb1b404c5cef5b521af4c2e16870be47fe1d26ed4e40a1b1e
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
81459bd345745decad426d64952cbde8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
08999bd9c01d6d6a99c562370854597eceba54cd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1cf580c784df4c70609a6995ccaf89e1af3a4d69576c358d522c248d21fd8b89
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2986b74ea1d6abfba94a40bd38728b9053e9c45ef111d503db76086e23743a49fbd207f5432938d62f54c5b925926baacd6266f013be0e6eb50538a196bac9b3
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7945a7445d0b1cb59209d62b4a92c8f8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f3372a6e1f7d640c0e587d6fd033416ffed65e04
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
9b991a716a5adf5c5bb5700528e03dd4c9933053153bf91ac203c0e7de25c152
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a67051ecc46747c7dc6b10b1a08ec3c795ebbd001276d77e798f210cff69c49704bcf35d926e55abe4f148085a2955b2cb8987d33f939b5898eef4f06de15b26
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<modelVersion>4.0.0</modelVersion>
|
|
4
4
|
<groupId>com.wix</groupId>
|
|
5
5
|
<artifactId>detox</artifactId>
|
|
6
|
-
<version>19.
|
|
6
|
+
<version>19.7.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
|
+
617b4e31171dd5f37b0a7da053246316
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1ddb43e2443fbabd7d1849f51790550c13763106
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
37288619efa08c7202001b3c5e50038cdf5053041cfcb5044ddd235eba3d8f42
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
9f81ad0ed181932a2f4242c28ec3cfaa3fa0fd5b3d94a4d1d355f4efb0c13ef51185a3defc6ed06fb995b8d99ef19d140911fc8f90a4952a211c6077193ece9e
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>com.wix</groupId>
|
|
4
4
|
<artifactId>detox</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>19.
|
|
7
|
-
<release>19.
|
|
6
|
+
<latest>19.7.0</latest>
|
|
7
|
+
<release>19.7.0</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>19.
|
|
9
|
+
<version>19.7.0</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20220525131841</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1164980a1032dcf1960469241b0baff7
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
923ca6212fb34facabc8789bab8c757c10279be4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e4842e25cbcbcd5c083e107d063c9f1f62b616d466e0647dd4eccfd89ca235db
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
cc652c355cea907e50b184616add3a8cdd2375cd473ee5ba2f9b4ba3b9c462a3365499285005c7c05ae9f8230efc55d06972a2b7c7b4d9f8e9e9b89c7706e4b2
|
package/Detox-ios-src.tbz
CHANGED
|
Binary file
|
package/Detox-ios.tbz
CHANGED
|
Binary file
|
|
@@ -2,7 +2,6 @@ package com.wix.detox.espresso;
|
|
|
2
2
|
|
|
3
3
|
import android.view.View;
|
|
4
4
|
|
|
5
|
-
import com.facebook.react.views.slider.ReactSliderManager;
|
|
6
5
|
import com.wix.detox.common.DetoxErrors.DetoxRuntimeException;
|
|
7
6
|
import com.wix.detox.common.DetoxErrors.StaleActionException;
|
|
8
7
|
import com.wix.detox.espresso.action.AdjustSliderToPositionAction;
|
|
@@ -151,8 +150,7 @@ public class DetoxAction {
|
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
public static ViewAction adjustSliderToPosition(final double newPosition) {
|
|
154
|
-
|
|
155
|
-
return new AdjustSliderToPositionAction(newPosition, reactSliderManager);
|
|
153
|
+
return new AdjustSliderToPositionAction(newPosition);
|
|
156
154
|
}
|
|
157
155
|
|
|
158
156
|
public static ViewAction takeViewScreenshot() {
|
package/android/detox/src/full/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.wix.detox.espresso.action
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import androidx.appcompat.widget.AppCompatSeekBar
|
|
5
|
+
import androidx.test.espresso.UiController
|
|
6
|
+
import androidx.test.espresso.ViewAction
|
|
7
|
+
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
|
|
8
|
+
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
|
9
|
+
import com.wix.detox.espresso.common.SliderHelper
|
|
10
|
+
import org.hamcrest.Matcher
|
|
11
|
+
import org.hamcrest.Matchers
|
|
12
|
+
|
|
13
|
+
class AdjustSliderToPositionAction(private val targetPositionPct: Double) : ViewAction {
|
|
14
|
+
override fun getDescription() = "adjustSliderToPosition"
|
|
15
|
+
override fun getConstraints(): Matcher<View?>? =
|
|
16
|
+
Matchers.allOf( isDisplayed(), isAssignableFrom(AppCompatSeekBar::class.java) )
|
|
17
|
+
|
|
18
|
+
override fun perform(uiController: UiController?, view: View) {
|
|
19
|
+
val sliderHelper = SliderHelper.create(view)
|
|
20
|
+
sliderHelper.setProgressPct(targetPositionPct)
|
|
21
|
+
}
|
|
22
|
+
}
|
package/android/detox/src/{main → full}/java/com/wix/detox/espresso/action/GetAttributesAction.kt
RENAMED
|
@@ -9,6 +9,7 @@ import android.widget.TextView
|
|
|
9
9
|
import androidx.test.espresso.UiController
|
|
10
10
|
import com.google.android.material.slider.Slider
|
|
11
11
|
import com.wix.detox.espresso.ViewActionWithResult
|
|
12
|
+
import com.wix.detox.espresso.common.SliderHelper
|
|
12
13
|
import org.hamcrest.Matcher
|
|
13
14
|
import org.hamcrest.Matchers
|
|
14
15
|
import org.hamcrest.Matchers.allOf
|
|
@@ -127,13 +128,24 @@ private class CheckBoxAttributes {
|
|
|
127
128
|
rootObject.put("value", view.isChecked)
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Note: this applies also to [androidx.appcompat.widget.AppCompatSeekBar], which
|
|
133
|
+
* is anything RN-slider-ish.
|
|
134
|
+
*/
|
|
130
135
|
private class ProgressBarAttributes {
|
|
131
136
|
fun get(json: JSONObject, view: View) {
|
|
132
137
|
if (view is ProgressBar) {
|
|
133
|
-
|
|
138
|
+
SliderHelper.maybeCreate(view)?.let {
|
|
139
|
+
getRNSliderValue(json, it)
|
|
140
|
+
} ?:
|
|
141
|
+
getProgressBarValue(json, view)
|
|
134
142
|
}
|
|
135
143
|
}
|
|
136
144
|
|
|
145
|
+
private fun getRNSliderValue(rootObject: JSONObject, sliderHelper: SliderHelper) {
|
|
146
|
+
rootObject.put("value", sliderHelper.getCurrentProgressPct())
|
|
147
|
+
}
|
|
148
|
+
|
|
137
149
|
private fun getProgressBarValue(rootObject: JSONObject, view: ProgressBar) =
|
|
138
150
|
rootObject.put("value", view.progress)
|
|
139
151
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.wix.detox.espresso.common
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import androidx.appcompat.widget.AppCompatSeekBar
|
|
5
|
+
import com.facebook.react.bridge.JavaOnlyMap
|
|
6
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
7
|
+
import com.facebook.react.views.slider.ReactSlider
|
|
8
|
+
import com.wix.detox.common.DetoxErrors.DetoxIllegalStateException
|
|
9
|
+
import com.wix.detox.espresso.action.common.ReflectUtils
|
|
10
|
+
import org.joor.Reflect
|
|
11
|
+
|
|
12
|
+
private const val CLASS_REACT_SLIDER_LEGACY = "com.facebook.react.views.slider.ReactSlider"
|
|
13
|
+
private const val CLASS_REACT_SLIDER_COMMUNITY = "com.reactnativecommunity.slider.ReactSlider"
|
|
14
|
+
|
|
15
|
+
abstract class SliderHelper(protected val slider: AppCompatSeekBar) {
|
|
16
|
+
fun getCurrentProgressPct(): Double {
|
|
17
|
+
val nativeProgress = slider.progress.toDouble()
|
|
18
|
+
val nativeMax = slider.max
|
|
19
|
+
return nativeProgress / nativeMax
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// TODO Make this more testable (e.g. by delegating the set action away)
|
|
23
|
+
fun setProgressPct(valuePct: Double) {
|
|
24
|
+
val maxJSProgress = calcMaxJSProgress()
|
|
25
|
+
val valueJS = valuePct * maxJSProgress
|
|
26
|
+
setProgressJS(valueJS)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
protected abstract fun setProgressJS(valueJS: Double)
|
|
30
|
+
|
|
31
|
+
private fun calcMaxJSProgress(): Double {
|
|
32
|
+
val nativeProgress = slider.progress.toDouble()
|
|
33
|
+
val nativeMax = slider.max
|
|
34
|
+
val toMaxFactor = nativeMax / nativeProgress
|
|
35
|
+
|
|
36
|
+
val jsProgress = getJSProgress()
|
|
37
|
+
return jsProgress * toMaxFactor
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private fun getJSProgress(): Double =
|
|
41
|
+
Reflect.on(slider).call("toRealProgress", slider.progress).get() as Double
|
|
42
|
+
|
|
43
|
+
companion object {
|
|
44
|
+
fun create(view: View) =
|
|
45
|
+
maybeCreate(view)
|
|
46
|
+
?: throw DetoxIllegalStateException("Cannot handle this type of a seek-bar view (Class ${view.javaClass.canonicalName}). " +
|
|
47
|
+
"Only React Native sliders are currently supported.")
|
|
48
|
+
|
|
49
|
+
fun maybeCreate(view: View): SliderHelper? =
|
|
50
|
+
when {
|
|
51
|
+
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_LEGACY)
|
|
52
|
+
-> LegacySliderHelper(view as ReactSlider)
|
|
53
|
+
ReflectUtils.isAssignableFrom(view, CLASS_REACT_SLIDER_COMMUNITY)
|
|
54
|
+
-> CommunitySliderHelper(view as AppCompatSeekBar)
|
|
55
|
+
else
|
|
56
|
+
-> null
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private class LegacySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
|
|
62
|
+
override fun setProgressJS(valueJS: Double) {
|
|
63
|
+
val reactSliderManager = com.facebook.react.views.slider.ReactSliderManager()
|
|
64
|
+
reactSliderManager.updateProperties(slider as ReactSlider, buildStyles("value", valueJS))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private fun buildStyles(vararg keysAndValues: Any) = ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private class CommunitySliderHelper(slider: AppCompatSeekBar): SliderHelper(slider) {
|
|
71
|
+
override fun setProgressJS(valueJS: Double) {
|
|
72
|
+
val reactSliderManager = Class.forName("com.reactnativecommunity.slider.ReactSliderManager").newInstance()
|
|
73
|
+
Reflect.on(reactSliderManager).call("setValue", slider, valueJS)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
package com.wix.detox.espresso.matcher
|
|
4
4
|
|
|
5
5
|
import android.view.View
|
|
6
|
+
import androidx.appcompat.widget.AppCompatSeekBar
|
|
6
7
|
import androidx.test.espresso.matcher.BoundedMatcher
|
|
7
8
|
import androidx.test.espresso.matcher.ViewMatchers
|
|
8
9
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
|
9
|
-
import com.
|
|
10
|
+
import com.wix.detox.espresso.common.SliderHelper
|
|
10
11
|
import org.hamcrest.BaseMatcher
|
|
11
12
|
import org.hamcrest.Description
|
|
12
13
|
import org.hamcrest.Matcher
|
|
13
14
|
import org.hamcrest.Matchers.allOf
|
|
14
15
|
import org.hamcrest.TypeSafeMatcher
|
|
16
|
+
import kotlin.math.abs
|
|
15
17
|
|
|
16
18
|
/*
|
|
17
19
|
* An extension of [androidx.test.espresso.matcher.ViewMatchers].
|
|
@@ -36,6 +38,19 @@ fun isOfClassName(className: String): Matcher<View> {
|
|
|
36
38
|
fun isMatchingAtIndex(index: Int, innerMatcher: Matcher<View>): Matcher<View> =
|
|
37
39
|
ViewAtIndexMatcher(index, innerMatcher)
|
|
38
40
|
|
|
41
|
+
fun toHaveSliderPosition(expectedValuePct: Double, tolerance: Double): Matcher<View?> =
|
|
42
|
+
object: BoundedMatcher<View?, AppCompatSeekBar>(AppCompatSeekBar::class.java) {
|
|
43
|
+
override fun describeTo(description: Description) {
|
|
44
|
+
description.appendText("sliderPositionPercent($expectedValuePct)")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun matchesSafely(view: AppCompatSeekBar): Boolean {
|
|
48
|
+
val sliderHelper = SliderHelper.create(view)
|
|
49
|
+
val progressPct = sliderHelper.getCurrentProgressPct()
|
|
50
|
+
return (abs(progressPct - expectedValuePct) <= tolerance)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
/**
|
|
40
55
|
* Same as [androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom], but accepts any class. Needed
|
|
41
56
|
* in order to avoid warning when passing 'any' class.
|
|
@@ -47,25 +62,3 @@ private class IsAssignableFromMatcher(private val clazz: Class<*>) : TypeSafeMat
|
|
|
47
62
|
description.appendText("is assignable from class: $clazz")
|
|
48
63
|
}
|
|
49
64
|
}
|
|
50
|
-
|
|
51
|
-
fun toHaveSliderPosition(expectedValue: Double, tolerance: Double): Matcher<View?> {
|
|
52
|
-
return object : BoundedMatcher<View?, ReactSlider>(ReactSlider::class.java) {
|
|
53
|
-
override fun describeTo(description: Description) {
|
|
54
|
-
description.appendText("expected: $expectedValue")
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
override fun matchesSafely(slider: ReactSlider?): Boolean {
|
|
58
|
-
val currentProgress = slider?.progress
|
|
59
|
-
|
|
60
|
-
if (currentProgress != null) {
|
|
61
|
-
val realProgress = slider.toRealProgress(currentProgress)
|
|
62
|
-
val currentPctFactor = slider.max / currentProgress.toDouble()
|
|
63
|
-
val realTotal = realProgress * currentPctFactor
|
|
64
|
-
val actualValue = realProgress / realTotal
|
|
65
|
-
return Math.abs(actualValue - expectedValue) <= tolerance
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return false
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
package/android/detox/src/testFull/java/com/wix/detox/espresso/action/GetAttributesActionTest.kt
CHANGED
|
@@ -4,6 +4,7 @@ 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
|
|
8
9
|
import org.assertj.core.api.Assertions.assertThat
|
|
9
10
|
import org.json.JSONObject
|
|
@@ -179,7 +180,7 @@ class GetAttributesActionTest {
|
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
@Test
|
|
182
|
-
fun `should return ProgressBar
|
|
183
|
+
fun `should return raw ProgressBar or SeekBar 'progress' via value attribute`() {
|
|
183
184
|
val progressBar: ProgressBar = mock {
|
|
184
185
|
on { progress } doReturn 42
|
|
185
186
|
}
|
|
@@ -189,7 +190,18 @@ class GetAttributesActionTest {
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
@Test
|
|
192
|
-
fun `should return Slider
|
|
193
|
+
fun `should return RN-Slider via value attribute`() {
|
|
194
|
+
val progressBar: ReactSlider = mock {
|
|
195
|
+
on { max } doReturn 100
|
|
196
|
+
on { progress } doReturn 50
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
val resultJson = perform(progressBar)
|
|
200
|
+
assertThat(resultJson.opt("value")).isEqualTo(0.5)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Test
|
|
204
|
+
fun `should return material-Slider state through value attribute`() {
|
|
193
205
|
val slider: Slider = mock {
|
|
194
206
|
on { value } doReturn 0.42f
|
|
195
207
|
}
|
|
@@ -225,7 +237,7 @@ class GetAttributesActionTest {
|
|
|
225
237
|
}
|
|
226
238
|
|
|
227
239
|
@Test
|
|
228
|
-
fun `should return text hint via
|
|
240
|
+
fun `should return text hint via 'placeholder' attribute, if applicable`() {
|
|
229
241
|
val textViewWithHint: TextView = mock {
|
|
230
242
|
on { hint } doReturn "hint-text-mock"
|
|
231
243
|
}
|
|
@@ -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
|
+
}
|
|
@@ -115,12 +115,12 @@ module.exports = {
|
|
|
115
115
|
H: {
|
|
116
116
|
alias: 'headless',
|
|
117
117
|
group: 'Execution:',
|
|
118
|
-
describe: '[Android Only] Launch emulator in headless mode. Useful when running on CI.',
|
|
118
|
+
describe: '[Android Only] Launch emulator in headless mode. Useful when running on CI. Only applicable for Google emulators.',
|
|
119
119
|
boolean: true,
|
|
120
120
|
},
|
|
121
121
|
gpu: {
|
|
122
122
|
group: 'Execution:',
|
|
123
|
-
describe: '[Android Only] Launch emulator with the specific -gpu [gpu mode] parameter.',
|
|
123
|
+
describe: '[Android Only] Launch emulator with the specific -gpu [gpu mode] parameter. Only applicable for Google emulators.',
|
|
124
124
|
},
|
|
125
125
|
keepLockFile:{
|
|
126
126
|
group: 'Configuration:',
|
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": "19.
|
|
4
|
+
"version": "19.7.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"detox": "local-cli/cli.js"
|
|
7
7
|
},
|
|
@@ -81,10 +81,17 @@
|
|
|
81
81
|
"yargs-unparser": "^2.0.0"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"jest
|
|
85
|
-
"jest-environment-node": ">=25.0.0",
|
|
84
|
+
"jest": "26.0.x - 26.4.x || ^26.5.2 || 27.x.x || 28.x.x",
|
|
86
85
|
"mocha": ">=6.0.0"
|
|
87
86
|
},
|
|
87
|
+
"peerDependenciesMeta": {
|
|
88
|
+
"jest": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"mocha": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
88
95
|
"engines": {
|
|
89
96
|
"node": ">=8.3.0"
|
|
90
97
|
},
|
|
@@ -170,5 +177,5 @@
|
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
},
|
|
173
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "cffadbdbdb197bae27a17366201d402414eb97cf"
|
|
174
181
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
const
|
|
1
|
+
const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-unpublished-require
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @see https://www.npmjs.com/package/jest-circus#overview
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
const
|
|
2
|
+
const maybeNodeEnvironment = require('jest-environment-node'); // eslint-disable-line node/no-unpublished-require
|
|
3
|
+
const NodeEnvironment = maybeNodeEnvironment.default || maybeNodeEnvironment;
|
|
3
4
|
|
|
4
5
|
const DetoxError = require('../../src/errors/DetoxError');
|
|
5
6
|
const Timer = require('../../src/utils/Timer');
|
|
@@ -3,12 +3,14 @@ const path = require('path');
|
|
|
3
3
|
|
|
4
4
|
const DetoxRuntimeError = require('../../../src/errors/DetoxRuntimeError');
|
|
5
5
|
|
|
6
|
-
function assertJestCircus26(
|
|
7
|
-
|
|
6
|
+
function assertJestCircus26(maybeProjectConfig) {
|
|
7
|
+
const projectConfig = maybeProjectConfig.projectConfig || maybeProjectConfig;
|
|
8
|
+
|
|
9
|
+
if (!/jest-circus/.test(projectConfig.testRunner)) {
|
|
8
10
|
throw new DetoxRuntimeError('Cannot run tests without "jest-circus" npm package, exiting.');
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
const circusPackageJson = path.join(path.dirname(
|
|
13
|
+
const circusPackageJson = path.join(path.dirname(projectConfig.testRunner), 'package.json');
|
|
12
14
|
if (!fs.existsSync(circusPackageJson)) {
|
|
13
15
|
throw new DetoxRuntimeError('Check that you have an installed copy of "jest-circus" npm package, exiting.');
|
|
14
16
|
}
|
|
@@ -31,7 +33,7 @@ function assertJestCircus26(config) {
|
|
|
31
33
|
);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
return
|
|
36
|
+
return maybeProjectConfig;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
module.exports = assertJestCircus26;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fdc81cf3b78017959191c37601de6524
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cf4847321052afae4f17902da472725f8c9255de
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cb04d709c936c2d18d6b7fd41b14d206a32b817b3af1109a61e7b3e36be5aa77
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3c8ca683b7f4e733efa7708dcda935fa7ef3bb3fc8e61d17e8a8769a209f8c2c5e981694b349b5202d10de941dec375a1cce342e9e4e8e6451a2016330101c78
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
715a0f4fda8d718ff772cede751b76e3
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2e243d4e578b0acdf70fa9eddaefc9b390fb00d4
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
270c6e648af226c57c27c178af2ac9501ff63cc64fd8d2d9a27c37d709dc42ab
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2d23ea4b372e5d76fd67e49ee23fe4147b9beb6ed1c37bb60c688a77356f3e91421e758b8c1bacdfdb956f993a13ec9c8eca9c286c8803c0b1f4e56446a39417
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
df8197870d64f3e4296ea905a8f12aa0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
819e13eb767e942d83e3380216863103a60cfd21
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b02600c900ccacec2971113bf2ea2409c483034b7f558f55dd11a65f811d29bd
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4f4938a489319ea9ca03ceda8fc42ffa5614a4efc194ee2bc5c8a8e3a2504e4e96076944b6fdd466b2bcb6e439794ee9c0e81c842e3593a2113f860874f16f9b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
de2d653cf23de5c2f2f5f3fecf4b8b91
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f6774f0a15ddb90a532f9ef603e8b78fdc83e57f
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
168be42a2f5e39a6b5f4d46191db364e2e3f15cb6f2060d36def9af2fa78ba23
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
c27045186a3f0860a750ddfaa9c39b664af506acc7edaf1c43351f4e05289b5b1d01cec6370fc9c95affd07d051271fda09c12791d0a8a9add0ef1510060c631
|
package/android/detox/src/main/java/com/wix/detox/espresso/action/AdjustSliderToPositionAction.kt
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
package com.wix.detox.espresso.action
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import androidx.test.espresso.UiController
|
|
5
|
-
import androidx.test.espresso.ViewAction
|
|
6
|
-
import androidx.test.espresso.matcher.ViewMatchers
|
|
7
|
-
import com.facebook.react.bridge.JavaOnlyMap
|
|
8
|
-
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
9
|
-
import com.facebook.react.views.slider.ReactSlider
|
|
10
|
-
import com.facebook.react.views.slider.ReactSliderManager
|
|
11
|
-
import org.hamcrest.Matcher
|
|
12
|
-
import org.hamcrest.Matchers
|
|
13
|
-
|
|
14
|
-
class AdjustSliderToPositionAction(private val desiredPosition: Double, private val mManager: ReactSliderManager) : ViewAction {
|
|
15
|
-
override fun getConstraints(): Matcher<View?>? = Matchers.allOf(
|
|
16
|
-
ViewMatchers.isAssignableFrom(ReactSlider::class.java),
|
|
17
|
-
getIsDisplayed())
|
|
18
|
-
|
|
19
|
-
override fun getDescription() = "adjustSliderToPosition"
|
|
20
|
-
|
|
21
|
-
fun getIsDisplayed(): Matcher<View?> = ViewMatchers.isDisplayed()
|
|
22
|
-
|
|
23
|
-
private fun buildStyles(vararg keysAndValues: Any) = ReactStylesDiffMap(JavaOnlyMap.of(*keysAndValues))
|
|
24
|
-
|
|
25
|
-
private fun calculateProgressTarget(view: ReactSlider): Double {
|
|
26
|
-
val sliderProgress = view.toRealProgress(view.progress)
|
|
27
|
-
val sliderScrollFactor = view.max / view.progress.toDouble()
|
|
28
|
-
val sliderMaxValue = sliderProgress * sliderScrollFactor
|
|
29
|
-
return desiredPosition * sliderMaxValue
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
override fun perform(uiController: UiController?, view: View) {
|
|
33
|
-
val progressNewValue = calculateProgressTarget(view as ReactSlider)
|
|
34
|
-
mManager.updateProperties(view, buildStyles("value", progressNewValue))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
package com.wix.detox.espresso.action
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import com.facebook.react.views.slider.ReactSlider
|
|
5
|
-
import com.facebook.react.views.slider.ReactSliderManager
|
|
6
|
-
import org.assertj.core.api.Assertions.assertThat
|
|
7
|
-
import org.hamcrest.Matcher
|
|
8
|
-
import org.junit.Before
|
|
9
|
-
import org.junit.Test
|
|
10
|
-
import org.mockito.kotlin.*
|
|
11
|
-
|
|
12
|
-
@Suppress("IllegalIdentifier")
|
|
13
|
-
class AdjustSliderToPositionActionTest {
|
|
14
|
-
val mockReactSliderManager: ReactSliderManager = mock()
|
|
15
|
-
var uut: AdjustSliderToPositionAction = spy(AdjustSliderToPositionAction(0.25, mockReactSliderManager))
|
|
16
|
-
private lateinit var mockReactSlider: ReactSlider
|
|
17
|
-
|
|
18
|
-
@Before
|
|
19
|
-
fun setup() {
|
|
20
|
-
mockReactSlider = mock {
|
|
21
|
-
on {progress}.thenReturn(250)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Test
|
|
26
|
-
fun `should have correct description`() {
|
|
27
|
-
assertThat(uut.description).isEqualTo("adjustSliderToPosition")
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Test
|
|
31
|
-
fun `should have correct constraints`() {
|
|
32
|
-
val mockReactSlider: ReactSlider = mock()
|
|
33
|
-
val mockView: View = mock()
|
|
34
|
-
val mockIsDisplayed: Matcher<View?> = mock {
|
|
35
|
-
on {matches(any())}.thenReturn(true)
|
|
36
|
-
}
|
|
37
|
-
doReturn(mockIsDisplayed).whenever(uut).getIsDisplayed()
|
|
38
|
-
|
|
39
|
-
assertThat(uut.constraints).isNotNull
|
|
40
|
-
assertThat(uut.constraints!!.matches(null)).isFalse()
|
|
41
|
-
assertThat(uut.constraints!!.matches(1)).isFalse()
|
|
42
|
-
assertThat(uut.constraints!!.matches(mockReactSlider)).isTrue()
|
|
43
|
-
assertThat(uut.constraints!!.matches(mockView)).isFalse()
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Test
|
|
47
|
-
fun `should change progress of slider`() {
|
|
48
|
-
val mockReactSliderManager: ReactSliderManager = mock {
|
|
49
|
-
on{updateProperties(any(), any())}.thenAnswer{
|
|
50
|
-
doReturn(750).whenever(mockReactSlider).progress
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
uut = spy(AdjustSliderToPositionAction(0.75, mockReactSliderManager))
|
|
54
|
-
uut.perform(null, mockReactSlider)
|
|
55
|
-
|
|
56
|
-
verify(mockReactSliderManager, times(1)).updateProperties(any(), any())
|
|
57
|
-
assertThat(mockReactSlider.progress).isEqualTo(750)
|
|
58
|
-
}
|
|
59
|
-
}
|