GestureDetector -> GestureFilter
Bug: 150387923
Test: None.
Change-Id: I703a7bc5667b3773dcbbb9617df46c87d4aeff6b
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/DoubleTapGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt
similarity index 62%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/DoubleTapGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt
index 6442fee..894fd81 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/DoubleTapGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/DoubleTapGestureFilterTest.kt
@@ -45,26 +45,26 @@
@kotlinx.coroutines.ObsoleteCoroutinesApi
@RunWith(JUnit4::class)
-class DoubleTapGestureDetectorTest {
+class DoubleTapGestureFilterTest {
private val DoubleTapTimeoutMillis = 100.milliseconds
@Suppress("DEPRECATION")
private val testContext = kotlinx.coroutines.test.TestCoroutineContext()
private val onDoubleTap: (PxPosition) -> Unit = mock()
- private lateinit var mRecognizer: DoubleTapGestureRecognizer
+ private lateinit var filter: DoubleTapGestureFilter
@Before
fun setup() {
- mRecognizer = DoubleTapGestureRecognizer(testContext)
- mRecognizer.>
- mRecognizer.doubleTapTimeout = DoubleTapTimeoutMillis
+ filter = DoubleTapGestureFilter(testContext)
+ filter.>
+ filter.doubleTapTimeout = DoubleTapTimeoutMillis
}
// Tests that verify conditions under which onDoubleTap will not be called.
@Test
fun onPointerInput_down_onDoubleTapNotCalled() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
verify(onDoubleTap, never()).invoke(any())
}
@@ -73,8 +73,8 @@
val down = down(0, 0.milliseconds)
val up = down.up(duration = 1.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(up)
verify(onDoubleTap, never()).invoke(any())
}
@@ -85,10 +85,10 @@
val up = down1.up(duration = 1.milliseconds)
val down2 = down(2, 100.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -99,10 +99,10 @@
val up = down1.up(duration = 1.milliseconds)
val down2 = down(2, 101.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -114,11 +114,11 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -131,12 +131,12 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(moveConsumed)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -149,12 +149,12 @@
val moveConsumed = down2.moveTo(101.milliseconds, x = 1f).consume(dx = 1f)
val up2 = moveConsumed.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(moveConsumed)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -170,12 +170,12 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1A, down1B)
- mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed1A, move1B)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1A, up1B)
+ filter::onPointerInput.invokeOverAllPasses(down1A, down1B)
+ filter::onPointerInput.invokeOverAllPasses(moveConsumed1A, move1B)
+ filter::onPointerInput.invokeOverAllPasses(up1A, up1B)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -191,12 +191,12 @@
val up2A = moveConsumed2A.up(duration = 102.milliseconds)
val up2B = move2B.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up2)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
- mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed2A, move2B)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2A, up2B)
+ filter::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ filter::onPointerInput.invokeOverAllPasses(moveConsumed2A, move2B)
+ filter::onPointerInput.invokeOverAllPasses(up2A, up2B)
verify(onDoubleTap, never()).invoke(any())
}
@@ -208,11 +208,11 @@
val down2 = down(0, 100.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -224,11 +224,11 @@
val down2 = down(0, 100.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -240,11 +240,11 @@
val down2 = down(0, 100.milliseconds).consumeDownChange()
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -256,11 +256,11 @@
val down2 = down(0, 100.milliseconds)
val up2 = down2.up(duration = 102.milliseconds).consumeDownChange()
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -276,11 +276,11 @@
val move1A3 = move1A2.moveTo(102.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1A, down1B)
- mRecognizer::onPointerInput.invokeOverAllPasses(move1A1, up2B)
+ filter::onPointerInput.invokeOverAllPasses(down1A, down1B)
+ filter::onPointerInput.invokeOverAllPasses(move1A1, up2B)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move1A2, down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(move1A3, up2)
+ filter::onPointerInput.invokeOverAllPasses(move1A2, down2)
+ filter::onPointerInput.invokeOverAllPasses(move1A3, up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -294,11 +294,11 @@
val move2A = down2A.moveTo(101.milliseconds)
val up2B = down2B.up(duration = 101.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
- mRecognizer::onPointerInput.invokeOverAllPasses(move2A, up2B)
+ filter::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ filter::onPointerInput.invokeOverAllPasses(move2A, up2B)
verify(onDoubleTap, never()).invoke(any())
}
@@ -311,11 +311,11 @@
val down2 = down(0, 13.milliseconds, 0f, 0f)
val up2 = down2.up(duration = 14.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(move, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(move, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
verify(onDoubleTap, never()).invoke(any())
}
@@ -328,11 +328,11 @@
val move2 = down2.moveTo(3.milliseconds, 1f, 1f)
val up2 = down2.up(duration = 4.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(move2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(move2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
verify(onDoubleTap, never()).invoke(any())
}
@@ -346,11 +346,11 @@
val down2 = down(2, 100.milliseconds)
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -363,12 +363,12 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -381,12 +381,12 @@
val move = down2.moveTo(101.milliseconds, x = 1f)
val up2 = move.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -402,12 +402,12 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1A, down1B)
- mRecognizer::onPointerInput.invokeOverAllPasses(move1A, move1B)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1A, up1B)
+ filter::onPointerInput.invokeOverAllPasses(down1A, down1B)
+ filter::onPointerInput.invokeOverAllPasses(move1A, move1B)
+ filter::onPointerInput.invokeOverAllPasses(up1A, up1B)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -423,12 +423,12 @@
val up2A = move2A.up(duration = 102.milliseconds)
val up2B = move2B.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
- mRecognizer::onPointerInput.invokeOverAllPasses(move2A, move2B)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2A, up2B)
+ filter::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ filter::onPointerInput.invokeOverAllPasses(move2A, move2B)
+ filter::onPointerInput.invokeOverAllPasses(up2A, up2B)
verify(onDoubleTap).invoke(any())
}
@@ -443,14 +443,14 @@
val down3 = down(0, 5.milliseconds, 0f, 0f)
val up3 = down3.up(6.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(move, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(move, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down3, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up3, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down3, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up3, IntPxSize(1.ipx, 1.ipx))
verify(onDoubleTap).invoke(any())
}
@@ -467,16 +467,16 @@
val down4 = down(0, 7.milliseconds, 0f, 0f)
val up4 = down4.up(8.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(move2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(move2, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down3, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up3, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(down4, IntPxSize(1.ipx, 1.ipx))
- mRecognizer::onPointerInput.invokeOverAllPasses(up4, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down3, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up3, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(down4, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(up4, IntPxSize(1.ipx, 1.ipx))
verify(onDoubleTap).invoke(any())
}
@@ -492,12 +492,12 @@
val wait2 = 50L
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(wait1, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
testContext.advanceTimeBy(wait2, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -511,11 +511,11 @@
val down2 = down(2, 100.milliseconds)
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(PxPosition.Origin)
}
@@ -528,12 +528,12 @@
val move2 = down2.moveTo(101.milliseconds, 3f, 5f)
val up2 = move2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(move2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(move2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(PxPosition(3.px, 5.px))
}
@@ -550,13 +550,13 @@
val move2B2 = move2B1.moveTo(102.milliseconds, x = 7f, y = 11f)
val up2B = move2B2.up(duration = 103.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
- mRecognizer::onPointerInput.invokeOverAllPasses(move2A, move2B1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2A, move2B2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2B)
+ filter::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ filter::onPointerInput.invokeOverAllPasses(move2A, move2B1)
+ filter::onPointerInput.invokeOverAllPasses(up2A, move2B2)
+ filter::onPointerInput.invokeOverAllPasses(up2B)
verify(onDoubleTap).invoke(PxPosition((7).px, (11).px))
}
@@ -566,7 +566,7 @@
@Test
fun onPointerInput_down_downNotConsumed() {
val down = down(0, 0.milliseconds)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ val result = filter::onPointerInput.invokeOverAllPasses(down)
assertThat(result.consumed.downChange).isFalse()
}
@@ -574,8 +574,8 @@
fun onPointerInput_downUp_upNotConsumed() {
val down = down(0, 0.milliseconds)
val up = down.up(1.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down)
+ val result = filter::onPointerInput.invokeOverAllPasses(up)
assertThat(result.consumed.downChange).isFalse()
}
@@ -585,10 +585,10 @@
val up = down.up(1.milliseconds)
val down2 = down(2, 100.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ val result = filter::onPointerInput.invokeOverAllPasses(down2)
assertThat(result.consumed.downChange).isFalse()
}
@@ -600,11 +600,11 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ val result = filter::onPointerInput.invokeOverAllPasses(up2)
assertThat(result.consumed.downChange).isFalse()
}
@@ -616,11 +616,11 @@
val down2 = down(2, 100.milliseconds)
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ val result = filter::onPointerInput.invokeOverAllPasses(up2)
assertThat(result.consumed.downChange).isTrue()
}
@@ -634,12 +634,12 @@
val down2 = down(1, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
- mRecognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
+ filter.onCancel()
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -651,12 +651,12 @@
val down2 = down(2, 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@@ -668,12 +668,12 @@
val down2 = down(1, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -686,13 +686,13 @@
val down2 = down(2, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down0)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -706,14 +706,14 @@
val down2 = down(2, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(up0)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -728,15 +728,15 @@
val down3 = down(3, 200.milliseconds)
val up3 = down3.up(duration = 201.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(up0)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down3)
- mRecognizer::onPointerInput.invokeOverAllPasses(up3)
+ filter::onPointerInput.invokeOverAllPasses(down3)
+ filter::onPointerInput.invokeOverAllPasses(up3)
verify(onDoubleTap).invoke(any())
}
@@ -753,17 +753,17 @@
val down3 = down(3, 300.milliseconds)
val up3 = down3.up(duration = 301.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(up0)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(up1)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down3)
- mRecognizer::onPointerInput.invokeOverAllPasses(up3)
+ filter::onPointerInput.invokeOverAllPasses(down3)
+ filter::onPointerInput.invokeOverAllPasses(up3)
verify(onDoubleTap, times(2)).invoke(any())
}
@@ -784,15 +784,15 @@
val down2 = down(2, 102.milliseconds)
val up2 = down2.up(duration = 103.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(up0)
testContext.advanceTimeBy(delay0, TimeUnit.MILLISECONDS)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down1)
testContext.advanceTimeBy(delay1, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up1)
- mRecognizer::onPointerInput.invokeOverAllPasses(down2)
- mRecognizer::onPointerInput.invokeOverAllPasses(up2)
+ filter::onPointerInput.invokeOverAllPasses(up1)
+ filter::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/LongPressGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt
similarity index 75%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/LongPressGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt
index 8cc98de..095b73a 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/LongPressGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/LongPressGestureFilterTest.kt
@@ -43,28 +43,28 @@
@kotlinx.coroutines.ObsoleteCoroutinesApi
@RunWith(JUnit4::class)
-class LongPressGestureDetectorTest {
+class LongPressGestureFilterTest {
private val LongPressTimeoutMillis = 100.milliseconds
@Suppress("DEPRECATION")
private val testContext = kotlinx.coroutines.test.TestCoroutineContext()
private val onLongPress: (PxPosition) -> Unit = mock()
private val customEventDispatcher: CustomEventDispatcher = mock()
- private lateinit var mRecognizer: LongPressGestureRecognizer
+ private lateinit var filter: LongPressGestureFilter
@Before
fun setup() {
- mRecognizer = LongPressGestureRecognizer(testContext)
- mRecognizer.>
- mRecognizer.longPressTimeout = LongPressTimeoutMillis
- mRecognizer.onInit(customEventDispatcher)
+ filter = LongPressGestureFilter(testContext)
+ filter.>
+ filter.longPressTimeout = LongPressTimeoutMillis
+ filter.onInit(customEventDispatcher)
}
// Tests that verify conditions under which onLongPress will not be called.
@Test
fun onPointerInput_down_eventNotFired() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
verify(onLongPress, never()).invoke(any())
verify(customEventDispatcher, never()).dispatchCustomEvent(any())
@@ -72,7 +72,7 @@
@Test
fun onPointerInput_downWithinTimeout_eventNotFired() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -84,9 +84,9 @@
val down = down(0)
val move = down.moveBy(50.milliseconds, 1f, 1f).consume(1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -100,9 +100,9 @@
val move0 = down0.moveBy(50.milliseconds, 1f, 1f).consume(1f, 0f)
val move1 = down0.moveBy(50.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0, down1)
+ filter::onPointerInput.invokeOverAllPasses(down0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move0, move1)
+ filter::onPointerInput.invokeOverAllPasses(move0, move1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -114,9 +114,9 @@
val down = down(0)
val up = down.up(50.milliseconds).consumeDownChange()
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -128,9 +128,9 @@
val down = down(0)
val up = down.up(50.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -150,13 +150,13 @@
// Act
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0)
+ filter::onPointerInput.invokeOverAllPasses(up0)
testContext.advanceTimeBy(1, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
@@ -169,9 +169,9 @@
@Test
fun onPointerInput_downMoveOutOfBoundsWait_eventNotFired() {
var pointer = down(0, 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -182,7 +182,7 @@
@Test
fun onPointerInput_downBeyondTimeout_eventFiredOnce() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -191,7 +191,7 @@
@Test
fun onPointerInput_2DownBeyondTimeout_eventFiredOnce() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0), down(1))
+ filter::onPointerInput.invokeOverAllPasses(down(0), down(1))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -201,15 +201,15 @@
@Test
fun onPointerInput_downMoveOutOfBoundsWaitUpThenDownWait_eventFiredOnce() {
var pointer = down(0, 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
pointer = pointer.up(105.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = down(1, 200.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -231,17 +231,17 @@
// Act
- mRecognizer::onPointerInput.invokeOverAllPasses(
+ filter::onPointerInput.invokeOverAllPasses(
down0
)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(
+ filter::onPointerInput.invokeOverAllPasses(
move0, down1
)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(
+ filter::onPointerInput.invokeOverAllPasses(
up0, move1
)
@@ -258,9 +258,9 @@
val down = down(0)
val move = down.moveBy(50.milliseconds, 1f, 1f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -273,7 +273,7 @@
fun onPointerInput_down_onLongPressCalledWithDownPosition() {
val down = down(0, x = 13f, y = 17f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(13.px, 17.px))
@@ -284,9 +284,9 @@
val down = down(0, x = 13f, y = 17f)
val move = down.moveTo(50.milliseconds, 7f, 5f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition((7).px, 5.px))
@@ -299,9 +299,9 @@
val move0 = down0.moveBy(50.milliseconds, 0f, 0f)
val down1 = down(1, 50.milliseconds, 11f, 19f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
+ filter::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(13.px, 17.px))
@@ -317,11 +317,11 @@
val up0 = move0.up(75.milliseconds)
val move1 = down1.moveBy(25.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
+ filter::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0, move1)
+ filter::onPointerInput.invokeOverAllPasses(up0, move1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(11.px, 19.px))
@@ -334,9 +334,9 @@
val move0 = down0.moveTo(50.milliseconds, 27f, 29f)
val down1 = down(1, 50.milliseconds, 11f, 19f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
+ filter::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(27.px, 29.px))
@@ -352,11 +352,11 @@
val up0 = move0.up(50.milliseconds)
val move1 = down1.moveTo(50.milliseconds, 27f, 23f)
- mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ filter::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
+ filter::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(up0, move1)
+ filter::onPointerInput.invokeOverAllPasses(up0, move1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(27.px, 23.px))
@@ -367,7 +367,7 @@
@Test
fun onPointerInput_1Down_notConsumed() {
val down0 = down(0)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(
+ val result = filter::onPointerInput.invokeOverAllPasses(
down0
)
assertThat(result.consumed.downChange).isFalse()
@@ -379,7 +379,7 @@
// Arrange
val down0 = down(0, 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(
+ filter::onPointerInput.invokeOverAllPasses(
down0
)
@@ -388,7 +388,7 @@
testContext.advanceTimeBy(10, TimeUnit.MILLISECONDS)
val move0 = down0.moveTo(10.milliseconds, 0f, 0f)
val down1 = down(0, 10.milliseconds)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(
+ val result = filter::onPointerInput.invokeOverAllPasses(
move0, down1
)
@@ -404,7 +404,7 @@
// Arrange
val down0 = down(0, 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(
+ filter::onPointerInput.invokeOverAllPasses(
down0
)
@@ -412,7 +412,7 @@
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
val up0 = down0.up(50.milliseconds)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(
+ val result = filter::onPointerInput.invokeOverAllPasses(
up0
)
@@ -427,7 +427,7 @@
// Arrange
val down0 = down(0, 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(
+ filter::onPointerInput.invokeOverAllPasses(
down0
)
@@ -435,7 +435,7 @@
testContext.advanceTimeBy(101, TimeUnit.MILLISECONDS)
val up0 = down0.up(100.milliseconds)
- val result = mRecognizer.onPointerInput(
+ val result = filter.onPointerInput(
listOf(up0),
PointerEventPass.InitialDown,
IntPxSize(0.ipx, 0.ipx)
@@ -452,16 +452,16 @@
// Arrange
var pointer = down(0, 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
pointer = pointer.moveTo(50.milliseconds, 5f).consume(1f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
// Act
testContext.advanceTimeBy(51, TimeUnit.MILLISECONDS)
pointer = pointer.up(100.milliseconds)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ val result = filter::onPointerInput.invokeOverAllPasses(pointer)
// Assert
@@ -472,8 +472,8 @@
@Test
fun onCancel_downCancelBeyondTimeout_eventNotFired() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- mRecognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter.onCancel()
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -482,9 +482,9 @@
@Test
fun onCancel_downAlmostTimeoutCancelTimeout_eventNotFired() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.onCancel()
+ filter.onCancel()
testContext.advanceTimeBy(1, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -493,10 +493,10 @@
@Test
fun onCancel_downCancelDownTimeExpires_eventFiredOnce() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.onCancel()
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -507,8 +507,8 @@
@Test
fun onCustomEvent_downCustomEventTimeout_eventNotFired() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- mRecognizer::onCustomEvent.invokeOverAllPasses(LongPressFiredEvent)
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onCustomEvent.invokeOverAllPasses(LongPressFiredEvent)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -517,10 +517,10 @@
@Test
fun onCustomEvent_downCustomEventTimeoutDownTimeout_eventFiredOnce() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- mRecognizer::onCustomEvent.invokeOverAllPasses(LongPressFiredEvent)
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onCustomEvent.invokeOverAllPasses(LongPressFiredEvent)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureDetectorTest.kt
deleted file mode 100644
index 458840d..0000000
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureDetectorTest.kt
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * Copyright 2019 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.core.gesture
-
-import androidx.ui.core.PointerEventPass
-import androidx.ui.core.consumeDownChange
-import androidx.ui.testutils.consume
-import androidx.ui.testutils.down
-import androidx.ui.testutils.invokeOverAllPasses
-import androidx.ui.testutils.invokeOverPasses
-import androidx.ui.testutils.moveBy
-import androidx.ui.testutils.moveTo
-import androidx.ui.testutils.up
-import androidx.ui.unit.IntPxSize
-import androidx.ui.unit.PxPosition
-import androidx.ui.unit.ipx
-import androidx.ui.unit.milliseconds
-import androidx.ui.unit.px
-import com.nhaarman.mockitokotlin2.any
-import com.nhaarman.mockitokotlin2.inOrder
-import com.nhaarman.mockitokotlin2.mock
-import com.nhaarman.mockitokotlin2.never
-import com.nhaarman.mockitokotlin2.times
-import com.nhaarman.mockitokotlin2.verify
-import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
-import org.hamcrest.CoreMatchers.`is`
-import org.hamcrest.MatcherAssert.assertThat
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-
-@RunWith(JUnit4::class)
-class PressIndicatorGestureDetectorTest {
-
- private lateinit var recognizer: PressIndicatorGestureRecognizer
-
- @Before
- fun setup() {
- recognizer = PressIndicatorGestureRecognizer()
- recognizer.>
- recognizer.>
- recognizer.>
- }
-
- // Verification of scenarios where onStart should not be called.
-
- @Test
- fun onPointerInput_downConsumed_onStartNotCalled() {
- recognizer::onPointerInput
- .invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
- verify(recognizer.onStart!!, never()).invoke(any())
- }
-
- @Test
- fun onPointerInput_disabledDown_onStartNotCalled() {
- recognizer.setEnabled(false)
- recognizer::onPointerInput
- .invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
- verify(recognizer.onStart!!, never()).invoke(any())
- }
-
- // Verification of scenarios where onStart should be called once.
-
- @Test
- fun onPointerInput_down_onStartCalledOnce() {
- recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- verify(recognizer.onStart!!).invoke(any())
- }
-
- @Test
- fun onPointerInput_downDown_onStartCalledOnce() {
- var pointer0 = down(0)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0)
- pointer0 = pointer0.moveTo(1.milliseconds)
- val pointer1 = down(1, 1.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
-
- verify(recognizer.onStart!!).invoke(any())
- }
-
- @Test
- fun onPointerInput_2Down1Up1Down_onStartCalledOnce() {
- var pointer0 = down(0)
- var pointer1 = down(1)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- pointer0 = pointer0.up(100.milliseconds)
- pointer1 = pointer1.moveTo(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- pointer0 = down(0, duration = 200.milliseconds)
- pointer1 = pointer1.moveTo(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
-
- verify(recognizer.onStart!!).invoke(any())
- }
-
- @Test
- fun onPointerInput_1DownMoveOutside2ndDown_onStartOnlyCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 10f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
- pointer0 = pointer0.moveTo(200.milliseconds)
- val pointer1 = down(1, x = 0f, y = 0f)
-
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
-
- verify(recognizer.onStart!!).invoke(any())
- }
-
- // Verification of scenarios where onStop should not be called.
-
- @Test
- fun onPointerInput_downMoveConsumedUp_onStopNotCalled() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveTo(100.milliseconds, 5f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_downConsumedUp_onStopNotCalled() {
- var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_2DownUp_onStopNotCalled() {
- var pointer0 = down(0)
- var pointer1 = down(1)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- pointer0 = pointer0.moveTo(100.milliseconds)
- pointer1 = pointer1.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
-
- verify(recognizer.onStop!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_downDisabledUp_onStopNotCalled() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.setEnabled(false)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_downDisabledEnabledUp_onStopNotCalled() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.setEnabled(false)
- recognizer.setEnabled(true)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!, never()).invoke()
- }
-
- // Verification of scenarios where onStop should be called once.
-
- @Test
- fun onPointerInput_downUp_onStopCalledOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!).invoke()
- }
-
- @Test
- fun onPointerInput_downUpConsumed_onStopCalledOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(100.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!).invoke()
- }
-
- @Test
- fun onPointerInput_downMoveUp_onStopCalledOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveTo(100.milliseconds, 5f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onStop!!).invoke()
- }
-
- @Test
- fun onPointerInput_2Down2Up_onStopCalledOnce() {
- var pointer1 = down(0)
- var pointer2 = down(1)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
- pointer1 = pointer1.up(100.milliseconds)
- pointer2 = pointer2.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
-
- verify(recognizer.onStop!!).invoke()
- }
-
- // Verification of scenarios where onCancel should not be called.
-
- @Test
- fun onPointerInput_downConsumedMoveConsumed_onCancelNotCalled() {
- var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onCancel!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_downUp_onCancelNotCalled() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onCancel!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_downMoveUp_onCancelNotCalled() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveTo(100.milliseconds, 5f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onCancel!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_2DownOneMoveOutsideOfBounds_onCancelNotCalled() {
- var pointer0 = down(0, x = 0f, y = 0f)
- var pointer1 = down(0, x = 4f, y = 4f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 0f, 0f)
- pointer1 = pointer1.moveTo(100.milliseconds, 5f, 4f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
-
- verify(recognizer.onCancel!!, never()).invoke()
- }
-
- @Test
- fun onPointerInput_notEnabledDownNotEnabled_onCancelNotCalled() {
- recognizer.setEnabled(false)
- recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- recognizer.setEnabled(false)
-
- verify(recognizer.onCancel!!, never()).invoke()
- }
-
- // Verification of scenarios where onCancel should be called once.
-
- @Test
- fun onPointerInput_downMoveConsumed_onCancelCalledOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_downMoveConsumedMoveConsumed_onCancelCalledOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_2Down2MoveConsumed_onCancelCalledOnce() {
- var pointer0 = down(0)
- var pointer1 = down(1)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- pointer0 = pointer0.moveBy(100.milliseconds, 5f).consume(1f)
- pointer1 = pointer1.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_2Down1MoveConsumedTheOtherMoveConsume_onCancelCalledOnce() {
- var pointer0 = down(0)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0)
- pointer0 = pointer0.moveTo(100.milliseconds)
- var pointer1 = down(1, duration = 100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- pointer0 = pointer0.moveBy(100L.milliseconds, 5f).consume(5f)
- pointer1 = pointer1.moveBy(100L.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- pointer0 = pointer0.moveBy(100L.milliseconds)
- pointer1 = pointer1.moveBy(100L.milliseconds, 5f).consume(5f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_1DownMoveOutsideOfBoundsLeft_onCancelCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, -1f, 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_1DownMoveOutsideOfBoundsRight_onCancelCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 1f, 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_1DownMoveOutsideOfBoundsUp_onCancelCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 0f, -1f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_1DownMoveOutsideOfBoundsDown_onCancelCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 0f, 1f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_2DownBothMoveOutsideOfBounds_onCancelCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 4f)
- var pointer1 = down(1, x = 4f, y = 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 0f, 5f)
- pointer1 = pointer1.moveTo(100.milliseconds, 5f, 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_1DownMoveOutsideBoundsThenInsideThenOutside_onCancelCalledOnce() {
- var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(100.milliseconds, 0f, 1f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(200.milliseconds, 0f, 0f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
- pointer0 = pointer0.moveTo(300.milliseconds, 0f, 1f)
- recognizer::onPointerInput
- .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- @Test
- fun onPointerInput_1DownMoveOutsideBoundsUpTwice_onCancelCalledTwice() {
- var time = 0L
-
- repeat(2) {
- var pointer = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- pointer = pointer.moveTo(time.milliseconds, 0f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- pointer = pointer.up(time.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- time += 100L
- }
-
- verify(recognizer.onCancel!!, times(2)).invoke()
- }
-
- @Test
- fun onPointerInput_downDisabled_onCancelCalledOnce() {
- val pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.setEnabled(false)
-
- verify(recognizer.onCancel!!).invoke()
- }
-
- // Verification of correct position returned by onStart.
-
- @Test
- fun onPointerInput_down_downPositionIsCorrect() {
- recognizer::onPointerInput
- .invokeOverAllPasses(down(0, 0.milliseconds, x = 13f, y = 17f))
- verify(recognizer.onStart!!).invoke(PxPosition(13.px, 17f.px))
- }
-
- // Verification of correct consumption behavior.
-
- @Test
- fun onPointerInput_down_downChangeConsumedDuringPostUp() {
- var pointer = down(0, 0.milliseconds)
- pointer = recognizer::onPointerInput.invokeOverPasses(
- pointer,
- PointerEventPass.InitialDown,
- PointerEventPass.PreUp,
- PointerEventPass.PreDown
- )
- assertThat(pointer.consumed.downChange, `is`(false))
-
- pointer = recognizer::onPointerInput.invoke(
- listOf(pointer),
- PointerEventPass.PostUp,
- IntPxSize(0.ipx, 0.ipx)
- ).first()
- assertThat(pointer.consumed.downChange, `is`(true))
- }
-
- @Test
- fun onPointerInput_disabledDown_noDownChangeConsumed() {
- recognizer.setEnabled(false)
- var pointer = down(0, 0.milliseconds)
- pointer = recognizer::onPointerInput.invokeOverAllPasses(pointer)
- assertThat(pointer.consumed.downChange, `is`(false))
- }
-
- // Verification of correct cancellation handling.
-
- @Test
- fun onCancel_justCancel_noCallbacksCalled() {
- recognizer.onCancel()
-
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-
- @Test
- fun onCancel_downConsumedCancel_noCallbacksCalled() {
- recognizer::onPointerInput
- .invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
- recognizer.onCancel()
-
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-
- @Test
- fun onCancel_downCancel_justStartAndCancelCalledInOrderOnce() {
- recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- recognizer.onCancel()
-
- inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
- verify(recognizer.onStart!!).invoke(any())
- verify(recognizer.onCancel!!).invoke()
- }
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-
- @Test
- fun onCancel_downUpCancel_justStartAndStopCalledInOrderOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.onCancel()
-
- inOrder(recognizer.onStart!!, recognizer.onStop!!) {
- verify(recognizer.onStart!!).invoke(any())
- verify(recognizer.onStop!!).invoke()
- }
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-
- @Test
- fun onCancel_downMoveCancel_justStartAndCancelCalledInOrderOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveTo(50.milliseconds, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.onCancel()
-
- inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
- verify(recognizer.onStart!!).invoke(any())
- verify(recognizer.onCancel!!).invoke()
- }
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-
- @Test
- fun onCancel_downMoveConsumedCancel_justStartAndCancelCalledInOrderOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- pointer = pointer.moveTo(50.milliseconds, 1f).consume(1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.onCancel()
-
- inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
- verify(recognizer.onStart!!).invoke(any())
- verify(recognizer.onCancel!!).invoke()
- }
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-
- @Test
- fun onCancel_downThenCancelThenDown_justStartCancelStartCalledInOrderOnce() {
- var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.onCancel()
- pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
-
- inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
- verify(recognizer.onStart!!).invoke(any())
- verify(recognizer.onCancel!!).invoke()
- verify(recognizer.onStart!!).invoke(any())
- }
- verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
- }
-}
\ No newline at end of file
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt
new file mode 100644
index 0000000..f5ac282
--- /dev/null
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/PressIndicatorGestureFilterTest.kt
@@ -0,0 +1,574 @@
+/*
+ * Copyright 2019 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.core.gesture
+
+import androidx.ui.core.PointerEventPass
+import androidx.ui.core.consumeDownChange
+import androidx.ui.testutils.consume
+import androidx.ui.testutils.down
+import androidx.ui.testutils.invokeOverAllPasses
+import androidx.ui.testutils.invokeOverPasses
+import androidx.ui.testutils.moveBy
+import androidx.ui.testutils.moveTo
+import androidx.ui.testutils.up
+import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.ipx
+import androidx.ui.unit.milliseconds
+import androidx.ui.unit.px
+import com.nhaarman.mockitokotlin2.any
+import com.nhaarman.mockitokotlin2.inOrder
+import com.nhaarman.mockitokotlin2.mock
+import com.nhaarman.mockitokotlin2.never
+import com.nhaarman.mockitokotlin2.times
+import com.nhaarman.mockitokotlin2.verify
+import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
+import org.hamcrest.CoreMatchers.`is`
+import org.hamcrest.MatcherAssert.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class PressIndicatorGestureFilterTest {
+
+ private lateinit var filter: PressIndicatorGestureFilter
+
+ @Before
+ fun setup() {
+ filter = PressIndicatorGestureFilter()
+ filter.>
+ filter.>
+ filter.>
+ }
+
+ // Verification of scenarios where onStart should not be called.
+
+ @Test
+ fun onPointerInput_downConsumed_onStartNotCalled() {
+ filter::onPointerInput
+ .invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
+ verify(filter.onStart!!, never()).invoke(any())
+ }
+
+ @Test
+ fun onPointerInput_disabledDown_onStartNotCalled() {
+ filter.setEnabled(false)
+ filter::onPointerInput
+ .invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
+ verify(filter.onStart!!, never()).invoke(any())
+ }
+
+ // Verification of scenarios where onStart should be called once.
+
+ @Test
+ fun onPointerInput_down_onStartCalledOnce() {
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ verify(filter.onStart!!).invoke(any())
+ }
+
+ @Test
+ fun onPointerInput_downDown_onStartCalledOnce() {
+ var pointer0 = down(0)
+ filter::onPointerInput.invokeOverAllPasses(pointer0)
+ pointer0 = pointer0.moveTo(1.milliseconds)
+ val pointer1 = down(1, 1.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+
+ verify(filter.onStart!!).invoke(any())
+ }
+
+ @Test
+ fun onPointerInput_2Down1Up1Down_onStartCalledOnce() {
+ var pointer0 = down(0)
+ var pointer1 = down(1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ pointer0 = pointer0.up(100.milliseconds)
+ pointer1 = pointer1.moveTo(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ pointer0 = down(0, duration = 200.milliseconds)
+ pointer1 = pointer1.moveTo(200.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+
+ verify(filter.onStart!!).invoke(any())
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutside2ndDown_onStartOnlyCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 10f, 0f)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ pointer0 = pointer0.moveTo(200.milliseconds)
+ val pointer1 = down(1, x = 0f, y = 0f)
+
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+
+ verify(filter.onStart!!).invoke(any())
+ }
+
+ // Verification of scenarios where onStop should not be called.
+
+ @Test
+ fun onPointerInput_downMoveConsumedUp_onStopNotCalled() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveTo(100.milliseconds, 5f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(200.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downConsumedUp_onStopNotCalled() {
+ var pointer = down(0, 0.milliseconds).consumeDownChange()
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_2DownUp_onStopNotCalled() {
+ var pointer0 = down(0)
+ var pointer1 = down(1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ pointer0 = pointer0.moveTo(100.milliseconds)
+ pointer1 = pointer1.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+
+ verify(filter.onStop!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downDisabledUp_onStopNotCalled() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.setEnabled(false)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downDisabledEnabledUp_onStopNotCalled() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.setEnabled(false)
+ filter.setEnabled(true)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!, never()).invoke()
+ }
+
+ // Verification of scenarios where onStop should be called once.
+
+ @Test
+ fun onPointerInput_downUp_onStopCalledOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downUpConsumed_onStopCalledOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(100.milliseconds).consumeDownChange()
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downMoveUp_onStopCalledOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveTo(100.milliseconds, 5f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(200.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onStop!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_2Down2Up_onStopCalledOnce() {
+ var pointer1 = down(0)
+ var pointer2 = down(1)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ pointer1 = pointer1.up(100.milliseconds)
+ pointer2 = pointer2.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+
+ verify(filter.onStop!!).invoke()
+ }
+
+ // Verification of scenarios where onCancel should not be called.
+
+ @Test
+ fun onPointerInput_downConsumedMoveConsumed_onCancelNotCalled() {
+ var pointer = down(0, 0.milliseconds).consumeDownChange()
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onCancel!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downUp_onCancelNotCalled() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onCancel!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downMoveUp_onCancelNotCalled() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveTo(100.milliseconds, 5f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onCancel!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_2DownOneMoveOutsideOfBounds_onCancelNotCalled() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ var pointer1 = down(0, x = 4f, y = 4f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 0f, 0f)
+ pointer1 = pointer1.moveTo(100.milliseconds, 5f, 4f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
+
+ verify(filter.onCancel!!, never()).invoke()
+ }
+
+ @Test
+ fun onPointerInput_notEnabledDownNotEnabled_onCancelNotCalled() {
+ filter.setEnabled(false)
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter.setEnabled(false)
+
+ verify(filter.onCancel!!, never()).invoke()
+ }
+
+ // Verification of scenarios where onCancel should be called once.
+
+ @Test
+ fun onPointerInput_downMoveConsumed_onCancelCalledOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downMoveConsumedMoveConsumed_onCancelCalledOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_2Down2MoveConsumed_onCancelCalledOnce() {
+ var pointer0 = down(0)
+ var pointer1 = down(1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ pointer0 = pointer0.moveBy(100.milliseconds, 5f).consume(1f)
+ pointer1 = pointer1.moveBy(100.milliseconds, 5f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_2Down1MoveConsumedTheOtherMoveConsume_onCancelCalledOnce() {
+ var pointer0 = down(0)
+ filter::onPointerInput.invokeOverAllPasses(pointer0)
+ pointer0 = pointer0.moveTo(100.milliseconds)
+ var pointer1 = down(1, duration = 100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ pointer0 = pointer0.moveBy(100L.milliseconds, 5f).consume(5f)
+ pointer1 = pointer1.moveBy(100L.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ pointer0 = pointer0.moveBy(100L.milliseconds)
+ pointer1 = pointer1.moveBy(100L.milliseconds, 5f).consume(5f)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutsideOfBoundsLeft_onCancelCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, -1f, 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutsideOfBoundsRight_onCancelCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 1f, 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutsideOfBoundsUp_onCancelCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 0f, -1f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutsideOfBoundsDown_onCancelCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 0f, 1f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_2DownBothMoveOutsideOfBounds_onCancelCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 4f)
+ var pointer1 = down(1, x = 4f, y = 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 0f, 5f)
+ pointer1 = pointer1.moveTo(100.milliseconds, 5f, 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutsideBoundsThenInsideThenOutside_onCancelCalledOnce() {
+ var pointer0 = down(0, x = 0f, y = 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(100.milliseconds, 0f, 1f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(200.milliseconds, 0f, 0f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+ pointer0 = pointer0.moveTo(300.milliseconds, 0f, 1f)
+ filter::onPointerInput
+ .invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ @Test
+ fun onPointerInput_1DownMoveOutsideBoundsUpTwice_onCancelCalledTwice() {
+ var time = 0L
+
+ repeat(2) {
+ var pointer = down(0, x = 0f, y = 0f)
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ pointer = pointer.moveTo(time.milliseconds, 0f, 1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ pointer = pointer.up(time.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ time += 100L
+ }
+
+ verify(filter.onCancel!!, times(2)).invoke()
+ }
+
+ @Test
+ fun onPointerInput_downDisabled_onCancelCalledOnce() {
+ val pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.setEnabled(false)
+
+ verify(filter.onCancel!!).invoke()
+ }
+
+ // Verification of correct position returned by onStart.
+
+ @Test
+ fun onPointerInput_down_downPositionIsCorrect() {
+ filter::onPointerInput
+ .invokeOverAllPasses(down(0, 0.milliseconds, x = 13f, y = 17f))
+ verify(filter.onStart!!).invoke(PxPosition(13.px, 17f.px))
+ }
+
+ // Verification of correct consumption behavior.
+
+ @Test
+ fun onPointerInput_down_downChangeConsumedDuringPostUp() {
+ var pointer = down(0, 0.milliseconds)
+ pointer = filter::onPointerInput.invokeOverPasses(
+ pointer,
+ PointerEventPass.InitialDown,
+ PointerEventPass.PreUp,
+ PointerEventPass.PreDown
+ )
+ assertThat(pointer.consumed.downChange, `is`(false))
+
+ pointer = filter::onPointerInput.invoke(
+ listOf(pointer),
+ PointerEventPass.PostUp,
+ IntPxSize(0.ipx, 0.ipx)
+ ).first()
+ assertThat(pointer.consumed.downChange, `is`(true))
+ }
+
+ @Test
+ fun onPointerInput_disabledDown_noDownChangeConsumed() {
+ filter.setEnabled(false)
+ var pointer = down(0, 0.milliseconds)
+ pointer = filter::onPointerInput.invokeOverAllPasses(pointer)
+ assertThat(pointer.consumed.downChange, `is`(false))
+ }
+
+ // Verification of correct cancellation handling.
+
+ @Test
+ fun onCancel_justCancel_noCallbacksCalled() {
+ filter.onCancel()
+
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+
+ @Test
+ fun onCancel_downConsumedCancel_noCallbacksCalled() {
+ filter::onPointerInput
+ .invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
+ filter.onCancel()
+
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+
+ @Test
+ fun onCancel_downCancel_justStartAndCancelCalledInOrderOnce() {
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter.onCancel()
+
+ inOrder(filter.onStart!!, filter.onCancel!!) {
+ verify(filter.onStart!!).invoke(any())
+ verify(filter.onCancel!!).invoke()
+ }
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+
+ @Test
+ fun onCancel_downUpCancel_justStartAndStopCalledInOrderOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.up(100.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.onCancel()
+
+ inOrder(filter.onStart!!, filter.onStop!!) {
+ verify(filter.onStart!!).invoke(any())
+ verify(filter.onStop!!).invoke()
+ }
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+
+ @Test
+ fun onCancel_downMoveCancel_justStartAndCancelCalledInOrderOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveTo(50.milliseconds, 1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.onCancel()
+
+ inOrder(filter.onStart!!, filter.onCancel!!) {
+ verify(filter.onStart!!).invoke(any())
+ verify(filter.onCancel!!).invoke()
+ }
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+
+ @Test
+ fun onCancel_downMoveConsumedCancel_justStartAndCancelCalledInOrderOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = pointer.moveTo(50.milliseconds, 1f).consume(1f)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.onCancel()
+
+ inOrder(filter.onStart!!, filter.onCancel!!) {
+ verify(filter.onStart!!).invoke(any())
+ verify(filter.onCancel!!).invoke()
+ }
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+
+ @Test
+ fun onCancel_downThenCancelThenDown_justStartCancelStartCalledInOrderOnce() {
+ var pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.onCancel()
+ pointer = down(0, 0.milliseconds)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+
+ inOrder(filter.onStart!!, filter.onCancel!!) {
+ verify(filter.onStart!!).invoke(any())
+ verify(filter.onCancel!!).invoke()
+ verify(filter.onStart!!).invoke(any())
+ }
+ verifyNoMoreInteractions(filter.onStart, filter.onStop, filter.onCancel)
+ }
+}
\ No newline at end of file
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawDragGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt
similarity index 79%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawDragGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt
index 3f6662a..92c4c4e 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawDragGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawDragGestureFilterTest.kt
@@ -45,9 +45,9 @@
// Verify correct behavior with no DragBlocker
@RunWith(JUnit4::class)
-class RawDragGestureDetectorTest {
+class RawDragGestureFilterTest {
- private lateinit var recognizer: RawDragGestureRecognizer
+ private lateinit var filter: RawDragGestureFilter
private lateinit var dragObserver: MockDragObserver
private lateinit var log: MutableList<LogItem>
private var dragStartBlocked = true
@@ -56,9 +56,9 @@
fun setup() {
log = mutableListOf()
dragObserver = MockDragObserver(log)
- recognizer = RawDragGestureRecognizer()
- recognizer.canStartDragging = { !dragStartBlocked }
- recognizer.dragObserver = dragObserver
+ filter = RawDragGestureFilter()
+ filter.canStartDragging = { !dragStartBlocked }
+ filter.dragObserver = dragObserver
}
// Verify the circumstances under which onStart/OnDrag should not be called.
@@ -67,9 +67,9 @@
fun onPointerInput_blockedAndMove_onStartAndOnDragNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
@@ -78,11 +78,11 @@
@Test
fun onPointerInput_unblockedNoMove_onStartAndOnDragNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 0f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
@@ -92,11 +92,11 @@
fun onPointerInput_unblockedMovementConsumed_onStartAndOnDragNotCalled() {
val down1 = down(1)
- recognizer::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
dragStartBlocked = false
val move1 = down1.moveBy(10.milliseconds, 1f, 1f).consume(dx = 1f, dy = 1f)
- recognizer::onPointerInput.invokeOverAllPasses(move1)
+ filter::onPointerInput.invokeOverAllPasses(move1)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
@@ -107,12 +107,12 @@
val down1 = down(1)
val down2 = down(2)
- recognizer::onPointerInput.invokeOverAllPasses(down1, down2)
+ filter::onPointerInput.invokeOverAllPasses(down1, down2)
dragStartBlocked = false
val move1 = down1.moveBy(10.milliseconds, 1f, 1f)
val move2 = down2.moveBy(10.milliseconds, -1f, -1f)
- recognizer::onPointerInput.invokeOverAllPasses(move1, move2)
+ filter::onPointerInput.invokeOverAllPasses(move1, move2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
@@ -124,7 +124,7 @@
// Arrange
val pointers = arrayOf(down(0), down(1), down(2))
- recognizer::onPointerInput.invokeOverAllPasses(*pointers)
+ filter::onPointerInput.invokeOverAllPasses(*pointers)
dragStartBlocked = false
// Act
@@ -148,7 +148,7 @@
0f,
2f
)
- recognizer::onPointerInput.invokeOverAllPasses(*pointers)
+ filter::onPointerInput.invokeOverAllPasses(*pointers)
// Assert
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
@@ -161,11 +161,11 @@
fun onPointerInput_unblockedAndMoveOnX_onStartAndOnDragCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
// onDrag get's called twice because it is called during PostUp and PostDown and nothing
@@ -177,11 +177,11 @@
fun onPointerInput_unblockedAndMoveOnY_oonStartAndOnDragCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 0f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
// onDrag get's called twice because it is called during PostUp and PostDown and nothing
@@ -193,11 +193,11 @@
fun onPointerInput_unblockedAndMoveConsumedBeyond0_onStartAndOnDragCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 1f, 0f).consume(dx = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
// onDrag get's called twice because it is called during PostUp and PostDown and nothing
@@ -210,11 +210,11 @@
@Test
fun onPointerInput_unblockedMove_onDragCalledWithTotalDistance() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveBy(100.milliseconds, 5f, -2f)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
val { it.methodName == "onDrag" }
assertThat(onDragLog).hasSize(2)
@@ -230,21 +230,21 @@
// Arrange
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
// Act
change = change.moveBy(100.milliseconds, 3f, -5f)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, -3f, 7f)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, 11f, 13f)
.consumePositionChange(5.px, 3.px)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, -13f, -11f)
.consumePositionChange((-3).px, (-5).px)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// Assert
@@ -270,7 +270,7 @@
var pointer1 = down(0)
var pointer2 = down(1)
var pointer3 = down(2)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
dragStartBlocked = false
pointer1 = pointer1.moveBy(100.milliseconds, 9f, -12f)
@@ -279,7 +279,7 @@
// Act
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
// Assert
@@ -306,11 +306,11 @@
@Test
fun onPointerInput_blockedDownMoveUp_onStopNotCalled() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveTo(10.milliseconds, 1f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@@ -318,10 +318,10 @@
@Test
fun onPointerInput_unBlockedDownUp_onStopNotCalled() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@@ -330,14 +330,14 @@
fun onPointerInput_unBlockedDownMoveAverage0Up_onStopNotCalled() {
var change1 = down(1)
var change2 = down(2)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
dragStartBlocked = false
change1 = change1.moveBy(10.milliseconds, 1f, 1f)
change2 = change2.moveBy(10.milliseconds, -1f, -1f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log.filter { it.methodName == "onStop" }).isEmpty()
}
@@ -346,12 +346,12 @@
@Test
fun onPointerInput_unblockedDownMoveUp_onStopCalledOnce() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(10.milliseconds, 1f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(1)
}
@@ -380,7 +380,7 @@
log.clear()
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
repeat(11) {
@@ -389,11 +389,11 @@
incrementPerMilliX,
incrementPerMilliY
)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
}
change = change.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
val loggedStops = log.filter { it.methodName == "onStop" }
assertThat(loggedStops).hasSize(1)
@@ -407,7 +407,7 @@
@Test
fun onPointerInput_unblockDownMoveUp_callBacksOccurInCorrectOrder() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -415,9 +415,9 @@
0f,
1f
)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
assertThat(log).hasSize(4)
assertThat(log[0].methodName).isEqualTo("onStart")
@@ -432,7 +432,7 @@
@Test
fun onPointerInput_down_downNotConsumed() {
- val result = recognizer::onPointerInput.invokeOverAllPasses(down(0))
+ val result = filter::onPointerInput.invokeOverAllPasses(down(0))
assertThat(result.consumed.downChange).isFalse()
}
@@ -440,14 +440,14 @@
fun onPointerInput_blockedDownMove_distanceChangeNotConsumed() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveTo(
10.milliseconds,
1f,
0f
)
dragObserver.dragConsume = PxPosition(7.ipx, (-11).ipx)
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
change,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -455,7 +455,7 @@
PointerEventPass.PostUp
)
dragObserver.dragConsume = PxPosition.Origin
- result = recognizer::onPointerInput.invokeOverPasses(
+ result = filter::onPointerInput.invokeOverPasses(
result,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -471,7 +471,7 @@
dragObserver.dragConsume = PxPosition.Origin
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -479,7 +479,7 @@
1f,
1f
)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change)
+ val result = filter::onPointerInput.invokeOverAllPasses(change)
assertThat(result.anyPositionChangeConsumed()).isFalse()
}
@@ -489,7 +489,7 @@
dragObserver.dragConsume = null
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -497,7 +497,7 @@
1f,
1f
)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change)
+ val result = filter::onPointerInput.invokeOverAllPasses(change)
assertThat(result.anyPositionChangeConsumed()).isFalse()
}
@@ -505,7 +505,7 @@
@Test
fun onPointerInput_moveCallBackConsumes_changeDistanceConsumedByCorrectAmount() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change, IntPxSize(0.ipx, 0.ipx))
+ filter::onPointerInput.invokeOverAllPasses(change, IntPxSize(0.ipx, 0.ipx))
dragStartBlocked = false
change = change.moveTo(
@@ -514,7 +514,7 @@
-5f
)
dragObserver.dragConsume = PxPosition(7.ipx, (-11).ipx)
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
change,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -522,7 +522,7 @@
PointerEventPass.PostUp
)
dragObserver.dragConsume = PxPosition.Origin
- result = recognizer::onPointerInput.invokeOverPasses(
+ result = filter::onPointerInput.invokeOverPasses(
result,
PointerEventPass.PostDown
)
@@ -534,7 +534,7 @@
@Test
fun onPointerInput_onStopConsumesUp() {
var change = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -542,9 +542,9 @@
1f,
0f
)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change)
+ val result = filter::onPointerInput.invokeOverAllPasses(change)
assertThat(result.consumed.downChange).isTrue()
}
@@ -552,11 +552,11 @@
@Test
fun onPointerInput_move_onStartCalledWithDownPosition() {
val down = down(0, 0.milliseconds, x = 3f, y = 4f)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(Duration(milliseconds = 10), 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
.isEqualTo(PxPosition(3.px, 4.px))
@@ -567,7 +567,7 @@
var pointer1 = down(1, x = 1f, y = 2f)
var pointer2 = down(2, x = 5f, y = 4f)
var pointer3 = down(3, x = 3f, y = 6f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
dragStartBlocked = false
pointer1 = pointer1.moveBy(100.milliseconds, 1f, 0f)
@@ -576,7 +576,7 @@
// Act
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
// average position
@@ -588,9 +588,9 @@
@Test
fun onCancel_downCancel_onCancelNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
- recognizer.onCancel()
+ filter.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@@ -598,11 +598,11 @@
@Test
fun onCancel_blockedDownMoveCancel_onCancelNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = true
val move = down.moveBy(1.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
- recognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(move)
+ filter.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@@ -612,11 +612,11 @@
@Test
fun onCancel_downMoveCancel_onCancelCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(1.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
- recognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(move)
+ filter.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).hasSize(1)
}
@@ -626,15 +626,15 @@
@Test
fun onCancel_downCancelDownMove_startPositionIsSecondDown() {
val down1 = down(1, x = 3f, y = 5f)
- recognizer::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
dragStartBlocked = false
- recognizer.onCancel()
+ filter.onCancel()
val down2 = down(2, x = 7f, y = 11f)
- recognizer::onPointerInput.invokeOverAllPasses(down2)
+ filter::onPointerInput.invokeOverAllPasses(down2)
val move = down2.moveBy(Duration(milliseconds = 10), 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
.isEqualTo(PxPosition(7.px, 11.px))
@@ -647,7 +647,7 @@
// Down, move, cancel.
var change = down(0, duration = 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
repeat(11) {
change = change.moveBy(
@@ -655,13 +655,13 @@
-1f,
-1f
)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
}
- recognizer.onCancel()
+ filter.onCancel()
// Down, Move, Up
change = down(1, duration = 200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
repeat(11) {
change = change.moveBy(
@@ -669,10 +669,10 @@
1f,
1f
)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
}
change = change.up(310.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// Assert.
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawPressStartGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt
similarity index 61%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawPressStartGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt
index e21e948..bf25a8a 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawPressStartGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawPressStartGestureFilterTest.kt
@@ -43,117 +43,117 @@
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class RawPressStartGestureDetectorTest {
+class RawPressStartGestureFilterTest {
- private lateinit var recognizer: RawPressStartGestureRecognizer
+ private lateinit var filter: RawPressStartGestureFilter
@Before
fun setup() {
- recognizer = RawPressStartGestureRecognizer()
- recognizer.>
+ filter = RawPressStartGestureFilter()
+ filter.>
}
// Verification of scenarios where onPressStart should not be called.
@Test
fun onPointerInput_downConsumed_onPressStartNotCalled() {
- recognizer::onPointerInput.invokeOverAllPasses(down(0).consumeDownChange())
- verify(recognizer.onPressStart, never()).invoke(any())
+ filter::onPointerInput.invokeOverAllPasses(down(0).consumeDownChange())
+ verify(filter.onPressStart, never()).invoke(any())
}
@Test
fun onPointerInput_downConsumedDown_onPressStartNotCalled() {
var pointer1 = down(1, duration = 0.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer1)
pointer1 = pointer1.moveBy(10.milliseconds)
val pointer2 = down(2, duration = 10.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
- verify(recognizer.onPressStart, never()).invoke(any())
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ verify(filter.onPressStart, never()).invoke(any())
}
@Test
fun onPointerInput_disabledDown_onPressStartNotCalled() {
- recognizer.setEnabled(false)
- recognizer::onPointerInput.invokeOverAllPasses(down(0))
- verify(recognizer.onPressStart, never()).invoke(any())
+ filter.setEnabled(false)
+ filter::onPointerInput.invokeOverAllPasses(down(0))
+ verify(filter.onPressStart, never()).invoke(any())
}
@Test
fun onPointerInput_disabledDownEnabledDown_onPressStartNotCalled() {
- recognizer.setEnabled(false)
+ filter.setEnabled(false)
var pointer1 = down(1, duration = 0.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer1)
- recognizer.setEnabled(true)
+ filter::onPointerInput.invokeOverAllPasses(pointer1)
+ filter.setEnabled(true)
pointer1 = pointer1.moveBy(10.milliseconds)
val pointer2 = down(2, duration = 10.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
- verify(recognizer.onPressStart, never()).invoke(any())
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ verify(filter.onPressStart, never()).invoke(any())
}
// Verification of scenarios where onPressStart should be called once.
@Test
fun onPointerInput_down_onPressStartCalledOnce() {
- recognizer::onPointerInput.invokeOverAllPasses(down(0))
- verify(recognizer.onPressStart).invoke(any())
+ filter::onPointerInput.invokeOverAllPasses(down(0))
+ verify(filter.onPressStart).invoke(any())
}
@Test
fun onPointerInput_downDown_onPressStartCalledOnce() {
var pointer0 = down(0)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0)
+ filter::onPointerInput.invokeOverAllPasses(pointer0)
pointer0 = pointer0.moveTo(1.milliseconds)
val pointer1 = down(1, 1.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
}
@Test
fun onPointerInput_2Down1Up1Down_onPressStartCalledOnce() {
var pointer0 = down(0)
var pointer1 = down(1)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.up(100.milliseconds)
pointer1 = pointer1.moveTo(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = down(0, duration = 200.milliseconds)
pointer1 = pointer1.moveTo(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
}
@Test
fun onPointerInput_1DownMoveOutside2ndDown_onPressStartOnlyCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 10f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
pointer0 = pointer0.moveTo(200.milliseconds)
val pointer1 = down(1, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
}
// Verification of correct position returned by onPressStart.
@Test
fun onPointerInput_down_downPositionIsCorrect() {
- recognizer::onPointerInput.invokeOverAllPasses(down(0, x = 13f, y = 17f))
- verify(recognizer.onPressStart).invoke(PxPosition(13.px, 17f.px))
+ filter::onPointerInput.invokeOverAllPasses(down(0, x = 13f, y = 17f))
+ verify(filter.onPressStart).invoke(PxPosition(13.px, 17f.px))
}
// Verification of correct consumption behavior.
@Test
fun onPointerInput_disabledDown_noDownChangeConsumed() {
- recognizer.setEnabled(false)
+ filter.setEnabled(false)
var pointer = down(0)
- pointer = recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ pointer = filter::onPointerInput.invokeOverAllPasses(pointer)
assertThat(pointer.consumed.downChange, `is`(false))
}
@@ -161,106 +161,106 @@
@Test
fun onCancel_justCancel_noCallbacksCalled() {
- recognizer.onCancel()
+ filter.onCancel()
- verifyNoMoreInteractions(recognizer.onPressStart)
+ verifyNoMoreInteractions(filter.onPressStart)
}
@Test
fun onCancel_downCancelDown_onPressStartCalledTwice() {
- recognizer::onPointerInput.invokeOverAllPasses(down(id = 0, duration = 0.milliseconds))
- recognizer.onCancel()
- recognizer::onPointerInput.invokeOverAllPasses(down(id = 0, duration = 1.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(id = 0, duration = 0.milliseconds))
+ filter.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(down(id = 0, duration = 1.milliseconds))
- verify(recognizer.onPressStart, times(2)).invoke(any())
+ verify(filter.onPressStart, times(2)).invoke(any())
}
// Verification of correct execution pass behavior
@Test
fun onPointerInput_initialDown_behaviorOccursAtCorrectTime() {
- recognizer.setExecutionPass(PointerEventPass.InitialDown)
+ filter.setExecutionPass(PointerEventPass.InitialDown)
- val pointer = recognizer::onPointerInput.invokeOverPasses(
+ val pointer = filter::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown
)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
assertThat(pointer.consumed.downChange, `is`(true))
}
@Test
fun onPointerInput_preUp_behaviorOccursAtCorrectTime() {
- recognizer.setExecutionPass(PointerEventPass.PreUp)
+ filter.setExecutionPass(PointerEventPass.PreUp)
- var pointer = recognizer::onPointerInput.invokeOverPasses(
+ var pointer = filter::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown
)
- verify(recognizer.onPressStart, never()).invoke(any())
+ verify(filter.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer::onPointerInput.invokeOverPasses(
+ pointer = filter::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PreUp
)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
assertThat(pointer.consumed.downChange, `is`(true))
}
@Test
fun onPointerInput_preDown_behaviorOccursAtCorrectTime() {
- recognizer.setExecutionPass(PointerEventPass.PreDown)
+ filter.setExecutionPass(PointerEventPass.PreDown)
- var pointer = recognizer::onPointerInput.invokeOverPasses(
+ var pointer = filter::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown,
PointerEventPass.PreUp
)
- verify(recognizer.onPressStart, never()).invoke(any())
+ verify(filter.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer::onPointerInput.invokeOverPasses(
+ pointer = filter::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PreDown
)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
assertThat(pointer.consumed.downChange, `is`(true))
}
@Test
fun onPointerInput_PostUp_behaviorOccursAtCorrectTime() {
- recognizer.setExecutionPass(PointerEventPass.PostUp)
+ filter.setExecutionPass(PointerEventPass.PostUp)
- var pointer = recognizer::onPointerInput.invokeOverPasses(
+ var pointer = filter::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
PointerEventPass.PreDown
)
- verify(recognizer.onPressStart, never()).invoke(any())
+ verify(filter.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer::onPointerInput.invokeOverPasses(
+ pointer = filter::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PostUp
)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
assertThat(pointer.consumed.downChange, `is`(true))
}
@Test
fun onPointerInput_postDown_behaviorOccursAtCorrectTime() {
- recognizer.setExecutionPass(PointerEventPass.PostDown)
+ filter.setExecutionPass(PointerEventPass.PostDown)
- var pointer = recognizer::onPointerInput.invokeOverPasses(
+ var pointer = filter::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -268,15 +268,15 @@
PointerEventPass.PostUp
)
- verify(recognizer.onPressStart, never()).invoke(any())
+ verify(filter.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer::onPointerInput.invokeOverPasses(
+ pointer = filter::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PostDown
)
- verify(recognizer.onPressStart).invoke(any())
+ verify(filter.onPressStart).invoke(any())
assertThat(pointer.consumed.downChange, `is`(true))
}
@@ -287,14 +287,14 @@
// and the 1st down is already consumed, the gesture detector won't consume the 2nd down.
@Test
fun onCancel_downCancelDownConsumedDown_thirdDownNotConsumed() {
- recognizer::onPointerInput
+ filter::onPointerInput
.invokeOverAllPasses(down(id = 0, duration = 0.milliseconds))
- recognizer.onCancel()
+ filter.onCancel()
var pointer1 = down(id = 1, duration = 10.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer1)
pointer1 = pointer1.moveTo(20.milliseconds, 0f, 0f)
val pointer2 = down(id = 2, duration = 20.milliseconds)
- val results = recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ val results = filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(results[0].consumed.downChange, `is`(false))
assertThat(results[1].consumed.downChange, `is`(false))
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawScaleGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt
similarity index 80%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawScaleGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt
index 273a581..5da5cfd 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawScaleGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/RawScaleGestureFilterTest.kt
@@ -42,9 +42,9 @@
// Verify correct behavior with no canStartScaling callback.
@RunWith(JUnit4::class)
-class RawScaleGestureDetectorTest {
+class RawScaleGestureFilterTest {
- private lateinit var recognizer: RawScaleGestureRecognizer
+ private lateinit var filter: RawScaleGestureFilter
private lateinit var scaleObserver: MockScaleObserver
private lateinit var log: MutableList<LogItem>
private var scaleStartBlocked = true
@@ -53,9 +53,9 @@
fun setup() {
log = mutableListOf()
scaleObserver = MockScaleObserver(log)
- recognizer = RawScaleGestureRecognizer()
- recognizer.canStartScaling = { !scaleStartBlocked }
- recognizer.scaleObserver = scaleObserver
+ filter = RawScaleGestureFilter()
+ filter.canStartScaling = { !scaleStartBlocked }
+ filter.scaleObserver = scaleObserver
}
// Verify the circumstances under which onStart/onScale should not be called.
@@ -65,10 +65,10 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = -1f, y = 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveBy(10.milliseconds, 1f, 1f)
pointer2 = pointer1.moveBy(10.milliseconds, -1f, -1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -79,12 +79,12 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = -1f, y = 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, 0f, 0f)
pointer2 = pointer1.moveBy(10.milliseconds, 0f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -94,11 +94,11 @@
fun onPointerInput_1PointerExistsAndMoves_onStartAndOnScaleNotCalled() {
val down1 = down(0)
- recognizer::onPointerInput.invokeOverAllPasses(down1)
+ filter::onPointerInput.invokeOverAllPasses(down1)
scaleStartBlocked = false
val move1 = down1.moveBy(10.milliseconds, 1f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(move1)
+ filter::onPointerInput.invokeOverAllPasses(move1)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -132,14 +132,14 @@
var pointer1 = down(1, x = 1f, y = 1f)
var pointer2 = down(0, x = 3f, y = 3f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
// The pointers move and rotate, but the average distance to the center doesn't change, so
// no scaling occurs.
pointer1 = pointer1.moveTo(10.milliseconds, 3f, 5f)
pointer2 = pointer2.moveTo(10.milliseconds, 5f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -175,7 +175,7 @@
var pointer1 = down(0, x = 1f, y = 2f)
var pointer2 = down(1, x = 2f, y = 1f)
var pointer3 = down(2, x = 4f, y = 4f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
scaleStartBlocked = false
// Act
@@ -185,7 +185,7 @@
pointer1 = pointer1.moveTo(10.milliseconds, 2f, 5f)
pointer2 = pointer2.moveTo(10.milliseconds, 4f, 2f)
pointer3 = pointer3.moveTo(10.milliseconds, 5f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
// Assert
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
@@ -223,7 +223,7 @@
var pointer2 = down(1, x = 4f, y = 1f)
var pointer3 = down(2, x = 4f, y = 5f)
var pointer4 = down(3, x = 6f, y = 3f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
scaleStartBlocked = false
// Act
@@ -234,7 +234,7 @@
pointer2 = pointer2.moveTo(10.milliseconds, 4f, 1f)
pointer3 = pointer3.moveTo(10.milliseconds, 4f, 3f)
pointer4 = pointer4.moveTo(10.milliseconds, 7f, 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
// Assert
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
@@ -268,14 +268,14 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 =
pointer1.moveTo(10.milliseconds, 2f, 2f).consume(-1f, -2f)
pointer2 =
pointer2.moveTo(10.milliseconds, 5f, 1f).consume(1f, -2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -288,12 +288,12 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
@@ -304,12 +304,12 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 0f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = -1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
@@ -320,12 +320,12 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 0f, dy = 0f).consume(dx = -1f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
@@ -336,12 +336,12 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 0f, dy = 0f).consume(dy = -1f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
@@ -352,16 +352,16 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
}
@@ -372,12 +372,12 @@
fun onPointerInput_2PointersIncreaseDistanceOnXBy50Percent_onScaleCalledWith150Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 2f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 3f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -388,12 +388,12 @@
fun onPointerInput_2PointersIncreaseDistanceOnYBy50Percent_onScaleCalledWith150Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 0f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 0f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -404,12 +404,12 @@
fun onPointerInput_2PointersDecreaseDistanceOnXBy50Percent_onScaleCalledWith50Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 2f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -420,12 +420,12 @@
fun onPointerInput_2PointersDecreaseDistanceOnYBy50Percent_onScaleCalledWith50Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 0f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 0f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -436,12 +436,12 @@
fun onPointerInput_2PointersIncDistOnBothAxisBy300Percent_onScaleCalledWith400Percent() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 4f, 4f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -452,12 +452,12 @@
fun onPointerInput_2PointersDecDistOnBothAxisBy75Percent_onScaleCalledWith25Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 4f, y = 4f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 1f, 1f)
pointer2 = pointer2.moveTo(10.milliseconds, 2f, 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -471,15 +471,15 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.up(20.milliseconds)
pointer2 = pointer2.moveBy(0.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@@ -488,14 +488,14 @@
fun onPointerInput_1PointerDownMoveUp_onStopNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer1)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer1)
pointer1 = pointer1.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1)
+ filter::onPointerInput.invokeOverAllPasses(pointer1)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@@ -506,18 +506,18 @@
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = 1f, y = 2f)
var pointer3 = down(2, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = -1f, dy = -1f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = -1f, dy = 1f)
pointer3 = pointer3.moveBy(10.milliseconds, dx = 1f, dy = 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
pointer1 = pointer1.up(20.milliseconds)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
pointer3 = pointer3.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@@ -528,14 +528,14 @@
fun onPointerInput_unblocked2DownMove2Up_onStopCalledOnce() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(1)
}
@@ -544,14 +544,14 @@
fun onPointerInput_unblocked2DownMove1Up_onStopNotCalled() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.moveTo(20.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log.filter { it.methodName == "onStop" }).isEmpty()
}
@@ -562,14 +562,14 @@
fun onPointerInput_unblocked2DownMove2Up_callbacksCalledInCorrectOrder() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log).hasSize(3)
assertThat(log[0].methodName).isEqualTo("onStart")
@@ -581,7 +581,7 @@
@Test
fun onPointerInput_1down_downNotConsumed() {
- val result = recognizer::onPointerInput.invokeOverAllPasses(down(0))
+ val result = filter::onPointerInput.invokeOverAllPasses(down(0))
assertThat(result.consumed.downChange).isFalse()
}
@@ -589,7 +589,7 @@
fun onPointerInput_2Down_downNotConsumed() {
val down1 = down(0, x = 1f, y = 1f)
val down2 = down(1, x = 2f, y = 2f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(down1, down2)
+ val result = filter::onPointerInput.invokeOverAllPasses(down1, down2)
assertThat(result.count { !it.consumed.downChange }).isEqualTo(2)
}
@@ -600,10 +600,10 @@
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { !it.anyPositionChangeConsumed() }).isEqualTo(2)
}
@@ -612,11 +612,11 @@
fun onPointerInput_unblocked2DownMoveCallBackDoesNotConsume_distanceChangeNotConsumed() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { !it.anyPositionChangeConsumed() }).isEqualTo(2)
}
@@ -627,11 +627,11 @@
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { !it.anyPositionChangeConsumed() }).isEqualTo(2)
}
@@ -643,13 +643,13 @@
var change1 = down(0, x = 2f, y = 0f)
var change2 = down(1, x = 4f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 6f, 0f)
scaleObserver.resultingScaleChange = 2f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -659,7 +659,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -677,13 +677,13 @@
var change1 = down(0, x = 0f, y = 2f)
var change2 = down(1, x = 0f, y = 4f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 0f, 6f)
scaleObserver.resultingScaleChange = 2f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -693,7 +693,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -710,11 +710,11 @@
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
.isEqualTo(PxPosition(-1.px, -1.px))
@@ -729,13 +729,13 @@
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 8f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 2f, 0f)
change2 = change2.moveTo(10.milliseconds, 6f, 0f)
scaleObserver.resultingScaleChange = .75f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -745,7 +745,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -763,13 +763,13 @@
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 0f, y = 8f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 2f)
change2 = change2.moveTo(10.milliseconds, 0f, 6f)
scaleObserver.resultingScaleChange = .75f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -779,7 +779,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -796,11 +796,11 @@
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 8f, y = 8f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 2f, 2f)
change2 = change2.moveTo(10.milliseconds, 6f, 6f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result[0].consumed.positionChange).isEqualTo(PxPosition(2.px, 2.px))
assertThat(result[1].consumed.positionChange).isEqualTo(PxPosition(-2.px, -2.px))
@@ -813,13 +813,13 @@
var change1 = down(0, x = 2f, y = 0f)
var change2 = down(1, x = 4f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 2f, 0f)
change2 = change2.moveTo(10.milliseconds, 8f, 0f)
scaleObserver.resultingScaleChange = 2f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -829,7 +829,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(
result, listOf(PointerEventPass.PostDown)
)
@@ -849,13 +849,13 @@
var change1 = down(0, x = 0f, y = 2f)
var change2 = down(1, x = 0f, y = 4f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 2f)
change2 = change2.moveTo(10.milliseconds, 0f, 8f)
scaleObserver.resultingScaleChange = 2f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -865,7 +865,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -883,13 +883,13 @@
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 8f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 4f, 0f)
scaleObserver.resultingScaleChange = .75f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -899,7 +899,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -917,13 +917,13 @@
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 0f, y = 8f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 0f, 4f)
scaleObserver.resultingScaleChange = .75f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -933,7 +933,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -951,13 +951,13 @@
var change1 = down(0, x = -1f, y = 0f)
var change2 = down(1, x = 1f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, -3f)
change2 = change2.moveTo(10.milliseconds, 0f, 3f)
scaleObserver.resultingScaleChange = 2f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -967,7 +967,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -985,13 +985,13 @@
var change1 = down(0, x = -4f, y = 0f)
var change2 = down(1, x = 4f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, -2f)
change2 = change2.moveTo(10.milliseconds, 0f, 2f)
scaleObserver.resultingScaleChange = .75f
- var result = recognizer::onPointerInput.invokeOverPasses(
+ var result = filter::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -1001,7 +1001,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer::onPointerInput
+ result = filter::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -1018,13 +1018,13 @@
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { it.consumed.downChange }).isEqualTo(0)
}
@@ -1035,11 +1035,11 @@
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { it.consumed.downChange }).isEqualTo(0)
}
@@ -1048,14 +1048,14 @@
fun onPointerInput_scale1Up_upChangeConsumed() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.moveTo(20.milliseconds, 3f, 3f)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.first { it.id == PointerId(0) }.consumed.downChange).isTrue()
}
@@ -1064,14 +1064,14 @@
fun onPointerInput_scale2Up_onStopConsumesUp() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ filter::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
+ val result = filter::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { it.consumed.downChange }).isEqualTo(2)
}
@@ -1081,9 +1081,9 @@
@Test
fun onCancel_downCancel_onCancelNotCalled() {
val down = down(0)
- recognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
scaleStartBlocked = false
- recognizer.onCancel()
+ filter.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@@ -1092,12 +1092,12 @@
fun onCancel_blockedDownMoveCancel_onCancelNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = true
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
- recognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@@ -1108,12 +1108,12 @@
fun onCancel_downMoveCancel_onCancelCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
- recognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter.onCancel()
assertThat(log.count { it.methodName == "onCancel" }).isEqualTo(1)
}
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/ScaleSlopExceededGestureFilterTest.kt
similarity index 87%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/ScaleSlopExceededGestureFilterTest.kt
index 2304cec..a70b309 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/ScaleSlopExceededGestureFilterTest.kt
@@ -37,19 +37,19 @@
private const val TestTouchSlop = 5
@RunWith(JUnit4::class)
-class ScaleSlopExceededGestureDetectorTest {
+class ScaleSlopExceededGestureFilterTest {
private val onScaleSlopExceeded: () -> Unit = { onScaleSlopExceededCount++ }
private var onScaleSlopExceededCount: Int = 0
- private lateinit var mRecognizer: ScaleSlopExceededGestureRecognizer
+ private lateinit var filter: ScaleSlopExceededGestureFilter
private val TinyNum = .01f
@Before
fun setup() {
>
- mRecognizer = ScaleSlopExceededGestureRecognizer(TestTouchSlop.px)
- mRecognizer.>
+ filter = ScaleSlopExceededGestureFilter(TestTouchSlop.px)
+ filter.>
}
// Verifies the circumstances under which onScaleSlopExceeded should not be called.
@@ -57,14 +57,14 @@
@Test
fun onPointerInputChanges_1PointerMoves10TimesScaleSlopInXAndY_onTouchSlopExceededNotCalled() {
var pointer = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveBy(
Duration(milliseconds = 10),
TestTouchSlop.toFloat() * 10,
TestTouchSlop.toFloat() * 10
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
assertThat(onScaleSlopExceededCount).isEqualTo(0)
}
@@ -458,7 +458,7 @@
// Arrange
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0.milliseconds, 0f, 50f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -473,7 +473,7 @@
10f,
100f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Translate, rotate and scale down.
pointer1 = pointer1.moveTo(
@@ -486,7 +486,7 @@
-40f,
75f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Translate, rotate and scale up.
pointer1 = pointer1.moveTo(
@@ -499,7 +499,7 @@
40f,
-20f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Translate, rotate and scale down.
pointer1 = pointer1.moveTo(
@@ -512,7 +512,7 @@
20f,
-80f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(onScaleSlopExceededCount).isEqualTo(0)
}
@@ -522,7 +522,7 @@
// Arrange
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0.milliseconds, 0f, 20f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -537,7 +537,7 @@
0f,
30 + TinyNum
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Under
pointer1 = pointer1.moveTo(
@@ -550,7 +550,7 @@
0f,
30 - TinyNum
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Over
pointer1 = pointer1.moveTo(
@@ -563,7 +563,7 @@
0f,
30 + TinyNum
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(onScaleSlopExceededCount).isEqualTo(1)
}
@@ -574,7 +574,7 @@
// Arrange
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -590,7 +590,7 @@
1f,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
}
// Verify that we have not gone over.
@@ -607,7 +607,7 @@
TinyNum,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Verify we have gone over.
assertThat(onScaleSlopExceededCount).isEqualTo(1)
@@ -618,7 +618,7 @@
// Arrange
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0.milliseconds, 0f, 1f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -634,7 +634,7 @@
0f,
1f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
}
// Verify that we have not gone over.
@@ -651,7 +651,7 @@
0f,
TinyNum
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Verify we have gone over.
assertThat(onScaleSlopExceededCount).isEqualTo(1)
@@ -666,7 +666,7 @@
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -678,15 +678,15 @@
11f,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
- mRecognizer.onCancel()
+ filter.onCancel()
pointer1 = down(0, 0.milliseconds, 0f, 0f)
pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -698,7 +698,7 @@
11f,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Assert
@@ -712,7 +712,7 @@
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -724,15 +724,15 @@
11 + TinyNum,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
- mRecognizer.onCancel()
+ filter.onCancel()
pointer1 = down(0, 0.milliseconds, 0f, 0f)
pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -744,7 +744,7 @@
11 + TinyNum,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Assert
@@ -765,7 +765,7 @@
// Arrange
var pointer1 = down(0, 0.milliseconds, x1s, y1s)
var pointer2 = down(1, 0L.milliseconds, x2s, y2s)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
pointer1 = pointer1.moveTo(
@@ -778,7 +778,7 @@
x2e,
y2e
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(onScaleSlopExceededCount).isEqualTo(expectedCound)
}
@@ -802,7 +802,7 @@
var pointer1 = down(0, 0.milliseconds, x1s, y1s)
var pointer2 = down(1, 0.milliseconds, x2s, y2s)
var pointer3 = down(2, 0.milliseconds, x3s, y3s)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
// Act
pointer1 = pointer1.moveTo(
@@ -820,7 +820,7 @@
x3e,
y3e
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
assertThat(onScaleSlopExceededCount).isEqualTo(expectedCound)
}
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TapGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt
similarity index 61%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/TapGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt
index 49a0b4ac..94abe3e 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TapGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TapGestureFilterTest.kt
@@ -38,102 +38,102 @@
import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
-class TapGestureDetectorTest {
+class TapGestureFilterTest {
- private lateinit var recognizer: TapGestureRecognizer
+ private lateinit var filter: TapGestureFilter
@Before
fun setup() {
- recognizer = TapGestureRecognizer()
- recognizer.>
+ filter = TapGestureFilter()
+ filter.>
}
// Verification for when onReleased should not be called.
@Test
fun pointerInputHandler_down_onReleaseNotCalled() {
- recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
- verify(recognizer.onTap, never()).invoke()
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downConsumedUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveConsumedUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f).consume(5f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downUpConsumed_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds).consumeDownChange()
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsNegativeXUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, -1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsPositiveXUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsNegativeYUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, -1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsPositiveYUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
// Verification for when onReleased should be called.
@@ -141,48 +141,48 @@
@Test
fun pointerInputHandler_downUp_onReleaseCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap).invoke()
+ verify(filter.onTap).invoke()
}
@Test
fun pointerInputHandler_downMoveUp_onReleaseCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap).invoke()
+ verify(filter.onTap).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsUpDownUp_onReleaseCalledOnce() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = down(1, duration = 150.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(200.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap).invoke()
+ verify(filter.onTap).invoke()
}
// Verification for when the down change should not be consumed.
@Test
fun pointerInputHandler_consumeDownOnStartIsFalse_downChangeNotConsumed() {
- recognizer.consumeDownOnStart = false
+ filter.consumeDownOnStart = false
val pointerEventChange =
- recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
assertThat(pointerEventChange.consumed.downChange, `is`(false))
}
@@ -191,7 +191,7 @@
@Test
fun pointerInputHandler_consumeDownOnStartIsDefault_downChangeConsumed() {
val pointerEventChange =
- recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ filter::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
assertThat(pointerEventChange.consumed.downChange, `is`(true))
}
@@ -200,12 +200,12 @@
@Test
fun pointerInputHandler_downMoveOutsideBoundsNegativeXUp_upChangeNotConsumed() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, -1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
assertThat(result.consumed.downChange, `is`(false))
}
@@ -213,12 +213,12 @@
@Test
fun pointerInputHandler_downMoveOutsideBoundsPositiveXUp_upChangeNotConsumed() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
assertThat(result.consumed.downChange, `is`(false))
}
@@ -226,12 +226,12 @@
@Test
fun pointerInputHandler_downMoveOutsideBoundsNegativeYUp_upChangeNotConsumed() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, -1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
assertThat(result.consumed.downChange, `is`(false))
}
@@ -239,13 +239,13 @@
@Test
fun pointerInputHandler_downMoveOutsideBoundsPositiveYUp_upChangeNotConsumed() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, 1f)
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ filter::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
assertThat(result.consumed.downChange, `is`(false))
}
@@ -255,9 +255,9 @@
@Test
fun pointerInputHandler_upChangeConsumed() {
var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- val pointerEventChange = recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ val pointerEventChange = filter::onPointerInput.invokeOverAllPasses(pointer)
assertThat(pointerEventChange.consumed.downChange, `is`(true))
}
@@ -266,7 +266,7 @@
@Test
fun pointerInputHandler_downChangeConsumedDuringPostUp() {
var pointerEventChange = down(0, 0.milliseconds)
- pointerEventChange = recognizer::onPointerInput.invokeOverPasses(
+ pointerEventChange = filter::onPointerInput.invokeOverPasses(
pointerEventChange,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -274,7 +274,7 @@
)
assertThat(pointerEventChange.consumed.downChange, `is`(false))
- pointerEventChange = recognizer::onPointerInput.invokeOverPasses(
+ pointerEventChange = filter::onPointerInput.invokeOverPasses(
pointerEventChange,
PointerEventPass.PostUp,
IntPxSize(0.ipx, 0.ipx)
@@ -285,9 +285,9 @@
@Test
fun pointerInputHandler_upChangeConsumedDuringPostUp() {
val pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
var pointerEventChange = pointer.up(100.milliseconds)
- pointerEventChange = recognizer::onPointerInput.invokeOverPasses(
+ pointerEventChange = filter::onPointerInput.invokeOverPasses(
pointerEventChange,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -295,7 +295,7 @@
)
assertThat(pointerEventChange.consumed.downChange, `is`(false))
- pointerEventChange = recognizer::onPointerInput.invokeOverPasses(
+ pointerEventChange = filter::onPointerInput.invokeOverPasses(
pointerEventChange,
PointerEventPass.PostUp,
IntPxSize(0.ipx, 0.ipx)
@@ -308,11 +308,11 @@
@Test
fun cancelationHandler_downCancelUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
- recognizer.onCancel()
+ filter::onPointerInput.invokeOverAllPasses(pointer)
+ filter.onCancel()
pointer = pointer.up(100.milliseconds)
- recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap, never()).invoke()
+ verify(filter.onTap, never()).invoke()
}
}
\ No newline at end of file
diff --git a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetectorTest.kt b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TouchSlopExceededGestureFilterTest.kt
similarity index 77%
rename from ui/ui-framework/src/test/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetectorTest.kt
rename to ui/ui-framework/src/test/java/androidx/ui/core/gesture/TouchSlopExceededGestureFilterTest.kt
index 377fdff..1fb74f0 100644
--- a/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetectorTest.kt
+++ b/ui/ui-framework/src/test/java/androidx/ui/core/gesture/TouchSlopExceededGestureFilterTest.kt
@@ -40,13 +40,13 @@
// Test for cases with more than one pointer
// Test for cases where things are reset when last pointer goes up
// Verify all methods called during onPostUp
-// Verify default behavior when no callback provided for recognizer or canDrag
+// Verify default behavior when no callback provided for filter or canDrag
// Changing this value will break tests that expect the value to be 10.
private const val TestTouchSlop = 10
@RunWith(JUnit4::class)
-class TouchSlopExceededGestureDetectorTest {
+class TouchSlopExceededGestureFilterTest {
private val onTouchSlopExceeded: () -> Unit = { onTouchSlopExceededCallCount++ }
private val canDrag: (Direction) -> Boolean = { direction ->
@@ -56,7 +56,7 @@
private var onTouchSlopExceededCallCount: Int = 0
private var canDragReturn = false
private var canDragDirections: MutableList<Direction> = mutableListOf()
- private lateinit var mRecognizer: TouchSlopExceededGestureRecognizer
+ private lateinit var filter: TouchSlopExceededGestureFilter
private val TinyNum = .01f
@@ -65,26 +65,26 @@
>
canDragReturn = true
canDragDirections.clear()
- mRecognizer =
- TouchSlopExceededGestureRecognizer(TestTouchSlop.px)
- mRecognizer.canDrag = canDrag
- mRecognizer.>
+ filter =
+ TouchSlopExceededGestureFilter(TestTouchSlop.px)
+ filter.canDrag = canDrag
+ filter.>
}
// Verify the circumstances under which canDrag should not be called.
@Test
fun onPointerInputChanges_down_canDragNotCalled() {
- mRecognizer::onPointerInput.invokeOverAllPasses(down(0))
+ filter::onPointerInput.invokeOverAllPasses(down(0))
assertThat(canDragDirections).isEmpty()
}
@Test
fun onPointerInputChanges_downUp_canDragNotCalled() {
val down = down(0, duration = 0.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val up = down.up(10.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(up)
assertThat(canDragDirections).isEmpty()
}
@@ -92,9 +92,9 @@
@Test
fun onPointerInputChanges_downMoveFullyConsumed_canDragNotCalled() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 5f).consume(3f, 5f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(canDragDirections).isEmpty()
}
@@ -104,9 +104,9 @@
@Test
fun onPointerInputChanges_downMove1Dimension_canDragCalledOnce() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
// Twice because while under touch slop, TouchSlopExceededGestureDetector checks during PostUp and PostDown
assertThat(canDragDirections).hasSize(2)
@@ -115,9 +115,9 @@
@Test
fun onPointerInputChanges_downMove2Dimensions_canDragCalledTwice() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 5f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
// 4 times because while under touch slop, TouchSlopExceededGestureDetector checks during PostUp and
// PostDown
@@ -127,9 +127,9 @@
@Test
fun onPointerInputChanges_downMoveOneDimensionPartiallyConsumed_canDragCalledOnce() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 0f, 5f).consume(0f, 4f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
// Twice because while under touch slop, DragGestureDetector checks during PostUp and
// PostDown
@@ -139,9 +139,9 @@
@Test
fun onPointerInputChanges_downMoveTwoDimensionPartiallyConsumed_canDragCalledTwice() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 5f).consume(2f, 4f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
// 4 times because while under touch slop, DragGestureDetector checks during PostUp and
// PostDown
@@ -153,12 +153,12 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
var move = down.moveTo(10.milliseconds, 0f, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
repeat(3) {
move = move.moveBy(Duration(milliseconds = 10), 0f, 1f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
}
// Once because although DragGestureDetector checks during PostUp and PostDown, slop is
@@ -171,11 +171,11 @@
val thirdSlop = TestTouchSlop / 3
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
var move = down
repeat(3) {
move = move.moveBy(Duration(milliseconds = 10), 0f, thirdSlop.toFloat())
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
}
// 6 times because while under touch slop, DragGestureDetector checks during PostUp and
@@ -188,16 +188,16 @@
val beyondSlop = TestTouchSlop + TinyNum
var event = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Back into touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, -beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region again
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Once because although DragGestureDetector checks during PostUp and PostDown, slop is
// surpassed during PostUp, and thus isn't checked again.
@@ -241,9 +241,9 @@
) {
canDragDirections.clear()
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), dx, dy)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
// Everything here is twice because DragGestureDetector checks during PostUp and PostDown.
assertThat(canDragDirections).hasSize(expectedDirections.size * 2)
@@ -261,13 +261,13 @@
@Test
fun onPointerInputChanges_downMoveWithinSlop_onTouchSlopExceededNotCalled() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 10),
TestTouchSlop.toFloat(),
TestTouchSlop.toFloat()
)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
}
@@ -278,13 +278,13 @@
canDragReturn = false
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 10),
beyondSlop,
beyondSlop
)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
}
@@ -293,10 +293,10 @@
fun onPointerInputChanges_moveBeyondSlopButConsumeUnder_onTouchSlopExceededNotCalled() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop + TinyNum, 0f).consume(dx = 1f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
// Assert
@@ -307,10 +307,10 @@
fun onPointerInputChanges_moveUnderToPostUpThenModOverInOppDir_onTouchSlopExceededNotCalled() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop.toFloat(), 0f)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -320,7 +320,7 @@
)
)
val move2 = move.consume(dx = (TestTouchSlop * 2f + TinyNum))
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
move2,
PointerEventPass.PostDown
)
@@ -338,46 +338,46 @@
val slop = TestTouchSlop.toFloat()
var change = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// Go around the border of the touch slop area
// To top left
change = change.moveTo(10.milliseconds, -slop, -slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// To bottom left
change = change.moveTo(20.milliseconds, -slop, slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// To bottom right
change = change.moveTo(30.milliseconds, slop, slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// To top right
change = change.moveTo(40.milliseconds, slop, -slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// Jump from corner to opposite corner and back
// To bottom left
change = change.moveTo(50.milliseconds, -slop, slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// To top right
change = change.moveTo(60.milliseconds, slop, -slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// Move the other diagonal
// To top left
change = change.moveTo(70.milliseconds, -slop, -slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// Jump from corner to opposite corner and back
// To bottom right
change = change.moveTo(80.milliseconds, slop, slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
// To top left
change = change.moveTo(90.milliseconds, -slop, -slop)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
}
@@ -389,13 +389,13 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 100),
beyondSlop,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -404,19 +404,19 @@
fun onPointerInputChanges_movePassedSlopIn2Events_onTouchSlopExceededCallOnce() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 100),
TestTouchSlop.toFloat(),
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
val move2 = down.moveBy(
Duration(milliseconds = 100),
1f,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(move2)
+ filter::onPointerInput.invokeOverAllPasses(move2)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -426,16 +426,16 @@
val beyondSlop = TestTouchSlop + TinyNum
var event = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Back into touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, -beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region again
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(event)
+ filter::onPointerInput.invokeOverAllPasses(event)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -445,9 +445,9 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0).consumeDownChange()
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 100), beyondSlop, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -457,7 +457,7 @@
val beyondSlop = TestTouchSlop + TinyNum
var change = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
canDragReturn = false
change = change.moveBy(
Duration(milliseconds = 10),
@@ -468,13 +468,13 @@
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
canDragReturn = true
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(
Duration(milliseconds = 10),
0f,
-beyondSlop
)
- mRecognizer::onPointerInput.invokeOverAllPasses(change)
+ filter::onPointerInput.invokeOverAllPasses(change)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -488,7 +488,7 @@
var pointer1 = down(1)
var pointer2 = down(2)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -502,7 +502,7 @@
-beyondSlop,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ filter::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Assert
@@ -517,7 +517,7 @@
val beyondSlop = TestTouchSlop + TinyNum
val pointers = arrayOf(down(0), down(1), down(2))
- mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
+ filter::onPointerInput.invokeOverAllPasses(*pointers)
// Act
@@ -540,7 +540,7 @@
0f,
beyondSlop * 2
)
- mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
+ filter::onPointerInput.invokeOverAllPasses(*pointers)
// Assert
@@ -555,7 +555,7 @@
val beyondSlop = TestTouchSlop + TinyNum
val pointers = arrayOf(down(0), down(1), down(2), down(3), down(4))
- mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
+ filter::onPointerInput.invokeOverAllPasses(*pointers)
// Act
@@ -573,7 +573,7 @@
beyondSlop * -1,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
+ filter::onPointerInput.invokeOverAllPasses(*pointers)
// Assert
@@ -588,13 +588,13 @@
val beyondSlop = TestTouchSlop + TinyNum
var pointer = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
// Act
repeat(5) {
pointer = pointer.moveBy(100.milliseconds, beyondSlop, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
}
// Assert
@@ -607,10 +607,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, 0f, 0f).consume(dx = beyondSlop)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -630,10 +630,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -644,7 +644,7 @@
)
val moveConsumed = move.consume(dx = beyondSlop)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
moveConsumed,
PointerEventPass.PostDown
)
@@ -660,10 +660,10 @@
val restOfSlopAndBeyond = TestTouchSlop - halfSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, halfSlop.toFloat(), 0f)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -674,7 +674,7 @@
)
val moveConsumed = move.consume(dx = -restOfSlopAndBeyond)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
moveConsumed,
PointerEventPass.PostDown
)
@@ -689,10 +689,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, 0f)
- mRecognizer::onPointerInput.invokeOverPasses(
+ filter::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -712,7 +712,7 @@
@Test
fun onPointerInputChanges_1Down_nothingConsumed() {
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(down(0))
+ val result = filter::onPointerInput.invokeOverAllPasses(down(0))
// Assert
@@ -725,10 +725,10 @@
fun onPointerInputChanges_1MoveUnderSlop_nothingConsumed() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop.toFloat(), TestTouchSlop.toFloat())
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ val result = filter::onPointerInput.invokeOverAllPasses(move)
// Assert
@@ -741,13 +741,13 @@
fun onPointerInputChanges_1MoveUnderSlopThenUp_nothingConsumed() {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop.toFloat(), TestTouchSlop.toFloat())
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
val up = move.up(20.milliseconds)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ val result = filter::onPointerInput.invokeOverAllPasses(up)
// Assert
@@ -761,10 +761,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, beyondSlop)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ val result = filter::onPointerInput.invokeOverAllPasses(move)
// Assert
@@ -778,13 +778,13 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, beyondSlop)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
val up = move.up(20.milliseconds)
- val result = mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ val result = filter::onPointerInput.invokeOverAllPasses(up)
// Assert
@@ -801,13 +801,13 @@
repeat(2) {
val down = down(0)
- mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ filter::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ filter::onPointerInput.invokeOverAllPasses(move)
val up = move.up(20.milliseconds)
- mRecognizer::onPointerInput.invokeOverAllPasses(up)
+ filter::onPointerInput.invokeOverAllPasses(up)
}
assertThat(onTouchSlopExceededCallCount).isEqualTo(2)
@@ -822,28 +822,28 @@
// Arrange
var pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
underSlop,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
// Act
- mRecognizer.onCancel()
+ filter.onCancel()
pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
underSlop,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
// Assert
@@ -857,28 +857,28 @@
// Arrange
var pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
overSlop,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
// Act
- mRecognizer.onCancel()
+ filter.onCancel()
pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
overSlop,
0f
)
- mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
+ filter::onPointerInput.invokeOverAllPasses(pointer)
// Assert