Fix ripple radius in selection controls
Ripple radius should be 24.dp (48.dp diameter) to match material spec
Fixes: 159069097
Fixes: 159069313
Test: new screenshot tests added
Change-Id: If819be5420f18c002b59a8a80f236e6d5ec95744
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
index 9f2424b..8b5e326 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
@@ -29,11 +29,14 @@
import androidx.ui.foundation.selection.ToggleableState
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.captureToBitmap
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.find
import androidx.ui.test.findByTag
import androidx.ui.test.isToggleable
+import androidx.ui.test.sendDown
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -78,6 +81,19 @@
}
@Test
+ fun checkBoxTest_pressed() {
+ composeTestRule.setMaterialContent {
+ Box(wrap.semantics().testTag(wrapperTestTag)) {
+ Checkbox(modifier = wrap, checked = false, })
+ }
+ }
+ findByTag(wrapperTestTag).doPartialGesture {
+ sendDown(center)
+ }
+ assertToggeableAgainstGolden("checkbox_pressed")
+ }
+
+ @Test
fun checkBoxTest_indeterminate() {
composeTestRule.setMaterialContent {
Box(wrap.semantics().testTag(wrapperTestTag)) {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
index 23f5c3d..abe539d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
@@ -29,11 +29,14 @@
import androidx.ui.foundation.Box
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.captureToBitmap
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.find
import androidx.ui.test.findByTag
import androidx.ui.test.isInMutuallyExclusiveGroup
+import androidx.ui.test.sendDown
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -78,6 +81,19 @@
}
@Test
+ fun radioButtonTest_pressed() {
+ composeTestRule.setMaterialContent {
+ Box(wrap.semantics().testTag(wrapperTestTag)) {
+ RadioButton(selected = false, >
+ }
+ }
+ findByTag(wrapperTestTag).doPartialGesture {
+ sendDown(center)
+ }
+ assertSelectableAgainstGolden("radioButton_pressed")
+ }
+
+ @Test
fun radioButtonTest_disabled_selected() {
composeTestRule.setMaterialContent {
Box(wrap.semantics().testTag(wrapperTestTag)) {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
index abb86cd..6f2b19d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
@@ -29,11 +29,14 @@
import androidx.ui.graphics.Color
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.captureToBitmap
+import androidx.ui.test.center
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
+import androidx.ui.test.doPartialGesture
import androidx.ui.test.find
import androidx.ui.test.findByTag
import androidx.ui.test.isToggleable
+import androidx.ui.test.sendDown
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -90,6 +93,20 @@
}
@Test
+ fun switchTest_pressed() {
+ composeTestRule.setMaterialContent {
+ Box(wrapperModifier) {
+ Switch(checked = false, enabled = true, })
+ }
+ }
+
+ findByTag(wrapperTestTag).doPartialGesture {
+ sendDown(center)
+ }
+ assertToggeableAgainstGolden("switch_pressed")
+ }
+
+ @Test
fun switchTest_disabled_checked() {
composeTestRule.setMaterialContent {
Box(wrapperModifier) {
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt b/ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt
index 927aa89..21a9535 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Checkbox.kt
@@ -131,7 +131,7 @@
state = state,
>
enabled = enabled,
- indication = RippleIndication(bounded = false)
+ indication = RippleIndication(bounded = false, radius = CheckboxRippleRadius)
)
.padding(CheckboxDefaultPadding),
enabled = enabled,
@@ -362,6 +362,7 @@
}
}
+private val CheckboxRippleRadius = 24.dp
private val CheckboxDefaultPadding = 2.dp
private val CheckboxSize = 20.dp
private val StrokeWidth = 2.dp
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt b/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
index 41a3ffe..ed96e0c 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/RadioButton.kt
@@ -339,7 +339,7 @@
selected = selected,
>
enabled = enabled,
- indication = RippleIndication(bounded = false)
+ indication = RippleIndication(bounded = false, radius = RadioButtonRippleRadius)
)
.wrapContentSize(Alignment.Center)
.padding(RadioButtonPadding)
@@ -409,6 +409,7 @@
}
}
+private val RadioButtonRippleRadius = 24.dp
private val RadioButtonPadding = 2.dp
private val RadioButtonSize = 20.dp
private val RadioRadius = RadioButtonSize / 2