expo-dev-menu 58.0.9 → 58.0.11
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/CHANGELOG.md +12 -0
- package/android/build.gradle +2 -2
- package/android/src/debug/java/expo/modules/devmenu/api/DevMenuApi.kt +1 -11
- package/android/src/debug/java/expo/modules/devmenu/compose/ripple/Ripple.kt +8 -2
- package/android/src/debug/java/expo/modules/devmenu/compose/ripple/RippleAlpha.kt +18 -6
- package/android/src/debug/java/expo/modules/devmenu/compose/ripple/RippleFactory.kt +35 -11
- package/android/src/debug/java/expo/modules/devmenu/compose/ripple/RippleHostView.kt +10 -2
- package/android/src/debug/java/expo/modules/devmenu/fab/FabState.kt +10 -2
- package/android/src/debug/java/expo/modules/devmenu/fab/FloatingActionButtonContent.kt +15 -3
- package/android/src/debug/java/expo/modules/devmenu/fab/MovableFloatingActionButton.kt +5 -1
- package/android/src/debug/java/expo/modules/devmenu/helpers/DevMenuReflectionExtensions.kt +0 -9
- package/android/src/debug/java/expo/modules/devmenu/launch/ExpoLauncherUrl.kt +8 -2
- package/android/src/testDebug/java/expo/modules/devmenu/api/DevMenuApiTest.kt +20 -0
- package/expo-dev-menu.podspec +0 -19
- package/ios/DevMenuViewController.swift +7 -0
- package/ios/SwiftUI/HeaderView.swift +2 -1
- package/package.json +6 -6
- package/android/src/debug/java/expo/modules/devmenu/react/DevMenuShakeDetectorListenerSwapper.kt +0 -39
- package/ios/UITests/DevMenuLooper.swift +0 -29
- package/ios/UITests/DevMenuTestOptions.swift +0 -4
- package/ios/UITests/DevMenuUIMatchers.swift +0 -106
- package/ios/UITests/MockedBridges.swift +0 -19
- package/ios/UITests/UIView+DevMenuExtension.swift +0 -7
- package/ios/UITests/XCTestCase+DevMenuExtension.swift +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Android] Disable the React Native shake gesture with its public API instead of replacing the shake listener through reflection. ([#51130](https://github.com/expo/expo/pull/51130) by [@alanjhughes](https://github.com/alanjhughes))
|
|
8
|
+
|
|
9
|
+
## 58.0.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [iOS] Disable the vertical bar while the dev menu is open so the sheet fills the full width on iPhone Duo. ([#50900](https://github.com/expo/expo/pull/50900) by [@alanjhughes](https://github.com/alanjhughes))
|
|
14
|
+
|
|
3
15
|
## 58.0.9
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/android/build.gradle
CHANGED
|
@@ -12,7 +12,7 @@ apply plugin: 'expo-module-gradle-plugin'
|
|
|
12
12
|
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
|
|
13
13
|
|
|
14
14
|
group = 'host.exp.exponent'
|
|
15
|
-
version = '58.0.
|
|
15
|
+
version = '58.0.11'
|
|
16
16
|
|
|
17
17
|
def hasDevLauncher = findProject(":expo-dev-launcher") != null
|
|
18
18
|
def configureInRelease = findProperty("expo.devmenu.configureInRelease") == "true"
|
|
@@ -29,7 +29,7 @@ android {
|
|
|
29
29
|
|
|
30
30
|
defaultConfig {
|
|
31
31
|
versionCode 10
|
|
32
|
-
versionName '58.0.
|
|
32
|
+
versionName '58.0.11'
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
buildTypes {
|
|
@@ -17,7 +17,6 @@ import expo.modules.devmenu.GoHomeAction
|
|
|
17
17
|
import expo.modules.devmenu.SwitchToComponentAction
|
|
18
18
|
import expo.modules.devmenu.helpers.getPrivateDeclaredFieldValue
|
|
19
19
|
import expo.modules.devmenu.helpers.setPrivateDeclaredFieldValue
|
|
20
|
-
import expo.modules.devmenu.react.DevMenuShakeDetectorListenerSwapper
|
|
21
20
|
import expo.modules.devmenu.websockets.DevMenuCommandHandlersProvider
|
|
22
21
|
import expo.modules.kotlin.weak
|
|
23
22
|
import java.lang.ref.WeakReference
|
|
@@ -89,15 +88,6 @@ object DevMenuApi {
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
fun uninstallDefaultShakeDetector(devSupportManager: DevSupportManager) {
|
|
92
|
-
|
|
93
|
-
Log.w("DevMenu", "DevSupportManager is not an instance of DevSupportManagerBase. Skipping uninstallation of the default shake detector.")
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
DevMenuShakeDetectorListenerSwapper()
|
|
98
|
-
.swapShakeDetectorListener(
|
|
99
|
-
devSupportManager,
|
|
100
|
-
newListener = {}
|
|
101
|
-
)
|
|
91
|
+
devSupportManager.shakeGestureEnabled = false
|
|
102
92
|
}
|
|
103
93
|
}
|
|
@@ -69,7 +69,11 @@ internal class CommonRippleNode(
|
|
|
69
69
|
override fun addRipple(interaction: PressInteraction.Press, size: Size, targetRadius: Float) {
|
|
70
70
|
// Finish existing ripples
|
|
71
71
|
ripples.forEach { _, ripple -> ripple.finish() }
|
|
72
|
-
val origin = if (bounded)
|
|
72
|
+
val origin = if (bounded) {
|
|
73
|
+
interaction.pressPosition
|
|
74
|
+
} else {
|
|
75
|
+
null
|
|
76
|
+
}
|
|
73
77
|
val rippleAnimation =
|
|
74
78
|
RippleAnimation(origin = origin, radius = targetRadius, bounded = bounded)
|
|
75
79
|
ripples[interaction] = rippleAnimation
|
|
@@ -186,7 +190,9 @@ internal class AndroidRippleNode(
|
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
private fun getOrCreateRippleContainer(): RippleContainer {
|
|
189
|
-
if (rippleContainer != null)
|
|
193
|
+
if (rippleContainer != null) {
|
|
194
|
+
return rippleContainer!!
|
|
195
|
+
}
|
|
190
196
|
val view = findNearestViewGroup(currentValueOf(LocalView))
|
|
191
197
|
rippleContainer = createAndAttachRippleContainerIfNeeded(view)
|
|
192
198
|
return rippleContainer!!
|
|
@@ -26,13 +26,25 @@ public class RippleAlpha(
|
|
|
26
26
|
public val pressedAlpha: Float
|
|
27
27
|
) {
|
|
28
28
|
override fun equals(other: Any?): Boolean {
|
|
29
|
-
if (this === other)
|
|
30
|
-
|
|
29
|
+
if (this === other) {
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
if (other !is RippleAlpha) {
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
31
35
|
|
|
32
|
-
if (draggedAlpha != other.draggedAlpha)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
+
if (draggedAlpha != other.draggedAlpha) {
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
if (focusedAlpha != other.focusedAlpha) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
if (hoveredAlpha != other.hoveredAlpha) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
if (pressedAlpha != other.pressedAlpha) {
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
36
48
|
|
|
37
49
|
return true
|
|
38
50
|
}
|
|
@@ -77,7 +77,11 @@ fun ripple(
|
|
|
77
77
|
color: Color = Color.Unspecified
|
|
78
78
|
): IndicationNodeFactory {
|
|
79
79
|
return if (radius == Dp.Unspecified && color == Color.Unspecified) {
|
|
80
|
-
if (bounded)
|
|
80
|
+
if (bounded) {
|
|
81
|
+
return DefaultBoundedRipple
|
|
82
|
+
} else {
|
|
83
|
+
DefaultUnboundedRipple
|
|
84
|
+
}
|
|
81
85
|
} else {
|
|
82
86
|
RippleNodeFactory(bounded, radius, color)
|
|
83
87
|
}
|
|
@@ -207,11 +211,19 @@ class RippleConfiguration(
|
|
|
207
211
|
val rippleAlpha: RippleAlpha? = null
|
|
208
212
|
) {
|
|
209
213
|
override fun equals(other: Any?): Boolean {
|
|
210
|
-
if (this === other)
|
|
211
|
-
|
|
214
|
+
if (this === other) {
|
|
215
|
+
return true
|
|
216
|
+
}
|
|
217
|
+
if (other !is RippleConfiguration) {
|
|
218
|
+
return false
|
|
219
|
+
}
|
|
212
220
|
|
|
213
|
-
if (color != other.color)
|
|
214
|
-
|
|
221
|
+
if (color != other.color) {
|
|
222
|
+
return false
|
|
223
|
+
}
|
|
224
|
+
if (rippleAlpha != other.rippleAlpha) {
|
|
225
|
+
return false
|
|
226
|
+
}
|
|
215
227
|
|
|
216
228
|
return true
|
|
217
229
|
}
|
|
@@ -249,12 +261,22 @@ private constructor(
|
|
|
249
261
|
}
|
|
250
262
|
|
|
251
263
|
override fun equals(other: Any?): Boolean {
|
|
252
|
-
if (this === other)
|
|
253
|
-
|
|
264
|
+
if (this === other) {
|
|
265
|
+
return true
|
|
266
|
+
}
|
|
267
|
+
if (other !is RippleNodeFactory) {
|
|
268
|
+
return false
|
|
269
|
+
}
|
|
254
270
|
|
|
255
|
-
if (bounded != other.bounded)
|
|
256
|
-
|
|
257
|
-
|
|
271
|
+
if (bounded != other.bounded) {
|
|
272
|
+
return false
|
|
273
|
+
}
|
|
274
|
+
if (radius != other.radius) {
|
|
275
|
+
return false
|
|
276
|
+
}
|
|
277
|
+
if (colorProducer != other.colorProducer) {
|
|
278
|
+
return false
|
|
279
|
+
}
|
|
258
280
|
return color == other.color
|
|
259
281
|
}
|
|
260
282
|
|
|
@@ -294,7 +316,9 @@ private class DelegatingThemeAwareRippleNode(
|
|
|
294
316
|
if (configuration == null) {
|
|
295
317
|
removeRipple()
|
|
296
318
|
} else {
|
|
297
|
-
if (rippleNode == null)
|
|
319
|
+
if (rippleNode == null) {
|
|
320
|
+
attachNewRipple()
|
|
321
|
+
}
|
|
298
322
|
}
|
|
299
323
|
}
|
|
300
324
|
}
|
|
@@ -227,7 +227,11 @@ internal class RippleHostView(context: Context) : View(context) {
|
|
|
227
227
|
}
|
|
228
228
|
postDelayed(resetRippleRunnable, ResetRippleDelayDuration)
|
|
229
229
|
} else {
|
|
230
|
-
val state = if (pressed)
|
|
230
|
+
val state = if (pressed) {
|
|
231
|
+
PressedState
|
|
232
|
+
} else {
|
|
233
|
+
RestingState
|
|
234
|
+
}
|
|
231
235
|
ripple?.state = state
|
|
232
236
|
}
|
|
233
237
|
lastRippleStateChangeTimeMillis = currentTime
|
|
@@ -276,7 +280,11 @@ private class UnprojectedRipple(private val bounded: Boolean) :
|
|
|
276
280
|
// The color of the mask here doesn't matter - we just need a mask to draw the bounded
|
|
277
281
|
// ripple
|
|
278
282
|
// against
|
|
279
|
-
/* mask */ if (bounded)
|
|
283
|
+
/* mask */ if (bounded) {
|
|
284
|
+
ColorDrawable(android.graphics.Color.WHITE)
|
|
285
|
+
} else {
|
|
286
|
+
null
|
|
287
|
+
}
|
|
280
288
|
) {
|
|
281
289
|
/**
|
|
282
290
|
* Store the ripple color so we can compare it later, as there is no way to get the currently
|
|
@@ -41,8 +41,16 @@ class FabState(
|
|
|
41
41
|
|
|
42
42
|
fun savePosition(offset: Offset) {
|
|
43
43
|
// Store position as 0–1 ratios within the safe area so it survives screen size changes
|
|
44
|
-
val normalizedX = if (fabAreaBounds.x > 0f)
|
|
45
|
-
|
|
44
|
+
val normalizedX = if (fabAreaBounds.x > 0f) {
|
|
45
|
+
offset.x / fabAreaBounds.x
|
|
46
|
+
} else {
|
|
47
|
+
0f
|
|
48
|
+
}
|
|
49
|
+
val normalizedY = if (fabAreaBounds.y > 0f) {
|
|
50
|
+
offset.y / fabAreaBounds.y
|
|
51
|
+
} else {
|
|
52
|
+
0f
|
|
53
|
+
}
|
|
46
54
|
|
|
47
55
|
prefs.edit {
|
|
48
56
|
putFloat(FAB_POSITION_X, normalizedX)
|
|
@@ -42,17 +42,29 @@ fun FloatingActionButtonContent(
|
|
|
42
42
|
showLabel: Boolean = true
|
|
43
43
|
) {
|
|
44
44
|
val scale by animateFloatAsState(
|
|
45
|
-
targetValue = if (isPressed && !isDragging)
|
|
45
|
+
targetValue = if (isPressed && !isDragging) {
|
|
46
|
+
0.9f
|
|
47
|
+
} else {
|
|
48
|
+
1f
|
|
49
|
+
},
|
|
46
50
|
label = "pressScale"
|
|
47
51
|
)
|
|
48
52
|
|
|
49
53
|
val idleAlpha by animateFloatAsState(
|
|
50
|
-
targetValue = if (isIdle)
|
|
54
|
+
targetValue = if (isIdle) {
|
|
55
|
+
0.5f
|
|
56
|
+
} else {
|
|
57
|
+
1f
|
|
58
|
+
},
|
|
51
59
|
label = "idleAlpha"
|
|
52
60
|
)
|
|
53
61
|
|
|
54
62
|
val idleSaturation by animateFloatAsState(
|
|
55
|
-
targetValue = if (isIdle)
|
|
63
|
+
targetValue = if (isIdle) {
|
|
64
|
+
0f
|
|
65
|
+
} else {
|
|
66
|
+
1f
|
|
67
|
+
},
|
|
56
68
|
label = "idleSaturation"
|
|
57
69
|
)
|
|
58
70
|
|
|
@@ -109,7 +109,11 @@ fun MovableFloatingActionButton(
|
|
|
109
109
|
if (state.isOpen) {
|
|
110
110
|
fab.restingOffset = fab.animatedOffset.value
|
|
111
111
|
val isOnLeftSide = fab.animatedOffset.value.x < fab.fabAreaBounds.x / 2f
|
|
112
|
-
val offScreenX = if (isOnLeftSide)
|
|
112
|
+
val offScreenX = if (isOnLeftSide) {
|
|
113
|
+
-totalFabSizePx.x
|
|
114
|
+
} else {
|
|
115
|
+
constraints.maxWidth.toFloat()
|
|
116
|
+
}
|
|
113
117
|
fab.animatedOffset.animateTo(
|
|
114
118
|
targetValue = Offset(offScreenX, fab.animatedOffset.value.y),
|
|
115
119
|
animationSpec = tween(durationMillis = 500)
|
|
@@ -26,12 +26,3 @@ fun <T> Class<out T>.setPrivateDeclaredFieldValue(filedName: String, obj: T, new
|
|
|
26
26
|
|
|
27
27
|
field.set(obj, newValue)
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
fun <T> Class<out T>.hasDeclaredField(fieldName: String): Boolean {
|
|
31
|
-
return try {
|
|
32
|
-
getDeclaredField(fieldName)
|
|
33
|
-
true
|
|
34
|
-
} catch (_: NoSuchFieldException) {
|
|
35
|
-
false
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -8,7 +8,11 @@ import android.net.Uri
|
|
|
8
8
|
* Keep in sync with `packages/expo-dev-menu/ios/Launch/ExpoLauncherURL.swift`.
|
|
9
9
|
*/
|
|
10
10
|
class ExpoLauncherUrl(val url: Uri) {
|
|
11
|
-
private val paramNames: Set<String> = if (url.isHierarchical)
|
|
11
|
+
private val paramNames: Set<String> = if (url.isHierarchical) {
|
|
12
|
+
url.queryParameterNames
|
|
13
|
+
} else {
|
|
14
|
+
emptySet()
|
|
15
|
+
}
|
|
12
16
|
private val hasReservedParams = paramNames.any { it.startsWith(RESERVED_PREFIX) }
|
|
13
17
|
|
|
14
18
|
val isLegacyHost = url.host == LEGACY_HOST
|
|
@@ -47,7 +51,9 @@ class ExpoLauncherUrl(val url: Uri) {
|
|
|
47
51
|
|
|
48
52
|
/** `__expo_<name>`, or the [legacy] param next to the legacy host. */
|
|
49
53
|
private fun param(name: String, legacy: String? = null): String? {
|
|
50
|
-
if (!url.isHierarchical)
|
|
54
|
+
if (!url.isHierarchical) {
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
51
57
|
return url.getQueryParameter(RESERVED_PREFIX + name)
|
|
52
58
|
?: legacy?.takeIf { isLegacyHost }?.let(url::getQueryParameter)
|
|
53
59
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package expo.modules.devmenu.api
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.devsupport.interfaces.DevSupportManager
|
|
4
|
+
import io.mockk.mockk
|
|
5
|
+
import io.mockk.verify
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
import org.junit.runner.RunWith
|
|
8
|
+
import org.robolectric.RobolectricTestRunner
|
|
9
|
+
|
|
10
|
+
@RunWith(RobolectricTestRunner::class)
|
|
11
|
+
internal class DevMenuApiTest {
|
|
12
|
+
@Test
|
|
13
|
+
fun `disables the React Native shake gesture`() {
|
|
14
|
+
val devSupportManager = mockk<DevSupportManager>(relaxed = true)
|
|
15
|
+
|
|
16
|
+
DevMenuApi.uninstallDefaultShakeDetector(devSupportManager)
|
|
17
|
+
|
|
18
|
+
verify { devSupportManager.shakeGestureEnabled = false }
|
|
19
|
+
}
|
|
20
|
+
}
|
package/expo-dev-menu.podspec
CHANGED
|
@@ -123,24 +123,5 @@ Pod::Spec.new do |s|
|
|
|
123
123
|
}
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
s.test_spec 'UITests' do |test_spec|
|
|
127
|
-
test_spec.requires_app_host = true
|
|
128
|
-
test_spec.source_files = 'ios/UITests/**/*'
|
|
129
|
-
test_spec.dependency 'React-CoreModules'
|
|
130
|
-
test_spec.dependency 'ReactAppDependencyProvider'
|
|
131
|
-
test_spec.dependency 'React'
|
|
132
|
-
# ExpoModulesCore requires React-hermes or React-jsc in tests, add ExpoModulesTestCore for the underlying dependencies
|
|
133
|
-
test_spec.dependency 'ExpoModulesTestCore'
|
|
134
|
-
test_spec.pod_target_xcconfig = {
|
|
135
|
-
'OTHER_LDFLAGS' => '$(inherited) -lc++'
|
|
136
|
-
}
|
|
137
|
-
test_spec.platforms = {
|
|
138
|
-
:ios => '16.4'
|
|
139
|
-
}
|
|
140
|
-
test_spec.pod_target_xcconfig = {
|
|
141
|
-
'OTHER_LDFLAGS' => '$(inherited) -lc++'
|
|
142
|
-
}
|
|
143
|
-
end
|
|
144
|
-
|
|
145
126
|
s.default_subspec = ['Main']
|
|
146
127
|
end
|
|
@@ -42,6 +42,13 @@ class DevMenuViewController: UIViewController {
|
|
|
42
42
|
}
|
|
43
43
|
#endif
|
|
44
44
|
|
|
45
|
+
#if canImport(SwiftUICore, _version: 8.0.85) && os(iOS)
|
|
46
|
+
@available(iOS 27.1, *)
|
|
47
|
+
override var preferredVerticalBarBehavior: UIVerticalBarBehavior {
|
|
48
|
+
return .disabled
|
|
49
|
+
}
|
|
50
|
+
#endif
|
|
51
|
+
|
|
45
52
|
private func setupSwiftUIView() {
|
|
46
53
|
let rootView = DevMenuRootView()
|
|
47
54
|
let hostingController = UIHostingController(rootView: rootView)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-dev-menu",
|
|
3
|
-
"version": "58.0.
|
|
3
|
+
"version": "58.0.11",
|
|
4
4
|
"description": "Expo/React Native module with the developer menu.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dev",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/preset-typescript": "^7.7.4",
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
31
|
+
"@expo/internal-scripts": "58.0.1",
|
|
32
|
+
"@testing-library/react-native": "^14.0.1",
|
|
33
|
+
"@types/jest": "^30.0.0",
|
|
33
34
|
"@types/node": "^22.14.0",
|
|
34
|
-
"babel-preset-expo": "58.0.
|
|
35
|
-
"expo-module-scripts": "56.0.4",
|
|
35
|
+
"babel-preset-expo": "58.0.12",
|
|
36
36
|
"react": "19.3.0",
|
|
37
|
-
"react-native": "0.88.0-rc.
|
|
37
|
+
"react-native": "0.88.0-rc.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"expo": "*",
|
package/android/src/debug/java/expo/modules/devmenu/react/DevMenuShakeDetectorListenerSwapper.kt
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
package expo.modules.devmenu.react
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.facebook.react.common.ShakeDetector
|
|
5
|
-
import com.facebook.react.devsupport.DevSupportManagerBase
|
|
6
|
-
import expo.modules.devmenu.helpers.getPrivateDeclaredFieldValue
|
|
7
|
-
import expo.modules.devmenu.helpers.hasDeclaredField
|
|
8
|
-
import expo.modules.devmenu.helpers.setPrivateDeclaredFieldValue
|
|
9
|
-
|
|
10
|
-
class DevMenuShakeDetectorListenerSwapper {
|
|
11
|
-
fun swapShakeDetectorListener(
|
|
12
|
-
devSupportManager: DevSupportManagerBase,
|
|
13
|
-
newListener: ShakeDetector.ShakeListener
|
|
14
|
-
) {
|
|
15
|
-
try {
|
|
16
|
-
val shakeDetector: ShakeDetector =
|
|
17
|
-
DevSupportManagerBase::class.java.getPrivateDeclaredFieldValue(
|
|
18
|
-
"shakeDetector",
|
|
19
|
-
devSupportManager
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
if (ShakeDetector::class.java.hasDeclaredField("shakeListener")) {
|
|
23
|
-
ShakeDetector::class.java.setPrivateDeclaredFieldValue(
|
|
24
|
-
"shakeListener",
|
|
25
|
-
shakeDetector,
|
|
26
|
-
newListener
|
|
27
|
-
)
|
|
28
|
-
} else {
|
|
29
|
-
ShakeDetector::class.java.setPrivateDeclaredFieldValue(
|
|
30
|
-
"mShakeListener",
|
|
31
|
-
shakeDetector,
|
|
32
|
-
newListener
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
} catch (e: Exception) {
|
|
36
|
-
Log.w("DevMenu", "Couldn't swap shake detector listener: ${e.message}", e)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import XCTest
|
|
3
|
-
|
|
4
|
-
class DevMenuLooper {
|
|
5
|
-
static func runMainLoop(for sec: Double) {
|
|
6
|
-
RunLoop.main.run(mode: .default, before: Date(timeIntervalSinceNow: sec))
|
|
7
|
-
RunLoop.main.run(mode: .common, before: Date(timeIntervalSinceNow: sec))
|
|
8
|
-
RunLoop.main.run(mode: .tracking, before: Date(timeIntervalSinceNow: sec))
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static func runMainLoopUntilEmpty() {
|
|
12
|
-
var isEmpty = false
|
|
13
|
-
|
|
14
|
-
DispatchQueue.main.async {
|
|
15
|
-
isEmpty = true
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let timout = Date(timeIntervalSinceNow: DevMenuTestOptions.defaultTimeout)
|
|
19
|
-
while timout.timeIntervalSinceNow > 0 {
|
|
20
|
-
if isEmpty {
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
DevMenuLooper.runMainLoop(for: DevMenuTestOptions.loopTime)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
XCTFail("Wait for main thread timeout.")
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import XCTest
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
class DevMenuViews {
|
|
5
|
-
static let mainScreen = "DevMenuMainScreen"
|
|
6
|
-
static let footer = "DevMenuFooter"
|
|
7
|
-
static let settingsScreen = "DevMenuSettingsScreen"
|
|
8
|
-
static let profileScreen = "DevMenuProfileScreen"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
class DevMenuUIMatchers {
|
|
12
|
-
static func currentRootView() -> UIView? {
|
|
13
|
-
return UIApplication.shared.keyWindow?.rootViewController?.view
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static func findView(rootView: UIView, _ matcher: (UIView) -> Bool) -> UIView? {
|
|
17
|
-
if matcher(rootView) {
|
|
18
|
-
return rootView
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
for subView in rootView.subviews {
|
|
22
|
-
let found = findView(rootView: subView, matcher)
|
|
23
|
-
if found != nil {
|
|
24
|
-
return found
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return nil
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static func findView(_ matcher: (UIView) -> Bool) -> UIView? {
|
|
32
|
-
guard let view = DevMenuUIMatchers.currentRootView() else {
|
|
33
|
-
return nil
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return findView(rootView: view, matcher)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static func findView(rootView: UIView, tag: String) -> UIView? {
|
|
40
|
-
return DevMenuUIMatchers.findView(rootView: rootView) {
|
|
41
|
-
return $0.accessibilityIdentifier == tag && $0.isVisible()
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
static func findView(tag: String) -> UIView? {
|
|
46
|
-
guard let view = DevMenuUIMatchers.currentRootView() else {
|
|
47
|
-
return nil
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return findView(rootView: view, tag: tag)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static func waitForView(_ matcher: (UIView) -> Bool) -> UIView {
|
|
54
|
-
let timer = Date(timeIntervalSinceNow: DevMenuTestOptions.defaultTimeout)
|
|
55
|
-
|
|
56
|
-
while timer.timeIntervalSinceNow > 0 {
|
|
57
|
-
DevMenuLooper.runMainLoop(for: DevMenuTestOptions.loopTime)
|
|
58
|
-
|
|
59
|
-
guard let view = DevMenuUIMatchers.currentRootView() else {
|
|
60
|
-
continue
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let found = findView(rootView: view, matcher)
|
|
64
|
-
if found != nil {
|
|
65
|
-
return found!
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
XCTFail("Can not find view.")
|
|
70
|
-
return UIView() // just for compiler
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static func waitForView(tag: String) -> UIView {
|
|
74
|
-
return waitForView {
|
|
75
|
-
return $0.accessibilityIdentifier == tag && $0.isVisible()
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static func waitForView(text: String) -> UIView {
|
|
80
|
-
return waitForView {
|
|
81
|
-
if type(of: $0) == NSClassFromString("RCTTextView")! {
|
|
82
|
-
return $0.isVisible() && ($0.value(forKey: "_textStorage") as! NSTextStorage).string == text
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return false
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static func findView(rootView: UIView, text: String) -> UIView? {
|
|
90
|
-
findView(rootView: rootView) {
|
|
91
|
-
if type(of: $0) == NSClassFromString("RCTTextView")! {
|
|
92
|
-
return $0.isVisible() && ($0.value(forKey: "_textStorage") as! NSTextStorage).string == text
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return false
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static func findView(text: String) -> UIView? {
|
|
100
|
-
guard let view = DevMenuUIMatchers.currentRootView() else {
|
|
101
|
-
return nil
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return findView(rootView: view, text: text)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
@testable import EXDevMenu
|
|
2
|
-
@testable import EXDevMenuInterface
|
|
3
|
-
import React
|
|
4
|
-
|
|
5
|
-
class UIMockedNOOPBridge: RCTBridge {
|
|
6
|
-
override func invalidate() {
|
|
7
|
-
// NOOP
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
override func setUp() {
|
|
11
|
-
bundleURL = URL(string: "http://localhost:1234")
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
class BridgeWithDevMenuExtension: UIMockedNOOPBridge {
|
|
16
|
-
override func module(forName moduleName: String!) -> Any! {
|
|
17
|
-
return []
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import XCTest
|
|
2
|
-
|
|
3
|
-
@testable import EXDevMenu
|
|
4
|
-
|
|
5
|
-
extension XCTest {
|
|
6
|
-
func assertViewExists(tag: String) {
|
|
7
|
-
XCTAssertNotNil(DevMenuUIMatchers.findView(tag: tag), "View with tag \(tag) does not exist.")
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
func assertViewExists(text: String) {
|
|
11
|
-
let view = DevMenuUIMatchers.findView(text: text)
|
|
12
|
-
XCTAssertNotNil(view, "View with text \(text) does not exist.")
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
func waitForView(tag: String) {
|
|
16
|
-
XCTAssertNotNil(DevMenuUIMatchers.waitForView(tag: tag))
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
func waitForDevMenu() {
|
|
20
|
-
waitForView(tag: DevMenuViews.mainScreen)
|
|
21
|
-
waitForView(tag: DevMenuViews.footer)
|
|
22
|
-
XCTAssertTrue(DevMenuManager.shared.isVisible)
|
|
23
|
-
|
|
24
|
-
DevMenuLooper.runMainLoopUntilEmpty()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
func runMainLoop(for sec: Double) {
|
|
28
|
-
DevMenuLooper.runMainLoop(for: sec)
|
|
29
|
-
}
|
|
30
|
-
}
|