Replace PxPosition with Offset
Relnote: "In order to consolidate the
number of classes used to represent
positioning information, standardize
on usage of the Offset class instead
of PxPosition. This provides the benefits
of an inline class to leverage a long
to pack 2 float values to represent x
and y offsets represented as floats."
Bug: 157948366
Test: re-ran compose tests
Change-Id: I3ad983207bc37af20afac03e2cd09b4240777687
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 ce92791..e8c9f31 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
@@ -56,7 +56,7 @@
import androidx.ui.test.findByText
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.Dp
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.PxSize
import androidx.ui.unit.center
import androidx.ui.unit.dp
@@ -549,8 +549,8 @@
}
runOnIdleCompose {
- val topLeft = childCoordinates!!.localToGlobal(PxPosition.Origin).x -
- parentCoordinates!!.localToGlobal(PxPosition.Origin).x
+ val topLeft = childCoordinates!!.localToGlobal(Offset.Zero).x -
+ parentCoordinates!!.localToGlobal(Offset.Zero).x
val currentPadding = with(composeTestRule.density) {
padding.toIntPx().value.toFloat()
}
@@ -559,7 +559,7 @@
}
}
-fun assertWithinOnePixel(expected: PxPosition, actual: PxPosition) {
+fun assertWithinOnePixel(expected: Offset, actual: Offset) {
assertWithinOnePixel(expected.x, actual.x)
assertWithinOnePixel(expected.y, actual.y)
}
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 c5fb2a0..55bd392 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
@@ -36,7 +36,7 @@
import androidx.ui.test.sendClick
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.height
import androidx.ui.unit.width
@@ -59,11 +59,11 @@
@Test
fun modalDrawer_testOffset_whenOpened() {
- var position: PxPosition? = null
+ var position: Offset? = null
composeTestRule.setMaterialContent {
ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates ->
- position = coords.localToGlobal(PxPosition.Origin)
+ position = coords.localToGlobal(Offset.Zero)
})
}, bodyContent = emptyContent())
}
@@ -74,11 +74,11 @@
@Test
fun modalDrawer_testOffset_whenClosed() {
- var position: PxPosition? = null
+ var position: Offset? = null
composeTestRule.setMaterialContent {
ModalDrawerLayout(DrawerState.Closed, {}, drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates ->
- position = coords.localToGlobal(PxPosition.Origin)
+ position = coords.localToGlobal(Offset.Zero)
})
}, bodyContent = emptyContent())
}
@@ -108,11 +108,11 @@
@Test
fun bottomDrawer_testOffset_whenOpened() {
- var position: PxPosition? = null
+ var position: Offset? = null
composeTestRule.setMaterialContent {
BottomDrawerLayout(DrawerState.Opened, {}, drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates ->
- position = coords.localToGlobal(PxPosition.Origin)
+ position = coords.localToGlobal(Offset.Zero)
})
}, bodyContent = emptyContent())
}
@@ -128,11 +128,11 @@
@Test
fun bottomDrawer_testOffset_whenClosed() {
- var position: PxPosition? = null
+ var position: Offset? = null
composeTestRule.setMaterialContent {
BottomDrawerLayout(DrawerState.Closed, {}, drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates ->
- position = coords.localToGlobal(PxPosition.Origin)
+ position = coords.localToGlobal(Offset.Zero)
})
}, bodyContent = emptyContent())
}
@@ -154,7 +154,7 @@
drawerContent = {
Box(
Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
- val pos = info.localToGlobal(PxPosition.Origin)
+ val pos = info.localToGlobal(Offset.Zero)
if (pos.x == 0.0f) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
@@ -227,7 +227,7 @@
findByTag("Drawer").doGesture {
val left = 1.0f
val centerY = (globalBounds.height / 2)
- sendClick(PxPosition(left, centerY))
+ sendClick(Offset(left, centerY))
}
runOnIdleCompose {
@@ -248,7 +248,7 @@
BottomDrawerLayout(drawerState.value, { drawerState.value = it },
drawerContent = {
Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates ->
- val pos = info.localToGlobal(PxPosition.Origin)
+ val pos = info.localToGlobal(Offset.Zero)
if (pos.y.roundToInt() == openedHeight?.value) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
@@ -326,7 +326,7 @@
val bounds = globalBounds
val centerX = bounds.width / 2
val bottom = bounds.height - 1.0f
- sendClick(PxPosition(centerX, bottom))
+ sendClick(Offset(centerX, bottom))
}
assertThat(drawerClicks).isEqualTo(1)
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 697adf4..d68c5ff 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
@@ -56,7 +56,7 @@
import androidx.ui.text.FirstBaseline
import androidx.ui.text.SoftwareKeyboardController
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.sp
@@ -160,7 +160,7 @@
// Click on (2, 2) which is Surface area and outside input area
findByTag("textField").doGesture {
- sendClick(PxPosition(2.ipx, 2.ipx))
+ sendClick(Offset(2f, 2f))
}
testRule.runOnIdleComposeWithDensity {
@@ -171,7 +171,7 @@
@Test
fun testLabelPosition_initial_withDefaultHeight() {
val labelSize = Ref<IntPxSize>()
- val labelPosition = Ref<PxPosition>()
+ val labelPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -211,7 +211,7 @@
fun testLabelPosition_initial_withCustomHeight() {
val height = 80.dp
val labelSize = Ref<IntPxSize>()
- val labelPosition = Ref<PxPosition>()
+ val labelPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -246,7 +246,7 @@
@Test
fun testLabelPosition_whenFocused() {
val labelSize = Ref<IntPxSize>()
- val labelPosition = Ref<PxPosition>()
+ val labelPosition = Ref<Offset>()
val baseline = Ref<Float>()
testRule.setMaterialContent {
Box {
@@ -287,7 +287,7 @@
@Test
fun testLabelPosition_whenInput() {
val labelSize = Ref<IntPxSize>()
- val labelPosition = Ref<PxPosition>()
+ val labelPosition = Ref<Offset>()
val baseline = Ref<Float>()
testRule.setMaterialContent {
Box {
@@ -324,7 +324,7 @@
@Test
fun testPlaceholderPosition_withLabel() {
val placeholderSize = Ref<IntPxSize>()
- val placeholderPosition = Ref<PxPosition>()
+ val placeholderPosition = Ref<Offset>()
val placeholderBaseline = Ref<Float>()
testRule.setMaterialContent {
Box {
@@ -366,7 +366,7 @@
@Test
fun testPlaceholderPosition_whenNoLabel() {
val placeholderSize = Ref<IntPxSize>()
- val placeholderPosition = Ref<PxPosition>()
+ val placeholderPosition = Ref<Offset>()
val placeholderBaseline = Ref<Float>()
val height = 60.dp
testRule.setMaterialContent {
@@ -409,7 +409,7 @@
@Test
fun testNoPlaceholder_whenInputNotEmpty() {
val placeholderSize = Ref<IntPxSize>()
- val placeholderPosition = Ref<PxPosition>()
+ val placeholderPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -462,9 +462,9 @@
val textFieldHeight = 60.dp
val textFieldWidth = 300.dp
val size = 30.dp
- val leadingPosition = Ref<PxPosition>()
+ val leadingPosition = Ref<Offset>()
val leadingSize = Ref<IntPxSize>()
- val trailingPosition = Ref<PxPosition>()
+ val trailingPosition = Ref<Offset>()
val trailingSize = Ref<IntPxSize>()
testRule.setMaterialContent {
@@ -511,7 +511,7 @@
fun testLabelPositionX_initial_withTrailingAndLeading() {
val height = 60.dp
val iconSize = 30.dp
- val labelPosition = Ref<PxPosition>()
+ val labelPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
FilledTextField(
@@ -540,7 +540,7 @@
@Test
fun testLabelPositionX_initial_withEmptyTrailingAndLeading() {
val height = 60.dp
- val labelPosition = Ref<PxPosition>()
+ val labelPosition = Ref<Offset>()
testRule.setMaterialContent {
Box {
FilledTextField(
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 d35fb91..5584105 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
@@ -29,7 +29,7 @@
import androidx.ui.test.createComposeRule
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import com.google.common.truth.Truth.assertThat
@@ -187,9 +187,9 @@
val expectedLeftPadding = 16.dp
val expectedRightPadding = 16.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textSize = Ref<IntPxSize>()
- val trailingPosition = Ref<PxPosition>()
+ val trailingPosition = Ref<Offset>()
val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Box {
@@ -224,9 +224,9 @@
val expectedLeftPadding = 16.dp
val expectedTextLeftPadding = 32.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textSize = Ref<IntPxSize>()
- val iconPosition = Ref<PxPosition>()
+ val iconPosition = Ref<Offset>()
val iconSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Box {
@@ -261,13 +261,13 @@
val expectedTextBaseline = 28.dp
val expectedSecondaryTextBaselineOffset = 20.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
- val secondaryTextPosition = Ref<PxPosition>()
+ val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
- val trailingPosition = Ref<PxPosition>()
+ val trailingPosition = Ref<Offset>()
val trailingBaseline = Ref<Float>()
val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
@@ -325,13 +325,13 @@
val expectedTextBaseline = 32.dp
val expectedSecondaryTextBaselineOffset = 20.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
- val secondaryTextPosition = Ref<PxPosition>()
+ val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
- val iconPosition = Ref<PxPosition>()
+ val iconPosition = Ref<Offset>()
val iconSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Box {
@@ -391,15 +391,15 @@
val expectedSecondaryTextBaselineOffset = 20.dp
val expectedRightPadding = 16.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
- val secondaryTextPosition = Ref<PxPosition>()
+ val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
- val iconPosition = Ref<PxPosition>()
+ val iconPosition = Ref<Offset>()
val iconSize = Ref<IntPxSize>()
- val trailingPosition = Ref<PxPosition>()
+ val trailingPosition = Ref<Offset>()
val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Box {
@@ -469,15 +469,15 @@
val expectedSecondaryTextBaselineOffset = 20.dp
val expectedRightPadding = 16.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
- val secondaryTextPosition = Ref<PxPosition>()
+ val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
- val iconPosition = Ref<PxPosition>()
+ val iconPosition = Ref<Offset>()
val iconSize = Ref<IntPxSize>()
- val trailingPosition = Ref<PxPosition>()
+ val trailingPosition = Ref<Offset>()
val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Box {
@@ -547,18 +547,18 @@
val expectedSecondaryTextBaselineOffset = 20.dp
val expectedRightPadding = 16.dp
- val textPosition = Ref<PxPosition>()
+ val textPosition = Ref<Offset>()
val textBaseline = Ref<Float>()
val textSize = Ref<IntPxSize>()
- val overlineTextPosition = Ref<PxPosition>()
+ val overlineTextPosition = Ref<Offset>()
val overlineTextBaseline = Ref<Float>()
val overlineTextSize = Ref<IntPxSize>()
- val secondaryTextPosition = Ref<PxPosition>()
+ val secondaryTextPosition = Ref<Offset>()
val secondaryTextBaseline = Ref<Float>()
val secondaryTextSize = Ref<IntPxSize>()
- val iconPosition = Ref<PxPosition>()
+ val iconPosition = Ref<Offset>()
val iconSize = Ref<IntPxSize>()
- val trailingPosition = Ref<PxPosition>()
+ val trailingPosition = Ref<Offset>()
val trailingSize = Ref<IntPxSize>()
val trailingBaseline = Ref<Float>()
composeTestRule.setMaterialContent {
@@ -654,11 +654,11 @@
private fun Dp.toIntPx() = (this.value * composeTestRule.density.density).roundToInt()
private fun saveLayout(
- coords: Ref<PxPosition>,
+ coords: Ref<Offset>,
size: Ref<IntPxSize>,
baseline: Ref<Float> = Ref()
): Modifier = Modifier.onPositioned { coordinates: LayoutCoordinates ->
- coords.value = coordinates.localToGlobal(PxPosition.Origin)
+ coords.value = coordinates.localToGlobal(Offset.Zero)
baseline.value = coordinates[FirstBaseline]?.value?.toFloat()?.let {
it + coords.value!!.y
}
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 764241e..8a5678a 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
@@ -52,7 +52,7 @@
import androidx.ui.test.sendSwipeLeft
import androidx.ui.test.sendSwipeRight
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.toPxSize
import androidx.ui.unit.toSize
@@ -88,8 +88,8 @@
@Test
fun scaffold_onlyContent_stackSlot() {
- lateinit var child1: PxPosition
- lateinit var child2: PxPosition
+ var child1: Offset = Offset.Zero
+ var child2: Offset = Offset.Zero
composeTestRule.setMaterialContent {
Scaffold {
Text("One",
@@ -106,15 +106,15 @@
@Test
fun scaffold_AppbarAndContent_inColumn() {
- lateinit var appbarPosition: PxPosition
+ var appbarPosition: Offset = Offset.Zero
lateinit var appbarSize: IntPxSize
- lateinit var contentPosition: PxPosition
+ var contentPosition: Offset = Offset.Zero
composeTestRule.setMaterialContent {
Scaffold(
topBar = {
Box(Modifier
.onPositioned { positioned: LayoutCoordinates ->
- appbarPosition = positioned.localToGlobal(PxPosition.Origin)
+ appbarPosition = positioned.localToGlobal(Offset.Zero)
appbarSize = positioned.size
}
.fillMaxWidth()
@@ -124,7 +124,7 @@
}
) {
Box(Modifier
- .onPositioned { contentPosition = it.localToGlobal(PxPosition.Origin) }
+ .onPositioned { contentPosition = it.localToGlobal(Offset.Zero) }
.fillMaxWidth()
.preferredHeight(50.dp)
.drawBackground(Color.Blue)
@@ -137,9 +137,9 @@
@Test
fun scaffold_bottomBarAndContent_inStack() {
- lateinit var appbarPosition: PxPosition
+ var appbarPosition: Offset = Offset.Zero
lateinit var appbarSize: IntPxSize
- lateinit var contentPosition: PxPosition
+ var contentPosition: Offset = Offset.Zero
lateinit var contentSize: IntPxSize
composeTestRule.setMaterialContent {
Scaffold(
@@ -174,7 +174,7 @@
@Test
@Ignore("unignore once animation sync is ready (b/147291885)")
fun scaffold_drawer_gestures() {
- lateinit var drawerChildPosition: PxPosition
+ var drawerChildPosition: Offset = Offset.Zero
val scaffoldState = ScaffoldState(isDrawerGesturesEnabled = false)
composeTestRule.setMaterialContent {
Semantics(properties = { testTag = scaffoldTag }) {
@@ -227,7 +227,7 @@
@Test
@Ignore("unignore once animation sync is ready (b/147291885)")
fun scaffold_drawer_manualControl() {
- lateinit var drawerChildPosition: PxPosition
+ var drawerChildPosition: Offset = Offset.Zero
val scaffoldState = ScaffoldState()
composeTestRule.setMaterialContent {
Semantics(properties = { testTag = scaffoldTag }) {
@@ -266,9 +266,9 @@
@Test
fun scaffold_centerDockedFab_position() {
- lateinit var fabPosition: PxPosition
+ var fabPosition: Offset = Offset.Zero
lateinit var fabSize: IntPxSize
- lateinit var bottomBarPosition: PxPosition
+ var bottomBarPosition: Offset = Offset.Zero
composeTestRule.setContent {
Scaffold(
floatingActionButton = {
@@ -304,9 +304,9 @@
@Test
fun scaffold_endDockedFab_position() {
- lateinit var fabPosition: PxPosition
+ var fabPosition: Offset = Offset.Zero
lateinit var fabSize: IntPxSize
- lateinit var bottomBarPosition: PxPosition
+ var bottomBarPosition: Offset = Offset.Zero
composeTestRule.setContent {
Scaffold(
floatingActionButton = {
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 246686d..b84cefa 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
@@ -42,7 +42,7 @@
import androidx.ui.test.findByTag
import androidx.ui.test.findByText
import androidx.ui.unit.IntPx
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import com.google.common.truth.Truth.assertThat
@@ -164,7 +164,7 @@
) {
with(composeTestRule.density) {
val buttonTextPos =
- localSnackCoords.childToLocal(localButtonTextCoords, PxPosition.Origin)
+ localSnackCoords.childToLocal(localButtonTextCoords, Offset.Zero)
assertThat(localTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
assertThat(localButtonTextCoords[FirstBaseline]).isNotEqualTo(IntPx.Zero)
assertThat(
@@ -246,7 +246,7 @@
if (localTextCoords != null && localButtonCoords != null && localSnackCoords != null) {
with(composeTestRule.density) {
val buttonPositionInSnack =
- localSnackCoords.childToLocal(localButtonCoords, PxPosition.Origin)
+ localSnackCoords.childToLocal(localButtonCoords, Offset.Zero)
val buttonCenter =
buttonPositionInSnack.y.roundToInt() +
(localButtonCoords.size.height / 2).value.toFloat()
@@ -303,9 +303,9 @@
if (localTextCoords != null && localButtonCoords != null && localSnackCoords != null) {
with(composeTestRule.density) {
val buttonPositionInSnack =
- localSnackCoords.childToLocal(localButtonCoords, PxPosition.Origin)
+ localSnackCoords.childToLocal(localButtonCoords, Offset.Zero)
val textPositionInSnack =
- localSnackCoords.childToLocal(localTextCoords, PxPosition.Origin)
+ localSnackCoords.childToLocal(localTextCoords, Offset.Zero)
assertThat(
textPositionInSnack.y.roundToInt().ipx + localTextCoords[FirstBaseline]!!
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 9bc5a04..043f69e 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
@@ -45,7 +45,7 @@
import androidx.ui.test.findAll
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -145,11 +145,11 @@
val tabRowWidth = tabRowCoords.size.width
val tabRowHeight = tabRowCoords.size.height
- val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
+ val indicatorPositionX = indicatorCoords.localToGlobal(Offset.Zero).x
val expectedPositionX = 0.dp.toPx()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
- val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
+ val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
@@ -163,11 +163,11 @@
// should be in the middle of the TabRow
runOnIdleCompose {
with(composeTestRule.density) {
- val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
+ val indicatorPositionX = indicatorCoords.localToGlobal(Offset.Zero).x
val expectedPositionX = (tabRowWidth / 2).value.toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
- val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
+ val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
val expectedPositionY =
(tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
@@ -213,7 +213,7 @@
val tabRowHeight = tabRowCoords.size.height
- val textPositionY = textCoords.localToGlobal(PxPosition.Origin).y
+ val textPositionY = textCoords.localToGlobal(Offset.Zero).y
val baselinePositionY = textPositionY + textBaseline
val expectedPositionY = (tabRowHeight.value.toFloat() - expectedBaselineDistance)
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
@@ -259,7 +259,7 @@
val tabRowHeight = tabRowCoords.size.height
- val textPositionY = textCoords.localToGlobal(PxPosition.Origin).y
+ val textPositionY = textCoords.localToGlobal(Offset.Zero).y
val baselinePositionY = textPositionY + textBaseline
val expectedPositionY = (tabRowHeight.value.toFloat() - expectedBaselineDistance)
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
@@ -304,7 +304,7 @@
val tabRowHeight = tabRowCoords.size.height
- val textPositionY = textCoords.localToGlobal(PxPosition.Origin).y
+ val textPositionY = textCoords.localToGlobal(Offset.Zero).y
val baselinePositionY = textPositionY + textBaseline
val expectedPositionY = (tabRowHeight.value.toFloat() - expectedBaselineDistance)
assertThat(baselinePositionY).isEqualTo(expectedPositionY)
@@ -355,12 +355,12 @@
val tabRowHeight = tabRowCoords.size.height
// Indicator should be placed in the bottom left of the first tab
- val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
+ 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()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
- val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
+ val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
@@ -373,12 +373,12 @@
// Indicator should now be placed in the bottom left of the second tab, so its x coordinate
// should be in the middle of the TabRow
composeTestRule.runOnIdleComposeWithDensity {
- val indicatorPositionX = indicatorCoords.localToGlobal(PxPosition.Origin).x
+ val indicatorPositionX = indicatorCoords.localToGlobal(Offset.Zero).x
val expectedPositionX =
(scrollableTabRowOffset + minimumTabWidth).toIntPx().value.toFloat()
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
- val indicatorPositionY = indicatorCoords.localToGlobal(PxPosition.Origin).y
+ val indicatorPositionY = indicatorCoords.localToGlobal(Offset.Zero).y
val expectedPositionY =
(tabRowHeight - indicatorHeight.toIntPx()).value.toFloat()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
index d1c07c5..d52810d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
@@ -36,6 +36,7 @@
import androidx.ui.foundation.InteractionState
import androidx.ui.foundation.indication
import androidx.ui.foundation.shape.corner.RoundedCornerShape
+import androidx.ui.geometry.Offset
import androidx.ui.graphics.Color
import androidx.ui.graphics.compositeOver
import androidx.ui.layout.fillMaxSize
@@ -53,7 +54,6 @@
import androidx.ui.test.findByTag
import androidx.ui.test.runOnUiThread
import androidx.ui.test.waitForIdle
-import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import com.google.common.truth.Truth
import org.junit.Rule
@@ -526,7 +526,7 @@
}
runOnUiThread {
- interactionState.addInteraction(Interaction.Pressed, PxPosition(10f, 10f))
+ interactionState.addInteraction(Interaction.Pressed, Offset(10f, 10f))
}
with(findByTag(Tag)) {
@@ -582,7 +582,7 @@
// Start ripple
runOnUiThread {
if (interaction is Interaction.Pressed) {
- interactionState.addInteraction(interaction, PxPosition(10f, 10f))
+ interactionState.addInteraction(interaction, Offset(10f, 10f))
} else {
interactionState.addInteraction(interaction)
}