Skip to content

Commit 2b6a5b7

Browse files
committed
Make Results quotes deterministic in tests
Change-Id: Ibe8131e3d92ebbcbd94723600c3620250db24b7a
1 parent 57e0d04 commit 2b6a5b7

9 files changed

+12
-3
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
file_pattern: '**/*.kt **/*.kts **/*.java **/*.xml'
5454

5555
- name: Verify Screenshot Tests (AndroidX)
56-
run: ./gradlew verifyDebugAndroidTestScreenshot
56+
run: ./gradlew validateDebugScreenshotTest
5757

5858
- name: Run local unit tests
5959
run: ./gradlew testDebugUnitTest

feature/results/src/main/java/com/android/developers/androidify/results/ResultsScreen.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,15 @@ fun ResultsScreenContents(
324324

325325
@Composable
326326
private fun BackgroundRandomQuotes(verboseLayout: Boolean = true) {
327+
val locaInspectionMode = LocalInspectionMode.current
327328
Box(modifier = Modifier.fillMaxSize()) {
328329
val listResultCompliments = stringArrayResource(R.array.list_compliments)
329330
val randomQuote = remember {
330-
listResultCompliments.random()
331+
if (locaInspectionMode) {
332+
listResultCompliments.first()
333+
} else {
334+
listResultCompliments.random()
335+
}
331336
}
332337
// Disable animation in tests
333338
val iterations = if (LocalInspectionMode.current) 0 else 100
@@ -342,7 +347,11 @@ private fun BackgroundRandomQuotes(verboseLayout: Boolean = true) {
342347
if (verboseLayout) {
343348
val listMinusOther = listResultCompliments.asList().minus(randomQuote)
344349
val randomQuote2 = remember {
345-
listMinusOther.random()
350+
if (locaInspectionMode) {
351+
listMinusOther.first()
352+
} else {
353+
listMinusOther.random()
354+
}
346355
}
347356
Text(
348357
randomQuote2,

0 commit comments

Comments
 (0)