[go: nahoru, domu]

Add partial gesture injection API

This allows developers to inject gestures that can be interspersed
with assertions, and it allows them to inject custom gestures. A new
receiver scope is introduced next to GestureScope, PartialGestureScope,
which contains the following methods:
* sendDown
* sendMoveTo
* sendMoveBy
* sendUp
* sendCancel

Use the action `doPartialGesture` to execute your partial gestures.

Bug: 152477560
Test: Added new tests for PartialGestureScope methods.
Relnote: "Adds `doPartialGesture` action with PartialGestureScope
receiver that has the methods `sendDown`, `sendMoveTo`, `sendMoveBy`,
`sendUp` and `sendCancel`."

Change-Id: I6b05886b2a2e49ae79a131ac9b6dbb7bdb0fb907
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
similarity index 97%
rename from ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt
rename to ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
index 143c07b..98b3c66 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.ui.test
+package androidx.ui.test.gesturescope
 
 import android.os.Bundle
 import android.view.Gravity
@@ -38,6 +38,11 @@
 import androidx.ui.layout.preferredSize
 import androidx.ui.semantics.Semantics
 import androidx.ui.test.android.AndroidComposeTestRule
+import androidx.ui.test.doGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.runOnUiThread
+import androidx.ui.test.sendClick
 import androidx.ui.unit.IntPxSize
 import androidx.ui.unit.PxPosition
 import androidx.ui.unit.px
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendDoubleClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
similarity index 96%
rename from ui/ui-test/src/androidTest/java/androidx/ui/test/SendDoubleClickTest.kt
rename to ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
index b356638..401abcd 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendDoubleClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.ui.test
+package androidx.ui.test.gesturescope
 
 import androidx.compose.Composable
 import androidx.test.filters.MediumTest
@@ -29,6 +29,11 @@
 import androidx.ui.layout.preferredSize
 import androidx.ui.semantics.Semantics
 import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnUiThread
+import androidx.ui.test.sendDoubleClick
 import androidx.ui.test.util.PointerInputRecorder
 import androidx.ui.test.util.assertTimestampsAreIncreasing
 import androidx.ui.unit.Px
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendLongClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
similarity index 93%
rename from ui/ui-test/src/androidTest/java/androidx/ui/test/SendLongClickTest.kt
rename to ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
index e7b21a7..8366cc4 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendLongClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.ui.test
+package androidx.ui.test.gesturescope
 
 import androidx.compose.Composable
 import androidx.test.filters.MediumTest
@@ -22,8 +22,8 @@
 import androidx.ui.core.DensityAmbient
 import androidx.ui.core.Modifier
 import androidx.ui.core.TestTag
-import androidx.ui.core.gesture.longPressGestureFilter
 import androidx.ui.core.gesture.LongPressTimeout
+import androidx.ui.core.gesture.longPressGestureFilter
 import androidx.ui.foundation.Box
 import androidx.ui.graphics.Color
 import androidx.ui.layout.Stack
@@ -31,6 +31,11 @@
 import androidx.ui.layout.preferredSize
 import androidx.ui.layout.wrapContentSize
 import androidx.ui.semantics.Semantics
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnUiThread
+import androidx.ui.test.sendLongClick
 import androidx.ui.test.util.PointerInputRecorder
 import androidx.ui.test.util.areAlmostEqualTo
 import androidx.ui.test.util.assertOnlyLastEventIsUp
@@ -70,7 +75,7 @@
 }
 
 /**
- * Tests [GestureScope.sendLongClick] without arguments. Verifies that the click is in the middle
+ * Tests [sendLongClick] without arguments. Verifies that the click is in the middle
  * of the component, that the gesture has a duration of 600 milliseconds and that all input
  * events were on the same location.
  */
@@ -113,7 +118,7 @@
 }
 
 /**
- * Tests [GestureScope.sendLongClick] with arguments. Verifies that the click is in the middle
+ * Tests [sendLongClick] with arguments. Verifies that the click is in the middle
  * of the component, that the gesture has a duration of 600 milliseconds and that all input
  * events were on the same location.
  */
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendSwipeTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
similarity index 94%
rename from ui/ui-test/src/androidTest/java/androidx/ui/test/SendSwipeTest.kt
rename to ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
index 8bdb5e9..f966857 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendSwipeTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.ui.test
+package androidx.ui.test.gesturescope
 
 import androidx.compose.Composable
 import androidx.test.filters.MediumTest
@@ -28,6 +28,14 @@
 import androidx.ui.layout.wrapContentSize
 import androidx.ui.semantics.Semantics
 import androidx.ui.semantics.testTag
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnUiThread
+import androidx.ui.test.sendSwipeDown
+import androidx.ui.test.sendSwipeLeft
+import androidx.ui.test.sendSwipeRight
+import androidx.ui.test.sendSwipeUp
 import androidx.ui.test.util.PointerInputRecorder
 import androidx.ui.test.util.assertOnlyLastEventIsUp
 import androidx.ui.test.util.assertTimestampsAreIncreasing
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendSwipeVelocityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
similarity index 96%
rename from ui/ui-test/src/androidTest/java/androidx/ui/test/SendSwipeVelocityTest.kt
rename to ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
index 7836d19..252823d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendSwipeVelocityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.ui.test
+package androidx.ui.test.gesturescope
 
 import androidx.compose.Composable
 import androidx.compose.remember
@@ -33,6 +33,11 @@
 import androidx.ui.semantics.Semantics
 import androidx.ui.semantics.testTag
 import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnUiThread
+import androidx.ui.test.sendSwipeWithVelocity
 import androidx.ui.test.util.PointerInputRecorder
 import androidx.ui.test.util.assertOnlyLastEventIsUp
 import androidx.ui.test.util.assertTimestampsAreIncreasing
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
new file mode 100644
index 0000000..b6c4ee7
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.test.partialgesturescope
+
+import androidx.test.filters.MediumTest
+import androidx.ui.graphics.Color
+import androidx.ui.test.GestureToken
+import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doPartialGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendCancel
+import androidx.ui.test.sendDown
+import androidx.ui.test.util.ClickableTestBox
+import androidx.ui.test.util.PointerInputRecorder
+import androidx.ui.test.util.assertTimestampsAreIncreasing
+import androidx.ui.test.util.inMilliseconds
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.px
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+private val width = 200.px
+private val height = 200.px
+
+private const val tag = "widget"
+
+@MediumTest
+@RunWith(Parameterized::class)
+class SendCancelTest(private val config: TestConfig) {
+    data class TestConfig(val cancelPosition: PxPosition?) {
+        val downPosition = PxPosition(1.px, 1.px)
+    }
+
+    companion object {
+        @JvmStatic
+        @Parameterized.Parameters(name = "{0}")
+        fun createTestSet(): List<TestConfig> {
+            return mutableListOf<TestConfig>().apply {
+                for (x in listOf(2.px, 99.px)) {
+                    for (y in listOf(3.px, 53.px)) {
+                        add(TestConfig(PxPosition(x, y)))
+                    }
+                }
+                add(TestConfig(null))
+            }
+        }
+    }
+
+    @get:Rule
+    val composeTestRule = createComposeRule()
+
+    private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
+    @get:Rule
+    val inputDispatcherRule: TestRule = dispatcherRule
+
+    private lateinit var recorder: PointerInputRecorder
+    private val expectedCancelPosition = config.cancelPosition ?: config.downPosition
+
+    @Test
+    fun testSendCancel() {
+        // Given some content
+        recorder = PointerInputRecorder()
+        composeTestRule.setContent {
+            ClickableTestBox(width, height, Color.Yellow, tag, recorder)
+        }
+
+        // When we inject a down event followed by a cancel event
+        lateinit var token: GestureToken
+        findByTag(tag).doPartialGesture { token = sendDown(config.downPosition) }
+        findByTag(tag).doPartialGesture { sendCancel(token, config.cancelPosition) }
+
+        runOnIdleCompose {
+            recorder.run {
+                // Then we have only recorded 1 down event
+                assertTimestampsAreIncreasing()
+                assertThat(events).hasSize(1)
+
+                // But the information in the token matches the cancel event
+                assertThat(token.downTime).isEqualTo(events[0].timestamp.inMilliseconds())
+                assertThat(token.eventTime)
+                    .isEqualTo(events[0].timestamp.inMilliseconds() + dispatcherRule.eventPeriod)
+                assertThat(token.lastPosition).isEqualTo(expectedCancelPosition)
+            }
+        }
+    }
+}
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
new file mode 100644
index 0000000..c56472e
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.test.partialgesturescope
+
+import androidx.test.filters.MediumTest
+import androidx.ui.graphics.Color
+import androidx.ui.test.GestureToken
+import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doPartialGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.util.ClickableTestBox
+import androidx.ui.test.util.PointerInputRecorder
+import androidx.ui.test.util.assertTimestampsAreIncreasing
+import androidx.ui.test.util.inMilliseconds
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.px
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+private val width = 200.px
+private val height = 200.px
+
+private const val tag = "widget"
+
+@MediumTest
+@RunWith(Parameterized::class)
+class SendDownTest(private val config: TestConfig) {
+    data class TestConfig(val position: PxPosition)
+
+    companion object {
+        @JvmStatic
+        @Parameterized.Parameters(name = "{0}")
+        fun createTestSet(): List<TestConfig> {
+            return mutableListOf<TestConfig>().apply {
+                for (x in listOf(1.px, 99.px)) {
+                    for (y in listOf(2.px, 53.px)) {
+                        add(TestConfig(PxPosition(x, y)))
+                    }
+                }
+            }
+        }
+    }
+
+    @get:Rule
+    val composeTestRule = createComposeRule()
+
+    @get:Rule
+    val inputDispatcherRule: TestRule = AndroidInputDispatcher.TestRule(
+        disableDispatchInRealTime = true
+    )
+
+    private lateinit var recorder: PointerInputRecorder
+    private val expectedPosition = config.position
+
+    @Test
+    fun testSendDown() {
+        // Given some content
+        recorder = PointerInputRecorder()
+        composeTestRule.setContent {
+            ClickableTestBox(width, height, Color.Yellow, tag, recorder)
+        }
+
+        // When we inject a down event
+        lateinit var token: GestureToken
+        findByTag(tag).doPartialGesture { token = sendDown(config.position) }
+
+        runOnIdleCompose {
+            recorder.run {
+                // Then we have recorded 1 down event
+                assertTimestampsAreIncreasing()
+                assertThat(events).hasSize(1)
+                assertThat(events[0].down).isTrue()
+                assertThat(events[0].position).isEqualTo(expectedPosition)
+
+                // That matches the information in the token
+                assertThat(token.downTime).isEqualTo(events[0].timestamp.inMilliseconds())
+                assertThat(token.eventTime).isEqualTo(events[0].timestamp.inMilliseconds())
+                assertThat(token.lastPosition).isEqualTo(expectedPosition)
+            }
+        }
+    }
+}
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
new file mode 100644
index 0000000..acc538a
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.test.partialgesturescope
+
+import androidx.test.filters.MediumTest
+import androidx.ui.graphics.Color
+import androidx.ui.test.GestureToken
+import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doPartialGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.sendMoveBy
+import androidx.ui.test.util.ClickableTestBox
+import androidx.ui.test.util.PointerInputRecorder
+import androidx.ui.test.util.assertTimestampsAreIncreasing
+import androidx.ui.test.util.inMilliseconds
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.inMilliseconds
+import androidx.ui.unit.px
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+private val width = 200.px
+private val height = 200.px
+
+private const val tag = "widget"
+
+@MediumTest
+@RunWith(Parameterized::class)
+class SendMoveByTest(private val config: TestConfig) {
+    data class TestConfig(val moveByDelta: PxPosition) {
+        val downPosition = PxPosition(1.px, 1.px)
+    }
+
+    companion object {
+        @JvmStatic
+        @Parameterized.Parameters(name = "{0}")
+        fun createTestSet(): List<TestConfig> {
+            return mutableListOf<TestConfig>().apply {
+                for (x in listOf(2.px, (-100).px)) {
+                    for (y in listOf(3.px, (-530).px)) {
+                        add(TestConfig(PxPosition(x, y)))
+                    }
+                }
+            }
+        }
+    }
+
+    @get:Rule
+    val composeTestRule = createComposeRule()
+
+    private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
+    @get:Rule
+    val inputDispatcherRule: TestRule = dispatcherRule
+
+    private lateinit var recorder: PointerInputRecorder
+    private val expectedEndPosition = config.downPosition + config.moveByDelta
+
+    @Test
+    fun testSendMoveBy() {
+        // Given some content
+        recorder = PointerInputRecorder()
+        composeTestRule.setContent {
+            ClickableTestBox(width, height, Color.Yellow, tag, recorder)
+        }
+
+        // When we inject a down event followed by a move event
+        lateinit var token: GestureToken
+        findByTag(tag).doPartialGesture { token = sendDown(config.downPosition) }
+        findByTag(tag).doPartialGesture { sendMoveBy(token, config.moveByDelta) }
+
+        runOnIdleCompose {
+            recorder.run {
+                // Then we have recorded 1 down event and 1 move event
+                assertTimestampsAreIncreasing()
+                assertThat(events).hasSize(2)
+                assertThat(events[1].down).isTrue()
+                assertThat(events[1].position).isEqualTo(expectedEndPosition)
+                assertThat((events[1].timestamp - events[0].timestamp).inMilliseconds())
+                    .isEqualTo(dispatcherRule.eventPeriod)
+
+                // And the information in the token matches the last move event
+                assertThat(token.downTime).isEqualTo(events[0].timestamp.inMilliseconds())
+                assertThat(token.eventTime).isEqualTo(events[1].timestamp.inMilliseconds())
+                assertThat(token.lastPosition).isEqualTo(expectedEndPosition)
+            }
+        }
+    }
+}
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
new file mode 100644
index 0000000..86092f5
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.test.partialgesturescope
+
+import androidx.test.filters.MediumTest
+import androidx.ui.graphics.Color
+import androidx.ui.test.GestureToken
+import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doPartialGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.sendMoveTo
+import androidx.ui.test.util.ClickableTestBox
+import androidx.ui.test.util.PointerInputRecorder
+import androidx.ui.test.util.assertTimestampsAreIncreasing
+import androidx.ui.test.util.inMilliseconds
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.inMilliseconds
+import androidx.ui.unit.px
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+private val width = 200.px
+private val height = 200.px
+
+private const val tag = "widget"
+
+@MediumTest
+@RunWith(Parameterized::class)
+class SendMoveToTest(private val config: TestConfig) {
+    data class TestConfig(val moveToPosition: PxPosition) {
+        val downPosition = PxPosition(1.px, 1.px)
+    }
+
+    companion object {
+        @JvmStatic
+        @Parameterized.Parameters(name = "{0}")
+        fun createTestSet(): List<TestConfig> {
+            return mutableListOf<TestConfig>().apply {
+                for (x in listOf(2.px, 99.px)) {
+                    for (y in listOf(3.px, 53.px)) {
+                        add(TestConfig(PxPosition(x, y)))
+                    }
+                }
+            }
+        }
+    }
+
+    @get:Rule
+    val composeTestRule = createComposeRule()
+
+    private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
+    @get:Rule
+    val inputDispatcherRule: TestRule = dispatcherRule
+
+    private lateinit var recorder: PointerInputRecorder
+    private val expectedEndPosition = config.moveToPosition
+
+    @Test
+    fun testSendMoveTo() {
+        // Given some content
+        recorder = PointerInputRecorder()
+        composeTestRule.setContent {
+            ClickableTestBox(width, height, Color.Yellow, tag, recorder)
+        }
+
+        // When we inject a down event followed by a move event
+        lateinit var token: GestureToken
+        findByTag(tag).doPartialGesture { token = sendDown(config.downPosition) }
+        findByTag(tag).doPartialGesture { sendMoveTo(token, config.moveToPosition) }
+
+        runOnIdleCompose {
+            recorder.run {
+                // Then we have recorded 1 down event and 1 move event
+                assertTimestampsAreIncreasing()
+                assertThat(events).hasSize(2)
+                assertThat(events[1].down).isTrue()
+                assertThat(events[1].position).isEqualTo(expectedEndPosition)
+                assertThat((events[1].timestamp - events[0].timestamp).inMilliseconds())
+                    .isEqualTo(dispatcherRule.eventPeriod)
+
+                // And the information in the token matches the last move event
+                assertThat(token.downTime).isEqualTo(events[0].timestamp.inMilliseconds())
+                assertThat(token.eventTime).isEqualTo(events[1].timestamp.inMilliseconds())
+                assertThat(token.lastPosition).isEqualTo(expectedEndPosition)
+            }
+        }
+    }
+}
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
new file mode 100644
index 0000000..6bc448b
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.test.partialgesturescope
+
+import androidx.test.filters.MediumTest
+import androidx.ui.graphics.Color
+import androidx.ui.test.GestureToken
+import androidx.ui.test.android.AndroidInputDispatcher
+import androidx.ui.test.createComposeRule
+import androidx.ui.test.doPartialGesture
+import androidx.ui.test.findByTag
+import androidx.ui.test.runOnIdleCompose
+import androidx.ui.test.sendDown
+import androidx.ui.test.sendUp
+import androidx.ui.test.util.ClickableTestBox
+import androidx.ui.test.util.PointerInputRecorder
+import androidx.ui.test.util.assertTimestampsAreIncreasing
+import androidx.ui.test.util.inMilliseconds
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.inMilliseconds
+import androidx.ui.unit.px
+import com.google.common.truth.Truth.assertThat
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.TestRule
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized
+
+private val width = 200.px
+private val height = 200.px
+
+private const val tag = "widget"
+
+@MediumTest
+@RunWith(Parameterized::class)
+class SendUpTest(private val config: TestConfig) {
+    data class TestConfig(val upPosition: PxPosition?) {
+        val downPosition: PxPosition = PxPosition(1.px, 1.px)
+    }
+
+    companion object {
+        @JvmStatic
+        @Parameterized.Parameters(name = "{0}")
+        fun createTestSet(): List<TestConfig> {
+            return mutableListOf<TestConfig>().apply {
+                for (x in listOf(2.px, 99.px)) {
+                    for (y in listOf(3.px, 53.px)) {
+                        add(TestConfig(PxPosition(x, y)))
+                    }
+                }
+                add(TestConfig(null))
+            }
+        }
+    }
+
+    @get:Rule
+    val composeTestRule = createComposeRule()
+
+    private val dispatcherRule = AndroidInputDispatcher.TestRule(disableDispatchInRealTime = true)
+    @get:Rule
+    val inputDispatcherRule: TestRule = dispatcherRule
+
+    private lateinit var recorder: PointerInputRecorder
+    private val expectedEndPosition = config.upPosition ?: config.downPosition
+
+    @Test
+    fun testSendUp() {
+        // Given some content
+        recorder = PointerInputRecorder()
+        composeTestRule.setContent {
+            ClickableTestBox(width, height, Color.Yellow, tag, recorder)
+        }
+
+        // When we inject a down event followed by an up event
+        lateinit var token: GestureToken
+        findByTag(tag).doPartialGesture { token = sendDown(config.downPosition) }
+        findByTag(tag).doPartialGesture { sendUp(token, config.upPosition) }
+
+        runOnIdleCompose {
+            recorder.run {
+                // Then we have recorded 1 down event and 1 move event
+                assertTimestampsAreIncreasing()
+                assertThat(events).hasSize(2)
+                assertThat(events[1].down).isFalse()
+                assertThat(events[1].position).isEqualTo(expectedEndPosition)
+                assertThat((events[1].timestamp - events[0].timestamp).inMilliseconds())
+                    .isEqualTo(dispatcherRule.eventPeriod)
+
+                // And the information in the token matches the last move event
+                assertThat(token.downTime).isEqualTo(events[0].timestamp.inMilliseconds())
+                assertThat(token.eventTime).isEqualTo(events[1].timestamp.inMilliseconds())
+                assertThat(token.lastPosition).isEqualTo(expectedEndPosition)
+            }
+        }
+    }
+}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt
new file mode 100644
index 0000000..ec46184
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/ClickableTestBox.kt
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.ui.test.util
+
+import androidx.compose.Composable
+import androidx.ui.core.DensityAmbient
+import androidx.ui.core.pointerinput.PointerInputModifier
+import androidx.ui.foundation.Box
+import androidx.ui.graphics.Color
+import androidx.ui.layout.size
+import androidx.ui.semantics.Semantics
+import androidx.ui.semantics.testTag
+import androidx.ui.unit.Px
+
+@Composable
+fun ClickableTestBox(
+    width: Px,
+    height: Px,
+    color: Color,
+    tag: String,
+    pointerInputModifier: PointerInputModifier
+) {
+    Semantics(container = true, properties = { testTag = tag }) {
+        with(DensityAmbient.current) {
+            Box(
+                modifier = pointerInputModifier.size(width.toDp(), height.toDp()),
+                backgroundColor = color
+            )
+        }
+    }
+}
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 3c25ab5..2321adc 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
@@ -27,6 +27,7 @@
 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
 
 class PointerInputRecorder : PointerInputModifier {
@@ -67,6 +68,8 @@
         }
 }
 
+fun Uptime.inMilliseconds(): Long = nanoseconds / 1_000_000
+
 val PointerInputRecorder.downEvents get() = events.filter { it.down }
 
 val PointerInputRecorder.recordedDuration: Duration