diff options
author | Yuri Schimke <yuri@schimke.ee> | 2024-04-09 11:39:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 11:39:19 +0100 |
commit | 76090d7dbd4a33efc7be3f989963d03878c540cf (patch) | |
tree | 605ed17b22f3c5e7c3d72afee1a2fe59f6d53a42 | |
parent | e451749c5564d051fa644f7f889e321751beeb3e (diff) | |
download | horologist-76090d7dbd4a33efc7be3f989963d03878c540cf.tar.gz |
Cleanup a11y tests (#2182)
88 files changed, 1176 insertions, 1986 deletions
diff --git a/composables/src/test/kotlin/com/google/android/horologist/composables/DatePickerA11yTest.kt b/composables/src/test/kotlin/com/google/android/horologist/composables/DatePickerA11yTest.kt index 9e34abde..60916041 100644 --- a/composables/src/test/kotlin/com/google/android/horologist/composables/DatePickerA11yTest.kt +++ b/composables/src/test/kotlin/com/google/android/horologist/composables/DatePickerA11yTest.kt @@ -14,93 +14,55 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") -@file:OptIn(ExperimentalWearFoundationApi::class) - package com.google.android.horologist.composables -import android.app.Application -import android.view.accessibility.AccessibilityManager import androidx.compose.ui.test.assertHasClickAction import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.performClick -import androidx.test.core.app.ApplicationProvider -import androidx.test.filters.FlakyTest -import androidx.wear.compose.foundation.ExperimentalWearFoundationApi -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams -import org.junit.Ignore +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -import org.robolectric.Shadows import java.time.LocalDate -@FlakyTest(detail = "https://github.com/google/horologist/issues/1806") -class DatePickerA11yTest : ScreenshotBaseTest( - screenshotTestRuleParams { - screenTimeText = {} - enableA11y = true - }, -) { +class DatePickerA11yTest : WearLegacyA11yTest() { @Test fun screenshot() { enableTouchExploration() - screenshotTestRule.setContent { + runScreenTest { DatePicker( onDateConfirm = {}, date = LocalDate.of(2022, 4, 25), ) } - - screenshotTestRule.takeScreenshot() } @Test - @Ignore("https://github.com/google/horologist/issues/1806") fun interactionTest() { enableTouchExploration() - screenshotTestRule.setContent { + runScreenTest { DatePicker( onDateConfirm = {}, date = LocalDate.of(2022, 4, 25), ) } - screenshotTestRule.interact { - onNodeWithContentDescription("Next") - .assertHasClickAction() - - waitForIdle() -// onNodeWithContentDescription("Day, 25") -// .assertIsFocused() - } - - screenshotTestRule.takeScreenshot() + composeRule.onNodeWithContentDescription("Next") + .assertHasClickAction() + .performClick() - screenshotTestRule.interact { - onNodeWithContentDescription("Next") - .performClick() + captureScreenshot("_2") - waitForIdle() -// waitUntil { -// onNodeWithContentDescription("April") -// .fetchSemanticsNode() -// .config[SemanticsProperties.Focused] -// } - } + composeRule.onNodeWithContentDescription("Next") + .assertHasClickAction() + .performClick() - screenshotTestRule.takeScreenshot() - } + captureScreenshot("_3") - companion object { - fun enableTouchExploration() { - val applicationContext = ApplicationProvider.getApplicationContext<Application>() - val a11yManager = applicationContext.getSystemService(AccessibilityManager::class.java) - val shadow = Shadows.shadowOf(a11yManager) + composeRule.onNodeWithContentDescription("Next") + .assertHasClickAction() + .performClick() - shadow.setEnabled(true) - shadow.setTouchExplorationEnabled(true) - } + captureScreenshot("_3") } } diff --git a/composables/src/test/kotlin/com/google/android/horologist/composables/TimePicker12hA11yTest.kt b/composables/src/test/kotlin/com/google/android/horologist/composables/TimePicker12hA11yTest.kt index 439af546..25624739 100644 --- a/composables/src/test/kotlin/com/google/android/horologist/composables/TimePicker12hA11yTest.kt +++ b/composables/src/test/kotlin/com/google/android/horologist/composables/TimePicker12hA11yTest.kt @@ -14,38 +14,28 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.composables import androidx.compose.ui.test.assertHasClickAction import androidx.compose.ui.test.onNodeWithContentDescription -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test import java.time.LocalTime -class TimePicker12hA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - screenTimeText = {} - enableA11y = true - }, -) { +class TimePicker12hA11yTest : WearLegacyA11yTest() { @Test fun initial() { - DatePickerA11yTest.enableTouchExploration() + enableTouchExploration() - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { TimePickerWith12HourClock( time = LocalTime.of(10, 10, 0), onTimeConfirm = {}, ) } - screenshotTestRule.interact { - onNodeWithContentDescription("Confirm") - .assertHasClickAction() - } + composeRule.onNodeWithContentDescription("Confirm") + .assertHasClickAction() } } diff --git a/composables/src/test/kotlin/com/google/android/horologist/composables/TimePickerA11yTest.kt b/composables/src/test/kotlin/com/google/android/horologist/composables/TimePickerA11yTest.kt index 16caa657..984bec98 100644 --- a/composables/src/test/kotlin/com/google/android/horologist/composables/TimePickerA11yTest.kt +++ b/composables/src/test/kotlin/com/google/android/horologist/composables/TimePickerA11yTest.kt @@ -14,40 +14,28 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.composables import androidx.compose.ui.test.assertHasClickAction import androidx.compose.ui.test.onNodeWithContentDescription -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test import java.time.LocalTime -class TimePickerA11yTest : ScreenshotBaseTest( - screenshotTestRuleParams { - screenTimeText = {} - enableA11y = true - }, -) { +class TimePickerA11yTest : WearLegacyA11yTest() { @Test fun initial() { - DatePickerA11yTest.enableTouchExploration() + enableTouchExploration() - screenshotTestRule.setContent { + runScreenTest { TimePicker( time = LocalTime.of(10, 10, 0), onTimeConfirm = {}, ) } - screenshotTestRule.interact { - onNodeWithContentDescription("Confirm") - .assertHasClickAction() - } - - screenshotTestRule.takeScreenshot() + composeRule.onNodeWithContentDescription("Confirm") + .assertHasClickAction() } } diff --git a/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest.png b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest.png new file mode 100644 index 00000000..74a004db --- /dev/null +++ b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4aa1dad36cf363a55f4dbc47fc67c62cd55d15e5eca2c886bdb63dcc06cedeb4 +size 34768 diff --git a/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest_2.png b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest_2.png new file mode 100644 index 00000000..9cbb3332 --- /dev/null +++ b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest_2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b091520ee3b2a7c609d30641dfe5ebb7f347a63f07fd6f289ab619a91c6fd64b +size 36542 diff --git a/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest_3.png b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest_3.png new file mode 100644 index 00000000..834425be --- /dev/null +++ b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_interactionTest_3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddff00a324c571b512e8d482ba45531a23e07cd197e292dc3ea479d429e4d0b7 +size 46350 diff --git a/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_screenshot.png b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_screenshot.png index e9da33e0..74a004db 100644 --- a/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_screenshot.png +++ b/composables/src/test/snapshots/images/com.google.android.horologist.composables_DatePickerA11yTest_screenshot.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dea845330891270dbb871a495f49718fb78f8175d4bbb884f0469ea9994259a9 -size 40974 +oid sha256:4aa1dad36cf363a55f4dbc47fc67c62cd55d15e5eca2c886bdb63dcc06cedeb4 +size 34768 diff --git a/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePicker12hA11yTest_initial.png b/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePicker12hA11yTest_initial.png index 532033eb..5d7ffcfb 100644 --- a/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePicker12hA11yTest_initial.png +++ b/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePicker12hA11yTest_initial.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16bcc2671b6b49525a3fe49e7162fc9db8a4cf6d9275535a3d6de3c84b26bda2 -size 40679 +oid sha256:fcc476b3f60dc6007346c4ebf3f6a2ecffb982a0e306f0540e62441dc21f260a +size 39010 diff --git a/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePickerA11yTest_initial.png b/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePickerA11yTest_initial.png index a46f2dec..ed46b946 100644 --- a/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePickerA11yTest_initial.png +++ b/composables/src/test/snapshots/images/com.google.android.horologist.composables_TimePickerA11yTest_initial.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:90a1c037b5476f27e9f1cef92221159513442305f6175f52a09d56401e96ff23 -size 39567 +oid sha256:5d5cc80411b1c8f59d9caeb87562f9603a0c3daa709b3115c135f9d60a7545c1 +size 38245 diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ButtonA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ButtonA11yTest.kt index 398d984d..957ae2d8 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ButtonA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ButtonA11yTest.kt @@ -14,16 +14,10 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.SemanticsActions import androidx.compose.ui.semantics.SemanticsProperties import androidx.compose.ui.test.SemanticsMatcher.Companion.keyIsDefined @@ -31,75 +25,57 @@ import androidx.compose.ui.test.SemanticsMatcher.Companion.keyNotDefined import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertContentDescriptionEquals import androidx.compose.ui.test.assertHasClickAction -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class ButtonA11yTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class ButtonA11yTest : WearLegacyA11yTest() { @Test fun default() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Button( - imageVector = Icons.Default.Check, - contentDescription = "contentDescription", - onClick = { }, - onLongClick = {}, - ) - } + runComponentTest { + Button( + imageVector = Icons.Default.Check, + contentDescription = "contentDescription", + onClick = { }, + onLongClick = {}, + ) } - screenshotTestRule.interact { - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertHasClickAction() - .assert(keyIsDefined(SemanticsActions.OnLongClick)) - .assertContentDescriptionEquals("contentDescription") - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertHasClickAction() + .assert(keyIsDefined(SemanticsActions.OnLongClick)) + .assertContentDescriptionEquals("contentDescription") } @Test fun material() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Button( - imageVector = Icons.Default.Check, - contentDescription = "contentDescription", - onClick = { }, - ) - } + runComponentTest { + Button( + imageVector = Icons.Default.Check, + contentDescription = "contentDescription", + onClick = { }, + ) } - screenshotTestRule.interact { - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertHasClickAction() - .assert(keyNotDefined(SemanticsActions.OnLongClick)) - .assertContentDescriptionEquals("contentDescription") - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertHasClickAction() + .assert(keyNotDefined(SemanticsActions.OnLongClick)) + .assertContentDescriptionEquals("contentDescription") } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Button( - imageVector = Icons.Default.Check, - contentDescription = "contentDescription", - onClick = { }, - enabled = false, - ) - } + runComponentTest { + Button( + imageVector = Icons.Default.Check, + contentDescription = "contentDescription", + onClick = { }, + enabled = false, + ) } - screenshotTestRule.interact { - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertHasClickAction() - .assertContentDescriptionEquals("contentDescription") - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertHasClickAction() + .assertContentDescriptionEquals("contentDescription") } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/CardA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/CardA11yTest.kt index 79e41994..477e3bcb 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/CardA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/CardA11yTest.kt @@ -14,106 +14,83 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.SemanticsProperties import androidx.compose.ui.test.SemanticsMatcher.Companion.keyIsDefined import androidx.compose.ui.test.assertHasClickAction import androidx.compose.ui.test.assertTextEquals import androidx.wear.compose.material.Text -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class CardA11yTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class CardA11yTest : WearLegacyA11yTest() { @Test fun default() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Card( - onClick = { }, - onLongClick = { }, + runComponentTest { + Card( + onClick = { }, + onLongClick = { }, + ) { + Column( + modifier = Modifier.fillMaxWidth(), ) { - Column( - modifier = Modifier.fillMaxWidth(), - ) { - Text("Hello, Card") + Text("Hello, Card") - androidx.wear.compose.material.Button(onClick = { }) { - Text("Click me!") - } + androidx.wear.compose.material.Button(onClick = { }) { + Text("Click me!") } } } } - screenshotTestRule.interact { - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertTextEquals("Click me!") - .assertHasClickAction() - // Not set by combinedClickable -// .assert(keyIsDefined(SemanticsActions.OnLongClick)) - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertTextEquals("Click me!") + .assertHasClickAction() } @Test fun material() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Card( - onClick = { }, + runComponentTest { + Card( + onClick = { }, + ) { + Column( + modifier = Modifier.fillMaxWidth(), ) { - Column( - modifier = Modifier.fillMaxWidth(), - ) { - Text("Hello, Card") + Text("Hello, Card") - androidx.wear.compose.material.Button(onClick = { }) { - Text("Click me!") - } + androidx.wear.compose.material.Button(onClick = { }) { + Text("Click me!") } } } } - screenshotTestRule.interact { - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertTextEquals("Click me!") - .assertHasClickAction() - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertTextEquals("Click me!") + .assertHasClickAction() } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Card( - onClick = {}, - onLongClick = {}, - enabled = false, + runComponentTest { + Card( + onClick = {}, + onLongClick = {}, + enabled = false, + ) { + Column( + modifier = Modifier.fillMaxWidth(), ) { - Column( - modifier = Modifier.fillMaxWidth(), - ) { - Text("Hello, Card") + Text("Hello, Card") - androidx.wear.compose.material.Button(onClick = { }) { - Text("Click me!") - } + androidx.wear.compose.material.Button(onClick = { }) { + Text("Click me!") } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt index f6885299..21351eef 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ChipA11yTest.kt @@ -14,16 +14,10 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Image -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.SemanticsActions import androidx.compose.ui.semantics.SemanticsProperties import androidx.compose.ui.test.SemanticsMatcher.Companion.keyIsDefined @@ -31,76 +25,56 @@ import androidx.compose.ui.test.SemanticsMatcher.Companion.keyNotDefined import androidx.compose.ui.test.assert import androidx.compose.ui.test.assertHasClickAction import androidx.compose.ui.test.assertTextEquals -import androidx.compose.ui.test.onRoot -import androidx.compose.ui.test.printToString import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class ChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class ChipA11yTest : WearLegacyA11yTest() { @Test fun withSecondaryLabelAndIcon() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Chip( - label = "Primary label", - onClick = { }, - onLongClick = {}, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image.asPaintable(), - ) - } + runComponentTest { + Chip( + label = "Primary label", + onClick = { }, + onLongClick = {}, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image.asPaintable(), + ) } - screenshotTestRule.interact { - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertHasClickAction() - .assert(keyIsDefined(SemanticsActions.OnLongClick)) - .assertTextEquals("Primary label, Secondary label") - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertHasClickAction() + .assert(keyIsDefined(SemanticsActions.OnLongClick)) + .assertTextEquals("Primary label, Secondary label") } @Test fun withSecondaryLabelAndIconMaterial() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Chip( - label = "Primary label", - onClick = { }, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image.asPaintable(), - ) - } + runComponentTest { + Chip( + label = "Primary label", + onClick = { }, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image.asPaintable(), + ) } - screenshotTestRule.interact { - println(onRoot().printToString()) - - onNode(keyIsDefined(SemanticsProperties.Role)) - .assertHasClickAction() - .assert(keyNotDefined(SemanticsActions.OnLongClick)) - } + composeRule.onNode(keyIsDefined(SemanticsProperties.Role)) + .assertHasClickAction() + .assert(keyNotDefined(SemanticsActions.OnLongClick)) } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - Chip( - label = "Primary label", - onClick = { }, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image.asPaintable(), - enabled = false, - ) - } + runComponentTest { + Chip( + label = "Primary label", + onClick = { }, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image.asPaintable(), + enabled = false, + ) } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt index 2c5ee6cd..4dc1df52 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/CompactChipA11yTest.kt @@ -14,73 +14,46 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class CompactChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class CompactChipA11yTest : WearLegacyA11yTest() { @Test fun withIcon() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - CompactChip( - label = "Primary label", - onClick = { }, - icon = Icons.Filled.Add.asPaintable(), - ) - } + runComponentTest { + CompactChip( + label = "Primary label", + onClick = { }, + icon = Icons.Filled.Add.asPaintable(), + ) } } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - CompactChip( - label = "Primary label", - onClick = { }, - icon = Icons.Filled.Add.asPaintable(), - enabled = false, - ) - } + runComponentTest { + CompactChip( + label = "Primary label", + onClick = { }, + icon = Icons.Filled.Add.asPaintable(), + enabled = false, + ) } } @Test fun iconOnly() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - CompactChip( - onClick = { }, - icon = Icons.Filled.Add.asPaintable(), - contentDescription = "contentDescription", - ) - } + runComponentTest { + CompactChip( + onClick = { }, + icon = Icons.Filled.Add.asPaintable(), + contentDescription = "contentDescription", + ) } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt index 5dc80245..dce4faec 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedChipA11yTest.kt @@ -14,54 +14,38 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Image -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class OutlinedChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class OutlinedChipA11yTest : WearLegacyA11yTest() { @Test fun withSecondaryLabelAndIcon() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - OutlinedChip( - label = "Primary label", - onClick = { }, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image.asPaintable(), - ) - } + runComponentTest { + OutlinedChip( + label = "Primary label", + onClick = { }, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image.asPaintable(), + ) } } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - OutlinedChip( - label = "Primary label", - onClick = { }, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image.asPaintable(), - enabled = false, - ) - } + runComponentTest { + OutlinedChip( + label = "Primary label", + onClick = { }, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image.asPaintable(), + enabled = false, + ) } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt index bcca1b6b..2804a12c 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/OutlinedCompactChipA11yTest.kt @@ -14,73 +14,46 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class OutlinedCompactChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class OutlinedCompactChipA11yTest : WearLegacyA11yTest() { @Test fun withIcon() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - OutlinedCompactChip( - onClick = { }, - label = "Primary label", - icon = Icons.Filled.Add.asPaintable(), - ) - } + runComponentTest { + OutlinedCompactChip( + onClick = { }, + label = "Primary label", + icon = Icons.Filled.Add.asPaintable(), + ) } } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - OutlinedCompactChip( - onClick = { }, - label = "Primary label", - icon = Icons.Filled.Add.asPaintable(), - enabled = false, - ) - } + runComponentTest { + OutlinedCompactChip( + onClick = { }, + label = "Primary label", + icon = Icons.Filled.Add.asPaintable(), + enabled = false, + ) } } @Test fun iconOnly() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center, - ) { - OutlinedCompactChip( - onClick = { }, - icon = Icons.Filled.Add.asPaintable(), - contentDescription = "contentDescription", - ) - } + runComponentTest { + OutlinedCompactChip( + onClick = { }, + icon = Icons.Filled.Add.asPaintable(), + contentDescription = "contentDescription", + ) } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/SplitToggleChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/SplitToggleChipA11yTest.kt index 4c0b905a..6cce3f60 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/SplitToggleChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/SplitToggleChipA11yTest.kt @@ -14,88 +14,68 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class SplitToggleChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class SplitToggleChipA11yTest : WearLegacyA11yTest() { @Test fun withSecondaryLabel() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - SplitToggleChip( - checked = true, - onCheckedChanged = { }, - label = "Primary label", - onClick = { }, - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - ) - } + runComponentTest { + SplitToggleChip( + checked = true, + onCheckedChanged = { }, + label = "Primary label", + onClick = { }, + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + ) } } @Test fun unchecked() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - SplitToggleChip( - checked = false, - onCheckedChanged = { }, - label = "Primary label", - onClick = { }, - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - ) - } + runComponentTest { + SplitToggleChip( + checked = false, + onCheckedChanged = { }, + label = "Primary label", + onClick = { }, + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + ) } } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - SplitToggleChip( - checked = true, - onCheckedChanged = { }, - label = "Primary label", - onClick = { }, - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - enabled = false, - ) - } + runComponentTest { + SplitToggleChip( + checked = true, + onCheckedChanged = { }, + label = "Primary label", + onClick = { }, + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + enabled = false, + ) } } @Test fun uncheckedAndDisabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - SplitToggleChip( - checked = false, - onCheckedChanged = { }, - label = "Primary label", - onClick = { }, - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - enabled = false, - ) - } + runComponentTest { + SplitToggleChip( + checked = false, + onCheckedChanged = { }, + label = "Primary label", + onClick = { }, + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + enabled = false, + ) } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/StepperA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/StepperA11yTest.kt index 24f96c2c..157101b9 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/StepperA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/StepperA11yTest.kt @@ -14,8 +14,6 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material import androidx.compose.runtime.getValue @@ -24,22 +22,15 @@ import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.wear.compose.material.Text -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test class StepperA11yTest : - ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - record = ScreenshotTestRule.RecordMode.Repair - }, - ) { + WearLegacyA11yTest() { @Test fun float() { - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { var value by remember { mutableFloatStateOf(0f) } @@ -56,7 +47,7 @@ class StepperA11yTest : @Test fun int() { - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { var value by remember { mutableIntStateOf(0) } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt index 69deef82..ec3e9445 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleButtonA11yTest.kt @@ -18,111 +18,89 @@ package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AirplanemodeActive import androidx.compose.material.icons.filled.AirplanemodeInactive -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test class ToggleButtonA11yTest : - ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, - ) { + WearLegacyA11yTest() { @Test fun default() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), - notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), - contentDescription = "contentDescription", - onCheckedChanged = {}, - ) - } + runComponentTest { + ToggleButton( + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), + contentDescription = "contentDescription", + onCheckedChanged = {}, + ) } } @Test fun notChecked() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), - notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), - contentDescription = "contentDescription", - onCheckedChanged = {}, - checked = false, - ) - } + runComponentTest { + ToggleButton( + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), + contentDescription = "contentDescription", + onCheckedChanged = {}, + checked = false, + ) } } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), - notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), - contentDescription = "contentDescription", - onCheckedChanged = {}, - enabled = false, - ) - } + runComponentTest { + ToggleButton( + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), + contentDescription = "contentDescription", + onCheckedChanged = {}, + enabled = false, + ) } } @Test fun notCheckedDisabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), - notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), - contentDescription = "contentDescription", - onCheckedChanged = {}, - checked = false, - enabled = false, - ) - } + runComponentTest { + ToggleButton( + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), + contentDescription = "contentDescription", + onCheckedChanged = {}, + checked = false, + enabled = false, + ) } } @Test fun text() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleButton( - text = "Monday", - onCheckedChanged = {}, - ) - } + runComponentTest { + ToggleButton( + text = "Monday", + onCheckedChanged = {}, + ) } } @Test fun iconOnly() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleButton( - checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), - notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), - contentDescription = "contentDescription", - onCheckedChanged = {}, - colors = ToggleButtonDefaults.iconOnlyColors(), - smallSize = true, - ) - } + runComponentTest { + ToggleButton( + checkedIcon = Icons.Filled.AirplanemodeActive.asPaintable(), + notCheckedIcon = Icons.Filled.AirplanemodeInactive.asPaintable(), + contentDescription = "contentDescription", + onCheckedChanged = {}, + colors = ToggleButtonDefaults.iconOnlyColors(), + smallSize = true, + ) } } } diff --git a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleChipA11yTest.kt b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleChipA11yTest.kt index 9c797a1d..c2235857 100644 --- a/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleChipA11yTest.kt +++ b/compose-material/src/test/java/com/google/android/horologist/compose/material/ToggleChipA11yTest.kt @@ -14,90 +14,70 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.compose.material -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Image -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class ToggleChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class ToggleChipA11yTest : WearLegacyA11yTest() { @Test fun withSecondaryLabelAndIcon() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleChip( - checked = true, - onCheckedChanged = { }, - label = "Primary label", - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image, - ) - } + runComponentTest { + ToggleChip( + checked = true, + onCheckedChanged = { }, + label = "Primary label", + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image, + ) } } @Test fun unchecked() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleChip( - checked = false, - onCheckedChanged = { }, - label = "Primary label", - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image, - ) - } + runComponentTest { + ToggleChip( + checked = false, + onCheckedChanged = { }, + label = "Primary label", + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image, + ) } } @Test fun disabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleChip( - checked = true, - onCheckedChanged = { }, - label = "Primary label", - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image, - enabled = false, - ) - } + runComponentTest { + ToggleChip( + checked = true, + onCheckedChanged = { }, + label = "Primary label", + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image, + enabled = false, + ) } } @Test fun uncheckedAndDisabled() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ToggleChip( - checked = false, - onCheckedChanged = { }, - label = "Primary label", - toggleControl = ToggleChipToggleControl.Switch, - secondaryLabel = "Secondary label", - icon = Icons.Default.Image, - enabled = false, - ) - } + runComponentTest { + ToggleChip( + checked = false, + onCheckedChanged = { }, + label = "Primary label", + toggleControl = ToggleChipToggleControl.Switch, + secondaryLabel = "Secondary label", + icon = Icons.Default.Image, + enabled = false, + ) } } } diff --git a/gradle.properties b/gradle.properties index e2cb5625..9eba7019 100644 --- a/gradle.properties +++ b/gradle.properties @@ -61,6 +61,5 @@ dependency.analysis.autoapply=false android.suppressUnsupportedCompileSdk=34 # Uncomment to enable record mode -#screenshot.record=repair #roborazzi.test.verify=true #roborazzi.test.record=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b2c2da96..5b616d12 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -49,7 +49,7 @@ ktlint = "0.50.0" metalava = "0.3.5" moshi = "1.15.1" okio = "3.9.0" -org-robolectric = "4.11.1" +org-robolectric = "4.12.1" playServicesAuth = "21.0.0" protobuf = "4.26.1" roborazzi = "1.11.0" @@ -141,6 +141,7 @@ annotation = { module = "androidx.test:annotation", version.ref = "annotation" } coil = { module = "io.coil-kt:coil-compose", version.ref = "io-coil-kt" } coil-base = { module = "io.coil-kt:coil-compose-base", version.ref = "io-coil-kt" } coil-svg = { module = "io.coil-kt:coil-svg", version.ref = "io-coil-kt" } +coil-test = { module = "io.coil-kt:coil-test", version.ref = "io-coil-kt" } com-squareup-okhttp3-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "com-squareup-okhttp3" } com-squareup-okhttp3-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "com-squareup-okhttp3" } com-squareup-okhttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "com-squareup-okhttp3" } @@ -203,11 +204,11 @@ robolectric = { module = "org.robolectric:robolectric", version.ref = "org-robol robolectric-shadows = { module = "org.robolectric:shadows-framework", version.ref = "org-robolectric" } roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", version.ref = "roborazzi" } roborazzi-compose = { group = "io.github.takahirom.roborazzi", name = "roborazzi-compose", version.ref = "roborazzi" } +roborazzi-painter = { group = "io.github.takahirom.roborazzi", name = "roborazzi-painter", version.ref = "roborazzi" } roborazzi-rule = { group = "io.github.takahirom.roborazzi", name = "roborazzi-junit-rule", version.ref = "roborazzi" } room-common = { module = "androidx.room:room-common", version.ref = "room" } room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" } room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" } -snapshot-android = { module = "com.github.QuickBirdEng.kotlin-snapshot-testing:snapshot-android", version.ref = "snapshot-android" } truth = { module = "com.google.truth:truth", version.ref = "truth" } turbine = { module = "app.cash.turbine:turbine", version.ref = "app-cash-turbine" } wearcompose-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "wearcompose" } diff --git a/health/composables/src/test/java/com/google/android/horologist/health/composables/components/MetricDisplayA11yTest.kt b/health/composables/src/test/java/com/google/android/horologist/health/composables/components/MetricDisplayA11yTest.kt index 5c9c0d3e..67361c59 100644 --- a/health/composables/src/test/java/com/google/android/horologist/health/composables/components/MetricDisplayA11yTest.kt +++ b/health/composables/src/test/java/com/google/android/horologist/health/composables/components/MetricDisplayA11yTest.kt @@ -14,61 +14,45 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.health.composables.components -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import androidx.compose.ui.unit.LayoutDirection import com.google.accompanist.testharness.TestHarness import com.google.android.horologist.health.composables.model.MetricUiModel import com.google.android.horologist.health.composables.theme.HR_HARD import com.google.android.horologist.health.composables.theme.HR_MODERATE -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class MetricDisplayA11yTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class MetricDisplayA11yTest : WearLegacyA11yTest() { @Test fun metricDisplay() { - screenshotTestRule.setContent(takeScreenshot = true) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { + runComponentTest { + MetricDisplay( + metric = MetricUiModel( + text = "139", + topRightText = "Vigorous", + bottomRightText = "bpm", + color = HR_MODERATE, + ), + ) + } + } + + @Test + fun rtl() { + runComponentTest { + TestHarness(layoutDirection = LayoutDirection.Rtl) { MetricDisplay( metric = MetricUiModel( text = "139", topRightText = "Vigorous", bottomRightText = "bpm", - color = HR_MODERATE, + color = HR_HARD, ), ) } } } - - @Test - fun rtl() { - screenshotTestRule.setContent(takeScreenshot = true) { - TestHarness(layoutDirection = LayoutDirection.Rtl) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - MetricDisplay( - metric = MetricUiModel( - text = "139", - topRightText = "Vigorous", - bottomRightText = "bpm", - color = HR_HARD, - ), - ) - } - } - } - } } diff --git a/health/composables/src/test/java/com/google/android/horologist/health/composables/screens/MetricsScreenA11yTest.kt b/health/composables/src/test/java/com/google/android/horologist/health/composables/screens/MetricsScreenA11yTest.kt index 21bf1d00..bbb665aa 100644 --- a/health/composables/src/test/java/com/google/android/horologist/health/composables/screens/MetricsScreenA11yTest.kt +++ b/health/composables/src/test/java/com/google/android/horologist/health/composables/screens/MetricsScreenA11yTest.kt @@ -14,28 +14,20 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.health.composables.screens import androidx.compose.ui.unit.LayoutDirection import com.google.accompanist.testharness.TestHarness import com.google.android.horologist.health.composables.model.MetricUiModel import com.google.android.horologist.health.composables.theme.HR_MAXIMUM -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class MetricsScreenA11yTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class MetricsScreenA11yTest : WearLegacyA11yTest() { @Test fun metricsScreenTwoMetrics() { - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { MetricsScreen( firstMetric = MetricUiModel( text = "198", @@ -52,7 +44,7 @@ class MetricsScreenA11yTest : ScreenshotBaseTest( @Test fun metricsScreenTwoMetrics_rtl() { - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { TestHarness(layoutDirection = LayoutDirection.Rtl) { MetricsScreen( firstMetric = MetricUiModel( diff --git a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_metricDisplay.png b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_metricDisplay.png index 6c7c1c78..7cb0a5fb 100644 --- a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_metricDisplay.png +++ b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_metricDisplay.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:53c3eb0bc4fcfe43c36a9558abe4ddcc725f4d4c1f6cae1ea11462e142749411 -size 18182 +oid sha256:fbe6bb74f76b40726d4a069c7891c1a5944191fc56948d21505dcfb5a5a17481 +size 23258 diff --git a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_rtl.png b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_rtl.png index b1cf18d4..d2d81791 100644 --- a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_rtl.png +++ b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.components_MetricDisplayA11yTest_rtl.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b573729472c02d1c8d1cfc6639ab60e298bd7bd75af53c89f4b81b75c8c2e89b -size 18070 +oid sha256:81616f5bdab3b1d7a953a7235dddbbf3c847aece30d82c5c271628eff7bc8894 +size 23046 diff --git a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics.png b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics.png index 6a0c8515..657d9dda 100644 --- a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics.png +++ b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76fe63af17ef8ce85bee693bbcc0c8553a5681a6f5a0f36bf7f1a6ccc06169c0 -size 18684 +oid sha256:da72df4228e271c4f3124c5b8d54869eeeedf4868801aa0b66e00b02e2f6fcaf +size 28682 diff --git a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics_rtl.png b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics_rtl.png index e1ac8eb6..649658e1 100644 --- a/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics_rtl.png +++ b/health/composables/src/test/snapshots/images/com.google.android.horologist.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics_rtl.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6af7cd6b072cfcf2e1f636f7233c19e5dcb049581af1be24050eb79d4f46ac20 -size 18692 +oid sha256:d80e21d35763768d0b7b3a6903ab1ee2c089d9b43fa9c27c8be0a7101d163f17 +size 28568 diff --git a/media/audio-ui/src/test/kotlin/com/google/android/horologist/audio/ui/VolumeScreenA11yScreenshotTest.kt b/media/audio-ui/src/test/kotlin/com/google/android/horologist/audio/ui/VolumeScreenA11yScreenshotTest.kt index 865d93f7..7db03f66 100644 --- a/media/audio-ui/src/test/kotlin/com/google/android/horologist/audio/ui/VolumeScreenA11yScreenshotTest.kt +++ b/media/audio-ui/src/test/kotlin/com/google/android/horologist/audio/ui/VolumeScreenA11yScreenshotTest.kt @@ -14,23 +14,15 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.audio.ui import androidx.wear.compose.material.MaterialTheme import com.google.android.horologist.audio.AudioOutput import com.google.android.horologist.audio.VolumeState -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class VolumeScreenA11yScreenshotTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - screenTimeText = { } - }, -) { +class VolumeScreenA11yScreenshotTest : WearLegacyA11yTest() { @Test fun volumeScreenAtMinimums() { @@ -40,7 +32,7 @@ class VolumeScreenA11yScreenshotTest : ScreenshotBaseTest( ) val audioOutput = AudioOutput.BluetoothHeadset("id", "Pixelbuds") - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { VolumeScreenTestCase( colors = MaterialTheme.colors, volumeState = volumeState, @@ -58,7 +50,7 @@ class VolumeScreenA11yScreenshotTest : ScreenshotBaseTest( // Media Router returns "Phone" val audioOutput = AudioOutput.WatchSpeaker("id", "Phone", false) - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { VolumeScreenTestCase( colors = MaterialTheme.colors, volumeState = volumeState, diff --git a/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenAtMinimums.png b/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenAtMinimums.png index 0dedaf85..72b467fc 100644 --- a/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenAtMinimums.png +++ b/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenAtMinimums.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:79d5aaff7b690e4d7d060514ae299ae3ee2f75e10d7fc23002bf0ec28093eb19 -size 53202 +oid sha256:df740ef93e5fed00b697204c610f65c286a38baed604566b20895a5957497e02 +size 43035 diff --git a/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenNotConnected.png b/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenNotConnected.png index 2bd83142..a2100038 100644 --- a/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenNotConnected.png +++ b/media/audio-ui/src/test/snapshots/images/com.google.android.horologist.audio.ui_VolumeScreenA11yScreenshotTest_volumeScreenNotConnected.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:30e277e313b13a725fad13cf2cdcab17f8d56ac630017a748b674e48c9b8012a -size 53349 +oid sha256:3452c7e7bab9fc8ce0c98c5ed7c50a7a947818dcc847bcea7bcc1d42f08a3c92 +size 43753 diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/app/UampWearApp.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/app/UampWearApp.kt index df14c7e9..e77ffe02 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/app/UampWearApp.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/app/UampWearApp.kt @@ -94,63 +94,51 @@ fun UampWearApp( ) }, libraryScreen = { - val columnState = rememberColumnState() - - ScreenScaffold(scrollState = columnState) { - if (appState.streamingMode == true) { - UampStreamingBrowseScreen( - onPlaylistsClick = { navController.navigateToCollections() }, - onSettingsClick = { navController.navigateToSettings() }, - columnState = columnState, - ) - } else { - UampBrowseScreen( - uampBrowseScreenViewModel = hiltViewModel(), - onDownloadItemClick = { - navController.navigateToCollection( - it.playlistUiModel.id, - it.playlistUiModel.title, - ) - }, - onPlaylistsClick = { navController.navigateToCollections() }, - onSettingsClick = { navController.navigateToSettings() }, - columnState = columnState, - ) - } + if (appState.streamingMode == true) { + UampStreamingBrowseScreen( + onPlaylistsClick = { navController.navigateToCollections() }, + onSettingsClick = { navController.navigateToSettings() }, + ) + } else { + UampBrowseScreen( + uampBrowseScreenViewModel = hiltViewModel(), + onDownloadItemClick = { + navController.navigateToCollection( + it.playlistUiModel.id, + it.playlistUiModel.title, + ) + }, + onPlaylistsClick = { navController.navigateToCollections() }, + onSettingsClick = { navController.navigateToSettings() }, + ) } }, categoryEntityScreen = { _, name -> - val columnState = rememberColumnState() - - ScreenScaffold(scrollState = columnState) { - if (appState.streamingMode == true) { - val viewModel: UampStreamingPlaylistScreenViewModel = hiltViewModel() + if (appState.streamingMode == true) { + val viewModel: UampStreamingPlaylistScreenViewModel = hiltViewModel() - UampStreamingPlaylistScreen( - playlistName = name, - viewModel = viewModel, - onDownloadItemClick = { - navController.navigateToPlayer() - }, - onShuffleClick = { navController.navigateToPlayer() }, - onPlayClick = { navController.navigateToPlayer() }, - columnState = columnState, - ) - } else { - val uampEntityScreenViewModel: UampEntityScreenViewModel = hiltViewModel() + UampStreamingPlaylistScreen( + playlistName = name, + viewModel = viewModel, + onDownloadItemClick = { + navController.navigateToPlayer() + }, + onShuffleClick = { navController.navigateToPlayer() }, + onPlayClick = { navController.navigateToPlayer() }, + ) + } else { + val uampEntityScreenViewModel: UampEntityScreenViewModel = hiltViewModel() - UampEntityScreen( - playlistName = name, - uampEntityScreenViewModel = uampEntityScreenViewModel, - onDownloadItemClick = { - navController.navigateToPlayer() - }, - onShuffleClick = { navController.navigateToPlayer() }, - onPlayClick = { navController.navigateToPlayer() }, - onErrorDialogCancelClick = { navController.popBackStack() }, - columnState = columnState, - ) - } + UampEntityScreen( + playlistName = name, + uampEntityScreenViewModel = uampEntityScreenViewModel, + onDownloadItemClick = { + navController.navigateToPlayer() + }, + onShuffleClick = { navController.navigateToPlayer() }, + onPlayClick = { navController.navigateToPlayer() }, + onErrorDialogCancelClick = { navController.popBackStack() }, + ) } }, mediaEntityScreen = { @@ -162,32 +150,22 @@ fun UampWearApp( val uampPlaylistsScreenViewModel: UampPlaylistsScreenViewModel = hiltViewModel() - val columnState = rememberColumnState() - - ScreenScaffold(scrollState = columnState) { - UampPlaylistsScreen( - uampPlaylistsScreenViewModel = uampPlaylistsScreenViewModel, - onPlaylistItemClick = { playlistUiModel -> - navController.navigateToCollection( - playlistUiModel.id, - playlistUiModel.title, - ) - }, - onErrorDialogCancelClick = { navController.popBackStack() }, - columnState = columnState, - ) - } + UampPlaylistsScreen( + uampPlaylistsScreenViewModel = uampPlaylistsScreenViewModel, + onPlaylistItemClick = { playlistUiModel -> + navController.navigateToCollection( + playlistUiModel.id, + playlistUiModel.title, + ) + }, + onErrorDialogCancelClick = { navController.popBackStack() }, + ) }, settingsScreen = { - val columnState = rememberColumnState() - - ScreenScaffold(scrollState = columnState) { - UampSettingsScreen( - columnState = columnState, - viewModel = hiltViewModel(), - navController = navController, - ) - } + UampSettingsScreen( + viewModel = hiltViewModel(), + navController = navController, + ) }, navHostState = navHostState, snackbarViewModel = hiltViewModel<SnackbarViewModel>(), @@ -253,15 +231,10 @@ fun UampWearApp( composable( route = GoogleSignInPromptScreen.navRoute, ) { - val columnState = rememberColumnState() - - ScreenScaffold(scrollState = columnState) { - GoogleSignInPromptScreen( - navController = navController, - columnState = columnState, - viewModel = hiltViewModel(), - ) - } + GoogleSignInPromptScreen( + navController = navController, + viewModel = hiltViewModel(), + ) } composable(route = GoogleSignInScreen.navRoute) { diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/auth/prompt/GoogleSignInPromptScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/auth/prompt/GoogleSignInPromptScreen.kt index 4de2a2a1..59296a9f 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/auth/prompt/GoogleSignInPromptScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/auth/prompt/GoogleSignInPromptScreen.kt @@ -32,6 +32,7 @@ import com.google.android.horologist.auth.composables.chips.GuestModeChip import com.google.android.horologist.auth.composables.chips.SignInChip import com.google.android.horologist.auth.ui.common.screens.prompt.SignInPromptScreen import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.compose.material.Confirmation import com.google.android.horologist.mediasample.R import com.google.android.horologist.mediasample.ui.navigation.navigateToGoogleSignIn @@ -39,7 +40,7 @@ import com.google.android.horologist.mediasample.ui.navigation.navigateToGoogleS @Composable fun GoogleSignInPromptScreen( navController: NavHostController, - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), modifier: Modifier = Modifier, viewModel: UampSignInPromptViewModel, ) { diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampBrowseScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampBrowseScreen.kt index 39ceda9e..ab4a41b4 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampBrowseScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampBrowseScreen.kt @@ -22,13 +22,14 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.media.ui.screens.browse.PlaylistDownloadBrowseScreen import com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel import com.google.android.horologist.mediasample.R @Composable fun UampBrowseScreen( - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), uampBrowseScreenViewModel: UampBrowseScreenViewModel, onDownloadItemClick: (PlaylistDownloadUiModel) -> Unit, onPlaylistsClick: () -> Unit, diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampStreamingBrowseScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampStreamingBrowseScreen.kt index a693f5c6..86456304 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampStreamingBrowseScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/browse/UampStreamingBrowseScreen.kt @@ -22,13 +22,14 @@ import androidx.compose.material.icons.filled.Settings import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.media.ui.R import com.google.android.horologist.media.ui.screens.browse.BrowseScreen import com.google.android.horologist.media.ui.screens.browse.BrowseScreenPlaylistsSectionButton @Composable fun UampStreamingBrowseScreen( - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), onPlaylistsClick: () -> Unit, onSettingsClick: () -> Unit, modifier: Modifier = Modifier, diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampEntityScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampEntityScreen.kt index d28b9add..c9db8485 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampEntityScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampEntityScreen.kt @@ -41,6 +41,7 @@ import androidx.wear.compose.material.Text import androidx.wear.compose.material.dialog.Alert import androidx.wear.compose.material.dialog.Dialog import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.compose.material.AlertDialog import com.google.android.horologist.media.ui.screens.entity.PlaylistDownloadScreen import com.google.android.horologist.media.ui.screens.entity.PlaylistDownloadScreenState @@ -50,7 +51,7 @@ import com.google.android.horologist.mediasample.R @Composable fun UampEntityScreen( - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), playlistName: String, uampEntityScreenViewModel: UampEntityScreenViewModel, onDownloadItemClick: (DownloadMediaUiModel) -> Unit, diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampStreamingPlaylistScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampStreamingPlaylistScreen.kt index 0ea9de08..411dc9f7 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampStreamingPlaylistScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/entity/UampStreamingPlaylistScreen.kt @@ -20,13 +20,14 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.media.ui.screens.entity.PlaylistStreamingScreen import com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel import com.google.android.horologist.media.ui.state.model.PlaylistUiModel @Composable fun UampStreamingPlaylistScreen( - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), playlistName: String, viewModel: UampStreamingPlaylistScreenViewModel, onDownloadItemClick: (DownloadMediaUiModel) -> Unit, diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/playlists/UampPlaylistsScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/playlists/UampPlaylistsScreen.kt index 53e48877..2b9ca30f 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/playlists/UampPlaylistsScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/playlists/UampPlaylistsScreen.kt @@ -38,6 +38,7 @@ import androidx.wear.compose.material.Text import androidx.wear.compose.material.dialog.Alert import androidx.wear.compose.material.dialog.Dialog import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.media.ui.screens.playlists.PlaylistsScreen import com.google.android.horologist.media.ui.screens.playlists.PlaylistsScreenState import com.google.android.horologist.media.ui.state.model.PlaylistUiModel @@ -45,7 +46,7 @@ import com.google.android.horologist.mediasample.R @Composable fun UampPlaylistsScreen( - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), uampPlaylistsScreenViewModel: UampPlaylistsScreenViewModel, onPlaylistItemClick: (PlaylistUiModel) -> Unit, onErrorDialogCancelClick: () -> Unit, diff --git a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/settings/UampSettingsScreen.kt b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/settings/UampSettingsScreen.kt index 8be2952c..9da84bfe 100644 --- a/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/settings/UampSettingsScreen.kt +++ b/media/sample/src/main/java/com/google/android/horologist/mediasample/ui/settings/UampSettingsScreen.kt @@ -38,6 +38,8 @@ import androidx.wear.compose.material.ToggleChip import androidx.wear.compose.material.ToggleChipDefaults import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.ScreenScaffold +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.compose.material.Chip import com.google.android.horologist.mediasample.R import com.google.android.horologist.mediasample.ui.navigation.navigateToDeveloperOptions @@ -46,55 +48,57 @@ import com.google.android.horologist.mediasample.ui.navigation.navigateToGoogleS @Composable fun UampSettingsScreen( - columnState: ScalingLazyColumnState, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), viewModel: SettingsScreenViewModel, navController: NavHostController, modifier: Modifier = Modifier, ) { val screenState by viewModel.screenState.collectAsStateWithLifecycle() - ScalingLazyColumn( - columnState = columnState, - modifier = modifier, - ) { - item { - ListHeader { - Text(text = stringResource(id = R.string.sample_settings)) - } - } - item { - if (screenState.authUser == null) { - Chip( - label = stringResource(id = R.string.login), - modifier = Modifier.fillMaxWidth(), - onClick = { navController.navigateToGoogleSignIn() }, - enabled = !screenState.guestMode, - ) - } else { - Chip( - label = stringResource(id = R.string.logout), - modifier = Modifier.fillMaxWidth(), - onClick = { navController.navigateToGoogleSignOutScreen() }, - ) + ScreenScaffold(scrollState = columnState) { + ScalingLazyColumn( + columnState = columnState, + modifier = modifier, + ) { + item { + ListHeader { + Text(text = stringResource(id = R.string.sample_settings)) + } } - } - item { - CheckedSetting( - screenState.guestMode, - stringResource(id = R.string.sample_guest_mode), - enabled = screenState.writable, - ) { - viewModel.setGuestMode(it) + item { + if (screenState.authUser == null) { + Chip( + label = stringResource(id = R.string.login), + modifier = Modifier.fillMaxWidth(), + onClick = { navController.navigateToGoogleSignIn() }, + enabled = !screenState.guestMode, + ) + } else { + Chip( + label = stringResource(id = R.string.logout), + modifier = Modifier.fillMaxWidth(), + onClick = { navController.navigateToGoogleSignOutScreen() }, + ) + } } - } - if (screenState.showDeveloperOptions) { item { - ActionSetting( - text = stringResource(id = R.string.sample_developer_options), - icon = Icons.Default.DataObject, - colors = ChipDefaults.secondaryChipColors(), - onClick = { navController.navigateToDeveloperOptions() }, - ) + CheckedSetting( + screenState.guestMode, + stringResource(id = R.string.sample_guest_mode), + enabled = screenState.writable, + ) { + viewModel.setGuestMode(it) + } + } + if (screenState.showDeveloperOptions) { + item { + ActionSetting( + text = stringResource(id = R.string.sample_developer_options), + icon = Icons.Default.DataObject, + colors = ChipDefaults.secondaryChipColors(), + onClick = { navController.navigateToDeveloperOptions() }, + ) + } } } } diff --git a/media/ui/api/current.api b/media/ui/api/current.api index a35837d8..eba90f67 100644 --- a/media/ui/api/current.api +++ b/media/ui/api/current.api @@ -370,7 +370,7 @@ package com.google.android.horologist.media.ui.screens.browse { } public final class PlaylistDownloadBrowseScreenKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void PlaylistDownloadBrowseScreen(com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, com.google.android.horologist.media.ui.screens.browse.BrowseScreenState browseScreenState, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel,kotlin.Unit> onDownloadItemClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel,kotlin.Unit> onDownloadItemInProgressClick, kotlin.jvm.functions.Function0<kotlin.Unit> onPlaylistsClick, kotlin.jvm.functions.Function0<kotlin.Unit> onSettingsClick, optional androidx.compose.ui.Modifier modifier, optional androidx.compose.ui.graphics.painter.Painter? downloadItemArtworkPlaceholder, optional String? onDownloadItemInProgressClickActionLabel); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void PlaylistDownloadBrowseScreen(com.google.android.horologist.media.ui.screens.browse.BrowseScreenState browseScreenState, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel,kotlin.Unit> onDownloadItemClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel,kotlin.Unit> onDownloadItemInProgressClick, kotlin.jvm.functions.Function0<kotlin.Unit> onPlaylistsClick, kotlin.jvm.functions.Function0<kotlin.Unit> onSettingsClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, optional androidx.compose.ui.graphics.painter.Painter? downloadItemArtworkPlaceholder, optional String? onDownloadItemInProgressClickActionLabel); } } @@ -404,7 +404,7 @@ package com.google.android.horologist.media.ui.screens.entity { } public final class PlaylistDownloadScreenKt { - method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void PlaylistDownloadScreen(com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, String playlistName, com.google.android.horologist.media.ui.screens.entity.PlaylistDownloadScreenState<com.google.android.horologist.media.ui.state.model.PlaylistUiModel,? extends com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel> playlistDownloadScreenState, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onDownloadButtonClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onCancelDownloadButtonClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel,kotlin.Unit> onDownloadItemClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel,kotlin.Unit> onDownloadItemInProgressClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onShuffleButtonClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onPlayButtonClick, optional androidx.compose.ui.Modifier modifier, optional kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit>? onDownloadCompletedButtonClick, optional String defaultMediaTitle, optional androidx.compose.ui.graphics.painter.Painter? downloadItemArtworkPlaceholder, optional String? onDownloadItemInProgressClickActionLabel); + method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void PlaylistDownloadScreen(String playlistName, com.google.android.horologist.media.ui.screens.entity.PlaylistDownloadScreenState<com.google.android.horologist.media.ui.state.model.PlaylistUiModel,? extends com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel> playlistDownloadScreenState, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onDownloadButtonClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onCancelDownloadButtonClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel,kotlin.Unit> onDownloadItemClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel,kotlin.Unit> onDownloadItemInProgressClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onShuffleButtonClick, kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit> onPlayButtonClick, optional androidx.compose.ui.Modifier modifier, optional com.google.android.horologist.compose.layout.ScalingLazyColumnState columnState, optional kotlin.jvm.functions.Function1<? super com.google.android.horologist.media.ui.state.model.PlaylistUiModel,kotlin.Unit>? onDownloadCompletedButtonClick, optional String defaultMediaTitle, optional androidx.compose.ui.graphics.painter.Painter? downloadItemArtworkPlaceholder, optional String? onDownloadItemInProgressClickActionLabel); method @com.google.android.horologist.annotations.ExperimentalHorologistApi public static com.google.android.horologist.media.ui.screens.entity.PlaylistDownloadScreenState.Loaded<com.google.android.horologist.media.ui.state.model.PlaylistUiModel,com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel> createPlaylistDownloadScreenStateLoaded(com.google.android.horologist.media.ui.state.model.PlaylistUiModel playlistModel, java.util.List<? extends com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel> downloadMediaList); } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt index d9fbf8a0..5ffdb690 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/BrowseScreen.kt @@ -34,6 +34,7 @@ import com.google.android.horologist.composables.Section.Companion.LOADED_STATE_ import com.google.android.horologist.composables.SectionContentScope import com.google.android.horologist.composables.SectionedList import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.ScreenScaffold import com.google.android.horologist.compose.material.Chip import com.google.android.horologist.compose.material.Title import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable @@ -58,11 +59,13 @@ public fun BrowseScreen( modifier: Modifier = Modifier, content: BrowseScreenScope.() -> Unit, ) { - SectionedList( - columnState = columnState, - modifier = modifier, - sections = BrowseScreenScope().apply(content).sections, - ) + ScreenScaffold(scrollState = columnState) { + SectionedList( + columnState = columnState, + modifier = modifier, + sections = BrowseScreenScope().apply(content).sections, + ) + } } /** diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt index 74a54d9c..9aea3fe0 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreen.kt @@ -31,6 +31,7 @@ import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.composables.PlaceholderChip import com.google.android.horologist.composables.Section import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.compose.material.Chip import com.google.android.horologist.images.base.paintable.ImageVectorPaintable.Companion.asPaintable import com.google.android.horologist.images.coil.CoilPaintable @@ -43,13 +44,13 @@ import com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiMode @ExperimentalHorologistApi @Composable public fun PlaylistDownloadBrowseScreen( - columnState: ScalingLazyColumnState, browseScreenState: BrowseScreenState, onDownloadItemClick: (PlaylistDownloadUiModel) -> Unit, onDownloadItemInProgressClick: (PlaylistDownloadUiModel) -> Unit, onPlaylistsClick: () -> Unit, onSettingsClick: () -> Unit, modifier: Modifier = Modifier, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), downloadItemArtworkPlaceholder: Painter? = null, onDownloadItemInProgressClickActionLabel: String? = null, ) { @@ -83,7 +84,10 @@ public fun PlaylistDownloadBrowseScreen( Chip( label = download.playlistUiModel.title, onClick = { onDownloadItemClick(download) }, - icon = CoilPaintable(download.playlistUiModel.artworkUri, downloadItemArtworkPlaceholder), + icon = CoilPaintable( + download.playlistUiModel.artworkUri, + downloadItemArtworkPlaceholder, + ), largeIcon = true, colors = ChipDefaults.secondaryChipColors(), ) diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/EntityScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/EntityScreen.kt index ef49b847..2b551413 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/EntityScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/EntityScreen.kt @@ -24,6 +24,7 @@ import androidx.wear.compose.foundation.lazy.ScalingLazyListScope import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.compose.layout.ScalingLazyColumn import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.ScreenScaffold import com.google.android.horologist.compose.material.Title /** @@ -38,22 +39,24 @@ public fun EntityScreen( buttonsContent: (@Composable () -> Unit)? = null, content: (ScalingLazyListScope.() -> Unit)? = null, ) { - ScalingLazyColumn( - columnState = columnState, - modifier = modifier, - ) { - item { - headerContent() - } - - buttonsContent?.let { + ScreenScaffold(scrollState = columnState) { + ScalingLazyColumn( + columnState = columnState, + modifier = modifier, + ) { item { - buttonsContent() + headerContent() + } + + buttonsContent?.let { + item { + buttonsContent() + } } - } - content?.let { - content() + content?.let { + content() + } } } } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt index 43e345f8..a86d5257 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreen.kt @@ -43,7 +43,6 @@ import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.clearAndSetSemantics -import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.onClick import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp @@ -56,6 +55,7 @@ import androidx.wear.compose.material.ProgressIndicatorDefaults import com.google.android.horologist.annotations.ExperimentalHorologistApi import com.google.android.horologist.composables.PlaceholderChip import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.rememberResponsiveColumnState import com.google.android.horologist.compose.material.Button import com.google.android.horologist.compose.material.ButtonSize import com.google.android.horologist.compose.material.Chip @@ -75,7 +75,6 @@ import com.google.android.horologist.media.ui.util.ifNan @ExperimentalHorologistApi @Composable public fun PlaylistDownloadScreen( - columnState: ScalingLazyColumnState, playlistName: String, playlistDownloadScreenState: PlaylistDownloadScreenState<PlaylistUiModel, DownloadMediaUiModel>, onDownloadButtonClick: (PlaylistUiModel) -> Unit, @@ -85,6 +84,7 @@ public fun PlaylistDownloadScreen( onShuffleButtonClick: (PlaylistUiModel) -> Unit, onPlayButtonClick: (PlaylistUiModel) -> Unit, modifier: Modifier = Modifier, + columnState: ScalingLazyColumnState = rememberResponsiveColumnState(), onDownloadCompletedButtonClick: ((PlaylistUiModel) -> Unit)? = null, defaultMediaTitle: String = "", downloadItemArtworkPlaceholder: Painter? = null, @@ -181,7 +181,10 @@ private fun MediaContent( label = mediaTitle, onClick = { onDownloadItemClick(downloadMediaUiModel) }, secondaryLabel = secondaryLabel, - icon = CoilPaintable(downloadMediaUiModel.artworkUri, downloadItemArtworkPlaceholder), + icon = CoilPaintable( + downloadMediaUiModel.artworkUri, + downloadItemArtworkPlaceholder, + ), largeIcon = true, colors = ChipDefaults.secondaryChipColors(), enabled = downloadMediaUiModel !is DownloadMediaUiModel.NotDownloaded, @@ -201,7 +204,10 @@ private fun MediaContent( ChipIconWithProgress( progress = progress, modifier = Modifier.clearAndSetSemantics { }, - icon = CoilPaintable(downloadMediaUiModel.artworkUri, downloadItemArtworkPlaceholder), + icon = CoilPaintable( + downloadMediaUiModel.artworkUri, + downloadItemArtworkPlaceholder, + ), largeIcon = true, ) } @@ -211,7 +217,10 @@ private fun MediaContent( { ChipIconWithProgress( modifier = Modifier.clearAndSetSemantics { }, - icon = CoilPaintable(downloadMediaUiModel.artworkUri, downloadItemArtworkPlaceholder), + icon = CoilPaintable( + downloadMediaUiModel.artworkUri, + downloadItemArtworkPlaceholder, + ), largeIcon = true, ) } diff --git a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt index e8d6eeea..4a139e1a 100644 --- a/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt +++ b/media/ui/src/main/java/com/google/android/horologist/media/ui/screens/playlists/PlaylistsScreen.kt @@ -28,6 +28,7 @@ import com.google.android.horologist.composables.PlaceholderChip import com.google.android.horologist.composables.Section import com.google.android.horologist.composables.SectionedList import com.google.android.horologist.compose.layout.ScalingLazyColumnState +import com.google.android.horologist.compose.layout.ScreenScaffold import com.google.android.horologist.compose.material.Chip import com.google.android.horologist.compose.material.Title import com.google.android.horologist.images.coil.CoilPaintable @@ -58,32 +59,34 @@ public fun <T> PlaylistsScreen( playlistContent: @Composable (playlist: T) -> Unit, modifier: Modifier = Modifier, ) { - SectionedList( - modifier = modifier, - columnState = columnState, - ) { - val sectionState = when (playlistsScreenState) { - is PlaylistsScreenState.Loaded<T> -> { - Section.State.Loaded(playlistsScreenState.playlistList) - } - - PlaylistsScreenState.Failed -> Section.State.Failed - PlaylistsScreenState.Loading -> Section.State.Loading - } + ScreenScaffold(scrollState = columnState) { + SectionedList( + modifier = modifier, + columnState = columnState, + ) { + val sectionState = when (playlistsScreenState) { + is PlaylistsScreenState.Loaded<T> -> { + Section.State.Loaded(playlistsScreenState.playlistList) + } - section(state = sectionState) { - header { - Title( - R.string.horologist_browse_playlist_title, - Modifier.padding(bottom = 12.dp), - ) + PlaylistsScreenState.Failed -> Section.State.Failed + PlaylistsScreenState.Loading -> Section.State.Loading } - loaded { playlistContent(it) } + section(state = sectionState) { + header { + Title( + R.string.horologist_browse_playlist_title, + Modifier.padding(bottom = 12.dp), + ) + } + + loaded { playlistContent(it) } - loading(count = 4) { - Column { - PlaceholderChip(colors = ChipDefaults.secondaryChipColors()) + loading(count = 4) { + Column { + PlaceholderChip(colors = ChipDefaults.secondaryChipColors()) + } } } } diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerA11yScreenshotTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerA11yScreenshotTest.kt index 80c674e8..54acd7cd 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerA11yScreenshotTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/MediaPlayerA11yScreenshotTest.kt @@ -22,17 +22,12 @@ import com.google.android.horologist.media.ui.state.PlayerUiState import com.google.android.horologist.media.ui.state.model.MediaUiModel import com.google.android.horologist.media.ui.state.model.TrackPositionUiModel import com.google.android.horologist.media.ui.uamp.UampColors -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test import org.robolectric.annotation.Config import kotlin.time.Duration.Companion.seconds -class MediaPlayerA11yScreenshotTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - }, -) { +class MediaPlayerA11yScreenshotTest : WearLegacyA11yTest() { @Test fun mediaPlayerLargeRound() { @@ -83,7 +78,7 @@ class MediaPlayerA11yScreenshotTest : ScreenshotBaseTest( connected = true, ) - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { MediaPlayerTestCase( colors = UampColors, playerUiState = playerUiState, diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaArtworkA11yTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaArtworkA11yTest.kt index 41bf83fa..01da4c5b 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaArtworkA11yTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaArtworkA11yTest.kt @@ -14,45 +14,58 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") +@file:OptIn(ExperimentalCoilApi::class) package com.google.android.horologist.media.ui.components -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Album -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.core.content.ContextCompat +import androidx.wear.compose.material.ChipDefaults +import coil.annotation.ExperimentalCoilApi +import coil.decode.DataSource +import coil.request.SuccessResult +import coil.test.FakeImageLoaderEngine import com.google.android.horologist.images.coil.FakeImageLoader import com.google.android.horologist.media.ui.state.model.MediaUiModel -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class MediaArtworkA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class MediaArtworkA11yTest : WearLegacyA11yTest() { + + override val imageLoader = FakeImageLoaderEngine.Builder() + .intercept( + predicate = { + it == FakeImageLoader.TestIconResourceUri + }, + interceptor = { + SuccessResult( + drawable = ContextCompat.getDrawable( + it.request.context, + FakeImageLoader.TestIconResource, + )!!, + request = it.request, + dataSource = DataSource.DISK, + ) + }, + ) + .build() + @Test fun a11y() { - screenshotTestRule.setContent( - takeScreenshot = true, - fakeImageLoader = FakeImageLoader.Resources, - ) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - MediaArtwork( - media = MediaUiModel( - id = "id", - title = "title", - artworkUri = FakeImageLoader.TestIconResourceUri, - ), - placeholder = rememberVectorPainter(image = Icons.Default.Album), - ) - } + runComponentTest { + MediaArtwork( + modifier = Modifier.size(ChipDefaults.LargeIconSize), + media = MediaUiModel( + id = "id", + title = "title", + artworkUri = FakeImageLoader.TestIconResourceUri, + ), + placeholder = rememberVectorPainter(image = Icons.Default.Album), + ) } } } diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaChipA11yTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaChipA11yTest.kt index dcd2c602..0ad32559 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaChipA11yTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/MediaChipA11yTest.kt @@ -14,43 +14,51 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") +@file:OptIn(ExperimentalCoilApi::class) package com.google.android.horologist.media.ui.components -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier +import androidx.core.content.ContextCompat +import coil.annotation.ExperimentalCoilApi +import coil.decode.DataSource +import coil.request.SuccessResult +import coil.test.FakeImageLoaderEngine import com.google.android.horologist.images.coil.FakeImageLoader import com.google.android.horologist.media.ui.state.model.MediaUiModel -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class MediaChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class MediaChipA11yTest : WearLegacyA11yTest() { + + override val imageLoader = FakeImageLoaderEngine.Builder() + .intercept( + predicate = { + it == FakeImageLoader.TestIconResourceUri + }, + interceptor = { + SuccessResult( + drawable = ContextCompat.getDrawable( + it.request.context, + FakeImageLoader.TestIconResource, + )!!, + request = it.request, + dataSource = DataSource.DISK, + ) + }, + ) + .build() @Test fun a11y() { - screenshotTestRule.setContent( - takeScreenshot = true, - fakeImageLoader = FakeImageLoader.Resources, - ) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - MediaChip( - media = MediaUiModel( - id = "id", - title = "Red Hot Chilli Peppers", - artworkUri = FakeImageLoader.TestIconResourceUri, - ), - onClick = {}, - ) - } + runComponentTest { + MediaChip( + media = MediaUiModel( + id = "id", + title = "Red Hot Chilli Peppers", + artworkUri = FakeImageLoader.TestIconResourceUri, + ), + onClick = {}, + ) } } } diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt index e377c219..044a40b7 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/components/actions/ShowPlaylistChipA11yTest.kt @@ -14,41 +14,23 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.media.ui.components.actions -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier import com.google.android.horologist.images.base.paintable.DrawableResPaintable -import com.google.android.horologist.images.coil.FakeImageLoader import com.google.android.horologist.logo.R -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class ShowPlaylistChipA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class ShowPlaylistChipA11yTest : WearLegacyA11yTest() { @Test fun a11y() { - screenshotTestRule.setContent( - takeScreenshot = true, - fakeImageLoader = FakeImageLoader.Resources, - ) { - Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { - ShowPlaylistChip( - artworkPaintable = DrawableResPaintable(R.drawable.horologist_logo), - name = "Playlists", - onClick = {}, - ) - } + runComponentTest { + ShowPlaylistChip( + artworkPaintable = DrawableResPaintable(R.drawable.horologist_logo), + name = "Playlists", + onClick = {}, + ) } } } diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekBackButtonA11yTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekBackButtonA11yTest.kt index d3d934b9..87959562 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekBackButtonA11yTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekBackButtonA11yTest.kt @@ -24,20 +24,14 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.google.android.horologist.media.ui.components.controls.SeekBackButton import com.google.android.horologist.media.ui.components.controls.SeekButtonIncrement -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class SeekBackButtonA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class SeekBackButtonA11yTest : WearLegacyA11yTest() { @Test fun incrementIsFive() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekBackButton( onClick = {}, @@ -49,7 +43,7 @@ class SeekBackButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsTen() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekBackButton( onClick = {}, @@ -61,7 +55,7 @@ class SeekBackButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsThirty() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekBackButton( onClick = {}, @@ -73,7 +67,7 @@ class SeekBackButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsOther() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekBackButton( onClick = {}, @@ -85,7 +79,7 @@ class SeekBackButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsUnknown() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekBackButton( onClick = {}, diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekForwardButtonA11yTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekForwardButtonA11yTest.kt index 751b91ad..4ba586a5 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekForwardButtonA11yTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/controls/SeekForwardButtonA11yTest.kt @@ -24,20 +24,14 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.google.android.horologist.media.ui.components.controls.SeekButtonIncrement import com.google.android.horologist.media.ui.components.controls.SeekForwardButton -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class SeekForwardButtonA11yTest : ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, -) { +class SeekForwardButtonA11yTest : WearLegacyA11yTest() { @Test fun incrementIsFive() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekForwardButton( onClick = {}, @@ -49,7 +43,7 @@ class SeekForwardButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsTen() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekForwardButton( onClick = {}, @@ -61,7 +55,7 @@ class SeekForwardButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsThirty() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekForwardButton( onClick = {}, @@ -73,7 +67,7 @@ class SeekForwardButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsOther() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekForwardButton( onClick = {}, @@ -85,7 +79,7 @@ class SeekForwardButtonA11yTest : ScreenshotBaseTest( @Test fun incrementIsUnknown() { - screenshotTestRule.setContent(takeScreenshot = true) { + runComponentTest { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) { SeekForwardButton( onClick = {}, diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yScreenshotTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yScreenshotTest.kt index ab367d53..91fcbf4c 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yScreenshotTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yScreenshotTest.kt @@ -14,43 +14,31 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.media.ui.screens.browse -import androidx.compose.runtime.LaunchedEffect -import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults -import com.google.android.horologist.media.ui.PlayerLibraryPreview +import androidx.compose.ui.test.hasScrollToNodeAction +import androidx.compose.ui.test.performTouchInput +import androidx.compose.ui.test.swipeUp import com.google.android.horologist.media.ui.state.model.PlaylistDownloadUiModel import com.google.android.horologist.media.ui.state.model.PlaylistUiModel -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test -class PlaylistDownloadBrowseScreenA11yScreenshotTest : ScreenshotBaseTest( - screenshotTestRuleParams { - enableA11y = true - }, -) { +class PlaylistDownloadBrowseScreenA11yScreenshotTest : WearLegacyA11yTest() { @Test fun browseScreen() { val screenState = BrowseScreenState.Loaded(downloadList) - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadBrowseScreen( - browseScreenState = screenState, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onPlaylistsClick = { }, - onSettingsClick = { }, - columnState = columnState, - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadBrowseScreen( + browseScreenState = screenState, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onPlaylistsClick = { }, + onSettingsClick = { }, + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @@ -58,25 +46,23 @@ class PlaylistDownloadBrowseScreenA11yScreenshotTest : ScreenshotBaseTest( fun secondPage() { val screenState = BrowseScreenState.Loaded(downloadList) - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - LaunchedEffect(Unit) { - columnState.state.scrollToItem(4, 0) - } - - PlayerLibraryPreview(columnState = columnState) { + composeRule.setContent { + TestScaffold { PlaylistDownloadBrowseScreen( browseScreenState = screenState, onDownloadItemClick = { }, onDownloadItemInProgressClick = { }, onPlaylistsClick = { }, onSettingsClick = { }, - columnState = columnState, onDownloadItemInProgressClickActionLabel = "cancel", ) } } + + composeRule.onNode(hasScrollToNodeAction()) + .performTouchInput { repeat(10) { swipeUp() } } + + captureScreenshot() } } diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yTallScreenshotTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yTallScreenshotTest.kt index bed9a72e..bd4c8713 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yTallScreenshotTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/browse/PlaylistDownloadBrowseScreenA11yTallScreenshotTest.kt @@ -22,25 +22,21 @@ import androidx.wear.compose.foundation.lazy.ScalingParams import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults import com.google.android.horologist.compose.layout.ScalingLazyColumnState import com.google.android.horologist.media.ui.PlayerLibraryPreview -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test import org.robolectric.annotation.Config @Config( - sdk = [30], + sdk = [33], qualifiers = "w227dp-h400dp-small-notlong-notround-watch-xhdpi-keyshidden-nonav", ) -class PlaylistDownloadBrowseScreenA11yTallScreenshotTest : ScreenshotBaseTest( - screenshotTestRuleParams { - }, -) { +class PlaylistDownloadBrowseScreenA11yTallScreenshotTest : WearLegacyA11yTest() { @Test fun browseScreen() { val screenState = BrowseScreenState.Loaded(downloadList) - screenshotTestRule.setContent(takeScreenshot = true) { + runScreenTest { val scalingParams = androidx.wear.compose.foundation.lazy.ScalingLazyColumnDefaults.scalingParams( edgeScale = 1f, diff --git a/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreenA11yScreenshotTest.kt b/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreenA11yScreenshotTest.kt index aa5525e2..ccb90eef 100644 --- a/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreenA11yScreenshotTest.kt +++ b/media/ui/src/test/java/com/google/android/horologist/media/ui/screens/entity/PlaylistDownloadScreenA11yScreenshotTest.kt @@ -14,243 +14,223 @@ * limitations under the License. */ -@file:Suppress("DEPRECATION") - package com.google.android.horologist.media.ui.screens.entity +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.MusicNote +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults +import androidx.wear.compose.material.MaterialTheme +import com.google.android.horologist.compose.layout.AppScaffold +import com.google.android.horologist.compose.layout.ResponsiveTimeText +import com.google.android.horologist.compose.pager.PagerScreen import com.google.android.horologist.images.base.util.rememberVectorPainter -import com.google.android.horologist.media.ui.PlayerLibraryPreview import com.google.android.horologist.media.ui.state.model.DownloadMediaUiModel import com.google.android.horologist.media.ui.state.model.PlaylistUiModel -import com.google.android.horologist.screenshots.ScreenshotBaseTest -import com.google.android.horologist.screenshots.ScreenshotTestRule +import com.google.android.horologist.screenshots.FixedTimeSource +import com.google.android.horologist.screenshots.rng.WearLegacyA11yTest import org.junit.Test class PlaylistDownloadScreenA11yScreenshotTest : - ScreenshotBaseTest( - ScreenshotTestRule.screenshotTestRuleParams { - enableA11y = true - screenTimeText = {} - }, - ) { + WearLegacyA11yTest() { @Test fun playlistDownloadScreenPreviewLoading() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = PlaylistDownloadScreenState.Loading, - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = PlaylistDownloadScreenState.Loading, + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewLoadedNoneDownloaded() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( - playlistModel = playlistUiModel, - downloadMediaList = notDownloaded, - ), - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - downloadItemArtworkPlaceholder = rememberVectorPainter( - image = Icons.Default.MusicNote, - tintColor = Color.Blue, - ), - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( + playlistModel = playlistUiModel, + downloadMediaList = notDownloaded, + ), + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + downloadItemArtworkPlaceholder = rememberVectorPainter( + image = Icons.Default.MusicNote, + tintColor = Color.Blue, + ), + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewLoadedNoneDownloadedDownloading() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( - playlistModel = playlistUiModel, - downloadMediaList = notDownloadedAndDownloading, - ), - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - downloadItemArtworkPlaceholder = rememberVectorPainter( - image = Icons.Default.MusicNote, - tintColor = Color.Blue, - ), - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( + playlistModel = playlistUiModel, + downloadMediaList = notDownloadedAndDownloading, + ), + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + downloadItemArtworkPlaceholder = rememberVectorPainter( + image = Icons.Default.MusicNote, + tintColor = Color.Blue, + ), + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewLoadedPartiallyDownloaded() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( - playlistModel = playlistUiModel, - downloadMediaList = downloadedNotDownloaded, - ), - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - downloadItemArtworkPlaceholder = rememberVectorPainter( - image = Icons.Default.MusicNote, - tintColor = Color.Blue, - ), - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( + playlistModel = playlistUiModel, + downloadMediaList = downloadedNotDownloaded, + ), + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + downloadItemArtworkPlaceholder = rememberVectorPainter( + image = Icons.Default.MusicNote, + tintColor = Color.Blue, + ), + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingUnknownSize() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( - playlistModel = playlistUiModel, - downloadMediaList = downloadedAndDownloadingUnknown, - ), - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - downloadItemArtworkPlaceholder = rememberVectorPainter( - image = Icons.Default.MusicNote, - tintColor = Color.Blue, - ), - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( + playlistModel = playlistUiModel, + downloadMediaList = downloadedAndDownloadingUnknown, + ), + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + downloadItemArtworkPlaceholder = rememberVectorPainter( + image = Icons.Default.MusicNote, + tintColor = Color.Blue, + ), + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingWaiting() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( - playlistModel = playlistUiModel, - downloadMediaList = downloadedAndDownloadingWaiting, - ), - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - downloadItemArtworkPlaceholder = rememberVectorPainter( - image = Icons.Default.MusicNote, - tintColor = Color.Blue, - ), - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( + playlistModel = playlistUiModel, + downloadMediaList = downloadedAndDownloadingWaiting, + ), + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + downloadItemArtworkPlaceholder = rememberVectorPainter( + image = Icons.Default.MusicNote, + tintColor = Color.Blue, + ), + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewLoadedFullyDownloaded() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() - - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( - playlistModel = playlistUiModel, - downloadMediaList = downloaded, - ), - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - downloadItemArtworkPlaceholder = rememberVectorPainter( - image = Icons.Default.MusicNote, - tintColor = Color.Blue, - ), - onDownloadItemInProgressClickActionLabel = "cancel", - ) - } + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = createPlaylistDownloadScreenStateLoaded( + playlistModel = playlistUiModel, + downloadMediaList = downloaded, + ), + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + downloadItemArtworkPlaceholder = rememberVectorPainter( + image = Icons.Default.MusicNote, + tintColor = Color.Blue, + ), + onDownloadItemInProgressClickActionLabel = "cancel", + ) } } @Test fun playlistDownloadScreenPreviewFailed() { - screenshotTestRule.setContent(takeScreenshot = true) { - val columnState = ScalingLazyColumnDefaults.responsive().create() + runScreenTest { + PlaylistDownloadScreen( + playlistName = "Playlist name", + playlistDownloadScreenState = PlaylistDownloadScreenState.Failed, + onDownloadButtonClick = { }, + onCancelDownloadButtonClick = { }, + onDownloadItemClick = { }, + onDownloadItemInProgressClick = { }, + onShuffleButtonClick = { }, + onPlayButtonClick = { }, + onDownloadItemInProgressClickActionLabel = "cancel", + ) + } + } - PlayerLibraryPreview(columnState = columnState) { - PlaylistDownloadScreen( - playlistName = "Playlist name", - playlistDownloadScreenState = PlaylistDownloadScreenState.Failed, - onDownloadButtonClick = { }, - onCancelDownloadButtonClick = { }, - onDownloadItemClick = { }, - onDownloadItemInProgressClick = { }, - onShuffleButtonClick = { }, - onPlayButtonClick = { }, - columnState = columnState, - onDownloadItemInProgressClickActionLabel = "cancel", - ) + @Composable + override fun TestScaffold(content: @Composable () -> Unit) { + AppScaffold( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colors.background), + timeText = { ResponsiveTimeText(timeSource = FixedTimeSource) }, + ) { + PagerScreen( + state = rememberPagerState { + 2 + }, + ) { + if (it == 0) { + content() + } } } } diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaArtworkA11yTest_a11y.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaArtworkA11yTest_a11y.png index 8a456189..f785adbc 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaArtworkA11yTest_a11y.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaArtworkA11yTest_a11y.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d8c4d1565f16100200ad97e15ec5aef86b5d535e9b03df1ff85c800f49afdea1 -size 44992 +oid sha256:b75570d2dee92a6fac2392cbbf06aa936cca84d6cefbe2ec9cd5fcd076e7ab3d +size 17200 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaChipA11yTest_a11y.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaChipA11yTest_a11y.png index b360a984..26a150cb 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaChipA11yTest_a11y.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.components_MediaChipA11yTest_a11y.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8ae17c59c4b9e5f438644a86dca3db695aad572a8f553128ea1c63ee378fa820 -size 34584 +oid sha256:335dea1b0f7bb3ef72fe710fa3be5eacd0558d288a5b318e1b123bfbde122fcf +size 26003 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsFive.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsFive.png index f32b5eb8..077be295 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsFive.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsFive.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65ee1825b4d468e531c03054015d0a5b0de25ba69d6b031a3b37c298333dafcf -size 24008 +oid sha256:a3d4b9c0e88a338b62f9b4d9070989135803e6f5c94d0726aded8b66ef69e867 +size 18244 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsOther.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsOther.png index 22fd7c2b..2ecf41ab 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsOther.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsOther.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dcdad626294926dcbf159b420e489b8885b1128aa99aa73e28ccbbee0e91b5b6 -size 23852 +oid sha256:00d00997b421152b4464fdee06c46c3ce28a05e449ba0e49ab57c9492a0ec0c4 +size 18187 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsTen.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsTen.png index cced9ad8..8da9c6eb 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsTen.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsTen.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8cfc51aa677b0a5405eb80be9eff72b32f1a08ea272ae5f93d3953863e13d510 -size 24156 +oid sha256:269b441718a68f7087eb443279d1ce3583de8b938d6c060900fcfd6788978257 +size 18369 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsThirty.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsThirty.png index b06afb26..41d1ad70 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsThirty.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsThirty.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e8434dcd5a2e27eb0a9c08881b7db4e977c4a62b53b45d16041af36342be9bbb -size 24602 +oid sha256:c0ed36198ba73e0f4bf9af9e07b3ab4fbd44b9fcbcbdea0efed59e6ccdeb1d4d +size 18620 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsUnknown.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsUnknown.png index a7a0f31e..13d30931 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsUnknown.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekBackButtonA11yTest_incrementIsUnknown.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88d289179de568daadfadf1aa5783cac1c3ad93d5dd25bb4d24c7f440ed91136 -size 23114 +oid sha256:afd9a368ea1057a0987b1aa023dc49f67deb1426f2404e348b1d5c1ae270fcc5 +size 17648 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsFive.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsFive.png index 159be04f..fb5bcdbd 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsFive.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsFive.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e068d2edc9c9b57e6a61d4203403362bac77fd8a4324c49023dfda2fd3b191a8 -size 23956 +oid sha256:97555355ed5a894525c0477727f1b392d04bef5b8b76f85cb8bb06fff298c83e +size 18373 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsOther.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsOther.png index 96ffa4bb..174a0954 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsOther.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsOther.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7c0953373e4d3171a46928f5e6761702aaa5acba43acfe1f26c99a6ebbac6b2 -size 23822 +oid sha256:de87394ecbb833500c470572476373976314026c5b80fb63b91c80710f6c2d6a +size 18310 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsTen.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsTen.png index f6e11fa1..e686ff1c 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsTen.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsTen.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5031110ec709dfef1e79b455a6f35676ec63164c8494c12515385af8fcfc0c3b -size 24115 +oid sha256:fd907ccab0630a3097d44440fa5f7dd11d660222aeae3566b3314e619903c0fc +size 18504 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsThirty.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsThirty.png index 142c6206..a06d8749 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsThirty.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsThirty.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ae5642e6784678345cdbf0346e4d407b84105788a2cd3d72fc62c76fa57153d -size 24575 +oid sha256:e430aa9741e311571801736bb7a4646a7409e38e3828c69beba90f1e9d8ca918 +size 18716 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsUnknown.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsUnknown.png index 11267c69..7c26d0b8 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsUnknown.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.controls_SeekForwardButtonA11yTest_incrementIsUnknown.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b77b82b94ec5e8a90f2a0a32ddc0044469147eb31672ef2a6dd7cd04d547d64 -size 23099 +oid sha256:c5195e72522bdba8b92c1e13ddb38f078aa70b216bae7f305a80633bacb7ecac +size 17741 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_browseScreen.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_browseScreen.png index bab4fd30..0dc2ab8b 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_browseScreen.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_browseScreen.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f8a455726d4b89dba09f52327082d04e562ac01100c268191fe525d57213d46d -size 64089 +oid sha256:9eff7505f4b763a098b1c63ec2d8841e74a4216645631282ee75fe939757facf +size 51060 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_secondPage.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_secondPage.png index e4e4f48d..9d7acc17 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_secondPage.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yScreenshotTest_secondPage.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e37b8f62591e5c3c74077b609914bef71e6cc3e998b82b4ea8d09472fb8e8c0 -size 61392 +oid sha256:860ad2851d95be57eb084a0a6c972a2f71ee3ee4c19da9997515595e61c95e5d +size 42992 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yTallScreenshotTest_browseScreen.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yTallScreenshotTest_browseScreen.png index a4e1daa2..e07dbd0f 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yTallScreenshotTest_browseScreen.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.browse_PlaylistDownloadBrowseScreenA11yTallScreenshotTest_browseScreen.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ddaf4e00d0c1931fff6620057eafe5cc46200bf6ea2c94de1c95c9b9226c0e0 -size 34938 +oid sha256:3aeb7c1231dc83da2a5f4413f494fb181f9623903dfc198d6704e1b8db1daa40 +size 62941 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewFailed.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewFailed.png index 363f6d0d..a96b68c2 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewFailed.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewFailed.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:292bd2a0a157783736c3529012300bd22e0db61f730a2ce300ee3ba3cabd86cd -size 44733 +oid sha256:d8b91483d7cb514795b24104d961b88cd31e9a778cc0f18dad6e04652c2b444d +size 34610 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedFullyDownloaded.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedFullyDownloaded.png index 1497f2bb..d0244824 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedFullyDownloaded.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedFullyDownloaded.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9ff4f6c80ab87965c410163dab9837032be81b62c07f3e5711202c570daddc26 -size 72830 +oid sha256:b5e66e27c568ea384aeef096e2231a0f162a40fb22207aa73754b87ac540c6c9 +size 59528 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloaded.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloaded.png index 8b23c609..b85e44da 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloaded.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloaded.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f39cae92cbbc5f082456f1af28992d2ec60034df6f36c1e03e314e3bbe804309 -size 68839 +oid sha256:941cd0fa3c9aea34d4e0f21540c48224078de34669f4549eafadde5fd7bc025a +size 54963 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloadedDownloading.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloadedDownloading.png index 5774b2f8..3dafb596 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloadedDownloading.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedNoneDownloadedDownloading.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b935cab4e20e1b6fc009b92d802922d2018f91c6441c21bd409079358cc8e26b -size 67050 +oid sha256:39b4de2b0f7ae5860a0f8c60656e052f443e5dddd1908f9c2cd542441b3be87d +size 53444 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloaded.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloaded.png index 4714bf1e..f00e69e1 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloaded.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloaded.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cacae218f9b23392da5862a72ca3e2a9708e319008f04fec14ece1b7f9d005a6 -size 71728 +oid sha256:4e1ef909f497cd8c432d5161d20cbb169c986c6c23f8388195a8b0bbd1bba1fb +size 58859 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingUnknownSize.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingUnknownSize.png index e1f2309b..ca9fedbf 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingUnknownSize.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingUnknownSize.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26481d919d1007c91dc1943c2a577a0070d43f05cd6180a59349ae1158c54797 -size 73781 +oid sha256:d7daa4bb822d4b6753ae03a8702cc775a3f942f79b35b4e579176f156d1dd74d +size 60692 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingWaiting.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingWaiting.png index 00cb1c0e..4b3a525d 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingWaiting.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoadedPartiallyDownloadedDownloadingWaiting.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d06b9322a29fb55e2a1d304448f7c32048781e65b39de0cbfe9fb4e9020f303c -size 73753 +oid sha256:359f15003270d9285bcf2278eba4e16bba9c52f3a20ecde9c21758e0e5f5537c +size 60654 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoading.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoading.png index 9f8159e4..66e8fe5b 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoading.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui.screens.entity_PlaylistDownloadScreenA11yScreenshotTest_playlistDownloadScreenPreviewLoading.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa2eca4d6857931cbee65af46afbaa44a1d64f2e95dcc7484d4d8db98962c19b -size 64439 +oid sha256:19d053f37afdd495bf554184ac2d99ee3625bf18b9a6044bd07ad525ecdda662 +size 52024 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerLargeRound.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerLargeRound.png index 73e4de9c..1ceacd45 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerLargeRound.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerLargeRound.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:67e2f0fd78e1c1bf8e1555993f90916063d8f6b1362db307d2f4ce71498b443d -size 146725 +oid sha256:5e947d16311cd4e60ac390fe2f5ad465d676e9e80cf66e729421a4b8318071b7 +size 117485 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSmallRound.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSmallRound.png index 0a04a3b8..7b51af13 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSmallRound.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSmallRound.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6131a00a869fcc594e2a0afe18de6e3cbd741fb73dff66e984fb54622fbd1bff -size 90882 +oid sha256:254d6b5d75918efb4b97b22a41f0b4515869d74e3aceb2e2e5d9cd8b96e685f0 +size 82586 diff --git a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSquare.png b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSquare.png index d9fe109c..097101fe 100644 --- a/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSquare.png +++ b/media/ui/src/test/snapshots/images/com.google.android.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerSquare.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba6e9c89f0faefd5d48d2907cf2677f6c08b9ebde8ac4457e11d379402942fa0 -size 76502 +oid sha256:8c28e15ca2e1369a69366fdcb4ed5f3446baa71b89393aaa4fc47ea7296a5335 +size 69486 diff --git a/roboscreenshots/api/current.api b/roboscreenshots/api/current.api index a4dea355..0bc7a131 100644 --- a/roboscreenshots/api/current.api +++ b/roboscreenshots/api/current.api @@ -7,93 +7,6 @@ package com.google.android.horologist.screenshots { field public static final com.google.android.horologist.screenshots.FixedTimeSource INSTANCE; } - @Deprecated @com.google.android.horologist.annotations.ExperimentalHorologistApi @org.junit.runner.RunWith(RobolectricTestRunner::class) @org.robolectric.annotation.Config(sdk={33}, qualifiers="w227dp-h227dp-small-notlong-round-watch-xhdpi-keyshidden-nonav", shadows={ShadowPixelCopy::class}) @org.robolectric.annotation.GraphicsMode(org.robolectric.annotation.GraphicsMode.Mode.NATIVE) public abstract class ScreenshotBaseTest { - ctor @Deprecated public ScreenshotBaseTest(optional com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams params); - method @Deprecated @org.junit.Rule public final com.google.android.horologist.screenshots.ScreenshotTestRule getScreenshotTestRule(); - property @Deprecated @org.junit.Rule public final com.google.android.horologist.screenshots.ScreenshotTestRule screenshotTestRule; - } - - @Deprecated @com.google.android.horologist.annotations.ExperimentalHorologistApi public final class ScreenshotTestRule implements org.junit.rules.TestRule { - ctor @Deprecated public ScreenshotTestRule(optional com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams params); - method @Deprecated public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description); - method @Deprecated public void interact(optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.test.junit4.ComposeTestRule,kotlin.Unit> block); - method @Deprecated public void setContent(optional boolean isComponent, optional kotlin.jvm.functions.Function1<? super kotlin.jvm.functions.Function0<kotlin.Unit>,kotlin.Unit>? componentDefaultContent, optional boolean takeScreenshot, optional Boolean? roundScreen, optional kotlin.jvm.functions.Function0<kotlin.Unit> timeText, optional kotlin.jvm.functions.Function0<kotlin.Unit> positionIndicator, optional com.google.android.horologist.images.coil.FakeImageLoader fakeImageLoader, kotlin.jvm.functions.Function0<kotlin.Unit> composable); - method @Deprecated public void takeScreenshot(); - field @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.Companion Companion; - } - - @Deprecated public enum ScreenshotTestRule.ClipMode { - method @Deprecated public static com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode valueOf(String value) throws java.lang.IllegalArgumentException, java.lang.NullPointerException; - method @Deprecated public static com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode[] values(); - enum_constant @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode Auto; - enum_constant @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode None; - enum_constant @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode Round; - } - - @Deprecated public static final class ScreenshotTestRule.Companion { - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams.Builder builder(); - method @Deprecated public inline com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams screenshotTestRuleParams(kotlin.jvm.functions.Function1<? super com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams.Builder,kotlin.Unit> block); - } - - @Deprecated public enum ScreenshotTestRule.RecordMode { - method @Deprecated public static com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode valueOf(String value) throws java.lang.IllegalArgumentException, java.lang.NullPointerException; - method @Deprecated public static com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode[] values(); - enum_constant @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode Record; - enum_constant @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode Repair; - enum_constant @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode Test; - field @Deprecated public static final com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode.Companion Companion; - } - - @Deprecated public static final class ScreenshotTestRule.RecordMode.Companion { - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode defaultRecordMode(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode fromProperty(String? property); - } - - @Deprecated public static final class ScreenshotTestRule.ScreenshotTestRuleParams { - ctor @Deprecated public ScreenshotTestRule.ScreenshotTestRuleParams(float tolerance, boolean enableA11y, kotlin.jvm.functions.Function0<kotlin.Unit> screenTimeText, String? testLabel, com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode record, com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode clipMode); - method @Deprecated public float component1(); - method @Deprecated public boolean component2(); - method @Deprecated public kotlin.jvm.functions.Function0<kotlin.Unit> component3(); - method @Deprecated public String? component4(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode component5(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode component6(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams copy(float tolerance, boolean enableA11y, kotlin.jvm.functions.Function0<kotlin.Unit> screenTimeText, String? testLabel, com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode record, com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode clipMode); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode getClipMode(); - method @Deprecated public boolean getEnableA11y(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode getRecord(); - method @Deprecated public kotlin.jvm.functions.Function0<kotlin.Unit> getScreenTimeText(); - method @Deprecated public String? getTestLabel(); - method @Deprecated public float getTolerance(); - property @Deprecated public final com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode clipMode; - property @Deprecated public final boolean enableA11y; - property @Deprecated public final com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode record; - property @Deprecated public final kotlin.jvm.functions.Function0<kotlin.Unit> screenTimeText; - property @Deprecated public final String? testLabel; - property @Deprecated public final float tolerance; - } - - @Deprecated public static final class ScreenshotTestRule.ScreenshotTestRuleParams.Builder { - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.ScreenshotTestRuleParams build(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode getClipMode(); - method @Deprecated public boolean getEnableA11y(); - method @Deprecated public com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode getRecord(); - method @Deprecated public kotlin.jvm.functions.Function0<kotlin.Unit> getScreenTimeText(); - method @Deprecated public String? getTestLabel(); - method @Deprecated public float getTolerance(); - method @Deprecated public void setClipMode(com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode); - method @Deprecated public void setEnableA11y(boolean); - method @Deprecated public void setRecord(com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode); - method @Deprecated public void setScreenTimeText(kotlin.jvm.functions.Function0<kotlin.Unit>); - method @Deprecated public void setTestLabel(String?); - method @Deprecated public void setTolerance(float); - property @Deprecated public final com.google.android.horologist.screenshots.ScreenshotTestRule.ClipMode clipMode; - property @Deprecated public final boolean enableA11y; - property @Deprecated public final com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode record; - property @Deprecated public final kotlin.jvm.functions.Function0<kotlin.Unit> screenTimeText; - property @Deprecated public final String? testLabel; - property @Deprecated public final float tolerance; - } - } package com.google.android.horologist.screenshots.rng { @@ -136,17 +49,43 @@ package com.google.android.horologist.screenshots.rng { method @org.robolectric.ParameterizedRobolectricTestRunner.Parameters public java.util.List<com.google.android.horologist.screenshots.rng.WearDevice> devices(); } + @org.junit.runner.RunWith(AndroidJUnit4::class) @org.robolectric.annotation.Config(sdk={33}, qualifiers=com.github.takahirom.roborazzi.RobolectricDeviceQualifiers.WearOSLargeRound) @org.robolectric.annotation.GraphicsMode(org.robolectric.annotation.GraphicsMode.Mode.NATIVE) public abstract class WearLegacyA11yTest { + ctor public WearLegacyA11yTest(); + method @androidx.compose.runtime.Composable public void ComponentScaffold(kotlin.jvm.functions.Function0<kotlin.Unit> content); + method @androidx.compose.runtime.Composable public void TestScaffold(kotlin.jvm.functions.Function0<kotlin.Unit> content); + method public final void captureScreenA11yRoboImage(String filePath, com.github.takahirom.roborazzi.RoborazziOptions roborazziOptions); + method public final void captureScreenshot(optional String suffix); + method @org.junit.Rule public final androidx.compose.ui.test.junit4.ComposeContentTestRule getComposeRule(); + method public coil.test.FakeImageLoaderEngine? getImageLoader(); + method @org.junit.Rule public final org.junit.rules.TestName getTestInfo(); + method public float getTolerance(); + method public final void runComponentTest(kotlin.jvm.functions.Function0<kotlin.Unit> content); + method public final void runScreenTest(kotlin.jvm.functions.Function0<kotlin.Unit> content); + method public String testName(String suffix); + property @org.junit.Rule public final androidx.compose.ui.test.junit4.ComposeContentTestRule composeRule; + property public coil.test.FakeImageLoaderEngine? imageLoader; + property @org.junit.Rule public final org.junit.rules.TestName testInfo; + property public float tolerance; + field public static final com.google.android.horologist.screenshots.rng.WearLegacyA11yTest.Companion Companion; + } + + public static final class WearLegacyA11yTest.Companion { + method public void enableTouchExploration(); + } + @org.junit.runner.RunWith(AndroidJUnit4::class) @org.robolectric.annotation.Config(sdk={33}, qualifiers=com.github.takahirom.roborazzi.RobolectricDeviceQualifiers.WearOSLargeRound) @org.robolectric.annotation.GraphicsMode(org.robolectric.annotation.GraphicsMode.Mode.NATIVE) public abstract class WearLegacyComponentTest { ctor public WearLegacyComponentTest(); method @androidx.compose.runtime.Composable public void ComponentScaffold(kotlin.jvm.functions.Function0<kotlin.Unit> content); method public com.google.android.horologist.screenshots.rng.WearDevice? getDevice(); method public com.google.android.horologist.images.coil.FakeImageLoader? getFakeImageLoader(); + method public coil.test.FakeImageLoaderEngine? getImageLoader(); method @org.junit.Rule public final org.junit.rules.TestName getTestInfo(); method public float getTolerance(); method public final void runComponentTest(kotlin.jvm.functions.Function0<kotlin.Unit> content); method public String testName(String suffix); property public com.google.android.horologist.screenshots.rng.WearDevice? device; property public com.google.android.horologist.images.coil.FakeImageLoader? fakeImageLoader; + property public coil.test.FakeImageLoaderEngine? imageLoader; property @org.junit.Rule public final org.junit.rules.TestName testInfo; property public float tolerance; } @@ -161,12 +100,14 @@ package com.google.android.horologist.screenshots.rng { method public final void captureScreenshot(String suffix); method @org.junit.Rule public final androidx.compose.ui.test.junit4.ComposeContentTestRule getComposeRule(); method public com.google.android.horologist.screenshots.rng.WearDevice? getDevice(); + method public coil.test.FakeImageLoaderEngine? getImageLoader(); method @org.junit.Rule public final org.junit.rules.TestName getTestInfo(); method public float getTolerance(); method public final void runTest(optional String? suffix, optional com.google.android.horologist.screenshots.rng.WearDevice? device, optional boolean applyDeviceConfig, kotlin.jvm.functions.Function0<kotlin.Unit> content); method public String testName(String suffix); property @org.junit.Rule public final androidx.compose.ui.test.junit4.ComposeContentTestRule composeRule; property public com.google.android.horologist.screenshots.rng.WearDevice? device; + property public coil.test.FakeImageLoaderEngine? imageLoader; property @org.junit.Rule public final org.junit.rules.TestName testInfo; property public float tolerance; field public static final com.google.android.horologist.screenshots.rng.WearScreenshotTest.Companion Companion; diff --git a/roboscreenshots/build.gradle.kts b/roboscreenshots/build.gradle.kts index bb382ea2..34d1eb55 100644 --- a/roboscreenshots/build.gradle.kts +++ b/roboscreenshots/build.gradle.kts @@ -41,7 +41,8 @@ android { kotlinOptions { jvmTarget = "11" - freeCompilerArgs = freeCompilerArgs + "-opt-in=com.google.android.horologist.annotations.ExperimentalHorologistApi" + freeCompilerArgs = + freeCompilerArgs + "-opt-in=com.google.android.horologist.annotations.ExperimentalHorologistApi" } composeOptions { @@ -101,13 +102,12 @@ dependencies { implementation(libs.wearcompose.material) implementation(libs.wearcompose.foundation) + api(libs.coil.test) api(libs.roborazzi) api(libs.roborazzi.compose) + api(libs.roborazzi.painter) api(libs.roborazzi.rule) - // TODO remove - implementation(libs.snapshot.android) - testImplementation(libs.robolectric) } diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/Diffing.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/Diffing.kt deleted file mode 100644 index 20ab2e53..00000000 --- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/Diffing.kt +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("DEPRECATION") - -package com.google.android.horologist.screenshots - -import android.annotation.SuppressLint -import android.graphics.Bitmap -import android.util.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.toArgb -import androidx.compose.ui.test.SemanticsNodeInteraction -import com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode -import com.quickbird.snapshot.Diffing -import com.quickbird.snapshot.FileSnapshotting -import com.quickbird.snapshot.FileStoring -import com.quickbird.snapshot.Snapshotting -import com.quickbird.snapshot.asserted -import com.quickbird.snapshot.bitmap -import okio.Buffer -import okio.ByteString -import java.io.File -import kotlin.math.ceil - -internal val Diffing.Companion.highlightWithRed - get() = Diffing<Color> { first, second -> - if (first == second) { - first.copy(alpha = first.alpha / 3f) - } else { - Color.Red - } - } - -internal val Bitmap.size: Size - get() = Size(width, height) - -internal fun Bitmap.eachPixel(fn: (Int, Int) -> Unit) { - val size = this.size - for (x in 0 until size.width) { - for (y in 0 until size.height) { - fn(x, y) - } - } -} - -internal fun Diffing.Companion.bitmapWithTolerance(tolerance: Float, colorDiffing: Diffing<Color>) = - Diffing<Bitmap> { originalBitmap, newBitmap -> - val originalBytes = originalBitmap.asByteString() - val newBytes = newBitmap.asByteString() - if (originalBitmap.size != newBitmap.size) { - newBitmap - } else if (originalBytes == newBytes) { - null - } else { - var differentCount = 0 - val diffBitmap = originalBitmap.copy(originalBitmap.config, true).apply { - eachPixel { x, y -> - val originalColor = Color(originalBitmap.getPixel(x, y)) - val newColor = Color(newBitmap.getPixel(x, y)) - - if (originalColor != newColor) { - differentCount += 1 - } - - val diffColor = colorDiffing(originalColor, newColor) ?: originalColor - setPixel(x, y, diffColor.toArgb()) - } - } - val pixelCount = originalBitmap.width * originalBitmap.height - val toleratedDiffs = ceil(tolerance * pixelCount).toInt() - if (differentCount <= toleratedDiffs) { - null - } else { - val diffPercent = differentCount.toDouble() / pixelCount - println("$diffPercent") - diffBitmap - } - } - } - -internal fun Bitmap.asByteString(): ByteString = Buffer().apply { - compress(Bitmap.CompressFormat.PNG, 0, outputStream()) -}.readByteString() - -internal fun Snapshotting<SemanticsNodeInteraction, Bitmap>.fileSnapshottingX() = FileSnapshotting( - fileStoring = FileStoring.bitmap, - snapshotting = this, -) - -@SuppressLint("NewApi") -internal suspend fun FileSnapshotting<SemanticsNodeInteraction, Bitmap>.snapshot( - value: SemanticsNodeInteraction, - testClass: Class<*>, - testName: String, - record: RecordMode, -) { - paparazziCompatibleSnapshot( - value = value, - record = record, - testName = testName, - testClass = testClass, - ) -} - -@SuppressLint("NewApi") -internal suspend fun FileSnapshotting<SemanticsNodeInteraction, Bitmap>.paparazziCompatibleSnapshot( - value: SemanticsNodeInteraction, - record: RecordMode = RecordMode.Test, - testClass: Class<*>, - testName: String, -) { - val referenceDirectory = File("src/test/snapshots/images").apply { - mkdirs() - } - val diffDirectory = File("out") - - val packageName = testClass.packageName - val className = testClass.simpleName - - val filePrefix = packageName + "_" + className + "_" + testName - val referenceFile = File(referenceDirectory, "$filePrefix.png") - val diffFileName = File(diffDirectory, "${filePrefix}_delta.png") - - val snapshot = snapshotting.snapshot(value) - val fileStoring = fileStoring.asserted - - if (record == RecordMode.Record || (record == RecordMode.Repair && !referenceFile.exists())) { - fileStoring.store(snapshot, referenceFile) - diffFileName.deleteRecursively() - println("Stored snapshot to: ${referenceFile.absolutePath}") - } else { - val reference = fileStoring.load(referenceFile) - val diff = snapshotting.diffing(reference, snapshot) - if (diff == null) { - diffFileName.deleteRecursively() - } else { - diffDirectory.mkdirs() - - fileStoring.store(diff, diffFileName) - - if (record == RecordMode.Test) { - throw AssertionError( - "Snapshot is different from the reference!\nDiff stored to: ${diffFileName.absolutePath}", - ) - } else if (record == RecordMode.Repair) { - fileStoring.store(snapshot, referenceFile) - } - } - } -} diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/ScreenshotBaseTest.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/ScreenshotBaseTest.kt deleted file mode 100644 index 652ef4c5..00000000 --- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/ScreenshotBaseTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("DEPRECATION") - -package com.google.android.horologist.screenshots - -import com.google.android.horologist.annotations.ExperimentalHorologistApi -import com.google.android.horologist.screenshots.ScreenshotTestRule.Companion.screenshotTestRuleParams -import org.junit.Rule -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner -import org.robolectric.annotation.Config -import org.robolectric.annotation.GraphicsMode -import org.robolectric.shadows.ShadowPixelCopy - -/** - * A test class that can be used as base class for tests that require a [ScreenshotTestRule]. - */ -@RunWith(RobolectricTestRunner::class) -@Config( - sdk = [33], - qualifiers = "w227dp-h227dp-small-notlong-round-watch-xhdpi-keyshidden-nonav", - shadows = [ShadowPixelCopy::class], -) -@GraphicsMode(GraphicsMode.Mode.NATIVE) -@ExperimentalHorologistApi -@Deprecated("Use RNG and roborazzi directly") -public abstract class ScreenshotBaseTest( - params: ScreenshotTestRule.ScreenshotTestRuleParams = screenshotTestRuleParams { }, -) { - - @get:Rule - public val screenshotTestRule: ScreenshotTestRule = ScreenshotTestRule(params) - - internal companion object { - internal const val USE_HARDWARE_RENDERER_NATIVE_ENV = "robolectric.screenshot.hwrdr.native" - - init { - // Future looking, not in current release - System.setProperty(USE_HARDWARE_RENDERER_NATIVE_ENV, "true") - } - } -} diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/ScreenshotTestRule.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/ScreenshotTestRule.kt deleted file mode 100644 index 75bc5eb6..00000000 --- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/ScreenshotTestRule.kt +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) -@file:Suppress("DEPRECATION") - -package com.google.android.horologist.screenshots - -import android.app.Application -import android.content.res.Resources -import android.graphics.Bitmap -import android.graphics.Canvas -import android.graphics.Paint -import android.graphics.PorterDuff -import android.graphics.PorterDuffXfermode -import android.os.Build -import android.view.View -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.wrapContentSize -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalView -import androidx.compose.ui.test.SemanticsNodeInteraction -import androidx.compose.ui.test.junit4.ComposeContentTestRule -import androidx.compose.ui.test.junit4.ComposeTestRule -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onRoot -import androidx.core.graphics.applyCanvas -import androidx.test.core.app.ApplicationProvider -import androidx.wear.compose.material.Scaffold -import com.google.android.horologist.annotations.ExperimentalHorologistApi -import com.google.android.horologist.compose.layout.ResponsiveTimeText -import com.google.android.horologist.images.coil.FakeImageLoader -import com.google.android.horologist.screenshots.RobolectricTempHelpers.capture -import com.google.android.horologist.screenshots.ScreenshotTestRule.RecordMode.Companion.defaultRecordMode -import com.google.android.horologist.screenshots.a11y.A11ySnapshotTransformer -import com.quickbird.snapshot.Diffing -import com.quickbird.snapshot.FileSnapshotting -import com.quickbird.snapshot.Snapshotting -import com.quickbird.snapshot.fileSnapshotting -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.junit.rules.RuleChain -import org.junit.rules.TestRule -import org.junit.runner.Description -import org.junit.runners.model.Statement -import org.robolectric.RobolectricTestRunner -import kotlin.math.min - -/** - * A [TestRule] that allows you to run screenshot tests of your composable components. - * - * This rule requires robolectric, so the test suite should run with [RobolectricTestRunner]. See - * [ScreenshotBaseTest] for a basic configuration. - */ -@ExperimentalHorologistApi -@Deprecated("Use RNG and roborazzi directly") -public class ScreenshotTestRule( - private val params: ScreenshotTestRuleParams = screenshotTestRuleParams { }, -) : TestRule { - - private val testClassInfoRule: TestClassInfoRule = TestClassInfoRule() - private val composeContentTestRule: ComposeContentTestRule = createComposeRule() - - private val snapshotTransformer: SnapshotTransformer = if (params.enableA11y) { - A11ySnapshotTransformer() - } else { - SnapshotTransformer.None - } - private val applicationContext = ApplicationProvider.getApplicationContext<Application>() - private val resources: Resources = - applicationContext.resources - - private var testContent: View? = null - private var snapshotCount: Int = 0 - private var isComponent: Boolean = false - - override fun apply(base: Statement, description: Description): Statement { - return object : Statement() { - override fun evaluate() { - try { - RuleChain.outerRule(testClassInfoRule) - .around(composeContentTestRule) - .apply(base, description) - .evaluate() - } finally { - testContent = null - snapshotCount = 0 - isComponent = false - } - } - } - } - - public fun setContent( - isComponent: Boolean = false, - componentDefaultContent: (@Composable (content: @Composable (() -> Unit)) -> Unit)? = null, - takeScreenshot: Boolean = false, - roundScreen: Boolean? = null, - timeText: @Composable () -> Unit = params.screenTimeText, - positionIndicator: @Composable () -> Unit = { }, - fakeImageLoader: FakeImageLoader = FakeImageLoader.Never, - composable: @Composable () -> Unit, - ) { - this.isComponent = isComponent - val round = roundScreen ?: resources.configuration.isScreenRound - - composeContentTestRule.setContent { - testContent = LocalView.current - - if (isComponent) { - if (componentDefaultContent == null) { - ComponentDefaults(fakeImageLoader, composable) - } else { - componentDefaultContent(composable) - } - } else { - ScreenshotDefaults(fakeImageLoader, round, timeText, positionIndicator, composable) - } - } - - runTest { - composeContentTestRule.awaitIdle() - } - - if (takeScreenshot) { - takeScreenshot() - } - } - - // should not give [ComposeContentTestRule] as scope, as we don't want clients to call - // [ComposeContentTestRule.setContent] - public fun interact(block: ComposeTestRule.() -> Unit = {}) { - block(composeContentTestRule) - } - - public fun takeScreenshot() { - val snapshotting = Snapshotting( - diffing = Diffing.bitmapWithTolerance( - tolerance = params.tolerance, - colorDiffing = Diffing.highlightWithRed, - ), - snapshot = { node: SemanticsNodeInteraction -> - val view = getView() - - val bitmap = captureBitmap(view) - - if (isComponent) { - bitmap - } else { - snapshotTransformer.transform(node, bitmap) - } - }, - ).fileSnapshotting - - runTest { - saveSnapshot(snapshotting) - } - } - - private fun captureBitmap(view: View): Bitmap { - val bitmap = Bitmap.createBitmap( - view.width, - view.height, - Bitmap.Config.ARGB_8888, - ) - - @Suppress("DEPRECATION") - val isFullScreen = view.height == view.display.height && view.width == view.display.width - - if (isFullScreen && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - capture(view, bitmap) - } else { - view.draw(Canvas(bitmap)) - } - - val shouldClip = when (params.clipMode) { - ClipMode.Round -> true - - ClipMode.Auto -> { - resources.configuration.isScreenRound && isFullScreen - } - - ClipMode.None -> false - } - return if (shouldClip) { - circularClip(bitmap) - } else { - bitmap - } - } - - internal fun circularClip(image: Bitmap): Bitmap { - // From https://github.com/coil-kt/coil/blob/2.0.0-rc01/coil-base/src/main/java/coil/transform/CircleCropTransformation.kt - val paint = Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG) - - val minSize = min(image.width, image.height) - val radius = minSize / 2f - val output = Bitmap.createBitmap(image.width, image.height, Bitmap.Config.ARGB_8888) - output.applyCanvas { - drawCircle(radius, radius, radius, paint) - paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN) - drawBitmap(image, radius - image.width / 2f, radius - image.height / 2f, paint) - } - - return output - } - - private fun getView(): View = testContent!! - - private suspend fun saveSnapshot(snapshotting: FileSnapshotting<SemanticsNodeInteraction, Bitmap>) { - snapshotting.snapshot( - composeContentTestRule.onRoot(), - testName = getTestName(), - record = params.record, - testClass = checkNotNull(testClassInfoRule.testClass) { "Could not retrieve information from test class" }, - ) - snapshotCount++ - } - - private fun getTestName(): String { - val label = if (params.testLabel != null) "_${params.testLabel}" else "" - val suffix = if (snapshotCount > 0) { - "_${snapshotCount + 1}" - } else { - "" - } - return testClassInfoRule.methodName + label + suffix - } - - @Composable - private fun ScreenshotDefaults( - fakeImageLoader: FakeImageLoader, - round: Boolean, - timeText: @Composable () -> Unit, - positionIndicator: @Composable () -> Unit, - content: @Composable () -> Unit, - ) { - fakeImageLoader.apply { - Box( - modifier = Modifier - .background(Color.Transparent), - ) { - DefaultTheme { - Scaffold( - modifier = Modifier - .fillMaxSize() - .run { - if (round) { - clip(CircleShape) - } else { - this - } - } - .background(Color.Black), - timeText = { - timeText() - }, - positionIndicator = positionIndicator, - ) { - content() - } - } - } - } - } - - @Composable - private fun ComponentDefaults( - fakeImageLoader: FakeImageLoader, - content: @Composable () -> Unit, - ) { - fakeImageLoader.override { - Box( - modifier = Modifier - .wrapContentSize() - .background(Color.Black.copy(alpha = 0.5f)), - contentAlignment = Alignment.Center, - ) { - DefaultTheme { - content() - } - } - } - } - - @Composable - private fun DefaultTheme(content: @Composable () -> Unit) { - content() - } - - public data class ScreenshotTestRuleParams( - public val tolerance: Float, - public val enableA11y: Boolean, - public val screenTimeText: @Composable () -> Unit, - public val testLabel: String?, - public val record: RecordMode, - public val clipMode: ClipMode, - ) { - - public class Builder internal constructor() { - public var tolerance: Float = 0.005f - public var enableA11y: Boolean = false - public var screenTimeText: @Composable () -> Unit = defaultScreenTimeText() - public var testLabel: String? = null - public var record: RecordMode = defaultRecordMode() - - public var clipMode: ClipMode = ClipMode.Auto - - public fun build(): ScreenshotTestRuleParams { - if (enableA11y) { - tolerance = 0.02f - } - - return ScreenshotTestRuleParams( - tolerance = tolerance, - enableA11y = enableA11y, - screenTimeText = screenTimeText, - testLabel = testLabel, - record = record, - clipMode = clipMode, - ) - } - } - } - - public enum class RecordMode { - Test, Record, Repair; - - public companion object { - public fun fromProperty(property: String?): RecordMode = when (property?.lowercase()) { - "test", "false" -> Test - "record", "true" -> Record - "repair" -> Repair - else -> Test - } - - public fun defaultRecordMode(): RecordMode = RecordMode.fromProperty( - System.getProperty("screenshot.record"), - ) - } - } - - public enum class ClipMode { - Round, None, Auto - } - - public companion object { - private fun defaultScreenTimeText(): @Composable () -> Unit = { - ResponsiveTimeText( - timeSource = FixedTimeSource, - ) - } - - public fun builder(): ScreenshotTestRuleParams.Builder = ScreenshotTestRuleParams.Builder() - - public inline fun screenshotTestRuleParams(block: ScreenshotTestRuleParams.Builder.() -> Unit): ScreenshotTestRuleParams { - return builder().apply { block() }.build() - } - } -} diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/TestClassInfoRule.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/TestClassInfoRule.kt deleted file mode 100644 index 633c896b..00000000 --- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/TestClassInfoRule.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.android.horologist.screenshots - -import org.junit.rules.TestWatcher -import org.junit.runner.Description - -internal class TestClassInfoRule : TestWatcher() { - - @Volatile - public var methodName: String? = null - private set - - @Volatile - public var testClass: Class<*>? = null - private set - - override fun starting(d: Description) { - methodName = d.methodName - testClass = d.testClass - } -} diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyA11yTest.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyA11yTest.kt new file mode 100644 index 00000000..7c99b6fd --- /dev/null +++ b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyA11yTest.kt @@ -0,0 +1,193 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:OptIn(ExperimentalRoborazziApi::class, ExperimentalCoilApi::class, ExperimentalCoilApi::class) + +package com.google.android.horologist.screenshots.rng + +import android.app.Application +import android.graphics.Bitmap +import android.os.Looper +import android.view.accessibility.AccessibilityManager +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.test.junit4.ComposeContentTestRule +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onRoot +import androidx.test.core.app.ApplicationProvider +import androidx.test.espresso.Espresso +import androidx.test.espresso.Root +import androidx.test.espresso.base.RootsOracle_Factory +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.wear.compose.material.MaterialTheme +import coil.annotation.ExperimentalCoilApi +import coil.test.FakeImageLoaderEngine +import com.github.takahirom.roborazzi.ExperimentalRoborazziApi +import com.github.takahirom.roborazzi.RoboComponent +import com.github.takahirom.roborazzi.RobolectricDeviceQualifiers +import com.github.takahirom.roborazzi.RoborazziOptions +import com.github.takahirom.roborazzi.ThresholdValidator +import com.github.takahirom.roborazzi.captureRoboImage +import com.google.android.horologist.compose.layout.AppScaffold +import com.google.android.horologist.compose.layout.ResponsiveTimeText +import com.google.android.horologist.screenshots.FixedTimeSource +import com.google.android.horologist.screenshots.a11y.A11ySnapshotTransformer +import com.google.android.horologist.screenshots.rng.WearScreenshotTest.Companion.useHardwareRenderer +import com.google.android.horologist.screenshots.rng.WearScreenshotTest.Companion.withImageLoader +import org.junit.Rule +import org.junit.rules.TestName +import org.junit.runner.RunWith +import org.robolectric.Shadows +import org.robolectric.annotation.Config +import org.robolectric.annotation.GraphicsMode + +@Config( + sdk = [33], + qualifiers = RobolectricDeviceQualifiers.WearOSLargeRound, +) +@RunWith(AndroidJUnit4::class) +@GraphicsMode(GraphicsMode.Mode.NATIVE) +public abstract class WearLegacyA11yTest { + @get:Rule + public val composeRule: ComposeContentTestRule = createComposeRule() + + @get:Rule + public val testInfo: TestName = TestName() + + // Allow for individual tolerances to be set on each test, should be between 0.0 and 1.0 + public open val tolerance: Float = 0.0f + + public open val imageLoader: FakeImageLoaderEngine? = null + + public fun runScreenTest( + content: @Composable () -> Unit, + ) { + composeRule.setContent { + TestScaffold { + content() + } + } + + captureScreenshot() + } + + public fun runComponentTest( + content: @Composable () -> Unit, + ) { + composeRule.setContent { + withImageLoader(imageLoader) { + ComponentScaffold { + content() + } + } + } + + captureScreenshot() + } + + public fun captureScreenshot(suffix: String = "") { + captureScreenA11yRoboImage( + filePath = testName(suffix), + roborazziOptions = RoborazziOptions( + recordOptions = RoborazziOptions.RecordOptions( + applyDeviceCrop = true, + ), + compareOptions = RoborazziOptions.CompareOptions( + resultValidator = ThresholdValidator(tolerance), + ), + ), + ) + } + + public open fun testName(suffix: String): String = "src/test/snapshots/images/" + + "${this.javaClass.`package`?.name}_${this.javaClass.simpleName}_" + + "${testInfo.methodName}$suffix.png" + + public fun captureScreenA11yRoboImage( + filePath: String, + roborazziOptions: RoborazziOptions, + ) { + Espresso.onIdle() + + val screenImage = captureScreenImageToBitmap(roborazziOptions) + + val annotatedImage = A11ySnapshotTransformer().transform(composeRule.onRoot(), screenImage) + + annotatedImage.captureRoboImage(filePath, roborazziOptions) + } + + @Suppress("INACCESSIBLE_TYPE") + private fun captureScreenImageToBitmap(roborazziOptions: RoborazziOptions): Bitmap { + val rootsOracle = RootsOracle_Factory { Looper.getMainLooper() }.get() + val listActiveRoots = rootsOracle.javaClass.getMethod("listActiveRoots") + listActiveRoots.isAccessible = true + @Suppress("UNCHECKED_CAST") + val roots: List<Root> = + listActiveRoots.invoke(rootsOracle) as List<Root> + + val rootComponent = RoboComponent.Screen( + rootsOrderByDepth = roots.sortedBy { it.windowLayoutParams.get()?.type }, + roborazziOptions = roborazziOptions, + ) + + val image = rootComponent.image!! + return image + } + + @Composable + public open fun TestScaffold(content: @Composable () -> Unit) { + AppScaffold( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colors.background), + timeText = { ResponsiveTimeText(timeSource = FixedTimeSource) }, + ) { + content() + } + } + + @Composable + public open fun ComponentScaffold(content: @Composable () -> Unit) { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier + .fillMaxSize() + .background(Color.Black), + ) { + content() + } + } + + public companion object { + public fun enableTouchExploration() { + val applicationContext = ApplicationProvider.getApplicationContext<Application>() + val a11yManager = applicationContext.getSystemService(AccessibilityManager::class.java) + val shadow = Shadows.shadowOf(a11yManager) + + shadow.setEnabled(true) + shadow.setTouchExplorationEnabled(true) + } + + init { + useHardwareRenderer() + } + } +} diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyComponentTest.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyComponentTest.kt index 74a9d3bd..64845cb1 100644 --- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyComponentTest.kt +++ b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearLegacyComponentTest.kt @@ -14,12 +14,14 @@ * limitations under the License. */ -@file:OptIn(ExperimentalRoborazziApi::class) +@file:OptIn(ExperimentalRoborazziApi::class, ExperimentalCoilApi::class) package com.google.android.horologist.screenshots.rng import androidx.compose.runtime.Composable import androidx.test.ext.junit.runners.AndroidJUnit4 +import coil.annotation.ExperimentalCoilApi +import coil.test.FakeImageLoaderEngine import com.github.takahirom.roborazzi.ExperimentalRoborazziApi import com.github.takahirom.roborazzi.RobolectricDeviceQualifiers import com.github.takahirom.roborazzi.RoborazziOptions @@ -27,6 +29,7 @@ import com.github.takahirom.roborazzi.ThresholdValidator import com.github.takahirom.roborazzi.captureRoboImage import com.google.android.horologist.images.coil.FakeImageLoader import com.google.android.horologist.screenshots.rng.WearScreenshotTest.Companion.useHardwareRenderer +import com.google.android.horologist.screenshots.rng.WearScreenshotTest.Companion.withImageLoader import org.junit.Rule import org.junit.rules.TestName import org.junit.runner.RunWith @@ -55,6 +58,8 @@ public abstract class WearLegacyComponentTest { // Allow for individual tolerances to be set on each test, should be between 0.0 and 1.0 public open val tolerance: Float = 0.0f + public open val imageLoader: FakeImageLoaderEngine? = null + public fun runComponentTest( content: @Composable () -> Unit, ) { @@ -73,8 +78,10 @@ public abstract class WearLegacyComponentTest { ), ), ) { - ComponentScaffold { - content() + withImageLoader(imageLoader) { + ComponentScaffold { + content() + } } } } diff --git a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt index 18b0b6e6..69bc8421 100644 --- a/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt +++ b/roboscreenshots/src/main/java/com/google/android/horologist/screenshots/rng/WearScreenshotTest.kt @@ -14,18 +14,24 @@ * limitations under the License. */ -@file:OptIn(ExperimentalRoborazziApi::class) +@file:OptIn(ExperimentalRoborazziApi::class, ExperimentalCoilApi::class) package com.google.android.horologist.screenshots.rng import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.createComposeRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.wear.compose.material.MaterialTheme +import coil.ImageLoader +import coil.annotation.ExperimentalCoilApi +import coil.compose.LocalImageLoader +import coil.test.FakeImageLoaderEngine import com.github.takahirom.roborazzi.ExperimentalRoborazziApi import com.github.takahirom.roborazzi.RobolectricDeviceQualifiers import com.github.takahirom.roborazzi.RoborazziOptions @@ -59,6 +65,8 @@ public abstract class WearScreenshotTest { // Allow for individual tolerances to be set on each test, should be between 0.0 and 1.0 public open val tolerance: Float = 0.0f + public open val imageLoader: FakeImageLoaderEngine? = null + public fun runTest( suffix: String? = null, device: WearDevice? = this.device, @@ -71,8 +79,10 @@ public abstract class WearScreenshotTest { } composeRule.setContent { - TestScaffold { - content() + withImageLoader(imageLoader) { + TestScaffold { + content() + } } } captureScreenshot(suffix.orEmpty()) @@ -117,5 +127,25 @@ public abstract class WearScreenshotTest { public fun useHardwareRenderer() { System.setProperty(USE_HARDWARE_RENDERER_NATIVE_ENV, "true") } + + @Composable + internal fun withImageLoader( + imageLoaderEngine: FakeImageLoaderEngine?, + content: @Composable () -> Unit, + ) { + if (imageLoaderEngine == null) { + content() + } else { + val imageLoader = ImageLoader.Builder(LocalContext.current) + .components { add(imageLoaderEngine) } + .build() + @Suppress("DEPRECATION") + ( + CompositionLocalProvider(LocalImageLoader provides imageLoader) { + content() + } + ) + } + } } } |