[go: nahoru, domu]

Change LayoutCoordinates to have size in IntPxSize.

Relnote: "LayoutCoordinates no longer has a position property. The
position property does not make sense when considering LayoutModifiers,
rotation, or scaling. Instead, developers should use parentCoordinates
and childToLocal() to calculate the transform from one
LayoutCoordinate to another.

LayoutCoordinates uses IntPxSize for the size property instead of
PxSize. Layouts use integer pixel sizes for layouts, so all layout sizes
should use integers and not floating point values."

Test: ran connectedCheck tests
Change-Id: I9367be21c2c202c8b6ad889b50a29454773f41af
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 6e14874..8bd5384 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
@@ -30,9 +30,9 @@
 import androidx.ui.test.findByTag
 import androidx.ui.test.globalBounds
 import androidx.ui.test.sendClick
-import androidx.ui.unit.Px
+import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
 import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
 import androidx.ui.unit.dp
 import androidx.ui.unit.height
 import androidx.ui.unit.px
@@ -94,7 +94,7 @@
 
     @Test
     fun modalDrawer_testEndPadding_whenOpened() {
-        var size: PxSize? = null
+        var size: IntPxSize? = null
         composeTestRule.setMaterialContent {
             ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = {
                 Container(expanded = true) {
@@ -107,7 +107,7 @@
 
         val width = composeTestRule.displayMetrics.widthPixels
         composeTestRule.runOnIdleComposeWithDensity {
-            assertThat(size!!.width.round().value)
+            assertThat(size!!.width.value)
                 .isEqualTo(width - 56.dp.toPx().round().value)
         }
     }
@@ -165,7 +165,7 @@
 
     @Test
     fun modalDrawer_openAndClose() {
-        var contentWidth: Px? = null
+        var contentWidth: IntPx? = null
         var openedLatch: CountDownLatch? = null
         var closedLatch: CountDownLatch? = CountDownLatch(1)
         val drawerState = DrawerStateHolder(DrawerState.Closed)
@@ -175,11 +175,11 @@
                     ModalDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
                             OnChildPositioned({ info ->
-                                val pos = info.localToGlobal(info.position)
+                                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 == contentWidth) {
+                                } else if (-pos.x.round() == contentWidth) {
                                     // If fully closed, mark the closedLatch if present
                                     closedLatch?.countDown()
                                 }
@@ -265,8 +265,8 @@
 
     @Test
     fun bottomDrawer_openAndClose() {
-        var contentHeight: Px? = null
-        var openedHeight: Px? = null
+        var contentHeight: IntPx? = null
+        var openedHeight: IntPx? = null
         var openedLatch: CountDownLatch? = null
         var closedLatch: CountDownLatch? = CountDownLatch(1)
         val drawerState = DrawerStateHolder(DrawerState.Closed)
@@ -276,11 +276,11 @@
                     BottomDrawerLayout(drawerState.state, { drawerState.state = it },
                         drawerContent = {
                             OnChildPositioned({ info ->
-                                val pos = info.localToGlobal(info.position)
-                                if (pos.y == openedHeight) {
+                                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 == contentHeight) {
+                                } else if (pos.y.round() == contentHeight) {
                                     // If fully closed, mark the closedLatch if present
                                     closedLatch?.countDown()
                                 }