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-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
index 65a8f4a..a8eb8f3 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
@@ -27,7 +27,7 @@
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize
import androidx.ui.layout.preferredWidth
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import org.junit.Assert.assertEquals
@@ -69,8 +69,8 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxPosition.Origin,
- parentCoordinates!!.childToLocal(childCoordinates!!, PxPosition.Origin)
+ Offset.Zero,
+ parentCoordinates!!.childToLocal(childCoordinates!!, Offset.Zero)
)
}
@@ -104,8 +104,8 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxPosition(5f, 0f),
- parentCoordinates!!.childToLocal(childCoordinates!!, PxPosition.Origin)
+ Offset(5f, 0f),
+ parentCoordinates!!.childToLocal(childCoordinates!!, Offset.Zero)
)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
index fb07256..dfb2ab0 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
@@ -34,7 +34,7 @@
import androidx.ui.test.sendClick
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.RecordingFilter
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -45,7 +45,7 @@
@RunWith(Parameterized::class)
class SendClickTest(private val config: TestConfig) {
data class TestConfig(
- val position: PxPosition?,
+ val position: Offset?,
val activityClass: Class<out ComponentActivity>
)
@@ -59,8 +59,8 @@
return mutableListOf<TestConfig>().apply {
for (x in listOf(0.0f, squareSize - 1.0f)) {
for (y in listOf(0.0f, squareSize - 1.0f)) {
- add(TestConfig(PxPosition(x, y), ComponentActivity::class.java))
- add(TestConfig(PxPosition(x, y), ActivityWithActionBar::class.java))
+ add(TestConfig(Offset(x, y), ComponentActivity::class.java))
+ add(TestConfig(Offset(x, y), ActivityWithActionBar::class.java))
}
}
add(TestConfig(null, ComponentActivity::class.java))
@@ -71,7 +71,7 @@
private data class ClickData(
val componentIndex: Int,
- val position: PxPosition
+ val position: Offset
)
private class ClickRecorder(
@@ -95,7 +95,7 @@
private val recordedClicks = mutableListOf<ClickData>()
private val expectedClickPosition =
- config.position ?: PxPosition(squareSize / 2, squareSize / 2)
+ config.position ?: Offset(squareSize / 2, squareSize / 2)
@Test
fun testClick() {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
index 4531879..fff7ddc 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
@@ -28,7 +28,7 @@
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.ClickableTestBox.defaultSize
import androidx.ui.test.util.ClickableTestBox.defaultTag
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -39,7 +39,7 @@
@MediumTest
@RunWith(Parameterized::class)
class SendDoubleClickTest(private val config: TestConfig) {
- data class TestConfig(val position: PxPosition?)
+ data class TestConfig(val position: Offset?)
companion object {
@JvmStatic
@@ -48,7 +48,7 @@
return mutableListOf<TestConfig>().apply {
for (x in listOf(1.0f, 33.0f, 99.0f)) {
for (y in listOf(1.0f, 33.0f, 99.0f)) {
- add(TestConfig(PxPosition(x, y)))
+ add(TestConfig(Offset(x, y)))
}
}
add(TestConfig(null))
@@ -64,11 +64,11 @@
disableDispatchInRealTime = true
)
- private val recordedDoubleClicks = mutableListOf<PxPosition>()
+ private val recordedDoubleClicks = mutableListOf<Offset>()
private val expectedClickPosition =
- config.position ?: PxPosition(defaultSize / 2, defaultSize / 2)
+ config.position ?: Offset(defaultSize / 2, defaultSize / 2)
- private fun recordDoubleClick(position: PxPosition) {
+ private fun recordDoubleClick(position: Offset) {
recordedDoubleClicks.add(position)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
index 4cb42d1..def81a7 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
@@ -31,7 +31,7 @@
import androidx.ui.test.util.ClickableTestBox.defaultSize
import androidx.ui.test.util.ClickableTestBox.defaultTag
import androidx.ui.test.util.isAlmostEqualTo
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -46,7 +46,7 @@
@MediumTest
@RunWith(Parameterized::class)
class SendLongClickTest(private val config: TestConfig) {
- data class TestConfig(val position: PxPosition?)
+ data class TestConfig(val position: Offset?)
companion object {
@JvmStatic
@@ -55,7 +55,7 @@
return mutableListOf<TestConfig>().apply {
for (x in listOf(1.0f, defaultSize / 4)) {
for (y in listOf(1.0f, defaultSize / 3)) {
- add(TestConfig(PxPosition(x, y)))
+ add(TestConfig(Offset(x, y)))
}
}
add(TestConfig(null))
@@ -66,11 +66,11 @@
@get:Rule
val composeTestRule = createComposeRule(disableTransitions = true)
- private val recordedLongClicks = mutableListOf<PxPosition>()
+ private val recordedLongClicks = mutableListOf<Offset>()
private val expectedClickPosition =
- config.position ?: PxPosition(defaultSize / 2, defaultSize / 2)
+ config.position ?: Offset(defaultSize / 2, defaultSize / 2)
- private fun recordLongPress(position: PxPosition) {
+ private fun recordLongPress(position: Offset) {
recordedLongClicks.add(position)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
index 08ad767..8b1a4e0 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
@@ -30,7 +30,7 @@
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.test.util.isMonotonicBetween
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
@@ -60,10 +60,10 @@
}
}
- val start0 = PxPosition(40f, 50f)
- val end0 = PxPosition(8f, 50f)
- val start1 = PxPosition(60f, 50f)
- val end1 = PxPosition(92f, 50f)
+ val start0 = Offset(40f, 50f)
+ val end0 = Offset(8f, 50f)
+ val start1 = Offset(60f, 50f)
+ val end1 = Offset(92f, 50f)
val duration = 400.milliseconds
findByTag(TAG).doGesture {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
index 97d662f..4575b06 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
@@ -37,8 +37,7 @@
import androidx.ui.test.util.isMonotonicBetween
import androidx.ui.test.util.recordedDuration
import androidx.ui.unit.Duration
-import androidx.ui.unit.PxPosition
-import androidx.ui.unit.getDistance
+import androidx.ui.geometry.Offset
import androidx.ui.unit.inMilliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -61,11 +60,11 @@
val eventPeriod: Long
)
- enum class Direction(val from: PxPosition, val to: PxPosition) {
- LeftToRight(PxPosition(boxStart, boxMiddle), PxPosition(boxEnd, boxMiddle)),
- RightToLeft(PxPosition(boxEnd, boxMiddle), PxPosition(boxStart, boxMiddle)),
- TopToBottom(PxPosition(boxMiddle, boxStart), PxPosition(boxMiddle, boxEnd)),
- BottomToTop(PxPosition(boxMiddle, boxEnd), PxPosition(boxMiddle, boxStart))
+ enum class Direction(val from: Offset, val to: Offset) {
+ LeftToRight(Offset(boxStart, boxMiddle), Offset(boxEnd, boxMiddle)),
+ RightToLeft(Offset(boxEnd, boxMiddle), Offset(boxStart, boxMiddle)),
+ TopToBottom(Offset(boxMiddle, boxStart), Offset(boxMiddle, boxEnd)),
+ BottomToTop(Offset(boxMiddle, boxEnd), Offset(boxMiddle, boxStart))
}
companion object {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/Common.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/Common.kt
index 268a078..bcd8bb5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/Common.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/Common.kt
@@ -16,17 +16,17 @@
package androidx.ui.test.inputdispatcher
+import androidx.ui.geometry.Offset
import androidx.ui.test.InputDispatcher
import androidx.ui.test.android.AndroidInputDispatcher
-import androidx.ui.unit.PxPosition
import com.google.common.truth.Truth.assertThat
-internal fun AndroidInputDispatcher.sendDownAndCheck(pointerId: Int, position: PxPosition) {
+internal fun AndroidInputDispatcher.sendDownAndCheck(pointerId: Int, position: Offset) {
sendDown(pointerId, position)
assertThat(getCurrentPosition(pointerId)).isEqualTo(position)
}
-internal fun AndroidInputDispatcher.movePointerAndCheck(pointerId: Int, position: PxPosition) {
+internal fun AndroidInputDispatcher.movePointerAndCheck(pointerId: Int, position: Offset) {
movePointer(pointerId, position)
assertThat(getCurrentPosition(pointerId)).isEqualTo(position)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt
index b6bc3ae..7319164 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/DelayTest.kt
@@ -23,7 +23,7 @@
import androidx.ui.test.android.AndroidInputDispatcher
import androidx.ui.test.util.MotionEventRecorder
import androidx.ui.unit.Duration
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
@@ -55,7 +55,7 @@
}
companion object {
- private val anyPosition = PxPosition.Origin
+ private val anyPosition = Offset.Zero
@JvmStatic
@Parameterized.Parameters(name = "{0}")
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt
index 5a7bc27..c7a6aba 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendCancelTest.kt
@@ -20,13 +20,13 @@
import android.view.MotionEvent.ACTION_DOWN
import android.view.MotionEvent.ACTION_POINTER_DOWN
import androidx.test.filters.SmallTest
+import androidx.ui.geometry.Offset
import androidx.ui.test.android.AndroidInputDispatcher
import androidx.ui.test.util.MotionEventRecorder
import androidx.ui.test.util.assertHasValidEventTimes
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verifyEvent
import androidx.ui.test.util.verifyPointer
-import androidx.ui.unit.PxPosition
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -44,8 +44,8 @@
private const val pointer2 = 22
// positions (used with corresponding pointerId: pointerX with positionX_Y)
- private val position1_1 = PxPosition(11f, 11f)
- private val position2_1 = PxPosition(21f, 21f)
+ private val position1_1 = Offset(11f, 11f)
+ private val position2_1 = Offset(21f, 21f)
}
private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt
index ca02532..7b876bf 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendClickTest.kt
@@ -22,7 +22,7 @@
import androidx.ui.test.util.MotionEventRecorder
import androidx.ui.test.util.assertHasValidEventTimes
import androidx.ui.test.util.verify
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -60,7 +60,7 @@
@get:Rule
val inputDispatcherRule: TestRule = dispatcherRule
- private val position = PxPosition(config.x, config.y)
+ private val position = Offset(config.x, config.y)
private val recorder = MotionEventRecorder()
private val subject = AndroidInputDispatcher(recorder::recordEvent)
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt
index 9158540..81b0ea2 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendDownTest.kt
@@ -21,13 +21,13 @@
import android.view.MotionEvent.ACTION_POINTER_DOWN
import android.view.MotionEvent.ACTION_POINTER_UP
import androidx.test.filters.SmallTest
+import androidx.ui.geometry.Offset
import androidx.ui.test.android.AndroidInputDispatcher
import androidx.ui.test.util.MotionEventRecorder
import androidx.ui.test.util.assertHasValidEventTimes
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verifyEvent
import androidx.ui.test.util.verifyPointer
-import androidx.ui.unit.PxPosition
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -47,13 +47,13 @@
private const val pointer4 = 44
// Positions (mostly used with corresponding pointerId: pointerX with positionX)
- private val position1 = PxPosition(1f, 1f)
- private val position2 = PxPosition(2f, 2f)
- private val position3 = PxPosition(3f, 3f)
- private val position4 = PxPosition(4f, 4f)
+ private val position1 = Offset(1f, 1f)
+ private val position2 = Offset(2f, 2f)
+ private val position3 = Offset(3f, 3f)
+ private val position4 = Offset(4f, 4f)
// Single alternative for pointer1
- private val position1_2 = PxPosition(12f, 12f)
+ private val position1_2 = Offset(12f, 12f)
}
private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt
index e4a9484..c3c573f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendMoveTest.kt
@@ -28,7 +28,7 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verifyEvent
import androidx.ui.test.util.verifyPointer
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -47,14 +47,14 @@
private const val pointer3 = 33
// positions (used with corresponding pointerId: pointerX with positionX_Y)
- private val position1_1 = PxPosition(11f, 11f)
- private val position2_1 = PxPosition(21f, 21f)
- private val position3_1 = PxPosition(31f, 31f)
+ private val position1_1 = Offset(11f, 11f)
+ private val position2_1 = Offset(21f, 21f)
+ private val position3_1 = Offset(31f, 31f)
- private val position1_2 = PxPosition(12f, 12f)
- private val position2_2 = PxPosition(22f, 22f)
+ private val position1_2 = Offset(12f, 12f)
+ private val position2_2 = Offset(22f, 22f)
- private val position1_3 = PxPosition(13f, 13f)
+ private val position1_3 = Offset(13f, 13f)
}
private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt
index ffd3ead..f7b4ead 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeLineTest.kt
@@ -25,8 +25,8 @@
import androidx.ui.test.util.moveEvents
import androidx.ui.test.util.splitsDurationEquallyInto
import androidx.ui.test.util.verify
-import androidx.ui.unit.PxPosition
import androidx.ui.unit.milliseconds
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -49,8 +49,8 @@
)
companion object {
- private val start = PxPosition(5f, 7f)
- private val end = PxPosition(23f, 29f)
+ private val start = Offset(5f, 7f)
+ private val end = Offset(23f, 29f)
@JvmStatic
@Parameterized.Parameters(name = "{0}")
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithDurationTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithDurationTest.kt
index a3441dc..b69b16a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithDurationTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithDurationTest.kt
@@ -20,12 +20,12 @@
import android.view.MotionEvent.ACTION_MOVE
import android.view.MotionEvent.ACTION_UP
import androidx.test.filters.SmallTest
+import androidx.ui.geometry.Offset
import androidx.ui.test.android.AndroidInputDispatcher
import androidx.ui.test.util.MotionEventRecorder
import androidx.ui.test.util.assertHasValidEventTimes
import androidx.ui.test.util.verify
import androidx.ui.unit.Duration
-import androidx.ui.unit.PxPosition
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
@@ -53,7 +53,7 @@
companion object {
private val curve = { t: Long ->
- PxPosition(t.toFloat(), (-t).toFloat())
+ Offset(t.toFloat(), (-t).toFloat())
}
@JvmStatic
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesAndEventPeriodTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesAndEventPeriodTest.kt
index 8e7d131..3b2432c 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesAndEventPeriodTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesAndEventPeriodTest.kt
@@ -19,6 +19,7 @@
import android.view.MotionEvent.ACTION_DOWN
import android.view.MotionEvent.ACTION_UP
import androidx.test.filters.SmallTest
+import androidx.ui.geometry.Offset
import androidx.ui.test.android.AndroidInputDispatcher
import androidx.ui.test.util.MotionEventRecorder
import androidx.ui.test.util.assertHasValidEventTimes
@@ -29,7 +30,6 @@
import androidx.ui.test.util.splitsDurationEquallyInto
import androidx.ui.test.util.verify
import androidx.ui.unit.Duration
-import androidx.ui.unit.PxPosition
import androidx.ui.unit.inMilliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.After
@@ -65,7 +65,7 @@
companion object {
private val curve = { t: Long ->
- PxPosition(t.toFloat(), (-t).toFloat())
+ Offset(t.toFloat(), (-t).toFloat())
}
@JvmStatic
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesTest.kt
index 15646c9..13379bc 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendSwipeWithKeyTimesTest.kt
@@ -25,7 +25,6 @@
import androidx.ui.test.util.assertHasValidEventTimes
import androidx.ui.test.util.verify
import androidx.ui.unit.Duration
-import androidx.ui.unit.PxPosition
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
@@ -55,7 +54,7 @@
companion object {
private val curve = { t: Long ->
- PxPosition(t.toFloat(), (-t).toFloat())
+ androidx.ui.geometry.Offset(t.toFloat(), (-t).toFloat())
}
@JvmStatic
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt
index ad3bd69..95f1e95 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/inputdispatcher/SendUpTest.kt
@@ -27,7 +27,7 @@
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verifyEvent
import androidx.ui.test.util.verifyPointer
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Rule
@@ -45,8 +45,8 @@
private const val pointer2 = 22
// positions (used with corresponding pointerId: pointerX with positionX_Y)
- private val position1_1 = PxPosition(11f, 11f)
- private val position2_1 = PxPosition(21f, 21f)
+ private val position1_1 = Offset(11f, 11f)
+ private val position2_1 = Offset(21f, 21f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
index 25fe407..40c0df0 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
@@ -29,7 +29,7 @@
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.test.util.expectError
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -42,8 +42,8 @@
@MediumTest
class SendCancelTest {
companion object {
- private val downPosition1 = PxPosition(10f, 10f)
- private val downPosition2 = PxPosition(20f, 20f)
+ private val downPosition1 = Offset(10f, 10f)
+ private val downPosition2 = Offset(20f, 20f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
index b4aa5d1..3ae7a1b 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
@@ -28,7 +28,7 @@
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -41,8 +41,8 @@
@MediumTest
class SendDownTest {
companion object {
- private val position1 = PxPosition(5f, 5f)
- private val position2 = PxPosition(7f, 7f)
+ private val position1 = Offset(5f, 5f)
+ private val position2 = Offset(7f, 7f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
index 32bf84b..20894e8 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
@@ -33,7 +33,7 @@
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.Before
@@ -47,10 +47,10 @@
@MediumTest
class SendMoveByTest {
companion object {
- private val downPosition1 = PxPosition(10f, 10f)
- private val downPosition2 = PxPosition(20f, 20f)
- private val delta1 = PxPosition(11f, 11f)
- private val delta2 = PxPosition(21f, 21f)
+ private val downPosition1 = Offset(10f, 10f)
+ private val downPosition2 = Offset(20f, 20f)
+ private val delta1 = Offset(11f, 11f)
+ private val delta2 = Offset(21f, 21f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
index 8c3fb88..4d7b032 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
@@ -26,7 +26,7 @@
import androidx.ui.test.sendUp
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.expectError
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -38,7 +38,7 @@
@MediumTest
class SendMoveTest() {
companion object {
- private val downPosition1 = PxPosition(10f, 10f)
+ private val downPosition1 = Offset(10f, 10f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
index 91baaca..c71d822 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
@@ -33,7 +33,7 @@
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import androidx.ui.unit.milliseconds
import com.google.common.truth.Truth.assertThat
import org.junit.Before
@@ -47,10 +47,10 @@
@MediumTest
class SendMoveToTest() {
companion object {
- private val downPosition1 = PxPosition(10f, 10f)
- private val downPosition2 = PxPosition(20f, 20f)
- private val moveToPosition1 = PxPosition(11f, 11f)
- private val moveToPosition2 = PxPosition(21f, 21f)
+ private val downPosition1 = Offset(10f, 10f)
+ private val downPosition2 = Offset(20f, 20f)
+ private val moveToPosition1 = Offset(11f, 11f)
+ private val moveToPosition2 = Offset(21f, 21f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
index dc99005..38cdceb 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
@@ -31,7 +31,7 @@
import androidx.ui.test.util.assertTimestampsAreIncreasing
import androidx.ui.test.util.expectError
import androidx.ui.test.util.verify
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -44,8 +44,8 @@
@MediumTest
class SendUpTest {
companion object {
- private val downPosition1 = PxPosition(10f, 10f)
- private val downPosition2 = PxPosition(20f, 20f)
+ private val downPosition1 = Offset(10f, 10f)
+ private val downPosition2 = Offset(20f, 20f)
}
@get:Rule
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt
index 3764a54..8a47c046 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/MotionEvents.kt
@@ -17,7 +17,7 @@
package androidx.ui.test.util
import android.view.MotionEvent
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.truth.Truth.assertThat
import kotlin.math.abs
@@ -54,7 +54,7 @@
}
internal fun MotionEvent.verify(
- curve: (Long) -> PxPosition,
+ curve: (Long) -> Offset,
expectedAction: Int,
expectedRelativeTime: Long
) {
@@ -65,7 +65,7 @@
}
internal fun MotionEvent.verify(
- expectedPosition: PxPosition,
+ expectedPosition: Offset,
expectedAction: Int,
expectedRelativeTime: Long
) {
@@ -87,7 +87,7 @@
internal fun MotionEvent.verifyPointer(
expectedPointerId: Int,
- expectedPosition: PxPosition
+ expectedPosition: Offset
) {
var index = -1
for (i in 0 until pointerCount) {
@@ -111,7 +111,7 @@
/**
* Checks that the coordinates are progressing in a monotonous direction
*/
-fun List<MotionEvent>.isMonotonicBetween(start: PxPosition, end: PxPosition) {
+fun List<MotionEvent>.isMonotonicBetween(start: Offset, end: Offset) {
map { it.x }.isMonotonicBetween(start.x, end.x, 1e-6f)
map { it.y }.isMonotonicBetween(start.y, end.y, 1e-6f)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
index 2837bf5..52acf8b 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
@@ -23,9 +23,9 @@
import androidx.ui.core.gesture.util.VelocityTracker
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.core.pointerinput.PointerInputModifier
+import androidx.ui.geometry.Offset
import androidx.ui.unit.Duration
import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
import com.google.common.truth.Truth.assertThat
@@ -125,7 +125,7 @@
expectedTimestamp: Uptime?,
expectedId: PointerId?,
expectedDown: Boolean,
- expectedPosition: PxPosition
+ expectedPosition: Offset
) {
if (expectedTimestamp != null) {
assertThat(timestamp).isEqualTo(expectedTimestamp)
@@ -140,7 +140,7 @@
/**
* Checks that the coordinates are progressing in a monotonous direction
*/
-fun List<DataPoint>.isMonotonicBetween(start: PxPosition, end: PxPosition) {
+fun List<DataPoint>.isMonotonicBetween(start: Offset, end: Offset) {
map { it.x }.isMonotonicBetween(start.x, end.x, 1e-3f)
map { it.y }.isMonotonicBetween(start.y, end.y, 1e-3f)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt
index ab6d5b3..1cc2dea 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/Truth.kt
@@ -16,7 +16,7 @@
package androidx.ui.test.util
-import androidx.ui.unit.PxPosition
+import androidx.ui.geometry.Offset
import com.google.common.collect.Ordering
import com.google.common.truth.FloatSubject
import com.google.common.truth.Truth.assertThat
@@ -31,10 +31,10 @@
}
/**
- * Verifies that the [PxPosition] is equal to the given position with some tolerance. The default
+ * Verifies that the [Offset] is equal to the given position with some tolerance. The default
* tolerance is 0.001.
*/
-fun PxPosition.isAlmostEqualTo(position: PxPosition, tolerance: Float = 1e-3f) {
+fun Offset.isAlmostEqualTo(position: Offset, tolerance: Float = 1e-3f) {
assertThat(x).isAlmostEqualTo(position.x, tolerance)
assertThat(y).isAlmostEqualTo(position.y, tolerance)
}