Removal of Px usages part 5 of n
Relnote: "Replaced usage of Px class in various
compose classes as part of the large
refactoring effort to only rely on Dp
and primitive types for pixel parameters"
Bug: 156681014
Test: re-ran compose tests
Change-Id: Id343458210b56a9a4cdae4ef3d0f97ea79004942
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 ed3afdc..8c75f3f 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
@@ -70,7 +70,7 @@
}, bodyContent = emptyContent())
}
runOnIdleCompose {
- assertThat(position!!.x.value).isEqualTo(0f)
+ assertThat(position!!.x).isEqualTo(0f)
}
}
@@ -86,7 +86,7 @@
}
val width = composeTestRule.displayMetrics.widthPixels
runOnIdleCompose {
- assertThat(position!!.x.round().value).isEqualTo(-width)
+ assertThat(position!!.x.px.round().value).isEqualTo(-width)
}
}
@@ -124,7 +124,7 @@
// temporary calculation of landscape screen
val expectedHeight = if (width > height) 0 else (height / 2f).roundToInt()
runOnIdleCompose {
- assertThat(position!!.y.round().value).isEqualTo(expectedHeight)
+ assertThat(position!!.y.px.round().value).isEqualTo(expectedHeight)
}
}
@@ -140,7 +140,7 @@
}
val height = composeTestRule.displayMetrics.heightPixels
runOnIdleCompose {
- assertThat(position!!.y.round().value).isEqualTo(height)
+ assertThat(position!!.y.px.round().value).isEqualTo(height)
}
}
@@ -157,10 +157,10 @@
Box(
Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
val pos = info.localToGlobal(PxPosition.Origin)
- if (pos.x == 0.px) {
+ if (pos.x == 0.0f) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (-pos.x.round() == contentWidth) {
+ } else if (-pos.x.px.round() == contentWidth) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -227,8 +227,8 @@
// Click on the left-center pixel of the drawer
findByTag("Drawer").doGesture {
- val left = 1.px
- val centerY = globalBounds.height / 2
+ val left = 1.0f
+ val centerY = (globalBounds.height / 2).value
sendClick(PxPosition(left, centerY))
}
@@ -251,10 +251,10 @@
drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
val pos = info.localToGlobal(PxPosition.Origin)
- if (pos.y.round() == openedHeight) {
+ if (pos.y.px.round() == openedHeight) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (pos.y.round() == contentHeight) {
+ } else if (pos.y.px.round() == contentHeight) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -326,8 +326,8 @@
// Click on the bottom-center pixel of the drawer
findByTag("Drawer").doGesture {
val bounds = globalBounds
- val centerX = bounds.width / 2
- val bottom = bounds.height - 1.px
+ val centerX = (bounds.width / 2).value
+ val bottom = (bounds.height - 1.px).value
sendClick(PxPosition(centerX, bottom))
}