Remove IntPx
Relnote: "Replaced usage of IntPx with Int. Replaced IntPxPosition
with IntOffset. Replaced IntPxSize with IntSize."
Test: ran many tests and demo app.
Bug: 148980115
Change-Id: Ib7b44d92ce3aff86c606753f0ac5c3122b71041d
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
index ff9e9cb..8be4be4 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
@@ -36,7 +36,6 @@
import androidx.ui.text.TextStyle
import androidx.ui.unit.Density
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import androidx.ui.unit.sp
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -62,7 +61,7 @@
TopAppBar(title = { Text("Title") })
}
.assertHeightEqualsTo(appBarHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -92,7 +91,7 @@
Text("title", Modifier.onPositioned { coords: LayoutCoordinates ->
titleCoords = coords
titleLastBaselineRelativePosition =
- coords[LastBaseline]!!.value.toFloat()
+ coords[LastBaseline]!!.toFloat()
})
},
actions = {
@@ -104,11 +103,11 @@
composeTestRule.runOnIdleComposeWithDensity {
val appBarBottomEdgeY = appBarCoords!!.globalPosition.y +
- appBarCoords!!.size.height.value
+ appBarCoords!!.size.height
// Navigation icon should be 4.dp from the start
val navigationIconPositionX = navigationIconCoords!!.globalPosition.x
- val navigationIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().value.toFloat()
+ val navigationIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().toFloat()
assertThat(navigationIconPositionX).isEqualTo(navigationIconExpectedPositionX)
// Navigation icon should be 4.dp from the bottom
@@ -121,7 +120,7 @@
// Title should be 72.dp from the start
val titlePositionX = titleCoords!!.globalPosition.x
// 4.dp padding for the whole app bar + 68.dp inset
- val titleExpectedPositionX = (4.dp.toIntPx() + 68.dp.toIntPx()).value.toFloat()
+ val titleExpectedPositionX = (4.dp.toIntPx() + 68.dp.toIntPx()).toFloat()
assertThat(titlePositionX).isEqualTo(titleExpectedPositionX)
// Absolute position of the baseline
@@ -129,13 +128,13 @@
titleCoords!!.globalPosition.y
// Baseline should be 20.sp from the bottom of the app bar
val titleExpectedLastBaselinePositionY =
- (appBarBottomEdgeY - 20.sp.toIntPx().value.toFloat())
+ (appBarBottomEdgeY - 20.sp.toIntPx().toFloat())
assertThat(titleLastBaselinePositionY).isEqualTo(titleExpectedLastBaselinePositionY)
// Action should be placed at the end
val actionPositionX = actionCoords!!.globalPosition.x
val actionExpectedPositionX =
- expectedActionPosition(appBarCoords!!.size.width.value.toFloat())
+ expectedActionPosition(appBarCoords!!.size.width.toFloat())
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
// Action should be 4.dp from the bottom
@@ -170,13 +169,13 @@
// Title should now be placed 16.dp from the start, as there is no navigation icon
val titlePositionX = titleCoords!!.globalPosition.x
// 4.dp padding for the whole app bar + 12.dp inset
- val titleExpectedPositionX = (4.dp.toIntPx() + 12.dp.toIntPx()).value.toFloat()
+ val titleExpectedPositionX = (4.dp.toIntPx() + 12.dp.toIntPx()).toFloat()
assertThat(titlePositionX).isEqualTo(titleExpectedPositionX)
// Action should still be placed at the end
val actionPositionX = actionCoords!!.globalPosition.x
val actionExpectedPositionX =
- expectedActionPosition(appBarCoords!!.size.width.value.toFloat())
+ expectedActionPosition(appBarCoords!!.size.width.toFloat())
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
}
}
@@ -208,7 +207,7 @@
BottomAppBar {}
}
.assertHeightEqualsTo(appBarHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -226,11 +225,11 @@
composeTestRule.runOnIdleComposeWithDensity {
// Child icon should be 4.dp from the start
val childIconPositionX = childCoords!!.globalPosition.x
- val childIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().value.toFloat()
+ val childIconExpectedPositionX = AppBarStartAndEndPadding.toIntPx().toFloat()
assertThat(childIconPositionX).isEqualTo(childIconExpectedPositionX)
val appBarBottomEdgeY = appBarCoords!!.globalPosition.y +
- appBarCoords!!.size.height.value
+ appBarCoords!!.size.height
// Child icon should be 4.dp from the bottom
val childIconPositionY = childCoords!!.globalPosition.y
@@ -251,8 +250,8 @@
}
private fun Density.expectedActionPosition(appBarWidth: Float): Float {
- return appBarWidth - AppBarStartAndEndPadding.toIntPx().value -
- FakeIconSize.toIntPx().value
+ return appBarWidth - AppBarStartAndEndPadding.toIntPx() -
+ FakeIconSize.toIntPx()
}
private val AppBarStartAndEndPadding = 4.dp
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
index 320ba93..66ffb61 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
@@ -104,7 +104,7 @@
Truth.assertThat(coord.size.width).isEqualTo(expectedItemWidth)
Truth.assertThat(coord.size.height).isEqualTo(expectedItemHeight)
Truth.assertThat(coord.globalPosition.x)
- .isEqualTo((expectedItemWidth * index).value.toFloat())
+ .isEqualTo((expectedItemWidth * index).toFloat())
}
}
}
@@ -141,24 +141,24 @@
composeTestRule.runOnIdleComposeWithDensity {
// Distance from the bottom to the text baseline and from the text baseline to the
// bottom of the icon
- val textBaseline = 12.dp.toIntPx().value.toFloat()
+ val textBaseline = 12.dp.toIntPx().toFloat()
// Relative position of the baseline to the top of text
- val relativeTextBaseline = textCoords[LastBaseline]!!.value.toFloat()
+ val relativeTextBaseline = textCoords[LastBaseline]!!.toFloat()
// Absolute y position of the text baseline
val absoluteTextBaseline = textCoords.globalPosition.y + relativeTextBaseline
- val itemBottom = itemCoords.size.height.value.toFloat() + itemCoords.globalPosition.y
+ val itemBottom = itemCoords.size.height.toFloat() + itemCoords.globalPosition.y
// Text baseline should be 12.dp from the bottom of the item
Truth.assertThat(absoluteTextBaseline).isEqualTo(itemBottom - textBaseline)
// The icon should be centered in the item
- val iconExpectedX = (itemCoords.size.width.value.toFloat() - iconCoords.size.width
- .value.toFloat()) / 2
+ val iconExpectedX = (itemCoords.size.width.toFloat() - iconCoords.size.width
+ .toFloat()) / 2
// The bottom of the icon is 12.dp above the text baseline
val iconExpectedY =
- absoluteTextBaseline - 12.dp.toIntPx().value.toFloat() -
- iconCoords.size.height.value
+ absoluteTextBaseline - 12.dp.toIntPx().toFloat() -
+ iconCoords.size.height
Truth.assertThat(iconCoords.globalPosition.x).isWithin(1f).of(iconExpectedX)
Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY)
@@ -204,10 +204,10 @@
composeTestRule.runOnIdleComposeWithDensity {
// The icon should be centered in the item
- val iconExpectedX = (itemCoords.size.width.value.toFloat() -
- iconCoords.size.width.value.toFloat()) / 2
+ val iconExpectedX = (itemCoords.size.width.toFloat() -
+ iconCoords.size.width.toFloat()) / 2
val iconExpectedY = ((itemCoords.size.height - iconCoords.size.height) / 2)
- .value.toFloat()
+ .toFloat()
Truth.assertThat(iconCoords.globalPosition.x).isWithin(1f).of(iconExpectedX)
Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY)
@@ -244,8 +244,8 @@
val iconExpectedY = (itemCoords.size.height - iconCoords.size.height) / 2
Truth.assertThat(iconCoords.globalPosition.x).isWithin(1f).of(
- iconExpectedX.value.toFloat())
- Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY.value.toFloat())
+ iconExpectedX.toFloat())
+ Truth.assertThat(iconCoords.globalPosition.y).isEqualTo(iconExpectedY.toFloat())
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
index fb7f056..c76740b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
@@ -223,7 +223,7 @@
with(composeTestRule.density) {
assertThat(realSize.height)
- .isGreaterThan(36.dp.toIntPx().value.toFloat())
+ .isGreaterThan(36.dp.toIntPx().toFloat())
}
}
@@ -491,8 +491,8 @@
assertThat(contentBounds.width).isLessThan(buttonBounds.width)
assertThat(contentBounds.height).isLessThan(buttonBounds.height)
with(composeTestRule.density) {
- assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
- assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
+ assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
}
assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
}
@@ -554,7 +554,7 @@
val topLeft = childCoordinates!!.localToGlobal(Offset.Zero).x -
parentCoordinates!!.localToGlobal(Offset.Zero).x
val currentPadding = with(composeTestRule.density) {
- padding.toIntPx().value.toFloat()
+ padding.toIntPx().toFloat()
}
assertThat(currentPadding).isEqualTo(topLeft)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DividerUiTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DividerUiTest.kt
index 5bc2877..3c4ee77 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DividerUiTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DividerUiTest.kt
@@ -19,7 +19,6 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.createComposeRule
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -42,7 +41,7 @@
Divider()
}
.assertHeightEqualsTo(defaultHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -53,7 +52,7 @@
.setMaterialContentAndCollectSizes {
Divider(thickness = height)
}
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
.assertHeightEqualsTo(height)
}
@@ -68,6 +67,6 @@
Divider(startIndent = indent, thickness = height)
}
.assertHeightEqualsTo(height)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
}
\ No newline at end of file
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 55bd392..44a9372 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
@@ -26,6 +26,7 @@
import androidx.ui.core.testTag
import androidx.ui.foundation.Box
import androidx.ui.foundation.clickable
+import androidx.ui.geometry.Offset
import androidx.ui.layout.fillMaxSize
import androidx.ui.test.createComposeRule
import androidx.ui.test.doGesture
@@ -34,9 +35,7 @@
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
import androidx.ui.test.sendClick
-import androidx.ui.unit.IntPx
-import androidx.ui.unit.IntPxSize
-import androidx.ui.geometry.Offset
+import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
import androidx.ui.unit.height
import androidx.ui.unit.width
@@ -90,7 +89,7 @@
@Test
fun modalDrawer_testEndPadding_whenOpened() {
- var size: IntPxSize? = null
+ var size: IntSize? = null
composeTestRule.setMaterialContent {
ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates ->
@@ -101,7 +100,7 @@
val width = composeTestRule.displayMetrics.widthPixels
composeTestRule.runOnIdleComposeWithDensity {
- assertThat(size!!.width.value)
+ assertThat(size!!.width)
.isEqualTo(width - 56.dp.toPx().roundToInt())
}
}
@@ -145,7 +144,7 @@
@Test
@Ignore("failing in postsubmit, fix in b/148751721")
fun modalDrawer_openAndClose() {
- var contentWidth: IntPx? = null
+ var contentWidth: Int? = null
var openedLatch: CountDownLatch? = null
var closedLatch: CountDownLatch? = CountDownLatch(1)
val drawerState = mutableStateOf(DrawerState.Closed)
@@ -158,7 +157,7 @@
if (pos.x == 0.0f) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (-pos.x.roundToInt() == contentWidth?.value) {
+ } else if (-pos.x.roundToInt() == contentWidth) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -239,8 +238,8 @@
@Test
@Ignore("failing in postsubmit, fix in b/148751721")
fun bottomDrawer_openAndClose() {
- var contentHeight: IntPx? = null
- var openedHeight: IntPx? = null
+ var contentHeight: Int? = null
+ var openedHeight: Int? = null
var openedLatch: CountDownLatch? = null
var closedLatch: CountDownLatch? = CountDownLatch(1)
val drawerState = mutableStateOf(DrawerState.Closed)
@@ -249,10 +248,10 @@
drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
val pos = info.localToGlobal(Offset.Zero)
- if (pos.y.roundToInt() == openedHeight?.value) {
+ if (pos.y.roundToInt() == openedHeight) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (pos.y.roundToInt() == contentHeight?.value) {
+ } else if (pos.y.roundToInt() == contentHeight) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -261,7 +260,7 @@
bodyContent = {
Box(Modifier.fillMaxSize().onPositioned {
contentHeight = it.size.height
- openedHeight = it.size.height * BottomDrawerOpenFraction
+ openedHeight = (it.size.height * BottomDrawerOpenFraction).roundToInt()
})
}
)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
index 14af10b..203aec8 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
@@ -29,9 +29,8 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.findByTag
import androidx.ui.unit.Dp
-import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -43,7 +42,7 @@
class ElevationOverlayTest(private val elevation: Dp?, overlayColor: Color?) {
private val Tag = "Surface"
- private val SurfaceSize = IntPxSize(10.ipx, 10.ipx)
+ private val SurfaceSize = IntSize(10, 10)
private val expectedOverlayColor = overlayColor!!
companion object {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
index 2f4cd3e..359c7c7 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/FilledTextFieldTest.kt
@@ -42,6 +42,7 @@
import androidx.ui.input.KeyboardType
import androidx.ui.input.PasswordVisualTransformation
import androidx.ui.input.TextInputService
+import androidx.ui.geometry.Offset
import androidx.ui.layout.Column
import androidx.ui.layout.Stack
import androidx.ui.layout.fillMaxWidth
@@ -61,10 +62,8 @@
import androidx.ui.test.sendSwipeUp
import androidx.ui.text.FirstBaseline
import androidx.ui.text.SoftwareKeyboardController
-import androidx.ui.unit.IntPxSize
-import androidx.ui.geometry.Offset
+import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import androidx.ui.unit.sp
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
@@ -78,6 +77,7 @@
import org.junit.runners.JUnit4
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
+import kotlin.math.roundToInt
@MediumTest
@RunWith(JUnit4::class)
@@ -184,7 +184,7 @@
@Test
fun testLabelPosition_initial_withDefaultHeight() {
- val labelSize = Ref<IntPxSize>()
+ val labelSize = Ref<IntSize>()
val labelPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
@@ -210,15 +210,15 @@
testRule.runOnIdleComposeWithDensity {
// size
assertThat(labelSize.value).isNotNull()
- assertThat(labelSize.value?.height).isGreaterThan(0.ipx)
- assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
+ assertThat(labelSize.value?.height).isGreaterThan(0)
+ assertThat(labelSize.value?.width).isGreaterThan(0)
// centered position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
assertThat(labelPosition.value?.y).isEqualTo(
((ExpectedMinimumTextFieldHeight.toIntPx() - labelSize.value!!.height) / 2f)
- .value.toFloat()
+ .roundToInt().toFloat()
)
}
}
@@ -226,7 +226,7 @@
@Test
fun testLabelPosition_initial_withCustomHeight() {
val height = 80.dp
- val labelSize = Ref<IntPxSize>()
+ val labelSize = Ref<IntSize>()
val labelPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
@@ -247,21 +247,21 @@
testRule.runOnIdleComposeWithDensity {
// size
assertThat(labelSize.value).isNotNull()
- assertThat(labelSize.value?.height).isGreaterThan(0.ipx)
- assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
+ assertThat(labelSize.value?.height).isGreaterThan(0)
+ assertThat(labelSize.value?.width).isGreaterThan(0)
// centered position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
assertThat(labelPosition.value?.y).isEqualTo(
- ((height.toIntPx() - labelSize.value!!.height) / 2f).value.toFloat()
+ ((height.toIntPx() - labelSize.value!!.height) / 2f).roundToInt().toFloat()
)
}
}
@Test
fun testLabelPosition_whenFocused() {
- val labelSize = Ref<IntPxSize>()
+ val labelSize = Ref<IntSize>()
val labelPosition = Ref<Offset>()
val baseline = Ref<Float>()
testRule.setMaterialContent {
@@ -275,7 +275,7 @@
labelPosition.value = it.globalPosition
labelSize.value = it.size
baseline.value =
- it[FirstBaseline]!!.value.toFloat() + labelPosition.value!!.y
+ it[FirstBaseline]!!.toFloat() + labelPosition.value!!.y
})
}
)
@@ -288,21 +288,21 @@
testRule.runOnIdleComposeWithDensity {
// size
assertThat(labelSize.value).isNotNull()
- assertThat(labelSize.value?.height).isGreaterThan(0.ipx)
- assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
+ assertThat(labelSize.value?.height).isGreaterThan(0)
+ assertThat(labelSize.value?.width).isGreaterThan(0)
// label's top position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
assertThat(baseline.value).isEqualTo(
- ExpectedBaselineOffset.toIntPx().value.toFloat()
+ ExpectedBaselineOffset.toIntPx().toFloat()
)
}
}
@Test
fun testLabelPosition_whenInput() {
- val labelSize = Ref<IntPxSize>()
+ val labelSize = Ref<IntSize>()
val labelPosition = Ref<Offset>()
val baseline = Ref<Float>()
testRule.setMaterialContent {
@@ -315,7 +315,7 @@
labelPosition.value = it.globalPosition
labelSize.value = it.size
baseline.value =
- it[FirstBaseline]!!.value.toFloat() + labelPosition.value!!.y
+ it[FirstBaseline]!!.toFloat() + labelPosition.value!!.y
})
}
)
@@ -325,21 +325,21 @@
testRule.runOnIdleComposeWithDensity {
// size
assertThat(labelSize.value).isNotNull()
- assertThat(labelSize.value?.height).isGreaterThan(0.ipx)
- assertThat(labelSize.value?.width).isGreaterThan(0.ipx)
+ assertThat(labelSize.value?.height).isGreaterThan(0)
+ assertThat(labelSize.value?.width).isGreaterThan(0)
// label's top position
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
assertThat(baseline.value).isEqualTo(
- ExpectedBaselineOffset.toIntPx().value.toFloat()
+ ExpectedBaselineOffset.toIntPx().toFloat()
)
}
}
@Test
fun testPlaceholderPosition_withLabel() {
- val placeholderSize = Ref<IntPxSize>()
+ val placeholderSize = Ref<IntSize>()
val placeholderPosition = Ref<Offset>()
val placeholderBaseline = Ref<Float>()
testRule.setMaterialContent {
@@ -356,8 +356,7 @@
placeholderPosition.value = it.globalPosition
placeholderSize.value = it.size
placeholderBaseline.value =
- it[FirstBaseline]!!.value.toFloat() +
- placeholderPosition.value!!.y
+ it[FirstBaseline]!!.toFloat() + placeholderPosition.value!!.y
})
}
)
@@ -369,23 +368,23 @@
testRule.runOnIdleComposeWithDensity {
// size
assertThat(placeholderSize.value).isNotNull()
- assertThat(placeholderSize.value?.height).isGreaterThan(0.ipx)
- assertThat(placeholderSize.value?.width).isGreaterThan(0.ipx)
+ assertThat(placeholderSize.value?.height).isGreaterThan(0)
+ assertThat(placeholderSize.value?.width).isGreaterThan(0)
// placeholder's position
assertThat(placeholderPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
assertThat(placeholderBaseline.value)
.isEqualTo(
- 60.dp.toIntPx().value.toFloat() -
- ExpectedLastBaselineOffset.toIntPx().value.toFloat()
+ 60.dp.toIntPx().toFloat() -
+ ExpectedLastBaselineOffset.toIntPx().toFloat()
)
}
}
@Test
fun testPlaceholderPosition_whenNoLabel() {
- val placeholderSize = Ref<IntPxSize>()
+ val placeholderSize = Ref<IntSize>()
val placeholderPosition = Ref<Offset>()
val placeholderBaseline = Ref<Float>()
val height = 60.dp
@@ -401,8 +400,7 @@
placeholderPosition.value = it.globalPosition
placeholderSize.value = it.size
placeholderBaseline.value =
- it[FirstBaseline]!!.value.toFloat() +
- placeholderPosition.value!!.y
+ it[FirstBaseline]!!.toFloat() + placeholderPosition.value!!.y
})
}
)
@@ -414,21 +412,21 @@
testRule.runOnIdleComposeWithDensity {
// size
assertThat(placeholderSize.value).isNotNull()
- assertThat(placeholderSize.value?.height).isGreaterThan(0.ipx)
- assertThat(placeholderSize.value?.width).isGreaterThan(0.ipx)
+ assertThat(placeholderSize.value?.height).isGreaterThan(0)
+ assertThat(placeholderSize.value?.width).isGreaterThan(0)
// centered position
assertThat(placeholderPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
assertThat(placeholderPosition.value?.y).isEqualTo(
- ((height.toIntPx() - placeholderSize.value!!.height) / 2f).value.toFloat()
+ ((height.toIntPx() - placeholderSize.value!!.height) / 2f).roundToInt().toFloat()
)
}
}
@Test
fun testNoPlaceholder_whenInputNotEmpty() {
- val placeholderSize = Ref<IntPxSize>()
+ val placeholderSize = Ref<IntSize>()
val placeholderPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
@@ -483,9 +481,9 @@
val textFieldWidth = 300.dp
val size = 30.dp
val leadingPosition = Ref<Offset>()
- val leadingSize = Ref<IntPxSize>()
+ val leadingSize = Ref<IntSize>()
val trailingPosition = Ref<Offset>()
- val trailingSize = Ref<IntPxSize>()
+ val trailingSize = Ref<IntSize>()
testRule.setMaterialContent {
FilledTextField(
@@ -510,20 +508,22 @@
testRule.runOnIdleComposeWithDensity {
// leading
- assertThat(leadingSize.value).isEqualTo(IntPxSize(size.toIntPx(), size.toIntPx()))
- assertThat(leadingPosition.value?.x).isEqualTo(IconPadding.toIntPx().value.toFloat())
+ assertThat(leadingSize.value).isEqualTo(IntSize(size.toIntPx(), size.toIntPx()))
+ assertThat(leadingPosition.value?.x).isEqualTo(IconPadding.toIntPx().toFloat())
assertThat(leadingPosition.value?.y).isEqualTo(
- ((textFieldHeight.toIntPx() - leadingSize.value!!.height) / 2f).value.toFloat()
+ ((textFieldHeight.toIntPx() - leadingSize.value!!.height) / 2f).roundToInt()
+ .toFloat()
)
// trailing
- assertThat(trailingSize.value).isEqualTo(IntPxSize(size.toIntPx(), size.toIntPx()))
+ assertThat(trailingSize.value).isEqualTo(IntSize(size.toIntPx(), size.toIntPx()))
assertThat(trailingPosition.value?.x).isEqualTo(
(textFieldWidth.toIntPx() - IconPadding.toIntPx() - trailingSize.value!!.width)
- .value.toFloat()
+ .toFloat()
)
- assertThat(trailingPosition.value?.y).isEqualTo(
- ((textFieldHeight.toIntPx() - trailingSize.value!!.height) / 2f).value.toFloat()
- )
+ assertThat(trailingPosition.value?.y)
+ .isEqualTo(((textFieldHeight.toIntPx() - trailingSize.value!!.height) / 2f)
+ .roundToInt().toFloat()
+ )
}
}
@@ -551,7 +551,7 @@
testRule.runOnIdleComposeWithDensity {
assertThat(labelPosition.value?.x).isEqualTo(
- (ExpectedPadding.toIntPx() + IconPadding.toIntPx() + iconSize.toIntPx()).value
+ (ExpectedPadding.toIntPx() + IconPadding.toIntPx() + iconSize.toIntPx())
.toFloat()
)
}
@@ -580,7 +580,7 @@
testRule.runOnIdleComposeWithDensity {
assertThat(labelPosition.value?.x).isEqualTo(
- ExpectedPadding.toIntPx().value.toFloat()
+ ExpectedPadding.toIntPx().toFloat()
)
}
}
@@ -836,8 +836,8 @@
val tag = "testTag"
val scrollerPosition = TextFieldScrollerPosition()
- val parentSize = 200.ipx
- val textFieldSize = 50.ipx
+ val parentSize = 200
+ val textFieldSize = 50
with(testRule.density) {
testRule.setContent {
@@ -863,7 +863,7 @@
findByTag(tag)
.captureToBitmap()
- .assertPixels(expectedSize = IntPxSize(parentSize, parentSize)) { position ->
+ .assertPixels(expectedSize = IntSize(parentSize, parentSize)) { position ->
if (position.x > textFieldSize && position.y > textFieldSize) Color.White else null
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
index 5e25dac..1814e90 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
@@ -116,8 +116,8 @@
)
}
with(composeTestRule.density) {
- assertThat(size.height.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx().value)
- assertThat(size.width.roundToInt().toFloat()).isAtLeast(48.dp.toIntPx().value)
+ assertThat(size.height.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx())
+ assertThat(size.width.roundToInt().toFloat()).isAtLeast(48.dp.toIntPx())
}
}
@@ -131,8 +131,8 @@
)
}
with(composeTestRule.density) {
- assertThat(size.width.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx().value)
- assertThat(size.height.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx().value)
+ assertThat(size.width.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx())
+ assertThat(size.height.roundToInt().toFloat()).isEqualTo(48.dp.toIntPx())
}
}
@@ -223,8 +223,8 @@
assertThat(contentBounds.width).isLessThan(buttonBounds.width)
assertThat(contentBounds.height).isLessThan(buttonBounds.height)
with(composeTestRule.density) {
- assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
- assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
+ assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
}
assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
}
@@ -254,8 +254,8 @@
assertThat(contentBounds.width).isLessThan(buttonBounds.width)
assertThat(contentBounds.height).isLessThan(buttonBounds.height)
with(composeTestRule.density) {
- assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
- assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
+ assertThat(contentBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
+ assertThat(contentBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
}
assertWithinOnePixel(buttonBounds.center(), contentBounds.center())
}
@@ -290,14 +290,14 @@
val textBounds = textCoordinates!!.boundsInRoot
val iconBounds = iconCoordinates!!.boundsInRoot
with(composeTestRule.density) {
- assertThat(textBounds.width).isEqualTo(2.dp.toIntPx().value.toFloat())
- assertThat(textBounds.height).isEqualTo(2.dp.toIntPx().value.toFloat())
- assertThat(iconBounds.width).isEqualTo(10.dp.toIntPx().value.toFloat())
- assertThat(iconBounds.height).isEqualTo(10.dp.toIntPx().value.toFloat())
+ assertThat(textBounds.width).isEqualTo(2.dp.toIntPx().toFloat())
+ assertThat(textBounds.height).isEqualTo(2.dp.toIntPx().toFloat())
+ assertThat(iconBounds.width).isEqualTo(10.dp.toIntPx().toFloat())
+ assertThat(iconBounds.height).isEqualTo(10.dp.toIntPx().toFloat())
assertWithinOnePixel(buttonBounds.center().y, iconBounds.center().y)
assertWithinOnePixel(buttonBounds.center().y, textBounds.center().y)
- val halfPadding = 6.dp.toIntPx().value.toFloat()
+ val halfPadding = 6.dp.toIntPx().toFloat()
assertWithinOnePixel(
iconBounds.center().x + iconBounds.width / 2 + halfPadding,
textBounds.center().x - textBounds.width / 2 - halfPadding
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
index 56c5ee5..e061541 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
@@ -37,6 +37,7 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
+import kotlin.math.roundToInt
@LargeTest
@RunWith(JUnit4::class)
@@ -78,8 +79,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
// Icon should be centered inside the IconButton
- Truth.assertThat(iconX).isEqualTo(12.dp.toIntPx().value.toFloat())
- Truth.assertThat(iconY).isEqualTo(12.dp.toIntPx().value.toFloat())
+ Truth.assertThat(iconX).isEqualTo((24.dp.toIntPx() / 2f).roundToInt().toFloat())
+ Truth.assertThat(iconY).isEqualTo((24.dp.toIntPx() / 2f).roundToInt().toFloat())
}
}
@@ -103,8 +104,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
- val expectedX = ((48.dp - width) / 2).toIntPx().value.toFloat()
- val expectedY = ((48.dp - height) / 2).toIntPx().value.toFloat()
+ val expectedX = ((48.dp.toIntPx() - width.toIntPx()) / 2f).roundToInt().toFloat()
+ val expectedY = ((48.dp.toIntPx() - height.toIntPx()) / 2f).roundToInt().toFloat()
// Icon should be centered inside the IconButton
Truth.assertThat(iconX).isEqualTo(expectedX)
Truth.assertThat(iconY).isEqualTo(expectedY)
@@ -142,8 +143,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
// Icon should be centered inside the IconButton
- Truth.assertThat(iconX).isEqualTo(12.dp.toIntPx().value.toFloat())
- Truth.assertThat(iconY).isEqualTo(12.dp.toIntPx().value.toFloat())
+ Truth.assertThat(iconX).isEqualTo((24.dp.toIntPx() / 2f).roundToInt().toFloat())
+ Truth.assertThat(iconY).isEqualTo((24.dp.toIntPx() / 2f).roundToInt().toFloat())
}
}
@@ -166,8 +167,8 @@
val iconX = iconCoords.positionInParent.x
val iconY = iconCoords.positionInParent.y
- val expectedX = ((48.dp - width) / 2).toIntPx().value.toFloat()
- val expectedY = ((48.dp - height) / 2).toIntPx().value.toFloat()
+ val expectedX = ((48.dp.toIntPx() - width.toIntPx()) / 2f).roundToInt().toFloat()
+ val expectedY = ((48.dp.toIntPx() - height.toIntPx()) / 2f).roundToInt().toFloat()
// Icon should be centered inside the IconButton
Truth.assertThat(iconX).isEqualTo(expectedX)
Truth.assertThat(iconY).isEqualTo(expectedY)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconTest.kt
index 378a760..6bf1b54 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconTest.kt
@@ -72,7 +72,7 @@
composeTestRule
.setMaterialContentAndCollectSizes {
val dummyImage = with(DensityAmbient.current) {
- ImageAsset(width.toIntPx().value, height.toIntPx().value)
+ ImageAsset(width.toIntPx(), height.toIntPx())
}
Icon(dummyImage)
@@ -89,7 +89,7 @@
composeTestRule
.setMaterialContentAndCollectSizes {
val dummyImage = with(DensityAmbient.current) {
- ImageAsset(width.toIntPx().value, height.toIntPx().value)
+ ImageAsset(width.toIntPx(), height.toIntPx())
}
Icon(dummyImage)
@@ -119,7 +119,7 @@
composeTestRule
.setMaterialContentAndCollectSizes {
val dummyImage = with(DensityAmbient.current) {
- ImageAsset(width.toIntPx().value, height.toIntPx().value)
+ ImageAsset(width.toIntPx(), height.toIntPx())
}
val imagePainter = ImagePainter(dummyImage)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
index 5584105..b4fef6f 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
@@ -25,13 +25,12 @@
import androidx.ui.foundation.Box
import androidx.ui.foundation.Image
import androidx.ui.foundation.Text
+import androidx.ui.geometry.Offset
import androidx.ui.graphics.ImageAsset
import androidx.ui.test.createComposeRule
import androidx.ui.unit.Dp
-import androidx.ui.unit.IntPxSize
-import androidx.ui.geometry.Offset
+import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -59,7 +58,7 @@
ListItem(text = "Primary text")
}
.assertHeightEqualsTo(expectedHeightNoIcon)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -71,7 +70,7 @@
ListItem(text = "Primary text", icon = icon24x24)
}
.assertHeightEqualsTo(expectedHeightSmallIcon)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -83,7 +82,7 @@
ListItem(text = "Primary text", icon = icon56x56)
}
.assertHeightEqualsTo(expectedHeightLargeIcon)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -95,7 +94,7 @@
ListItem(text = "Primary text", secondaryText = "Secondary text")
}
.assertHeightEqualsTo(expectedHeightNoIcon)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -112,7 +111,7 @@
)
}
.assertHeightEqualsTo(expectedHeightWithIcon)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -128,7 +127,7 @@
)
}
.assertHeightEqualsTo(expectedHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -144,7 +143,7 @@
)
}
.assertHeightEqualsTo(expectedHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -161,7 +160,7 @@
)
}
.assertHeightEqualsTo(expectedHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -178,7 +177,7 @@
)
}
.assertHeightEqualsTo(expectedHeight)
- .assertWidthEqualsTo { dm.widthPixels.ipx }
+ .assertWidthEqualsTo { dm.widthPixels }
}
@Test
@@ -188,9 +187,9 @@
val expectedRightPadding = 16.dp
val textPosition = Ref<Offset>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val trailingPosition = Ref<Offset>()
- val trailingSize = Ref<IntPxSize>()
+ val trailingSize = Ref<IntSize>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -203,17 +202,18 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx()
- .value.toFloat())
+ .toFloat())
assertThat(textPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).value.toFloat()
+ ((listItemHeight.toIntPx() - textSize.value!!.height) / 2f).roundToInt().toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels - trailingSize.value!!.width.value -
- expectedRightPadding.toIntPx().value.toFloat()
+ dm.widthPixels - trailingSize.value!!.width -
+ expectedRightPadding.toIntPx().toFloat()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).value.toFloat()
+ ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2f).roundToInt()
+ .toFloat()
)
}
}
@@ -225,9 +225,9 @@
val expectedTextLeftPadding = 32.dp
val textPosition = Ref<Offset>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val iconPosition = Ref<Offset>()
- val iconSize = Ref<IntPxSize>()
+ val iconSize = Ref<IntSize>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -238,18 +238,18 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(iconPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - iconSize.value!!.height) / 2).value.toFloat()
+ ((listItemHeight.toIntPx() - iconSize.value!!.height) / 2f).roundToInt().toFloat()
)
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() +
- iconSize.value!!.width.value +
- expectedTextLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() +
+ iconSize.value!!.width +
+ expectedTextLeftPadding.toIntPx().toFloat()
)
assertThat(textPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).value.toFloat()
+ ((listItemHeight.toIntPx() - textSize.value!!.height) / 2f).roundToInt().toFloat()
)
}
}
@@ -263,13 +263,13 @@
val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
- val secondaryTextSize = Ref<IntPxSize>()
+ val secondaryTextSize = Ref<IntSize>()
val trailingPosition = Ref<Offset>()
val trailingBaseline = Ref<Float>()
- val trailingSize = Ref<IntPxSize>()
+ val trailingSize = Ref<IntSize>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -294,25 +294,25 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat()
)
assertThat(textBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat()
)
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat() +
- expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels - trailingSize.value!!.width.value -
- expectedRightPadding.toIntPx().value.toFloat()
+ dm.widthPixels - trailingSize.value!!.width -
+ expectedRightPadding.toIntPx().toFloat()
)
assertThat(trailingBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat()
)
}
}
@@ -327,12 +327,12 @@
val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
- val secondaryTextSize = Ref<IntPxSize>()
+ val secondaryTextSize = Ref<IntSize>()
val iconPosition = Ref<Offset>()
- val iconSize = Ref<IntPxSize>()
+ val iconSize = Ref<IntSize>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -357,26 +357,26 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() + iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(textBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat()
)
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() +
- iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() +
+ iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat() +
- expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().value.toFloat()
+ expectedIconTopPadding.toIntPx().toFloat()
)
}
}
@@ -393,14 +393,14 @@
val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
- val secondaryTextSize = Ref<IntPxSize>()
+ val secondaryTextSize = Ref<IntSize>()
val iconPosition = Ref<Offset>()
- val iconSize = Ref<IntPxSize>()
+ val iconSize = Ref<IntSize>()
val trailingPosition = Ref<Offset>()
- val trailingSize = Ref<IntPxSize>()
+ val trailingSize = Ref<IntSize>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -428,34 +428,34 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() + iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(textBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat()
)
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() +
- iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() +
+ iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat() +
- expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().value.toFloat()
+ expectedIconTopPadding.toIntPx().toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels - trailingSize.value!!.width.value -
- expectedRightPadding.toIntPx().value.toFloat()
+ dm.widthPixels - trailingSize.value!!.width -
+ expectedRightPadding.toIntPx().toFloat()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).value.toFloat()
+ ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).toFloat()
)
}
}
@@ -471,14 +471,14 @@
val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
- val secondaryTextSize = Ref<IntPxSize>()
+ val secondaryTextSize = Ref<IntSize>()
val iconPosition = Ref<Offset>()
- val iconSize = Ref<IntPxSize>()
+ val iconSize = Ref<IntSize>()
val trailingPosition = Ref<Offset>()
- val trailingSize = Ref<IntPxSize>()
+ val trailingSize = Ref<IntSize>()
composeTestRule.setMaterialContent {
Box {
ListItem(
@@ -507,32 +507,31 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() + iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(textBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat()
)
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() + iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() + iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedTextBaseline.toIntPx().value.toFloat() +
- expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
+ expectedTextBaseline.toIntPx().toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().toFloat()
)
- assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx()
- .value.toFloat())
+ assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toFloat())
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().value.toFloat()
+ expectedIconTopPadding.toIntPx().toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels - trailingSize.value!!.width.value.toFloat() -
- expectedRightPadding.toIntPx().value.toFloat()
+ dm.widthPixels - trailingSize.value!!.width.toFloat() -
+ expectedRightPadding.toIntPx().toFloat()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().value.toFloat()
+ expectedIconTopPadding.toIntPx().toFloat()
)
}
}
@@ -549,17 +548,17 @@
val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
- val textSize = Ref<IntPxSize>()
+ val textSize = Ref<IntSize>()
val overlineTextPosition = Ref<Offset>()
val overlineTextBaseline = Ref<Float>()
- val overlineTextSize = Ref<IntPxSize>()
+ val overlineTextSize = Ref<IntSize>()
val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
- val secondaryTextSize = Ref<IntPxSize>()
+ val secondaryTextSize = Ref<IntSize>()
val iconPosition = Ref<Offset>()
- val iconSize = Ref<IntPxSize>()
+ val iconSize = Ref<IntSize>()
val trailingPosition = Ref<Offset>()
- val trailingSize = Ref<IntPxSize>()
+ val trailingSize = Ref<IntSize>()
val trailingBaseline = Ref<Float>()
composeTestRule.setMaterialContent {
Box {
@@ -608,45 +607,45 @@
}
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() +
- iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() +
+ iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(textBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().value.toFloat() +
- expectedTextBaselineOffset.toIntPx().value.toFloat()
+ expectedOverlineBaseline.toIntPx().toFloat() +
+ expectedTextBaselineOffset.toIntPx().toFloat()
)
assertThat(overlineTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() +
- iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() +
+ iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(overlineTextBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().value.toFloat()
+ expectedOverlineBaseline.toIntPx().toFloat()
)
assertThat(secondaryTextPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat() +
- iconSize.value!!.width.value +
- expectedContentLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat() +
+ iconSize.value!!.width +
+ expectedContentLeftPadding.toIntPx().toFloat()
)
assertThat(secondaryTextBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().value.toFloat() +
- expectedTextBaselineOffset.toIntPx().value.toFloat() +
- expectedSecondaryTextBaselineOffset.toIntPx().value.toFloat()
+ expectedOverlineBaseline.toIntPx().toFloat() +
+ expectedTextBaselineOffset.toIntPx().toFloat() +
+ expectedSecondaryTextBaselineOffset.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.x).isEqualTo(
- expectedLeftPadding.toIntPx().value.toFloat()
+ expectedLeftPadding.toIntPx().toFloat()
)
assertThat(iconPosition.value!!.y).isEqualTo(
- expectedIconTopPadding.toIntPx().value.toFloat()
+ expectedIconTopPadding.toIntPx().toFloat()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
- dm.widthPixels - trailingSize.value!!.width.value -
- expectedRightPadding.toIntPx().value.toFloat()
+ dm.widthPixels - trailingSize.value!!.width -
+ expectedRightPadding.toIntPx().toFloat()
)
assertThat(trailingBaseline.value!!).isEqualTo(
- expectedOverlineBaseline.toIntPx().value.toFloat()
+ expectedOverlineBaseline.toIntPx().toFloat()
)
}
}
@@ -655,11 +654,11 @@
private fun saveLayout(
coords: Ref<Offset>,
- size: Ref<IntPxSize>,
+ size: Ref<IntSize>,
baseline: Ref<Float> = Ref()
): Modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
coords.value = coordinates.localToGlobal(Offset.Zero)
- baseline.value = coordinates[FirstBaseline]?.value?.toFloat()?.let {
+ baseline.value = coordinates[FirstBaseline]?.toFloat()?.let {
it + coords.value!!.y
}
size.value = coordinates.size
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
index 7ba6686..93df35d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
@@ -21,6 +21,7 @@
import androidx.compose.mutableStateOf
import androidx.compose.setValue
import androidx.test.filters.MediumTest
+import androidx.ui.core.DensityAmbient
import androidx.ui.core.LayoutDirection
import androidx.ui.core.Modifier
import androidx.ui.core.testTag
@@ -44,11 +45,10 @@
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.waitForIdle
import androidx.ui.unit.Density
-import androidx.ui.unit.IntPxPosition
-import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.IntOffset
+import androidx.ui.unit.IntSize
import androidx.ui.unit.Position
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -100,18 +100,20 @@
@Test
fun menu_hasExpectedSize() {
composeTestRule.setContent {
- DropdownMenu(
- expanded = true,
- toggle = {
- Box(Modifier.size(20.dp).drawBackground(Color.Blue))
- },
- >
- ) {
- Semantics(properties = { testTag = "MenuContent1" }, container = true) {
- Box(Modifier.preferredSize(70.dp))
- }
- Semantics(properties = { testTag = "MenuContent2" }, container = true) {
- Box(Modifier.preferredSize(130.dp))
+ with(DensityAmbient.current) {
+ DropdownMenu(
+ expanded = true,
+ toggle = {
+ Box(Modifier.size(20.toDp()).drawBackground(Color.Blue))
+ },
+ >
+ ) {
+ Semantics(properties = { testTag = "MenuContent1" }, container = true) {
+ Box(Modifier.preferredSize(70.toDp()))
+ }
+ Semantics(properties = { testTag = "MenuContent2" }, container = true) {
+ Box(Modifier.preferredSize(130.toDp()))
+ }
}
}
}
@@ -123,8 +125,8 @@
hasAnyChildThat(hasTestTag("MenuContent2"))
).assertExists().fetchSemanticsNode()
with(composeTestRule.density) {
- assertThat(node.size.width).isEqualTo(130.dp.toIntPx() + MenuElevation.toIntPx() * 2)
- assertThat(node.size.height).isEqualTo(200.dp.toIntPx() +
+ assertThat(node.size.width).isEqualTo(130 + MenuElevation.toIntPx() * 2)
+ assertThat(node.size.height).isEqualTo(200 +
DropdownMenuVerticalPadding.toIntPx() * 2 + MenuElevation.toIntPx() * 2
)
}
@@ -139,12 +141,12 @@
widthPixels = screenWidth
heightPixels = screenHeight
}
- val anchorPosition = IntPxPosition(100.ipx, 200.ipx)
- val anchorSize = IntPxSize(10.ipx, 20.ipx)
+ val anchorPosition = IntOffset(100, 200)
+ val anchorSize = IntSize(10, 20)
val inset = with(density) { MenuElevation.toIntPx() }
val offsetX = 20
val offsetY = 40
- val popupSize = IntPxSize(50.ipx, 80.ipx)
+ val popupSize = IntSize(50, 80)
val ltrPosition = DropdownMenuPositionProvider(
Position(offsetX.dp, offsetY.dp),
@@ -158,10 +160,10 @@
)
assertThat(ltrPosition.x).isEqualTo(
- anchorPosition.x + anchorSize.width - inset + offsetX.ipx
+ anchorPosition.x + anchorSize.width - inset + offsetX
)
assertThat(ltrPosition.y).isEqualTo(
- anchorPosition.y + anchorSize.height - inset + offsetY.ipx
+ anchorPosition.y + anchorSize.height - inset + offsetY
)
val rtlPosition = DropdownMenuPositionProvider(
@@ -176,10 +178,10 @@
)
assertThat(rtlPosition.x).isEqualTo(
- anchorPosition.x - popupSize.width + inset - offsetX.ipx
+ anchorPosition.x - popupSize.width + inset - offsetX
)
assertThat(rtlPosition.y).isEqualTo(
- anchorPosition.y + anchorSize.height - inset + offsetY.ipx
+ anchorPosition.y + anchorSize.height - inset + offsetY
)
}
@@ -192,13 +194,13 @@
widthPixels = screenWidth
heightPixels = screenHeight
}
- val anchorPosition = IntPxPosition(450.ipx, 950.ipx)
- val anchorPositionRtl = IntPxPosition(50.ipx, 950.ipx)
- val anchorSize = IntPxSize(10.ipx, 20.ipx)
+ val anchorPosition = IntOffset(450, 950)
+ val anchorPositionRtl = IntOffset(50, 950)
+ val anchorSize = IntSize(10, 20)
val inset = with(density) { MenuElevation.toIntPx() }
val offsetX = 20
val offsetY = 40
- val popupSize = IntPxSize(150.ipx, 80.ipx)
+ val popupSize = IntSize(150, 80)
val ltrPosition = DropdownMenuPositionProvider(
Position(offsetX.dp, offsetY.dp),
@@ -212,10 +214,10 @@
)
assertThat(ltrPosition.x).isEqualTo(
- anchorPosition.x - popupSize.width + inset - offsetX.ipx
+ anchorPosition.x - popupSize.width + inset - offsetX
)
assertThat(ltrPosition.y).isEqualTo(
- anchorPosition.y - popupSize.height + inset - offsetY.ipx
+ anchorPosition.y - popupSize.height + inset - offsetY
)
val rtlPosition = DropdownMenuPositionProvider(
@@ -230,10 +232,10 @@
)
assertThat(rtlPosition.x).isEqualTo(
- anchorPositionRtl.x + anchorSize.width - inset + offsetX.ipx
+ anchorPositionRtl.x + anchorSize.width - inset + offsetX
)
assertThat(rtlPosition.y).isEqualTo(
- anchorPositionRtl.y - popupSize.height + inset - offsetY.ipx
+ anchorPositionRtl.y - popupSize.height + inset - offsetY
)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
index 1554075..4efacb2 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
@@ -32,6 +32,7 @@
import androidx.ui.foundation.Icon
import androidx.ui.foundation.Text
import androidx.ui.foundation.drawBackground
+import androidx.ui.geometry.Offset
import androidx.ui.graphics.Color
import androidx.ui.layout.DpConstraints
import androidx.ui.layout.InnerPadding
@@ -51,8 +52,7 @@
import androidx.ui.test.runOnUiThread
import androidx.ui.test.sendSwipeLeft
import androidx.ui.test.sendSwipeRight
-import androidx.ui.unit.IntPxSize
-import androidx.ui.geometry.Offset
+import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
import androidx.ui.unit.toSize
import androidx.ui.unit.width
@@ -106,7 +106,7 @@
@Test
fun scaffold_AppbarAndContent_inColumn() {
var appbarPosition: Offset = Offset.Zero
- lateinit var appbarSize: IntPxSize
+ lateinit var appbarSize: IntSize
var contentPosition: Offset = Offset.Zero
composeTestRule.setMaterialContent {
Scaffold(
@@ -130,16 +130,16 @@
)
}
}
- assertThat(appbarPosition.y + appbarSize.height.value.toFloat())
+ assertThat(appbarPosition.y + appbarSize.height.toFloat())
.isEqualTo(contentPosition.y)
}
@Test
fun scaffold_bottomBarAndContent_inStack() {
var appbarPosition: Offset = Offset.Zero
- lateinit var appbarSize: IntPxSize
+ lateinit var appbarSize: IntSize
var contentPosition: Offset = Offset.Zero
- lateinit var contentSize: IntPxSize
+ lateinit var contentSize: IntSize
composeTestRule.setMaterialContent {
Scaffold(
bottomBar = {
@@ -165,8 +165,8 @@
)
}
}
- val appBarBottom = appbarPosition.y + appbarSize.height.value
- val contentBottom = contentPosition.y + contentSize.height.value
+ val appBarBottom = appbarPosition.y + appbarSize.height
+ val contentBottom = contentPosition.y + contentSize.height
assertThat(appBarBottom).isEqualTo(contentBottom)
}
@@ -266,7 +266,7 @@
@Test
fun scaffold_centerDockedFab_position() {
var fabPosition: Offset = Offset.Zero
- lateinit var fabSize: IntPxSize
+ lateinit var fabSize: IntSize
var bottomBarPosition: Offset = Offset.Zero
composeTestRule.setContent {
Scaffold(
@@ -297,14 +297,14 @@
Text("body")
}
}
- val expectedFabY = bottomBarPosition.y - (fabSize.height / 2).value
+ val expectedFabY = bottomBarPosition.y - (fabSize.height / 2)
assertThat(fabPosition.y).isEqualTo(expectedFabY)
}
@Test
fun scaffold_endDockedFab_position() {
var fabPosition: Offset = Offset.Zero
- lateinit var fabSize: IntPxSize
+ lateinit var fabSize: IntSize
var bottomBarPosition: Offset = Offset.Zero
composeTestRule.setContent {
Scaffold(
@@ -336,7 +336,7 @@
Text("body")
}
}
- val expectedFabY = bottomBarPosition.y - (fabSize.height / 2).value
+ val expectedFabY = bottomBarPosition.y - (fabSize.height / 2)
assertThat(fabPosition.y).isEqualTo(expectedFabY)
}
@@ -379,7 +379,7 @@
@Test
fun scaffold_geometry_fabSize() {
- lateinit var fabSize: IntPxSize
+ lateinit var fabSize: IntSize
val showFab = mutableStateOf(true)
val scaffoldState = ScaffoldState()
composeTestRule.setContent {
@@ -417,7 +417,7 @@
@Test
fun scaffold_geometry_bottomBarSize() {
- lateinit var bottomBarSize: IntPxSize
+ lateinit var bottomBarSize: IntSize
val showBottom = mutableStateOf(true)
val scaffoldState = ScaffoldState()
composeTestRule.setContent {
@@ -454,7 +454,7 @@
@Test
fun scaffold_geometry_topBarSize() {
- lateinit var topBarSize: IntPxSize
+ lateinit var topBarSize: IntSize
val showTop = mutableStateOf(true)
val scaffoldState = ScaffoldState()
composeTestRule.setContent {
@@ -491,7 +491,7 @@
@Test
fun scaffold_innerPadding_lambdaParam() {
- lateinit var bottomBarSize: IntPxSize
+ lateinit var bottomBarSize: IntSize
lateinit var innerPadding: InnerPadding
val scaffoldState = ScaffoldState()
@@ -522,7 +522,7 @@
@Test
fun scaffold_bottomBar_geometryPropagation() {
- lateinit var bottomBarSize: IntPxSize
+ lateinit var bottomBarSize: IntSize
lateinit var geometry: ScaffoldGeometry
val scaffoldState = ScaffoldState()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
index b84cefa..99fb902 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
@@ -31,6 +31,7 @@
import androidx.ui.core.testTag
import androidx.ui.foundation.Text
import androidx.ui.foundation.shape.corner.CutCornerShape
+import androidx.ui.geometry.Offset
import androidx.ui.graphics.Color
import androidx.ui.graphics.compositeOver
import androidx.ui.layout.DpConstraints
@@ -41,10 +42,7 @@
import androidx.ui.test.doClick
import androidx.ui.test.findByTag
import androidx.ui.test.findByText
-import androidx.ui.unit.IntPx
-import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
-import androidx.ui.unit.ipx
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -106,11 +104,11 @@
assertThat(textCoords).isNotNull()
textCoords?.let {
with(composeTestRule.density) {
- assertThat(it[FirstBaseline]).isNotEqualTo(IntPx.Zero)
+ assertThat(it[FirstBaseline]).isNotEqualTo(0)
assertThat(it[FirstBaseline])
.isEqualTo(it[LastBaseline])
// TODO(aelias): Remove 'parentCoordinates!!' when Semantics no longer using PassThroughLayout
- assertThat(it.parentCoordinates!!.positionInParent.y.roundToInt().ipx +
+ assertThat(it.parentCoordinates!!.positionInParent.y.roundToInt() +
it[FirstBaseline]!!)
.isEqualTo(30.dp.toIntPx())
}
@@ -165,14 +163,14 @@
with(composeTestRule.density) {
val buttonTextPos =
localSnackCoords.childToLocal(localButtonTextCoords, Offset.Zero)
- assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
- assertThat(localButtonTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
+ assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(0)
+ assertThat(localButtonTextCoords[FirstBaseline]).isNotEqualTo(0)
assertThat(
- localTextCoords.globalPosition.y.roundToInt().ipx +
+ localTextCoords.globalPosition.y.roundToInt() +
localTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
assertThat(
- buttonTextPos.y.roundToInt().ipx + localButtonTextCoords[FirstBaseline]!!
+ buttonTextPos.y.roundToInt() + localButtonTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
}
}
@@ -197,12 +195,12 @@
assertThat(textCoords).isNotNull()
textCoords?.let {
with(composeTestRule.density) {
- assertThat(it[FirstBaseline]).isNotEqualTo(IntPx.Zero)
- assertThat(it[LastBaseline]).isNotEqualTo(IntPx.Zero)
+ assertThat(it[FirstBaseline]).isNotEqualTo(0)
+ assertThat(it[LastBaseline]).isNotEqualTo(0)
assertThat(it[FirstBaseline]).isNotEqualTo(it[LastBaseline])
// TODO(aelias): Remove 'parentCoordinates!!' when Semantics no longer using PassThroughLayout
assertThat(
- it.parentCoordinates!!.positionInParent.y.roundToInt().ipx +
+ it.parentCoordinates!!.positionInParent.y.roundToInt() +
it[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
}
@@ -249,19 +247,19 @@
localSnackCoords.childToLocal(localButtonCoords, Offset.Zero)
val buttonCenter =
buttonPositionInSnack.y.roundToInt() +
- (localButtonCoords.size.height / 2).value.toFloat()
+ (localButtonCoords.size.height / 2).toFloat()
- assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
- assertThat(localTextCoords[LastBaseline]).isNotEqualTo(IntPx.Zero)
+ assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(0)
+ assertThat(localTextCoords[LastBaseline]).isNotEqualTo(0)
assertThat(localTextCoords[FirstBaseline])
.isNotEqualTo(localTextCoords[LastBaseline])
assertThat(
- localTextCoords.globalPosition.y.roundToInt().ipx +
+ localTextCoords.globalPosition.y.roundToInt() +
localTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
assertThat(buttonCenter).isEqualTo(
- (localSnackCoords.size.height / 2).value.toFloat()
+ (localSnackCoords.size.height / 2).toFloat()
)
}
}
@@ -308,22 +306,22 @@
localSnackCoords.childToLocal(localTextCoords, Offset.Zero)
assertThat(
- textPositionInSnack.y.roundToInt().ipx + localTextCoords[FirstBaseline]!!
+ textPositionInSnack.y.roundToInt() + localTextCoords[FirstBaseline]!!
).isEqualTo(30.dp.toIntPx())
assertThat(
- buttonPositionInSnack.y.roundToInt().ipx -
- textPositionInSnack.y.roundToInt().ipx -
+ buttonPositionInSnack.y.roundToInt() -
+ textPositionInSnack.y.roundToInt() -
localTextCoords[LastBaseline]!!
).isEqualTo(18.dp.toIntPx())
assertThat(
- localSnackCoords.size.height - buttonPositionInSnack.y.roundToInt().ipx -
+ localSnackCoords.size.height - buttonPositionInSnack.y.roundToInt() -
localButtonCoords.size.height
).isEqualTo(8.dp.toIntPx())
assertThat(
- localSnackCoords.size.width - buttonPositionInSnack.x.roundToInt().ipx -
+ localSnackCoords.size.width - buttonPositionInSnack.x.roundToInt() -
localButtonCoords.size.width
).isEqualTo(8.dp.toIntPx())
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
index 043f69e..35dd52a 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
@@ -150,7 +150,7 @@
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
- val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
tabRowWidth to tabRowHeight
@@ -164,12 +164,12 @@
runOnIdleCompose {
with(composeTestRule.density) {
val indicatorPositionX = indicatorCoords.localToGlobal(Offset.Zero).x
- val expectedPositionX = (tabRowWidth / 2).value.toFloat()
+ val expectedPositionX = (tabRowWidth / 2).toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
val expectedPositionY =
- (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
+ (tabRowHeight - indicatorHeight.toIntPx()).toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
}
}
@@ -195,7 +195,7 @@
text = {
Text(text, Modifier.onPositioned { coords: LayoutCoordinates ->
textCoords = coords
- textBaseline = coords[LastBaseline]!!.value.toFloat()
+ textBaseline = coords[LastBaseline]!!.toFloat()
})
},
selected = state == index,
@@ -209,13 +209,13 @@
val expectedBaseline = 18.dp
val indicatorHeight = 2.dp
val expectedBaselineDistance =
- (expectedBaseline.toIntPx() + indicatorHeight.toIntPx()).value.toFloat()
+ (expectedBaseline.toIntPx() + indicatorHeight.toIntPx()).toFloat()
val tabRowHeight = tabRowCoords.size.height
val textPositionY = textCoords.localToGlobal(Offset.Zero).y
val baselinePositionY = textPositionY + textBaseline
- val expectedPositionY = (tabRowHeight.value.toFloat() - expectedBaselineDistance)
+ val expectedPositionY = (tabRowHeight.toFloat() - expectedBaselineDistance)
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
}
}
@@ -240,7 +240,7 @@
text = {
Text(text, Modifier.onPositioned { coords: LayoutCoordinates ->
textCoords = coords
- textBaseline = coords[LastBaseline]!!.value.toFloat()
+ textBaseline = coords[LastBaseline]!!.toFloat()
})
},
icon = { Icon(Icons.Filled.Favorite) },
@@ -255,13 +255,13 @@
val expectedBaseline = 14.dp
val indicatorHeight = 2.dp
val expectedBaselineDistance =
- (expectedBaseline.toIntPx() + indicatorHeight.toIntPx()).value.toFloat()
+ (expectedBaseline.toIntPx() + indicatorHeight.toIntPx()).toFloat()
val tabRowHeight = tabRowCoords.size.height
val textPositionY = textCoords.localToGlobal(Offset.Zero).y
val baselinePositionY = textPositionY + textBaseline
- val expectedPositionY = (tabRowHeight.value.toFloat() - expectedBaselineDistance)
+ val expectedPositionY = (tabRowHeight.toFloat() - expectedBaselineDistance)
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
}
}
@@ -286,7 +286,7 @@
text = {
Text(text, Modifier.preferredWidth(100.dp).onPositioned { coords ->
textCoords = coords
- textBaseline = coords[LastBaseline]!!.value.toFloat()
+ textBaseline = coords[LastBaseline]!!.toFloat()
}, maxLines = 2)
},
selected = state == index,
@@ -300,13 +300,13 @@
val expectedBaseline = 10.dp
val indicatorHeight = 2.dp
val expectedBaselineDistance =
- (expectedBaseline.toIntPx() + indicatorHeight.toIntPx()).value.toFloat()
+ (expectedBaseline.toIntPx() + indicatorHeight.toIntPx()).toFloat()
val tabRowHeight = tabRowCoords.size.height
val textPositionY = textCoords.localToGlobal(Offset.Zero).y
val baselinePositionY = textPositionY + textBaseline
- val expectedPositionY = (tabRowHeight.value.toFloat() - expectedBaselineDistance)
+ val expectedPositionY = (tabRowHeight.toFloat() - expectedBaselineDistance)
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
}
}
@@ -357,11 +357,11 @@
// Indicator should be placed in the bottom left of the first tab
val indicatorPositionX = indicatorCoords.localToGlobal(Offset.Zero).x
// Tabs in a scrollable tab row are offset 52.dp from each end
- val expectedPositionX = scrollableTabRowOffset.toIntPx().value.toFloat()
+ val expectedPositionX = scrollableTabRowOffset.toIntPx().toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
- val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
tabRowHeight
@@ -375,12 +375,12 @@
composeTestRule.runOnIdleComposeWithDensity {
val indicatorPositionX = indicatorCoords.localToGlobal(Offset.Zero).x
val expectedPositionX =
- (scrollableTabRowOffset + minimumTabWidth).toIntPx().value.toFloat()
+ (scrollableTabRowOffset + minimumTabWidth).toIntPx().toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
val expectedPositionY =
- (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
+ (tabRowHeight - indicatorHeight.toIntPx()).toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
}
}