Skip to content

Commit 387e8da

Browse files
committed
Smoke test
1 parent c9990c0 commit 387e8da

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

app/src/androidTest/kotlin/com/darkrockstudios/app/securecamera/ComposeTestUtils.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,28 @@ fun ComposeContentTestRule.setTextField(value: String, placeholder: Int) {
129129
performTextClearance()
130130
performTextInput(value)
131131
}
132+
}
133+
134+
fun ComposeContentTestRule.waitUntilTextAppearsAtLeastOnce(
135+
text: String,
136+
timeout: Duration = 5.seconds,
137+
ignoreCase: Boolean = false
138+
): Boolean {
139+
var seen = false
140+
waitUntil(timeout.inWholeMilliseconds) {
141+
val anyTree =
142+
onAllNodes(
143+
hasText(text, substring = true, ignoreCase = ignoreCase),
144+
useUnmergedTree = false
145+
)
146+
.fetchSemanticsNodes().isNotEmpty() ||
147+
onAllNodes(
148+
hasText(text, substring = true, ignoreCase = ignoreCase),
149+
useUnmergedTree = true
150+
)
151+
.fetchSemanticsNodes().isNotEmpty()
152+
if (anyTree) seen = true
153+
anyTree // stop waiting as soon as we see it
154+
}
155+
return seen
132156
}

app/src/androidTest/kotlin/com/darkrockstudios/app/securecamera/SmokeTestUiTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ class SmokeTestUiTest {
5252

5353
setPinFields("3133734", "313373")
5454
onNodeWithText(str(R.string.pin_creation_button)).performClick()
55-
waitForTextEitherTree(R.string.pin_creation_error, assert = false)
55+
waitUntilTextAppearsAtLeastOnce(str(R.string.pin_creation_error))
5656

5757
setPinFields("123456", "123456")
5858
onNodeWithText(str(R.string.pin_creation_button)).performClick()
59-
waitForTextEitherTree(R.string.pin_creation_error_weak_pin, assert = false)
59+
waitUntilTextAppearsAtLeastOnce(str(R.string.pin_creation_error_weak_pin))
6060

6161
setPinFields("313373", "313373")
6262
onNodeWithText(str(R.string.pin_creation_button)).performClick()
6363

64-
waitForTextEitherTree(str(R.string.pin_creating_vault), assert = false)
64+
waitUntilTextAppearsAtLeastOnce(str(R.string.pin_creating_vault))
6565

6666
waitForEitherTree(hasRole(Role.Button) and hasContentDescription(str(R.string.camera_shutter_button_desc)))
6767
.performClick()

0 commit comments

Comments
 (0)