detox 20.1.0-next-is-hittable-check.0 → 20.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar → 20.1.0/detox-20.1.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar → 20.1.0/detox-20.1.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom → 20.1.0/detox-20.1.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.1.0/detox-20.1.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/build.gradle +0 -1
- package/android/detox/src/full/java/com/wix/detox/TestEngineFacade.kt +3 -3
- package/android/detox/src/full/java/com/wix/detox/adapters/server/QueryStatusActionHandler.kt +12 -80
- package/android/detox/src/full/java/com/wix/detox/espresso/common/UiControllerImplReflected.kt +16 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/idlingresources/DescriptiveIdlingResource.kt +8 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/BusyResourcesInquirer.kt +48 -0
- package/android/detox/src/full/java/com/wix/detox/inquiry/DetoxBusyResource.kt +92 -0
- package/android/detox/src/full/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescription.kt → inquiry/DetoxBusyResourceDescription.kt} +6 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AnimatedModuleIdlingResource.java +18 -7
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResource.kt +2 -4
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/BridgeIdlingResource.java +12 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DetoxBaseIdlingResource.java +2 -0
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResource.java +14 -8
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResource.kt +1 -6
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIManagerModuleReflected.kt +1 -1
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/uimodule/UIModuleIdlingResource.kt +4 -6
- package/android/detox/src/testFull/java/com/wix/detox/adapters/server/QueryStatusActionHandlerSpec.kt +35 -94
- package/android/detox/src/testFull/java/com/wix/detox/espresso/registry/{IRStatusInquirerTest.kt → BusyResourcesInquirerTest.kt} +46 -7
- package/android/detox/src/testFull/java/com/wix/detox/{reactnative/idlingresources/IdlingResourceDescriptionSpec.kt → inquiry/DetoxBusyResourceDescriptionSpec.kt} +6 -6
- package/android/detox/src/testFull/java/com/wix/detox/inquiry/DetoxBusyResourceSpec.kt +134 -0
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/AsyncStorageIdlingResourceSpec.kt +4 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/NetworkIdlingResourcesTest.kt +5 -5
- package/android/detox/src/testFull/java/com/wix/detox/reactnative/idlingresources/timers/TimersIdlingResourceSpec.kt +4 -6
- package/index.d.ts +102 -18
- package/internals.d.ts +34 -9
- package/local-cli/cli.js +6 -3
- package/local-cli/init.js +1 -1
- package/local-cli/test.js +6 -6
- package/local-cli/testCommand/TestRunnerCommand.js +97 -94
- package/local-cli/testCommand/TestRunnerError.js +17 -0
- package/local-cli/testCommand/builder.js +0 -1
- package/local-cli/testCommand/middlewares.js +4 -13
- package/local-cli/testCommand/warnings.js +0 -3
- package/package.json +18 -15
- package/runners/deprecation.js +42 -44
- package/runners/jest/index.d.ts +60 -0
- package/runners/jest/index.js +3 -8
- package/runners/jest/reporters/DetoxReporter.js +21 -10
- package/runners/jest/testEnvironment/index.js +57 -41
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +62 -35
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +12 -14
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -5
- package/runners/jest/testEnvironment/utils/assertJestCircus27.js +17 -3
- package/src/DetoxWorker.js +95 -49
- package/src/android/interactions/native.js +3 -2
- package/src/artifacts/ArtifactsManager.js +6 -6
- package/src/artifacts/utils/temporaryPath.js +32 -2
- package/src/client/actions/SyncStatusSchema.json +21 -0
- package/src/client/actions/formatters/SyncStatusFormatter.js +2 -0
- package/src/client/actions/formatters/sync-resources/BgThreadFormatter.js +5 -0
- package/src/configuration/collectCliConfig.js +1 -12
- package/src/configuration/composeRunnerConfig.js +5 -4
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -3
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +3 -16
- package/src/devices/common/drivers/android/exec/ADB.js +4 -0
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +4 -0
- package/src/devices/runtime/RuntimeDevice.js +3 -3
- package/src/errors/DetoxConfigErrorComposer.js +6 -1
- package/src/errors/DetoxError.js +5 -1
- package/src/ios/expectTwo.js +3 -2
- package/src/ipc/IPCClient.js +26 -17
- package/src/ipc/IPCServer.js +11 -3
- package/src/ipc/SessionState.js +11 -11
- package/src/logger/DetoxLogger.js +63 -43
- package/src/logger/index.js +1 -0
- package/src/logger/utils/BunyanLogger.js +50 -7
- package/src/logger/utils/CategoryThreadDispatcher.js +8 -29
- package/src/logger/utils/DetoxLogFinalizer.js +166 -0
- package/src/logger/utils/MessageStack.js +17 -6
- package/src/logger/utils/ThreadDispatcher.js +5 -25
- package/src/logger/utils/customConsoleLogger.js +22 -5
- package/src/logger/utils/getMainCategory.js +5 -0
- package/src/logger/utils/sanitizeBunyanContext.js +3 -1
- package/src/logger/utils/streams/BunyanTransformer.js +72 -0
- package/src/logger/utils/streams/ChromeTraceTransformer.js +132 -0
- package/src/logger/utils/streams/DetoxJSONLParser.js +31 -0
- package/src/logger/utils/streams/JSONLStringer.js +55 -0
- package/src/logger/utils/streams/index.js +7 -0
- package/src/logger/utils/streams/transformers.js +39 -0
- package/src/logger/utils/tracerLegacy.js +14 -25
- package/src/realms/DetoxContext.js +11 -7
- package/src/realms/DetoxInternalsFacade.js +0 -6
- package/src/realms/DetoxPrimaryContext.js +42 -87
- package/src/realms/DetoxSecondaryContext.js +8 -12
- package/src/utils/argparse.js +11 -0
- package/src/utils/logger.js +1 -1
- package/src/utils/pathUtils.js +11 -0
- package/src/utils/shellUtils.js +17 -0
- package/src/utils/traceInvocationCall.js +21 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.1.0-next-is-hittable-check.0/detox-20.1.0-next-is-hittable-check.0.pom.sha512 +0 -1
- package/android/detox/src/full/java/com/wix/detox/espresso/registry/IRStatusInquirer.kt +0 -24
- package/android/detox/src/full/java/com/wix/detox/reactnative/idlingresources/DescriptiveIdlingResource.kt +0 -10
- package/local-cli/build.test.js +0 -104
- package/local-cli/run-server.test.js +0 -23
- package/local-cli/test.test.js +0 -569
- package/runners/jest/deprecation.js +0 -25
- package/runners/jest/testEnvironment/utils/assertJestCircus27.test.js +0 -23
- package/src/configuration/utils/warnings.js +0 -12
- package/src/logger/utils/streamUtils.js +0 -240
- package/src/utils/trace.js +0 -3
@@ -9,12 +9,12 @@ import org.joor.Reflect
|
|
9
9
|
private const val CLASS_UI_MANAGER_MODULE = "com.facebook.react.uimanager.UIManagerModule"
|
10
10
|
private const val METHOD_GET_NATIVE_MODULE = "getNativeModule"
|
11
11
|
private const val METHOD_GET_UI_IMPLEMENTATION = "getUIImplementation"
|
12
|
+
private const val METHOD_IS_EMPTY = "isEmpty"
|
12
13
|
private const val FIELD_UI_OPERATION_QUEUE = "mOperationsQueue"
|
13
14
|
private const val FIELD_DISPATCH_RUNNABLES = "mDispatchUIRunnables"
|
14
15
|
private const val FIELD_DISPATCH_RUNNABLES_LOCK = "mDispatchRunnablesLock"
|
15
16
|
private const val FIELD_NON_BATCHED_OPS = "mNonBatchedOperations"
|
16
17
|
private const val FIELD_NON_BATCHED_OPS_LOCK = "mNonBatchedOperationsLock"
|
17
|
-
private const val METHOD_IS_EMPTY = "isEmpty"
|
18
18
|
|
19
19
|
class UIManagerModuleReflected(private val reactContext: ReactContext) {
|
20
20
|
|
@@ -6,7 +6,6 @@ import androidx.test.espresso.IdlingResource.ResourceCallback
|
|
6
6
|
import com.facebook.react.bridge.ReactContext
|
7
7
|
import com.wix.detox.reactnative.helpers.RNHelpers
|
8
8
|
import com.wix.detox.reactnative.idlingresources.DetoxBaseIdlingResource
|
9
|
-
import com.wix.detox.reactnative.idlingresources.IdlingResourceDescription
|
10
9
|
import org.joor.ReflectException
|
11
10
|
|
12
11
|
/**
|
@@ -21,11 +20,10 @@ class UIModuleIdlingResource(private val reactContext: ReactContext)
|
|
21
20
|
private var callback: ResourceCallback? = null
|
22
21
|
|
23
22
|
override fun getName(): String = UIModuleIdlingResource::class.java.name
|
24
|
-
override fun
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
.build()
|
23
|
+
override fun getDebugName(): String = " ui"
|
24
|
+
override fun getBusyHint(): Map<String, Any> {
|
25
|
+
return mapOf("reason" to "UI rendering activity")
|
26
|
+
}
|
29
27
|
|
30
28
|
override fun checkIdle(): Boolean {
|
31
29
|
try {
|
@@ -1,9 +1,8 @@
|
|
1
1
|
package com.wix.detox.adapters.server
|
2
2
|
|
3
|
-
import androidx.test.espresso.IdlingResource
|
4
3
|
import com.wix.detox.TestEngineFacade
|
5
|
-
import com.wix.detox.
|
6
|
-
import com.wix.detox.
|
4
|
+
import com.wix.detox.inquiry.DetoxBusyResource
|
5
|
+
import com.wix.detox.inquiry.DetoxBusyResourceDescription
|
7
6
|
import org.mockito.kotlin.eq
|
8
7
|
import org.mockito.kotlin.mock
|
9
8
|
import org.mockito.kotlin.verify
|
@@ -31,103 +30,45 @@ object QueryStatusActionHandlerSpec : Spek({
|
|
31
30
|
}
|
32
31
|
}
|
33
32
|
|
34
|
-
fun
|
33
|
+
fun uut() = QueryStatusActionHandler(outboundServerAdapter, testEngineFacade)
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
verify(outboundServerAdapter).sendMessage(eq("currentStatusResult"), eq(expectedData), eq(messageId))
|
40
|
-
}
|
41
|
-
|
42
|
-
fun createMockedDescriptiveResource(description: IdlingResourceDescription):
|
43
|
-
DescriptiveIdlingResource {
|
44
|
-
val resource: DescriptiveIdlingResource = mock()
|
45
|
-
whenever(resource.getDescription()).thenReturn(description)
|
46
|
-
return resource
|
47
|
-
}
|
48
|
-
|
49
|
-
it("should return busy app status with descriptive resource") {
|
50
|
-
val fakeDescription = IdlingResourceDescription.Builder()
|
51
|
-
.name("foo")
|
52
|
-
.addDescription("bar", "baz")
|
53
|
-
.addDescription("qux", "quux")
|
54
|
-
.build()
|
55
|
-
|
56
|
-
val busyResources: List<IdlingResource> = listOf(
|
57
|
-
createMockedDescriptiveResource(fakeDescription)
|
58
|
-
)
|
59
|
-
whenever(testEngineFacade.getBusyIdlingResources()).thenReturn(busyResources)
|
35
|
+
describe("given an idle app") {
|
36
|
+
it("should send an idle status indication") {
|
37
|
+
val expectedData = mapOf("status" to mapOf("app_status" to "idle"))
|
60
38
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
mapOf("name" to "foo", "description" to mapOf("bar" to "baz", "qux" to "quux"))
|
65
|
-
)
|
66
|
-
val expectedData = mapOf("status" to mapOf("app_status" to "busy", "busy_resources" to expectedBusyResourceDescription))
|
67
|
-
verify(outboundServerAdapter).sendMessage(eq("currentStatusResult"), eq(expectedData), eq(messageId))
|
68
|
-
}
|
69
|
-
|
70
|
-
abstract class LooperIdlingResource: IdlingResource {}
|
71
|
-
|
72
|
-
fun createMockedLooperIdlingResource(resourceName: String): LooperIdlingResource {
|
73
|
-
val resource: LooperIdlingResource = mock()
|
74
|
-
whenever(resource.name).thenReturn(resourceName)
|
75
|
-
return resource
|
39
|
+
uut().handle(params, messageId)
|
40
|
+
verify(outboundServerAdapter).sendMessage(eq("currentStatusResult"), eq(expectedData), eq(messageId))
|
41
|
+
}
|
76
42
|
}
|
77
43
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
44
|
+
describe("given a busy app") {
|
45
|
+
fun aBusyResourceDescription(description: Map<String, Any>): DetoxBusyResourceDescription =
|
46
|
+
mock {
|
47
|
+
on { json() }.thenReturn(description)
|
48
|
+
}
|
49
|
+
|
50
|
+
fun aBusyResource(identifier: String): DetoxBusyResource {
|
51
|
+
val mockedDescription = aBusyResourceDescription(mapOf("mock" to identifier))
|
52
|
+
return mock {
|
53
|
+
on { getDescription() }.thenReturn(mockedDescription)
|
54
|
+
}
|
55
|
+
}
|
87
56
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
mapOf(
|
97
|
-
"name" to "looper",
|
98
|
-
"description" to mapOf(
|
99
|
-
"thread" to "\"mqt_native\" (Native Modules Thread)",
|
100
|
-
"execution_type" to "native module calls"
|
57
|
+
it("should send a descriptive busy-status indication") {
|
58
|
+
val busyResource = aBusyResource("some-resource")
|
59
|
+
val busyResource2 = aBusyResource("yet-another-resource")
|
60
|
+
val expectedData = mapOf<String, Any>("status" to mapOf(
|
61
|
+
"app_status" to "busy",
|
62
|
+
"busy_resources" to listOf(
|
63
|
+
mapOf("mock" to "some-resource"),
|
64
|
+
mapOf("mock" to "yet-another-resource"),
|
101
65
|
)
|
102
|
-
)
|
103
|
-
|
104
|
-
"name" to "looper",
|
105
|
-
"description" to mapOf("thread" to "\"unmapped\"")
|
106
|
-
)
|
107
|
-
)
|
108
|
-
val expectedData = mapOf("status" to mapOf("app_status" to "busy", "busy_resources" to expectedBusyResourceDescription))
|
109
|
-
verify(outboundServerAdapter).sendMessage(eq("currentStatusResult"), eq(expectedData), eq(messageId))
|
110
|
-
}
|
66
|
+
))
|
67
|
+
whenever(testEngineFacade.getAllBusyResources()).thenReturn(listOf(busyResource, busyResource2))
|
111
68
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
return resource
|
116
|
-
}
|
117
|
-
|
118
|
-
it("should return busy app status with unknown resource") {
|
119
|
-
val busyResources: List<IdlingResource> = listOf(
|
120
|
-
createMockedIdlingResource( "quux")
|
121
|
-
)
|
122
|
-
whenever(testEngineFacade.getBusyIdlingResources()).thenReturn(busyResources)
|
123
|
-
|
124
|
-
queryStatusHandler().handle(params, messageId)
|
125
|
-
|
126
|
-
val expectedBusyResourceDescription = listOf(
|
127
|
-
mapOf("name" to "unknown", "description" to mapOf("identifier" to "quux"))
|
128
|
-
)
|
129
|
-
val expectedData = mapOf("status" to mapOf("app_status" to "busy", "busy_resources" to expectedBusyResourceDescription))
|
130
|
-
verify(outboundServerAdapter).sendMessage(eq("currentStatusResult"), eq(expectedData), eq(messageId))
|
69
|
+
uut().handle(params, messageId)
|
70
|
+
verify(outboundServerAdapter).sendMessage(eq("currentStatusResult"), eq(expectedData), eq(messageId))
|
71
|
+
}
|
131
72
|
}
|
132
|
-
|
73
|
+
}
|
133
74
|
})
|
@@ -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
|
26
|
+
class BusyResourcesInquirerTest {
|
25
27
|
|
26
28
|
lateinit var registry: IdlingResourceRegistry
|
27
|
-
lateinit var
|
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
|
-
|
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(
|
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<
|
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
|
-
|
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.
|
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
|
7
|
+
class DetoxBusyResourceDescriptionSpec: Spek({
|
8
8
|
describe("Idling Resource Description Builder") {
|
9
|
-
lateinit var description:
|
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 =
|
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 =
|
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 =
|
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") {
|
@@ -24,20 +24,20 @@ class NetworkIdlingResourcesTest {
|
|
24
24
|
// Note: Ideally, we should test that the list of busy resources is protected,
|
25
25
|
// rather than testing thread-safety as a whole.
|
26
26
|
@Test
|
27
|
-
fun `should return the
|
27
|
+
fun `should return the descriptive data a thread-safe way`() {
|
28
28
|
val localExecutor = Executors.newSingleThreadExecutor()
|
29
|
-
var
|
29
|
+
var busyHint: Map<String, Any>? = null
|
30
30
|
|
31
31
|
synchronized(uut) {
|
32
32
|
localExecutor.submit {
|
33
|
-
|
33
|
+
busyHint = uut.getBusyHint()
|
34
34
|
}
|
35
35
|
|
36
36
|
yieldToOtherThreads(localExecutor)
|
37
|
-
assertThat(
|
37
|
+
assertThat(busyHint).isNull()
|
38
38
|
}
|
39
39
|
yieldToOtherThreads(localExecutor)
|
40
|
-
assertThat(
|
40
|
+
assertThat(busyHint).isNotNull
|
41
41
|
}
|
42
42
|
|
43
43
|
// Note: Ideally, we should test that the list of busy resources is protected,
|
@@ -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") {
|