[go: nahoru, domu]

Replace Container with Box for material components

Bug: 151407926
Test: should pass
Change-Id: I6a30fa9d9786f37a9e67f34bd9181e720aad565c
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 beccd9e..9794f24 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
@@ -22,8 +22,9 @@
 import androidx.test.filters.MediumTest
 import androidx.ui.core.TestTag
 import androidx.ui.core.onPositioned
+import androidx.ui.foundation.Box
 import androidx.ui.foundation.Clickable
-import androidx.ui.layout.Container
+import androidx.ui.layout.LayoutSize
 import androidx.ui.semantics.Semantics
 import androidx.ui.test.createComposeRule
 import androidx.ui.test.doGesture
@@ -63,13 +64,9 @@
         var position: PxPosition? = null
         composeTestRule.setMaterialContent {
             ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = {
-                Container(
-                    onPositioned { coords ->
-                        position = coords.localToGlobal(PxPosition.Origin)
-                    },
-                    expanded = true
-                ) {
-                }
+                Box(LayoutSize.Fill + onPositioned { coords ->
+                    position = coords.localToGlobal(PxPosition.Origin)
+                })
             }, bodyContent = emptyContent())
         }
         composeTestRule.runOnIdleCompose {
@@ -82,13 +79,9 @@
         var position: PxPosition? = null
         composeTestRule.setMaterialContent {
             ModalDrawerLayout(DrawerState.Closed, {}, drawerContent = {
-                Container(
-                    onPositioned { coords ->
-                        position = coords.localToGlobal(PxPosition.Origin)
-                    },
-                    expanded = true
-                ) {
-                }
+                Box(LayoutSize.Fill + onPositioned { coords ->
+                    position = coords.localToGlobal(PxPosition.Origin)
+                })
             }, bodyContent = emptyContent())
         }
         val width = composeTestRule.displayMetrics.widthPixels
@@ -102,13 +95,7 @@
         var size: IntPxSize? = null
         composeTestRule.setMaterialContent {
             ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = {
-                Container(
-                    onPositioned { coords ->
-                        size = coords.size
-                    },
-                    expanded = true
-                ) {
-                }
+                Box(LayoutSize.Fill + onPositioned { coords -> size = coords.size })
             }, bodyContent = emptyContent())
         }
 
@@ -124,13 +111,9 @@
         var position: PxPosition? = null
         composeTestRule.setMaterialContent {
             BottomDrawerLayout(DrawerState.Opened, {}, drawerContent = {
-                Container(
-                    onPositioned { coords ->
-                        position = coords.localToGlobal(PxPosition.Origin)
-                    },
-                    expanded = true
-                ) {
-                }
+                Box(LayoutSize.Fill + onPositioned { coords ->
+                    position = coords.localToGlobal(PxPosition.Origin)
+                })
             }, bodyContent = emptyContent())
         }
 
@@ -148,13 +131,9 @@
         var position: PxPosition? = null
         composeTestRule.setMaterialContent {
             BottomDrawerLayout(DrawerState.Closed, {}, drawerContent = {
-                Container(
-                    onPositioned { coords ->
-                        position = coords.localToGlobal(PxPosition.Origin)
-                    },
-                    expanded = true
-                ) {
-                }
+                Box(LayoutSize.Fill + onPositioned { coords ->
+                    position = coords.localToGlobal(PxPosition.Origin)
+                })
             }, bodyContent = emptyContent())
         }
         val height = composeTestRule.displayMetrics.heightPixels
@@ -168,7 +147,7 @@
         composeTestRule
             .setMaterialContentAndCollectSizes {
                 StaticDrawer {
-                    Container(expanded = true, children = emptyContent())
+                    Box(LayoutSize.Fill)
                 }
             }
             .assertWidthEqualsTo(256.dp)
@@ -186,10 +165,8 @@
                 Semantics(container = true) {
                     ModalDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
-                            Container(
-                                expanded = true,
-                                children = emptyContent(),
-                                modifier = onPositioned { info ->
+                            Box(
+                                LayoutSize.Fill + onPositioned { info ->
                                     val pos = info.localToGlobal(PxPosition.Origin)
                                     if (pos.x == 0.px) {
                                         // If fully opened, mark the openedLatch if present
@@ -202,11 +179,7 @@
                             )
                         },
                         bodyContent = {
-                            Container(
-                                expanded = true,
-                                children = emptyContent(),
-                                modifier = onPositioned { contentWidth = it.size.width }
-                            )
+                            Box(LayoutSize.Fill + onPositioned { contentWidth = it.size.width })
                         })
                 }
             }
@@ -243,12 +216,12 @@
                     ModalDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
                             Clickable( drawerClicks += 1 }) {
-                                Container(expanded = true, children = emptyContent())
+                                Box(LayoutSize.Fill, children = emptyContent())
                             }
                         },
                         bodyContent = {
                             Clickable( bodyClicks += 1 }) {
-                                Container(expanded = true, children = emptyContent())
+                                Box(LayoutSize.Fill, children = emptyContent())
                             }
                         })
                 }
@@ -292,30 +265,22 @@
                 Semantics(container = true) {
                     BottomDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
-                            Container(
-                                expanded = true,
-                                children = emptyContent(),
-                                modifier = onPositioned { info ->
-                                    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()
-                                    }
+                            Box(LayoutSize.Fill + onPositioned { info ->
+                                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 = {
-                            Container(
-                                expanded = true,
-                                children = emptyContent(),
-                                modifier = onPositioned {
-                                    contentHeight = it.size.height
-                                    openedHeight = it.size.height * BottomDrawerOpenFraction
-                                }
-                            )
+                            Box(LayoutSize.Fill + onPositioned {
+                                contentHeight = it.size.height
+                                openedHeight = it.size.height * BottomDrawerOpenFraction
+                            })
                         }
                     )
                 }
@@ -353,12 +318,12 @@
                     BottomDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
                             Clickable( drawerClicks += 1 }) {
-                                Container(expanded = true, children = emptyContent())
+                                Box(LayoutSize.Fill, children = emptyContent())
                             }
                         },
                         bodyContent = {
                             Clickable( bodyClicks += 1 }) {
-                                Container(expanded = true, children = emptyContent())
+                                Box(LayoutSize.Fill, children = emptyContent())
                             }
                         })
                 }