Address few minor issues in Drawer.
This CL adds parameters requested to allow better Drawer customization, as well as semantics for proper container identification
Fixes: 149274110
Fixes: 154862521
Test: tests updated
Change-Id: I2a3420d18074f82789018087449becd999dfc236
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
index 613d4e2..841f60a 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
@@ -27,7 +27,6 @@
import androidx.ui.foundation.Box
import androidx.ui.foundation.Clickable
import androidx.ui.layout.fillMaxSize
-import androidx.ui.semantics.Semantics
import androidx.ui.test.createComposeRule
import androidx.ui.test.doGesture
import androidx.ui.test.findByTag
@@ -154,27 +153,25 @@
val drawerState = mutableStateOf(DrawerState.Closed)
composeTestRule.setMaterialContent {
TestTag("Drawer") {
- Semantics(container = true) {
- ModalDrawerLayout(drawerState.value, { drawerState.value = it },
- drawerContent = {
- Box(
- Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
- val pos = info.localToGlobal(PxPosition.Origin)
- if (pos.x == 0.px) {
- // If fully opened, mark the openedLatch if present
- openedLatch?.countDown()
- } else if (-pos.x.round() == contentWidth) {
- // If fully closed, mark the closedLatch if present
- closedLatch?.countDown()
- }
+ ModalDrawerLayout(drawerState.value, { drawerState.value = it },
+ drawerContent = {
+ Box(
+ Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
+ val pos = info.localToGlobal(PxPosition.Origin)
+ if (pos.x == 0.px) {
+ // If fully opened, mark the openedLatch if present
+ openedLatch?.countDown()
+ } else if (-pos.x.round() == contentWidth) {
+ // If fully closed, mark the closedLatch if present
+ closedLatch?.countDown()
}
- )
- },
- bodyContent = {
- Box(Modifier.fillMaxSize()
- .onPositioned { contentWidth = it.size.width })
- })
- }
+ }
+ )
+ },
+ bodyContent = {
+ Box(Modifier.fillMaxSize()
+ .onPositioned { contentWidth = it.size.width })
+ })
}
}
// Drawer should start in closed state
@@ -205,19 +202,17 @@
composeTestRule.setMaterialContent {
// emulate click on the screen
TestTag("Drawer") {
- Semantics(container = true) {
- ModalDrawerLayout(drawerState.value, { drawerState.value = it },
- drawerContent = {
- Clickable( drawerClicks += 1 }) {
- Box(Modifier.fillMaxSize(), children = emptyContent())
- }
- },
- bodyContent = {
- Clickable( bodyClicks += 1 }) {
- Box(Modifier.fillMaxSize(), children = emptyContent())
- }
- })
- }
+ ModalDrawerLayout(drawerState.value, { drawerState.value = it },
+ drawerContent = {
+ Clickable( drawerClicks += 1 }) {
+ Box(Modifier.fillMaxSize(), children = emptyContent())
+ }
+ },
+ bodyContent = {
+ Clickable( bodyClicks += 1 }) {
+ Box(Modifier.fillMaxSize(), children = emptyContent())
+ }
+ })
}
}
@@ -255,28 +250,26 @@
val drawerState = mutableStateOf(DrawerState.Closed)
composeTestRule.setMaterialContent {
TestTag("Drawer") {
- Semantics(container = true) {
- BottomDrawerLayout(drawerState.value, { drawerState.value = it },
- drawerContent = {
- Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
- val pos = info.localToGlobal(PxPosition.Origin)
- if (pos.y.round() == openedHeight) {
- // If fully opened, mark the openedLatch if present
- openedLatch?.countDown()
- } else if (pos.y.round() == contentHeight) {
- // If fully closed, mark the closedLatch if present
- closedLatch?.countDown()
- }
- })
- },
- bodyContent = {
- Box(Modifier.fillMaxSize().onPositioned {
- contentHeight = it.size.height
- openedHeight = it.size.height * BottomDrawerOpenFraction
- })
- }
- )
- }
+ BottomDrawerLayout(drawerState.value, { drawerState.value = it },
+ drawerContent = {
+ Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
+ val pos = info.localToGlobal(PxPosition.Origin)
+ if (pos.y.round() == openedHeight) {
+ // If fully opened, mark the openedLatch if present
+ openedLatch?.countDown()
+ } else if (pos.y.round() == contentHeight) {
+ // If fully closed, mark the closedLatch if present
+ closedLatch?.countDown()
+ }
+ })
+ },
+ bodyContent = {
+ Box(Modifier.fillMaxSize().onPositioned {
+ contentHeight = it.size.height
+ openedHeight = it.size.height * BottomDrawerOpenFraction
+ })
+ }
+ )
}
}
// Drawer should start in closed state
@@ -307,19 +300,17 @@
composeTestRule.setMaterialContent {
// emulate click on the screen
TestTag("Drawer") {
- Semantics(container = true) {
- BottomDrawerLayout(drawerState.value, { drawerState.value = it },
- drawerContent = {
- Clickable( drawerClicks += 1 }) {
- Box(Modifier.fillMaxSize(), children = emptyContent())
- }
- },
- bodyContent = {
- Clickable( bodyClicks += 1 }) {
- Box(Modifier.fillMaxSize(), children = emptyContent())
- }
- })
- }
+ BottomDrawerLayout(drawerState.value, { drawerState.value = it },
+ drawerContent = {
+ Clickable( drawerClicks += 1 }) {
+ Box(Modifier.fillMaxSize(), children = emptyContent())
+ }
+ },
+ bodyContent = {
+ Clickable( bodyClicks += 1 }) {
+ Box(Modifier.fillMaxSize(), children = emptyContent())
+ }
+ })
}
}