Add filter chip screenshot tests.
Bug: 192585545, 182821022
Test: screenshot tests.
Relnote: N/A
Change-Id: I09d20ae90cb3edd019471e9e5af9db5140ef38d2
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ChipScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ChipScreenshotTest.kt
index c8759df..d646868b 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ChipScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ChipScreenshotTest.kt
@@ -17,6 +17,10 @@
package androidx.compose.material
import android.os.Build
+import androidx.compose.foundation.layout.requiredSize
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Done
+import androidx.compose.material.icons.filled.Home
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
@@ -104,6 +108,130 @@
assertChipAgainstGolden("actionChip_outlined_disabled")
}
+ @Test
+ fun filterChip_selected() {
+ rule.setMaterialContent {
+ FilterChip(
+ selected = true,
+ >
+ modifier = Modifier.testTag(TestTag),
+ selectedIcon = {
+ Icon(
+ imageVector = Icons.Filled.Done,
+ contentDescription = "Localized Description",
+ modifier = Modifier.requiredSize(ChipDefaults.SelectedIconSize)
+ )
+ }
+ ) {
+ Text("Filter Chip")
+ }
+ }
+ assertChipAgainstGolden("filterChip_selected")
+ }
+
+ @Test
+ fun filterChip_withLeadingIcon_selected() {
+ rule.setMaterialContent {
+ FilterChip(
+ selected = true,
+ >
+ modifier = Modifier.testTag(TestTag),
+ leadingIcon = {
+ Icon(
+ Icons.Filled.Home,
+ contentDescription = "Localized Description"
+ )
+ },
+ selectedIcon = {
+ Icon(
+ imageVector = Icons.Filled.Done,
+ contentDescription = "Localized Description",
+ modifier = Modifier.requiredSize(ChipDefaults.SelectedIconSize)
+ )
+ }
+ ) {
+ Text("Filter Chip")
+ }
+ }
+ assertChipAgainstGolden("filterChip_with_leading_icon_selected")
+ }
+
+ @Test
+ fun filterChip_notSelected() {
+ rule.setMaterialContent {
+ FilterChip(selected = false, modifier = Modifier.testTag(TestTag)) {
+ Text("Filter Chip")
+ }
+ }
+ assertChipAgainstGolden("filterChip_notSelected")
+ }
+
+ @Test
+ fun filterChip_disabled_selected() {
+ rule.setMaterialContent {
+ FilterChip(
+ selected = true,
+ >
+ enabled = false,
+ modifier = Modifier.testTag(TestTag),
+ selectedIcon = {
+ Icon(
+ imageVector = Icons.Filled.Done,
+ tint = LocalContentColor.current,
+ contentDescription = "Localized Description",
+ modifier = Modifier.requiredSize(ChipDefaults.SelectedIconSize)
+ )
+ }
+ ) {
+ Text("Filter Chip")
+ }
+ }
+ assertChipAgainstGolden("filterChip_disabled_selected")
+ }
+
+ @Test
+ fun filterChip_withLeadingIcon_disabled_selected() {
+ rule.setMaterialContent {
+ FilterChip(
+ selected = true,
+ >
+ enabled = false,
+ modifier = Modifier.testTag(TestTag),
+ leadingIcon = {
+ Icon(
+ Icons.Filled.Home,
+ contentDescription = "Localized Description"
+ )
+ },
+ selectedIcon = {
+ Icon(
+ imageVector = Icons.Filled.Done,
+ contentDescription = "Localized Description",
+ modifier = Modifier.requiredSize(ChipDefaults.SelectedIconSize)
+ )
+ }
+ ) {
+ Text("Filter Chip")
+ }
+ }
+ assertChipAgainstGolden("filterChip_with_leading_icon_disabled_selected")
+ }
+
+ @Test
+ fun filterChip_disabled_notSelected() {
+ rule.setMaterialContent {
+ FilterChip(
+ selected = false,
+ >
+ enabled = false,
+ modifier = Modifier.testTag(TestTag)
+ ) {
+ Text("filter Chip")
+ }
+ }
+ assertChipAgainstGolden("filterChip_disabled_notSelected")
+ }
+
private fun assertChipAgainstGolden(goldenIdentifier: String) {
rule.onNodeWithTag(TestTag)
.captureToImage()