Changed lambda props to functions.
Bug: 150387923
Test: ./gradlew ui:ui-framework:test
Test: ./gradlew ui:ui-framework:connectedCheck
Test: ./gradlew ui:ui-platform:test
Test: ./gradlew ui:ui-platform:connectedCheck
Change-Id: I175829e687af1d31917f1c98ec42f633259f1d71
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/DoubleTapGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/DoubleTapGestureDetector.kt
index 1fc73ac..984568f 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/DoubleTapGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/DoubleTapGestureDetector.kt
@@ -31,6 +31,7 @@
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.util.fastAny
+import androidx.ui.util.fastAny
import kotlinx.coroutines.Job
import kotlin.coroutines.CoroutineContext
@@ -61,7 +62,7 @@
}
internal class DoubleTapGestureRecognizer(
- coroutineContext: CoroutineContext
+ val coroutineContext: CoroutineContext
) : PointerInputFilter() {
lateinit var onDoubleTap: (PxPosition) -> Unit
@@ -73,45 +74,48 @@
private var state = State.Idle
private var job: Job? = null
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, bounds: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
- var changesToReturn = changes
+ var changesToReturn = changes
- if (pass == PointerEventPass.PostUp) {
- if (state == State.Idle && changesToReturn.all { it.changedToDown() }) {
- state = State.Down
- } else if (state == State.Down && changesToReturn.all { it.changedToUp() }) {
- state = State.Up
- job = delay(doubleTapTimeout, coroutineContext) {
- state = State.Idle
- }
- } else if (state == State.Up && changesToReturn.all { it.changedToDown() }) {
- job?.cancel()
- state = State.SecondDown
- } else if (state == State.SecondDown && changesToReturn.all { it.changedToUp() }) {
- changesToReturn = changesToReturn.map { it.consumeDownChange() }
- state = State.Idle
- onDoubleTap.invoke(changes[0].previous.position!!)
- } else if ((state == State.Down || state == State.SecondDown) &&
- !changesToReturn.anyPointersInBounds(bounds)
- ) {
- // If we are in one of the down states, and none of pointers are in our bounds,
- // then we should cancel and wait till we can be Idle again.
+ if (pass == PointerEventPass.PostUp) {
+ if (state == State.Idle && changesToReturn.all { it.changedToDown() }) {
+ state = State.Down
+ } else if (state == State.Down && changesToReturn.all { it.changedToUp() }) {
+ state = State.Up
+ job = delay(doubleTapTimeout, coroutineContext) {
state = State.Idle
}
- }
-
- if (pass == PointerEventPass.PostDown &&
- changesToReturn.fastAny { it.anyPositionChangeConsumed() }
+ } else if (state == State.Up && changesToReturn.all { it.changedToDown() }) {
+ job?.cancel()
+ state = State.SecondDown
+ } else if (state == State.SecondDown && changesToReturn.all { it.changedToUp() }) {
+ changesToReturn = changesToReturn.map { it.consumeDownChange() }
+ state = State.Idle
+ onDoubleTap.invoke(changes[0].previous.position!!)
+ } else if ((state == State.Down || state == State.SecondDown) &&
+ !changesToReturn.anyPointersInBounds(bounds)
) {
+ // If we are in one of the down states, and none of pointers are in our bounds,
+ // then we should cancel and wait till we can be Idle again.
state = State.Idle
}
-
- changesToReturn
}
- override var cancelHandler = {
+ if (pass == PointerEventPass.PostDown &&
+ changesToReturn.fastAny { it.anyPositionChangeConsumed() }
+ ) {
+ state = State.Idle
+ }
+
+ return changesToReturn
+ }
+
+ override fun onCancel() {
job?.cancel()
state = State.Idle
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressDragGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressDragGestureDetector.kt
index 96e2519..bb0b943 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressDragGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressDragGestureDetector.kt
@@ -125,8 +125,8 @@
glue.longPressDragObserver = longPressDragObserver
return RawDragGestureDetector(glue.dragObserver, glue::dragEnabled) +
- PointerInputModifierImpl(glue) +
- LongPressGestureDetector(glue.onLongPress)
+ PointerInputModifierImpl(glue) +
+ LongPressGestureDetector(glue.onLongPress)
}
/**
@@ -166,22 +166,26 @@
// This handler ensures that onStop will be called after long press happened, but before
// dragging actually has begun.
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, _: IntPxSize ->
- if (pass == PointerEventPass.PostUp &&
- dragEnabled &&
- !dragStarted &&
- changes.all { it.changedToUpIgnoreConsumed() }
- ) {
- dragEnabled = false
- longPressDragObserver.onStop(PxPosition.Origin)
- }
- changes
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+
+ if (pass == PointerEventPass.PostUp &&
+ dragEnabled &&
+ !dragStarted &&
+ changes.all { it.changedToUpIgnoreConsumed() }
+ ) {
+ dragEnabled = false
+ longPressDragObserver.onStop(PxPosition.Origin)
}
+ return changes
+ }
// This handler ensures that onCancel is called if onLongPress was previously called but
// dragging has not yet started.
- override val cancelHandler = {
+ override fun onCancel() {
if (dragEnabled && !dragStarted) {
dragEnabled = false
longPressDragObserver.onCancel()
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressGestureDetector.kt
index e0c33b3..374ac2f 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/LongPressGestureDetector.kt
@@ -74,12 +74,15 @@
private var job: Job? = null
private lateinit var customEventDispatcher: CustomEventDispatcher
- override val initHandler = { customEventDispatcher: CustomEventDispatcher ->
+ override fun onInit(customEventDispatcher: CustomEventDispatcher) {
this.customEventDispatcher = customEventDispatcher
}
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, bounds: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
var changesToReturn = changes
@@ -130,23 +133,22 @@
resetToIdle()
}
- changesToReturn
+ return changesToReturn
}
- override val customEventHandler: (CustomEvent, PointerEventPass) -> Unit =
- { customEvent, pointerInputPass ->
- if (
- state == State.Primed &&
- customEvent is LongPressFiredEvent &&
- pointerInputPass == PointerEventPass.InitialDown
- ) {
- // If we are primed but something else fired long press, we should reset.
- // Doesn't matter what pass we are on, just choosing one so we only reset once.
- resetToIdle()
- }
+ override fun onCustomEvent(customEvent: CustomEvent, pass: PointerEventPass) {
+ if (
+ state == State.Primed &&
+ customEvent is LongPressFiredEvent &&
+ pass == PointerEventPass.InitialDown
+ ) {
+ // If we are primed but something else fired long press, we should reset.
+ // Doesn't matter what pass we are on, just choosing one so we only reset once.
+ resetToIdle()
}
+ }
- override val cancelHandler = {
+ override fun onCancel() {
resetToIdle()
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/PressIndicatorGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/PressIndicatorGestureDetector.kt
index a6d4fd0..707d16b 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/PressIndicatorGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/PressIndicatorGestureDetector.kt
@@ -133,8 +133,11 @@
}
}
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, bounds: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
var internalChanges = changes
@@ -185,10 +188,10 @@
onCancel?.invoke()
}
- internalChanges
+ return internalChanges
}
- override val cancelHandler = {
+ override fun onCancel() {
if (state == State.Started) {
state = State.Idle
onCancel?.invoke()
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawDragGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawDragGestureDetector.kt
index 1cbb595..d014b20 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawDragGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawDragGestureDetector.kt
@@ -140,8 +140,11 @@
var canStartDragging: (() -> Boolean)? = null
lateinit var dragObserver: DragObserver
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, _: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
var changesToReturn = changes
@@ -296,10 +299,10 @@
changesToReturn = movedChanges + otherChanges
}
- changesToReturn
+ return changesToReturn
}
- override val cancelHandler = {
+ override fun onCancel() {
downPositions.clear()
velocityTrackers.clear()
if (started) {
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawPressStartGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawPressStartGestureDetector.kt
index 46749f6..f2c1899 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawPressStartGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawPressStartGestureDetector.kt
@@ -70,8 +70,11 @@
private var active = false
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, _: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
var internalChanges = changes
@@ -92,10 +95,10 @@
}
}
- internalChanges
+ return internalChanges
}
- override val cancelHandler = {
+ override fun onCancel() {
active = false
}
@@ -104,7 +107,7 @@
// Whenever we are disabled, we can just go ahead and become inactive (which is the state we
// should be in if we are to pretend that we aren't in the hierarchy.
if (!enabled) {
- cancelHandler()
+ onCancel()
}
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawScaleGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawScaleGestureDetector.kt
index 0a4c7d9..0c1fb9a 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawScaleGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/RawScaleGestureDetector.kt
@@ -134,8 +134,11 @@
lateinit var scaleObserver: RawScaleObserver
var canStartScaling: (() -> Boolean)? = null
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, _: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
var changesToReturn = changes
@@ -222,10 +225,10 @@
changesToReturn = currentlyDownChanges + otherChanges
}
- changesToReturn
+ return changesToReturn
}
- override val cancelHandler = {
+ override fun onCancel() {
if (active) {
scaleObserver.onCancel()
active = false
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetector.kt
index b4f0b79..596c13b 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/ScaleSlopExceededGestureDetector.kt
@@ -71,8 +71,11 @@
var passedSlop = false
var scaleDiffTotal = 0f
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, _: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
if (pass == PointerEventPass.PostUp) {
@@ -104,10 +107,10 @@
scaleDiffTotal = 0f
}
- changes
+ return changes
}
- override val cancelHandler = {
+ override fun onCancel() {
passedSlop = false
scaleDiffTotal = 0f
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TapGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TapGestureDetector.kt
index a740b46..2f2ee57 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TapGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TapGestureDetector.kt
@@ -74,46 +74,53 @@
*/
private var active = false
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, bounds: IntPxSize ->
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
- var internalChanges = changes
+ var internalChanges = changes
- if (pass == PointerEventPass.PostUp) {
+ if (pass == PointerEventPass.PostUp) {
- if (internalChanges.all { it.changedToDown() }) {
- // If we have not yet started and all of the changes changed to down, we are
- // starting.
- active = true
- } else if (active && internalChanges.all { it.changedToUp() }) {
- // If we have started and all of the changes changed to up, we are stopping.
- active = false
- internalChanges = internalChanges.map { it.consumeDownChange() }
- onTap.invoke()
- } else if (!internalChanges.anyPointersInBounds(bounds)) {
- // If none of the pointers are in bounds of our bounds, we should reset and wait
- // till all pointers are changing to down.
- cancelHandler()
- }
-
- if (active && consumeDownOnStart) {
- // If we have started, we should consume the down change on all changes.
- internalChanges = internalChanges.map { it.consumeDownChange() }
- }
+ if (internalChanges.all { it.changedToDown() }) {
+ // If we have not yet started and all of the changes changed to down, we are
+ // starting.
+ active = true
+ } else if (active && internalChanges.all { it.changedToUp() }) {
+ // If we have started and all of the changes changed to up, we are stopping.
+ active = false
+ internalChanges = internalChanges.map { it.consumeDownChange() }
+ onTap.invoke()
+ } else if (!internalChanges.anyPointersInBounds(bounds)) {
+ // If none of the pointers are in bounds of our bounds, we should reset and wait
+ // till all pointers are changing to down.
+ reset()
}
- if (pass == PointerEventPass.PostDown && active &&
- internalChanges.fastAny { it.anyPositionChangeConsumed() }
- ) {
- // On the final pass, if we have started and any of the changes had consumed
- // position changes, we cancel.
- cancelHandler()
+ if (active && consumeDownOnStart) {
+ // If we have started, we should consume the down change on all changes.
+ internalChanges = internalChanges.map { it.consumeDownChange() }
}
-
- internalChanges
}
- override val cancelHandler = {
+ if (pass == PointerEventPass.PostDown && active &&
+ internalChanges.fastAny { it.anyPositionChangeConsumed() }
+ ) {
+ // On the final pass, if we have started and any of the changes had consumed
+ // position changes, we cancel.
+ reset()
+ }
+
+ return internalChanges
+ }
+
+ override fun onCancel() {
+ reset()
+ }
+
+ private fun reset() {
active = false
}
}
\ No newline at end of file
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetector.kt b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetector.kt
index 6d4e4d2..fb0f5e8 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetector.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/gesture/TouchSlopExceededGestureDetector.kt
@@ -65,118 +65,121 @@
var canDrag: ((Direction) -> Boolean)? = null
var onTouchSlopExceeded: () -> Unit = {}
- override val pointerInputHandler =
- { changes: List<PointerInputChange>, pass: PointerEventPass, _: IntPxSize ->
- if (pass == PointerEventPass.PostUp) {
- changes.forEach {
- if (it.changedToUpIgnoreConsumed()) {
- pointerTrackers.remove(it.id)
- } else if (it.changedToDownIgnoreConsumed()) {
- pointerTrackers[it.id] = PointerTrackingData()
- }
- }
-
- if (!passedSlop) {
- pointerTrackers.forEach {
- it.value.dxForPass = 0f
- it.value.dyForPass = 0f
- }
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+ if (pass == PointerEventPass.PostUp) {
+ changes.forEach {
+ if (it.changedToUpIgnoreConsumed()) {
+ pointerTrackers.remove(it.id)
+ } else if (it.changedToDownIgnoreConsumed()) {
+ pointerTrackers[it.id] = PointerTrackingData()
}
}
- if (!passedSlop &&
- (pass == PointerEventPass.PostUp || pass == PointerEventPass.PostDown)
- ) {
-
- changes.filter { it.current.down && !it.changedToDownIgnoreConsumed() }.forEach {
-
- if (!passedSlop) {
-
- // TODO(shepshapard): handle the case that the pointerTrackingData is null,
- // either with an exception or a logged error, or something else. It should
- // only ever be able to be null at this point if we received a "move"
- // change for a pointer before we received an change that the pointer
- // became "down".
- val pointerTracker: PointerTrackingData = pointerTrackers[it.id]!!
-
- val positionChanged = it.positionChange()
- val dx = positionChanged.x.value
- val dy = positionChanged.y.value
-
- // TODO(shepshapard): I believe the logic in this block could be simplified
- // to be much more clear. Will need to revisit. The need to make
- // improvements may be rendered obsolete with upcoming changes however.
-
- val directionX = when {
- dx == 0f -> null
- dx < 0f -> Direction.LEFT
- else -> Direction.RIGHT
- }
- val directionY = when {
- dy == 0f -> null
- dy < 0f -> Direction.UP
- else -> Direction.DOWN
- }
-
- val internalCanDrag = canDrag
-
- val canDragX =
- directionX != null &&
- (internalCanDrag == null || internalCanDrag.invoke(directionX))
- val canDragY =
- directionY != null &&
- (internalCanDrag == null || internalCanDrag.invoke(directionY))
-
- if (pass == PointerEventPass.PostUp) {
- pointerTracker.dxForPass = dx
- pointerTracker.dyForPass = dy
- pointerTracker.dxUnderSlop += dx
- pointerTracker.dyUnderSlop += dy
- } else {
- pointerTracker.dxUnderSlop += dx - pointerTracker.dxForPass
- pointerTracker.dyUnderSlop += dy - pointerTracker.dyForPass
- }
-
- val passedSlopX =
- canDragX && Math.abs(pointerTracker.dxUnderSlop) > touchSlop.value
- val passedSlopY =
- canDragY && Math.abs(pointerTracker.dyUnderSlop) > touchSlop.value
-
- if (passedSlopX || passedSlopY) {
- passedSlop = true
- onTouchSlopExceeded.invoke()
- } else {
- if (!canDragX &&
- ((directionX == Direction.LEFT &&
- pointerTracker.dxUnderSlop < 0) ||
- (directionX == Direction.RIGHT &&
- pointerTracker.dxUnderSlop > 0))
- ) {
- pointerTracker.dxUnderSlop = 0f
- }
- if (!canDragY &&
- ((directionY == Direction.LEFT &&
- pointerTracker.dyUnderSlop < 0) ||
- (directionY == Direction.DOWN &&
- pointerTracker.dyUnderSlop > 0))
- ) {
- pointerTracker.dyUnderSlop = 0f
- }
- }
- }
+ if (!passedSlop) {
+ pointerTrackers.forEach {
+ it.value.dxForPass = 0f
+ it.value.dyForPass = 0f
}
}
-
- if (passedSlop &&
- pass == PointerEventPass.PostDown &&
- changes.all { it.changedToUpIgnoreConsumed() }
- ) {
- passedSlop = false
- }
- changes
}
- override val cancelHandler = {
+ if (!passedSlop &&
+ (pass == PointerEventPass.PostUp || pass == PointerEventPass.PostDown)
+ ) {
+
+ changes.filter { it.current.down && !it.changedToDownIgnoreConsumed() }.forEach {
+
+ if (!passedSlop) {
+
+ // TODO(shepshapard): handle the case that the pointerTrackingData is null,
+ // either with an exception or a logged error, or something else. It should
+ // only ever be able to be null at this point if we received a "move"
+ // change for a pointer before we received an change that the pointer
+ // became "down".
+ val pointerTracker: PointerTrackingData = pointerTrackers[it.id]!!
+
+ val positionChanged = it.positionChange()
+ val dx = positionChanged.x.value
+ val dy = positionChanged.y.value
+
+ // TODO(shepshapard): I believe the logic in this block could be simplified
+ // to be much more clear. Will need to revisit. The need to make
+ // improvements may be rendered obsolete with upcoming changes however.
+
+ val directionX = when {
+ dx == 0f -> null
+ dx < 0f -> Direction.LEFT
+ else -> Direction.RIGHT
+ }
+ val directionY = when {
+ dy == 0f -> null
+ dy < 0f -> Direction.UP
+ else -> Direction.DOWN
+ }
+
+ val internalCanDrag = canDrag
+
+ val canDragX =
+ directionX != null &&
+ (internalCanDrag == null || internalCanDrag.invoke(directionX))
+ val canDragY =
+ directionY != null &&
+ (internalCanDrag == null || internalCanDrag.invoke(directionY))
+
+ if (pass == PointerEventPass.PostUp) {
+ pointerTracker.dxForPass = dx
+ pointerTracker.dyForPass = dy
+ pointerTracker.dxUnderSlop += dx
+ pointerTracker.dyUnderSlop += dy
+ } else {
+ pointerTracker.dxUnderSlop += dx - pointerTracker.dxForPass
+ pointerTracker.dyUnderSlop += dy - pointerTracker.dyForPass
+ }
+
+ val passedSlopX =
+ canDragX && Math.abs(pointerTracker.dxUnderSlop) > touchSlop.value
+ val passedSlopY =
+ canDragY && Math.abs(pointerTracker.dyUnderSlop) > touchSlop.value
+
+ if (passedSlopX || passedSlopY) {
+ passedSlop = true
+ onTouchSlopExceeded.invoke()
+ } else {
+ if (!canDragX &&
+ ((directionX == Direction.LEFT &&
+ pointerTracker.dxUnderSlop < 0) ||
+ (directionX == Direction.RIGHT &&
+ pointerTracker.dxUnderSlop > 0))
+ ) {
+ pointerTracker.dxUnderSlop = 0f
+ }
+ if (!canDragY &&
+ ((directionY == Direction.LEFT &&
+ pointerTracker.dyUnderSlop < 0) ||
+ (directionY == Direction.DOWN &&
+ pointerTracker.dyUnderSlop > 0))
+ ) {
+ pointerTracker.dyUnderSlop = 0f
+ }
+ }
+ }
+ }
+ }
+
+ if (passedSlop &&
+ pass == PointerEventPass.PostDown &&
+ changes.all { it.changedToUpIgnoreConsumed() }
+ ) {
+ passedSlop = false
+ }
+ return changes
+ }
+
+ override fun onCancel() {
pointerTrackers.clear()
passedSlop = false
}
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/DoubleTapGestureDetectorTest.kt
index bc5094e..6442fee 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/DoubleTapGestureDetectorTest.kt
@@ -63,104 +63,104 @@
// Tests that verify conditions under which onDoubleTap will not be called.
@Test
- fun pointerInputHandler_down_onDoubleTapNotCalled() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onPointerInput_down_onDoubleTapNotCalled() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUp_onDoubleTapNotCalled() {
val down = down(0, 0.milliseconds)
val up = down.up(duration = 1.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownWithinTimeout_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownWithinTimeout_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up = down1.up(duration = 1.milliseconds)
val down2 = down(2, 100.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownOutsideTimeout_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownOutsideTimeout_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up = down1.up(duration = 1.milliseconds)
val down2 = down(2, 101.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownOutsideTimeoutUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownOutsideTimeoutUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downMoveConsumedUpDownInsideTimeoutUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downMoveConsumedUpDownInsideTimeoutUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val moveConsumed = down1.moveTo(1.milliseconds, x = 1f).consume(dx = 1f)
val up1 = moveConsumed.up(duration = 2.milliseconds)
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(moveConsumed)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownInsideTimeoutMoveConsumedUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownInsideTimeoutMoveConsumedUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(2, 100.milliseconds)
val moveConsumed = down2.moveTo(101.milliseconds, x = 1f).consume(dx = 1f)
val up2 = moveConsumed.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(moveConsumed)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_2Down1MoveConsumedUpDownInsideTimeoutUp_onDoubleTapNotCalled() {
+ fun onPointerInput_2Down1MoveConsumedUpDownInsideTimeoutUp_onDoubleTapNotCalled() {
val down1A = down(0, 0.milliseconds)
val down1B = down(1, 0.milliseconds)
val moveConsumed1A = down1A.moveTo(1.milliseconds, x = 1f).consume(dx = 1f)
@@ -170,18 +170,18 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1A, down1B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(moveConsumed1A, move1B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1A, up1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1A, down1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed1A, move1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1A, up1B)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUp2DownInsideTimeout1MoveConsumedUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUp2DownInsideTimeout1MoveConsumedUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up2 = down1.up(duration = 1.milliseconds)
val down2A = down(0, 100.milliseconds)
@@ -191,82 +191,82 @@
val up2A = moveConsumed2A.up(duration = 102.milliseconds)
val up2B = move2B.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2A, down2B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(moveConsumed2A, move2B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2A, up2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(moveConsumed2A, move2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2A, up2B)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downConsumedUpDownWithinTimeoutUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downConsumedUpDownWithinTimeoutUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds).consumeDownChange()
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(0, 100.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpConsumedDownWithinTimeoutUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpConsumedDownWithinTimeoutUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds).consumeDownChange()
val down2 = down(0, 100.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownConsumedWithinTimeoutUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownConsumedWithinTimeoutUp_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(0, 100.milliseconds).consumeDownChange()
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownWithinTimeoutUpConsumed_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownWithinTimeoutUpConsumed_onDoubleTapNotCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(0, 100.milliseconds)
val up2 = down2.up(duration = 102.milliseconds).consumeDownChange()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_2down1Up1DownWithinTimeout1Up_onDoubleTapNotCalled() {
+ fun onPointerInput_2down1Up1DownWithinTimeout1Up_onDoubleTapNotCalled() {
val down1A = down(0, 0.milliseconds)
val down1B = down(1, 0.milliseconds)
val move1A1 = down1A.moveTo(2.milliseconds)
@@ -276,17 +276,17 @@
val move1A3 = move1A2.moveTo(102.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1A, down1B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move1A1, up2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1A, down1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move1A1, up2B)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move1A2, down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move1A3, up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move1A2, down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move1A3, up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_1down1Up2DownWithinTimeout1Up_onDoubleTapNotCalled() {
+ fun onPointerInput_1down1Up2DownWithinTimeout1Up_onDoubleTapNotCalled() {
val down1 = down(0, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2A = down(0, 100.milliseconds)
@@ -294,45 +294,45 @@
val move2A = down2A.moveTo(101.milliseconds)
val up2B = down2B.up(duration = 101.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2A, down2B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2A, up2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move2A, up2B)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downMoveOutOfBoundsUpDownUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downMoveOutOfBoundsUpDownUp_onDoubleTapNotCalled() {
val down = down(0, 0.milliseconds, 0f, 0f)
val move = down.moveTo(1.milliseconds, 1f, 1f)
val up = move.up(duration = 12.milliseconds)
val down2 = down(0, 13.milliseconds, 0f, 0f)
val up2 = down2.up(duration = 14.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ 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))
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownMoveOutOfBoundsUp_onDoubleTapNotCalled() {
+ fun onPointerInput_downUpDownMoveOutOfBoundsUp_onDoubleTapNotCalled() {
val down = down(0, 0.milliseconds, 0f, 0f)
val up = down.up(duration = 1.milliseconds)
val down2 = down(0, 2.milliseconds, 0f, 0f)
val move2 = down2.moveTo(3.milliseconds, 1f, 1f)
val up2 = down2.up(duration = 4.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ 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))
verify(onDoubleTap, never()).invoke(any())
}
@@ -340,59 +340,59 @@
// Tests that verify conditions under which onDoubleTap will be called.
@Test
- fun pointerInputHandler_downUpDownInsideTimeoutUp_onDoubleTapCalled() {
+ fun onPointerInput_downUpDownInsideTimeoutUp_onDoubleTapCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(2, 100.milliseconds)
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun pointerInputHandler_downMoveUpDownInsideTimeoutUp_onDoubleTapCalled() {
+ fun onPointerInput_downMoveUpDownInsideTimeoutUp_onDoubleTapCalled() {
val down1 = down(1, 0.milliseconds)
val move = down1.moveTo(1.milliseconds, x = 1f)
val up1 = move.up(duration = 2.milliseconds)
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownInsideTimeoutMoveUp_onDoubleTapCalled() {
+ fun onPointerInput_downUpDownInsideTimeoutMoveUp_onDoubleTapCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(2, 10.milliseconds)
val move = down2.moveTo(101.milliseconds, x = 1f)
val up2 = move.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun pointerInputHandler_2Down1MoveUpDownInsideTimeoutUp_onDoubleTapCalled() {
+ fun onPointerInput_2Down1MoveUpDownInsideTimeoutUp_onDoubleTapCalled() {
val down1A = down(0, 0.milliseconds)
val down1B = down(1, 0.milliseconds)
val move1A = down1A.moveTo(1.milliseconds, x = 1f)
@@ -402,18 +402,18 @@
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1A, down1B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move1A, move1B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1A, up1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1A, down1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move1A, move1B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1A, up1B)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun pointerInputHandler_downUp2DownInsideTimeout1MoveUp_onDoubleTapCalled() {
+ fun onPointerInput_downUp2DownInsideTimeout1MoveUp_onDoubleTapCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2A = down(0, 100.milliseconds)
@@ -423,18 +423,18 @@
val up2A = move2A.up(duration = 102.milliseconds)
val up2B = move2B.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2A, down2B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2A, move2B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2A, up2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move2A, move2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2A, up2B)
verify(onDoubleTap).invoke(any())
}
@Test
- fun pointerInputHandler_downMoveOutOfBoundsUpDownUpDownUp_onDoubleTapCalledOnce() {
+ fun onPointerInput_downMoveOutOfBoundsUpDownUpDownUp_onDoubleTapCalledOnce() {
val down = down(0, 0.milliseconds, 0f, 0f)
val move = down.moveTo(1.milliseconds, 1f, 1f)
val up = move.up(duration = 2.milliseconds)
@@ -443,20 +443,20 @@
val down3 = down(0, 5.milliseconds, 0f, 0f)
val up3 = down3.up(6.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
+ 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.pointerInputHandler.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down3, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up3, 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))
verify(onDoubleTap).invoke(any())
}
@Test
- fun pointerInputHandler_downUpDownMoveOutOfBoundsUpDownUpDownUp_onDoubleTapCalledOnce() {
+ fun onPointerInput_downUpDownMoveOutOfBoundsUpDownUpDownUp_onDoubleTapCalledOnce() {
val down = down(0, 0.milliseconds, 0f, 0f)
val up = down.up(duration = 2.milliseconds)
val down2 = down(0, 3.milliseconds, 0f, 0f)
@@ -467,16 +467,16 @@
val down4 = down(0, 7.milliseconds, 0f, 0f)
val up4 = down4.up(8.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2, IntPxSize(1.ipx, 1.ipx))
+ 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))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down3, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up3, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down4, IntPxSize(1.ipx, 1.ipx))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up4, 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))
verify(onDoubleTap).invoke(any())
}
@@ -484,7 +484,7 @@
// This test verifies that the 2nd down causes the double tap time out timer to stop such that
// the second wait doesn't cause the gesture detector to reset to an idle state.
@Test
- fun pointerInputHandler_downUpWaitHalfDownWaitHalfUp_onDoubleTapCalled() {
+ fun onPointerInput_downUpWaitHalfDownWaitHalfUp_onDoubleTapCalled() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val wait1 = 50L
@@ -492,12 +492,12 @@
val wait2 = 50L
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(wait1, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
testContext.advanceTimeBy(wait2, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@@ -505,41 +505,41 @@
// Tests that verify correctness of PxPosition value passed to onDoubleTap
@Test
- fun pointerInputHandler_downUpDownUpAllAtOrigin_onDoubleTapCalledWithOrigin() {
+ fun onPointerInput_downUpDownUpAllAtOrigin_onDoubleTapCalledWithOrigin() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(2, 100.milliseconds)
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(PxPosition.Origin)
}
@Test
- fun pointerInputHandler_downUpDownMoveUp_onDoubleTapCalledWithFinalMovePosition() {
+ fun onPointerInput_downUpDownMoveUp_onDoubleTapCalledWithFinalMovePosition() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2 = down(2, 100.milliseconds)
val move2 = down2.moveTo(101.milliseconds, 3f, 5f)
val up2 = move2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(PxPosition(3.px, 5.px))
}
@Test
- fun pointerInputHandler_downUp2Down2Move1UpThen1Up_onDoubleTapCalledWithFinalFingerPosition() {
+ fun onPointerInput_downUp2Down2Move1UpThen1Up_onDoubleTapCalledWithFinalFingerPosition() {
val down1 = down(1, 0.milliseconds)
val up1 = down1.up(duration = 1.milliseconds)
val down2A = down(0, 100.milliseconds)
@@ -550,13 +550,13 @@
val move2B2 = move2B1.moveTo(102.milliseconds, x = 7f, y = 11f)
val up2B = move2B2.up(duration = 103.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2A, down2B)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2A, move2B1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2A, move2B2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2A, down2B)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move2A, move2B1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2A, move2B2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2B)
verify(onDoubleTap).invoke(PxPosition((7).px, (11).px))
}
@@ -564,63 +564,63 @@
// Tests that verify correct consumption behavior
@Test
- fun pointerInputHandler_down_downNotConsumed() {
+ fun onPointerInput_down_downNotConsumed() {
val down = down(0, 0.milliseconds)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(down)
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_downUp_upNotConsumed() {
+ fun onPointerInput_downUp_upNotConsumed() {
val down = down(0, 0.milliseconds)
val up = down.up(1.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(up)
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_downUpDownInsideTimeout_lastDownNotConsumed() {
+ fun onPointerInput_downUpDownInsideTimeout_lastDownNotConsumed() {
val down = down(0, 0.milliseconds)
val up = down.up(1.milliseconds)
val down2 = down(2, 100.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(down2)
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_downUpDownOutsideTimeoutUp_lastUpNotConsumed() {
+ fun onPointerInput_downUpDownOutsideTimeoutUp_lastUpNotConsumed() {
val down = down(0, 0.milliseconds)
val up = down.up(1.milliseconds)
val down2 = down(2, 101.milliseconds)
val up2 = down2.up(duration = 102.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(up2)
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_downUpDownInsideTimeoutUp_lastUpConsumed() {
+ fun onPointerInput_downUpDownInsideTimeoutUp_lastUpConsumed() {
val down = down(0, 0.milliseconds)
val up = down.up(1.milliseconds)
val down2 = down(2, 100.milliseconds)
val up2 = down2.up(duration = 101.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(up2)
assertThat(result.consumed.downChange).isTrue()
}
@@ -628,77 +628,77 @@
// Tests that verify correct cancellation behavior
@Test
- fun cancelHandler_downUpCancelWaitDownUp_onDoubleTapNotCalled() {
+ fun onCancel_downUpCancelWaitDownUp_onDoubleTapNotCalled() {
val down1 = down(0, duration = 100.milliseconds)
val up1 = down1.up(duration = 101.milliseconds)
val down2 = down(1, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
- mRecognizer.cancelHandler()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ mRecognizer.onCancel()
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun cancelHandler_downUpWaitCancelDownUp_onDoubleTapNotCalled() {
+ fun onCancel_downUpWaitCancelDownUp_onDoubleTapNotCalled() {
val down1 = down(1, 100.milliseconds)
val up1 = down1.up(duration = 101.milliseconds)
val down2 = down(2, 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap, never()).invoke(any())
}
@Test
- fun cancelHandler_cancelDownUpDownUp_onDoubleTapCalledOnce() {
+ fun onCancel_cancelDownUpDownUp_onDoubleTapCalledOnce() {
val down1 = down(0, duration = 100.milliseconds)
val up1 = down1.up(duration = 101.milliseconds)
val down2 = down(1, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun cancelHandler_downCancelDownUpDownUp_onDoubleTapCalledOnce() {
+ fun onCancel_downCancelDownUpDownUp_onDoubleTapCalledOnce() {
val down0 = down(0, duration = 99.milliseconds)
val down1 = down(1, duration = 100.milliseconds)
val up1 = down1.up(duration = 101.milliseconds)
val down2 = down(2, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun cancelHandler_downUpCancelDownUpDownUp_onDoubleTapCalledOnce() {
+ fun onCancel_downUpCancelDownUpDownUp_onDoubleTapCalledOnce() {
val down0 = down(0, duration = 98.milliseconds)
val up0 = down0.up(duration = 99.milliseconds)
val down1 = down(1, duration = 100.milliseconds)
@@ -706,20 +706,20 @@
val down2 = down(2, duration = 200.milliseconds)
val up2 = down2.up(duration = 201.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
verify(onDoubleTap).invoke(any())
}
@Test
- fun cancelHandler_downUpDownCancelDownUpDownUp_onDoubleTapCalledOnce() {
+ fun onCancel_downUpDownCancelDownUpDownUp_onDoubleTapCalledOnce() {
val down0 = down(0, duration = 97.milliseconds)
val up0 = down0.up(duration = 98.milliseconds)
val down1 = down(1, 99.milliseconds)
@@ -728,21 +728,21 @@
val down3 = down(3, 200.milliseconds)
val up3 = down3.up(duration = 201.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down3)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up3)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down3)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up3)
verify(onDoubleTap).invoke(any())
}
@Test
- fun cancelHandler_downUpDownUpCancelDownUpDownUp_onDoubleTapCalledTwice() {
+ fun onCancel_downUpDownUpCancelDownUpDownUp_onDoubleTapCalledTwice() {
val down0 = down(0, 0.milliseconds)
val up0 = down0.up(duration = 1.milliseconds)
val down1 = down(1, 100.milliseconds)
@@ -753,17 +753,17 @@
val down3 = down(3, 300.milliseconds)
val up3 = down3.up(duration = 301.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up2)
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down3)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up3)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down3)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up3)
verify(onDoubleTap, times(2)).invoke(any())
}
@@ -773,7 +773,7 @@
// be forced back into the IDLE state, preventing the double tap that follows cancel from
// firing.
@Test
- fun cancelHandler_downUpWaitCancelDownWaitUpDownUp_onDoubleTapCalledOnce() {
+ fun onCancel_downUpWaitCancelDownWaitUpDownUp_onDoubleTapCalledOnce() {
val down0 = down(0, 0.milliseconds)
val up0 = down0.up(duration = 1.milliseconds)
val delay0 = 50L
@@ -784,15 +784,15 @@
val down2 = down(2, 102.milliseconds)
val up2 = down2.up(duration = 103.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0)
testContext.advanceTimeBy(delay0, TimeUnit.MILLISECONDS)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
testContext.advanceTimeBy(delay1, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up1)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down2)
+ mRecognizer::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/LongPressGestureDetectorTest.kt
index 5e8277b..8cc98de 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/LongPressGestureDetectorTest.kt
@@ -57,22 +57,22 @@
mRecognizer = LongPressGestureRecognizer(testContext)
mRecognizer.onLongPress = onLongPress
mRecognizer.longPressTimeout = LongPressTimeoutMillis
- mRecognizer.initHandler.invoke(customEventDispatcher)
+ mRecognizer.onInit(customEventDispatcher)
}
// Tests that verify conditions under which onLongPress will not be called.
@Test
- fun pointerInputHandler_down_eventNotFired() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onPointerInput_down_eventNotFired() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
verify(onLongPress, never()).invoke(any())
verify(customEventDispatcher, never()).dispatchCustomEvent(any())
}
@Test
- fun pointerInputHandler_downWithinTimeout_eventNotFired() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onPointerInput_downWithinTimeout_eventNotFired() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -80,13 +80,13 @@
}
@Test
- fun pointerInputHandler_DownMoveConsumed_eventNotFired() {
+ fun onPointerInput_DownMoveConsumed_eventNotFired() {
val down = down(0)
val move = down.moveBy(50.milliseconds, 1f, 1f).consume(1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -94,15 +94,15 @@
}
@Test
- fun pointerInputHandler_2Down1MoveConsumed_eventNotFired() {
+ fun onPointerInput_2Down1MoveConsumed_eventNotFired() {
val down0 = down(0)
val down1 = down(1)
val move0 = down0.moveBy(50.milliseconds, 1f, 1f).consume(1f, 0f)
val move1 = down0.moveBy(50.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0, down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move0, move1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move0, move1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -110,13 +110,13 @@
}
@Test
- fun pointerInputHandler_DownUpConsumed_eventNotFired() {
+ fun onPointerInput_DownUpConsumed_eventNotFired() {
val down = down(0)
val up = down.up(50.milliseconds).consumeDownChange()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -124,13 +124,13 @@
}
@Test
- fun pointerInputHandler_DownUpNotConsumed_eventNotFired() {
+ fun onPointerInput_DownUpNotConsumed_eventNotFired() {
val down = down(0)
val up = down.up(50.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -138,7 +138,7 @@
}
@Test
- fun pointerInputHandler_2DownIndependentlyUnderTimeoutAndDoNotOverlap_eventNotFired() {
+ fun onPointerInput_2DownIndependentlyUnderTimeoutAndDoNotOverlap_eventNotFired() {
// Arrange
@@ -150,13 +150,13 @@
// Act
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0)
testContext.advanceTimeBy(1, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
@@ -167,11 +167,11 @@
}
@Test
- fun pointerInputHandler_downMoveOutOfBoundsWait_eventNotFired() {
+ fun onPointerInput_downMoveOutOfBoundsWait_eventNotFired() {
var pointer = down(0, 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -181,8 +181,8 @@
// Tests that verify conditions under which onLongPress will be called.
@Test
- fun pointerInputHandler_downBeyondTimeout_eventFiredOnce() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onPointerInput_downBeyondTimeout_eventFiredOnce() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -190,8 +190,8 @@
}
@Test
- fun pointerInputHandler_2DownBeyondTimeout_eventFiredOnce() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0), down(1))
+ fun onPointerInput_2DownBeyondTimeout_eventFiredOnce() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0), down(1))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -199,17 +199,17 @@
}
@Test
- fun pointerInputHandler_downMoveOutOfBoundsWaitUpThenDownWait_eventFiredOnce() {
+ fun onPointerInput_downMoveOutOfBoundsWaitUpThenDownWait_eventFiredOnce() {
var pointer = down(0, 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
pointer = pointer.up(105.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = down(1, 200.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -217,7 +217,7 @@
}
@Test
- fun pointerInputHandler_2DownIndependentlyUnderTimeoutButOverlapTimeIsOver_eventFiredOnce() {
+ fun onPointerInput_2DownIndependentlyUnderTimeoutButOverlapTimeIsOver_eventFiredOnce() {
// Arrange
@@ -231,17 +231,17 @@
// Act
- mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ mRecognizer::onPointerInput.invokeOverAllPasses(
down0
)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ mRecognizer::onPointerInput.invokeOverAllPasses(
move0, down1
)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ mRecognizer::onPointerInput.invokeOverAllPasses(
up0, move1
)
@@ -254,13 +254,13 @@
}
@Test
- fun pointerInputHandler_downMoveNotConsumed_eventFiredOnce() {
+ fun onPointerInput_downMoveNotConsumed_eventFiredOnce() {
val down = down(0)
val move = down.moveBy(50.milliseconds, 1f, 1f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -270,45 +270,45 @@
// Tests that verify correctness of PxPosition value passed to onLongPress
@Test
- fun pointerInputHandler_down_onLongPressCalledWithDownPosition() {
+ fun onPointerInput_down_onLongPressCalledWithDownPosition() {
val down = down(0, x = 13f, y = 17f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(13.px, 17.px))
}
@Test
- fun pointerInputHandler_downMove_onLongPressCalledWithMovePosition() {
+ fun onPointerInput_downMove_onLongPressCalledWithMovePosition() {
val down = down(0, x = 13f, y = 17f)
val move = down.moveTo(50.milliseconds, 7f, 5f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition((7).px, 5.px))
}
@Test
- fun pointerInputHandler_downThenDown_onLongPressCalledWithFirstDownPosition() {
+ fun onPointerInput_downThenDown_onLongPressCalledWithFirstDownPosition() {
val down0 = down(0, x = 13f, y = 17f)
val move0 = down0.moveBy(50.milliseconds, 0f, 0f)
val down1 = down(1, 50.milliseconds, 11f, 19f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move0, down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(13.px, 17.px))
}
@Test
- fun pointerInputHandler_down0ThenDown1ThenUp0_onLongPressCalledWithDown1Position() {
+ fun onPointerInput_down0ThenDown1ThenUp0_onLongPressCalledWithDown1Position() {
val down0 = down(0, x = 13f, y = 17f)
val move0 = down0.moveTo(50.milliseconds, 27f, 29f)
@@ -317,33 +317,33 @@
val up0 = move0.up(75.milliseconds)
val move1 = down1.moveBy(25.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move0, down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0, move1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0, move1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(11.px, 19.px))
}
@Test
- fun pointerInputHandler_down0ThenMove0AndDown1_onLongPressCalledWithMove0Position() {
+ fun onPointerInput_down0ThenMove0AndDown1_onLongPressCalledWithMove0Position() {
val down0 = down(0, x = 13f, y = 17f)
val move0 = down0.moveTo(50.milliseconds, 27f, 29f)
val down1 = down(1, 50.milliseconds, 11f, 19f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move0, down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(27.px, 29.px))
}
@Test
- fun pointerInputHandler_down0Down1Move1Up0_onLongPressCalledWithMove1Position() {
+ fun onPointerInput_down0Down1Move1Up0_onLongPressCalledWithMove1Position() {
val down0 = down(0, x = 13f, y = 17f)
val move0 = down0.moveBy(25.milliseconds, 0f, 0f)
@@ -352,11 +352,11 @@
val up0 = move0.up(50.milliseconds)
val move1 = down1.moveTo(50.milliseconds, 27f, 23f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down0)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down0)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move0, down1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move0, down1)
testContext.advanceTimeBy(25, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up0, move1)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up0, move1)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(PxPosition(27.px, 23.px))
@@ -365,21 +365,21 @@
// Tests that verify that consumption behavior
@Test
- fun pointerInputHandler_1Down_notConsumed() {
+ fun onPointerInput_1Down_notConsumed() {
val down0 = down(0)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(
down0
)
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_1DownThen1Down_notConsumed() {
+ fun onPointerInput_1DownThen1Down_notConsumed() {
// Arrange
val down0 = down(0, 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(
move0, down1
)
@@ -399,12 +399,12 @@
}
@Test
- fun pointerInputHandler_1DownUnderTimeUp_upNotConsumed() {
+ fun onPointerInput_1DownUnderTimeUp_upNotConsumed() {
// Arrange
val down0 = down(0, 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ mRecognizer::onPointerInput.invokeOverAllPasses(
down0
)
@@ -412,7 +412,7 @@
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
val up0 = down0.up(50.milliseconds)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(
up0
)
@@ -422,12 +422,12 @@
}
@Test
- fun pointerInputHandler_1DownOverTimeUp_upConsumedOnInitialDown() {
+ fun onPointerInput_1DownOverTimeUp_upConsumedOnInitialDown() {
// Arrange
val down0 = down(0, 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(
+ mRecognizer::onPointerInput.invokeOverAllPasses(
down0
)
@@ -435,7 +435,7 @@
testContext.advanceTimeBy(101, TimeUnit.MILLISECONDS)
val up0 = down0.up(100.milliseconds)
- val result = mRecognizer.pointerInputHandler.invoke(
+ val result = mRecognizer.onPointerInput(
listOf(up0),
PointerEventPass.InitialDown,
IntPxSize(0.ipx, 0.ipx)
@@ -447,21 +447,21 @@
}
@Test
- fun pointerInputHandler_1DownOverTimeMoveConsumedUp_upNotConsumed() {
+ fun onPointerInput_1DownOverTimeMoveConsumedUp_upNotConsumed() {
// Arrange
var pointer = down(0, 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
testContext.advanceTimeBy(50, TimeUnit.MILLISECONDS)
pointer = pointer.moveTo(50.milliseconds, 5f).consume(1f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Act
testContext.advanceTimeBy(51, TimeUnit.MILLISECONDS)
pointer = pointer.up(100.milliseconds)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Assert
@@ -471,9 +471,9 @@
// Tests that verify correct behavior around cancellation.
@Test
- fun cancelHandler_downCancelBeyondTimeout_eventNotFired() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
- mRecognizer.cancelHandler()
+ fun onCancel_downCancelBeyondTimeout_eventNotFired() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ mRecognizer.onCancel()
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -481,10 +481,10 @@
}
@Test
- fun cancelHandler_downAlmostTimeoutCancelTimeout_eventNotFired() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onCancel_downAlmostTimeoutCancelTimeout_eventNotFired() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.cancelHandler()
+ mRecognizer.onCancel()
testContext.advanceTimeBy(1, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -492,11 +492,11 @@
}
@Test
- fun cancelHandler_downCancelDownTimeExpires_eventFiredOnce() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onCancel_downCancelDownTimeExpires_eventFiredOnce() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(99, TimeUnit.MILLISECONDS)
- mRecognizer.cancelHandler()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ mRecognizer.onCancel()
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress).invoke(any())
@@ -506,9 +506,9 @@
// Verify correct behavior around responding to LongPressFiredEvent
@Test
- fun customEventHandler_downCustomEventTimeout_eventNotFired() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
- mRecognizer.customEventHandler.invokeOverAllPasses(LongPressFiredEvent)
+ fun onCustomEvent_downCustomEventTimeout_eventNotFired() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ mRecognizer::onCustomEvent.invokeOverAllPasses(LongPressFiredEvent)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
verify(onLongPress, never()).invoke(any())
@@ -516,11 +516,11 @@
}
@Test
- fun customEventHandler_downCustomEventTimeoutDownTimeout_eventFiredOnce() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
- mRecognizer.customEventHandler.invokeOverAllPasses(LongPressFiredEvent)
+ fun onCustomEvent_downCustomEventTimeoutDownTimeout_eventFiredOnce() {
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ mRecognizer::onCustomEvent.invokeOverAllPasses(LongPressFiredEvent)
testContext.advanceTimeBy(100, TimeUnit.MILLISECONDS)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ mRecognizer::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
index 4d0eaee..458840d 100644
--- 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
@@ -60,16 +60,16 @@
// Verification of scenarios where onStart should not be called.
@Test
- fun pointerInputHandler_downConsumed_onStartNotCalled() {
- recognizer.pointerInputHandler
+ fun onPointerInput_downConsumed_onStartNotCalled() {
+ recognizer::onPointerInput
.invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
verify(recognizer.onStart!!, never()).invoke(any())
}
@Test
- fun pointerInputHandler_disabledDown_onStartNotCalled() {
+ fun onPointerInput_disabledDown_onStartNotCalled() {
recognizer.setEnabled(false)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
verify(recognizer.onStart!!, never()).invoke(any())
}
@@ -77,47 +77,47 @@
// Verification of scenarios where onStart should be called once.
@Test
- fun pointerInputHandler_down_onStartCalledOnce() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ fun onPointerInput_down_onStartCalledOnce() {
+ recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
verify(recognizer.onStart!!).invoke(any())
}
@Test
- fun pointerInputHandler_downDown_onStartCalledOnce() {
+ fun onPointerInput_downDown_onStartCalledOnce() {
var pointer0 = down(0)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0)
pointer0 = pointer0.moveTo(1.milliseconds)
val pointer1 = down(1, 1.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onStart!!).invoke(any())
}
@Test
- fun pointerInputHandler_2Down1Up1Down_onStartCalledOnce() {
+ fun onPointerInput_2Down1Up1Down_onStartCalledOnce() {
var pointer0 = down(0)
var pointer1 = down(1)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.up(100.milliseconds)
pointer1 = pointer1.moveTo(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = down(0, duration = 200.milliseconds)
pointer1 = pointer1.moveTo(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onStart!!).invoke(any())
}
@Test
- fun pointerInputHandler_1DownMoveOutside2ndDown_onStartOnlyCalledOnce() {
+ fun onPointerInput_1DownMoveOutside2ndDown_onStartOnlyCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 10f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
pointer0 = pointer0.moveTo(200.milliseconds)
val pointer1 = down(1, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onStart!!).invoke(any())
}
@@ -125,58 +125,58 @@
// Verification of scenarios where onStop should not be called.
@Test
- fun pointerInputHandler_downMoveConsumedUp_onStopNotCalled() {
+ fun onPointerInput_downMoveConsumedUp_onStopNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!, never()).invoke()
}
@Test
- fun pointerInputHandler_downConsumedUp_onStopNotCalled() {
+ fun onPointerInput_downConsumedUp_onStopNotCalled() {
var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!, never()).invoke()
}
@Test
- fun pointerInputHandler_2DownUp_onStopNotCalled() {
+ fun onPointerInput_2DownUp_onStopNotCalled() {
var pointer0 = down(0)
var pointer1 = down(1)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.moveTo(100.milliseconds)
pointer1 = pointer1.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onStop!!, never()).invoke()
}
@Test
- fun pointerInputHandler_downDisabledUp_onStopNotCalled() {
+ fun onPointerInput_downDisabledUp_onStopNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
recognizer.setEnabled(false)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!, never()).invoke()
}
@Test
- fun pointerInputHandler_downDisabledEnabledUp_onStopNotCalled() {
+ fun onPointerInput_downDisabledEnabledUp_onStopNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
recognizer.setEnabled(false)
recognizer.setEnabled(true)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!, never()).invoke()
}
@@ -184,45 +184,45 @@
// Verification of scenarios where onStop should be called once.
@Test
- fun pointerInputHandler_downUp_onStopCalledOnce() {
+ fun onPointerInput_downUp_onStopCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!).invoke()
}
@Test
- fun pointerInputHandler_downUpConsumed_onStopCalledOnce() {
+ fun onPointerInput_downUpConsumed_onStopCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!).invoke()
}
@Test
- fun pointerInputHandler_downMoveUp_onStopCalledOnce() {
+ fun onPointerInput_downMoveUp_onStopCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onStop!!).invoke()
}
@Test
- fun pointerInputHandler_2Down2Up_onStopCalledOnce() {
+ fun onPointerInput_2Down2Up_onStopCalledOnce() {
var pointer1 = down(0)
var pointer2 = down(1)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.up(100.milliseconds)
pointer2 = pointer2.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
verify(recognizer.onStop!!).invoke()
}
@@ -230,55 +230,55 @@
// Verification of scenarios where onCancel should not be called.
@Test
- fun pointerInputHandler_downConsumedMoveConsumed_onCancelNotCalled() {
+ fun onPointerInput_downConsumedMoveConsumed_onCancelNotCalled() {
var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onCancel!!, never()).invoke()
}
@Test
- fun pointerInputHandler_downUp_onCancelNotCalled() {
+ fun onPointerInput_downUp_onCancelNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onCancel!!, never()).invoke()
}
@Test
- fun pointerInputHandler_downMoveUp_onCancelNotCalled() {
+ fun onPointerInput_downMoveUp_onCancelNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onCancel!!, never()).invoke()
}
@Test
- fun pointerInputHandler_2DownOneMoveOutsideOfBounds_onCancelNotCalled() {
+ fun onPointerInput_2DownOneMoveOutsideOfBounds_onCancelNotCalled() {
var pointer0 = down(0, x = 0f, y = 0f)
var pointer1 = down(0, x = 4f, y = 4f)
- recognizer.pointerInputHandler
+ 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.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
verify(recognizer.onCancel!!, never()).invoke()
}
@Test
- fun pointerInputHandler_notEnabledDownNotEnabled_onCancelNotCalled() {
+ fun onPointerInput_notEnabledDownNotEnabled_onCancelNotCalled() {
recognizer.setEnabled(false)
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
recognizer.setEnabled(false)
verify(recognizer.onCancel!!, never()).invoke()
@@ -287,147 +287,147 @@
// Verification of scenarios where onCancel should be called once.
@Test
- fun pointerInputHandler_downMoveConsumed_onCancelCalledOnce() {
+ fun onPointerInput_downMoveConsumed_onCancelCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_downMoveConsumedMoveConsumed_onCancelCalledOnce() {
+ fun onPointerInput_downMoveConsumedMoveConsumed_onCancelCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_2Down2MoveConsumed_onCancelCalledOnce() {
+ fun onPointerInput_2Down2MoveConsumed_onCancelCalledOnce() {
var pointer0 = down(0)
var pointer1 = down(1)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.moveBy(100.milliseconds, 5f).consume(1f)
pointer1 = pointer1.moveBy(100.milliseconds, 5f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_2Down1MoveConsumedTheOtherMoveConsume_onCancelCalledOnce() {
+ fun onPointerInput_2Down1MoveConsumedTheOtherMoveConsume_onCancelCalledOnce() {
var pointer0 = down(0)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0)
pointer0 = pointer0.moveTo(100.milliseconds)
var pointer1 = down(1, duration = 100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.moveBy(100L.milliseconds, 5f).consume(5f)
pointer1 = pointer1.moveBy(100L.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.moveBy(100L.milliseconds)
pointer1 = pointer1.moveBy(100L.milliseconds, 5f).consume(5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_1DownMoveOutsideOfBoundsLeft_onCancelCalledOnce() {
+ fun onPointerInput_1DownMoveOutsideOfBoundsLeft_onCancelCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, -1f, 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_1DownMoveOutsideOfBoundsRight_onCancelCalledOnce() {
+ fun onPointerInput_1DownMoveOutsideOfBoundsRight_onCancelCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_1DownMoveOutsideOfBoundsUp_onCancelCalledOnce() {
+ fun onPointerInput_1DownMoveOutsideOfBoundsUp_onCancelCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 0f, -1f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_1DownMoveOutsideOfBoundsDown_onCancelCalledOnce() {
+ fun onPointerInput_1DownMoveOutsideOfBoundsDown_onCancelCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_2DownBothMoveOutsideOfBounds_onCancelCalledOnce() {
+ fun onPointerInput_2DownBothMoveOutsideOfBounds_onCancelCalledOnce() {
var pointer0 = down(0, x = 0f, y = 4f)
var pointer1 = down(1, x = 4f, y = 0f)
- recognizer.pointerInputHandler
+ 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.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, pointer1, size = IntPxSize(5.ipx, 5.ipx))
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_1DownMoveOutsideBoundsThenInsideThenOutside_onCancelCalledOnce() {
+ fun onPointerInput_1DownMoveOutsideBoundsThenInsideThenOutside_onCancelCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(200.milliseconds, 0f, 0f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
pointer0 = pointer0.moveTo(300.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler
+ recognizer::onPointerInput
.invokeOverAllPasses(pointer0, IntPxSize(1.ipx, 1.ipx))
verify(recognizer.onCancel!!).invoke()
}
@Test
- fun pointerInputHandler_1DownMoveOutsideBoundsUpTwice_onCancelCalledTwice() {
+ fun onPointerInput_1DownMoveOutsideBoundsUpTwice_onCancelCalledTwice() {
var time = 0L
repeat(2) {
var pointer = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(time.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(time.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
time += 100L
}
@@ -435,9 +435,9 @@
}
@Test
- fun pointerInputHandler_downDisabled_onCancelCalledOnce() {
+ fun onPointerInput_downDisabled_onCancelCalledOnce() {
val pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
recognizer.setEnabled(false)
verify(recognizer.onCancel!!).invoke()
@@ -446,8 +446,8 @@
// Verification of correct position returned by onStart.
@Test
- fun pointerInputHandler_down_downPositionIsCorrect() {
- recognizer.pointerInputHandler
+ fun onPointerInput_down_downPositionIsCorrect() {
+ recognizer::onPointerInput
.invokeOverAllPasses(down(0, 0.milliseconds, x = 13f, y = 17f))
verify(recognizer.onStart!!).invoke(PxPosition(13.px, 17f.px))
}
@@ -455,9 +455,9 @@
// Verification of correct consumption behavior.
@Test
- fun pointerInputHandler_down_downChangeConsumedDuringPostUp() {
+ fun onPointerInput_down_downChangeConsumedDuringPostUp() {
var pointer = down(0, 0.milliseconds)
- pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ pointer = recognizer::onPointerInput.invokeOverPasses(
pointer,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -465,7 +465,7 @@
)
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer.pointerInputHandler.invoke(
+ pointer = recognizer::onPointerInput.invoke(
listOf(pointer),
PointerEventPass.PostUp,
IntPxSize(0.ipx, 0.ipx)
@@ -474,35 +474,35 @@
}
@Test
- fun pointerInputHandler_disabledDown_noDownChangeConsumed() {
+ fun onPointerInput_disabledDown_noDownChangeConsumed() {
recognizer.setEnabled(false)
var pointer = down(0, 0.milliseconds)
- pointer = recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ pointer = recognizer::onPointerInput.invokeOverAllPasses(pointer)
assertThat(pointer.consumed.downChange, `is`(false))
}
// Verification of correct cancellation handling.
@Test
- fun cancelHandler_justCancel_noCallbacksCalled() {
- recognizer.cancelHandler.invoke()
+ fun onCancel_justCancel_noCallbacksCalled() {
+ recognizer.onCancel()
verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
}
@Test
- fun cancelHandler_downConsumedCancel_noCallbacksCalled() {
- recognizer.pointerInputHandler
+ fun onCancel_downConsumedCancel_noCallbacksCalled() {
+ recognizer::onPointerInput
.invokeOverAllPasses(down(0, 0.milliseconds).consumeDownChange())
- recognizer.cancelHandler.invoke()
+ recognizer.onCancel()
verifyNoMoreInteractions(recognizer.onStart, recognizer.onStop, recognizer.onCancel)
}
@Test
- fun cancelHandler_downCancel_justStartAndCancelCalledInOrderOnce() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
- recognizer.cancelHandler.invoke()
+ fun onCancel_downCancel_justStartAndCancelCalledInOrderOnce() {
+ recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ recognizer.onCancel()
inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
verify(recognizer.onStart!!).invoke(any())
@@ -512,12 +512,12 @@
}
@Test
- fun cancelHandler_downUpCancel_justStartAndStopCalledInOrderOnce() {
+ fun onCancel_downUpCancel_justStartAndStopCalledInOrderOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
- recognizer.cancelHandler.invoke()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ recognizer.onCancel()
inOrder(recognizer.onStart!!, recognizer.onStop!!) {
verify(recognizer.onStart!!).invoke(any())
@@ -527,12 +527,12 @@
}
@Test
- fun cancelHandler_downMoveCancel_justStartAndCancelCalledInOrderOnce() {
+ fun onCancel_downMoveCancel_justStartAndCancelCalledInOrderOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(50.milliseconds, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
- recognizer.cancelHandler.invoke()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ recognizer.onCancel()
inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
verify(recognizer.onStart!!).invoke(any())
@@ -542,12 +542,12 @@
}
@Test
- fun cancelHandler_downMoveConsumedCancel_justStartAndCancelCalledInOrderOnce() {
+ fun onCancel_downMoveConsumedCancel_justStartAndCancelCalledInOrderOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(50.milliseconds, 1f).consume(1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
- recognizer.cancelHandler.invoke()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ recognizer.onCancel()
inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
verify(recognizer.onStart!!).invoke(any())
@@ -557,12 +557,12 @@
}
@Test
- fun cancelHandler_downThenCancelThenDown_justStartCancelStartCalledInOrderOnce() {
+ fun onCancel_downThenCancelThenDown_justStartCancelStartCalledInOrderOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
- recognizer.cancelHandler.invoke()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ recognizer.onCancel()
pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
inOrder(recognizer.onStart!!, recognizer.onCancel!!) {
verify(recognizer.onStart!!).invoke(any())
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/RawDragGestureDetectorTest.kt
index 9dbc55c..3f6662a 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/RawDragGestureDetectorTest.kt
@@ -64,67 +64,67 @@
// Verify the circumstances under which onStart/OnDrag should not be called.
@Test
- fun pointerInputHandler_blockedAndMove_onStartAndOnDragNotCalled() {
+ fun onPointerInput_blockedAndMove_onStartAndOnDragNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
}
@Test
- fun pointerInputHandler_unblockedNoMove_onStartAndOnDragNotCalled() {
+ fun onPointerInput_unblockedNoMove_onStartAndOnDragNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 0f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
}
@Test
- fun pointerInputHandler_unblockedMovementConsumed_onStartAndOnDragNotCalled() {
+ fun onPointerInput_unblockedMovementConsumed_onStartAndOnDragNotCalled() {
val down1 = down(1)
- recognizer.pointerInputHandler.invokeOverAllPasses(down1)
+ recognizer::onPointerInput.invokeOverAllPasses(down1)
dragStartBlocked = false
val move1 = down1.moveBy(10.milliseconds, 1f, 1f).consume(dx = 1f, dy = 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move1)
+ recognizer::onPointerInput.invokeOverAllPasses(move1)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
}
@Test
- fun pointerInputHandler_unblockedMovementIsInOppositeDirections_onStartAndOnDragNotCalled() {
+ fun onPointerInput_unblockedMovementIsInOppositeDirections_onStartAndOnDragNotCalled() {
val down1 = down(1)
val down2 = down(2)
- recognizer.pointerInputHandler.invokeOverAllPasses(down1, down2)
+ recognizer::onPointerInput.invokeOverAllPasses(down1, down2)
dragStartBlocked = false
val move1 = down1.moveBy(10.milliseconds, 1f, 1f)
val move2 = down2.moveBy(10.milliseconds, -1f, -1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move1, move2)
+ recognizer::onPointerInput.invokeOverAllPasses(move1, move2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onDrag" }).isEmpty()
}
@Test
- fun pointerInputHandler_3PointsMoveAverage0_onStartAndOnDragNotCalled() {
+ fun onPointerInput_3PointsMoveAverage0_onStartAndOnDragNotCalled() {
// Arrange
val pointers = arrayOf(down(0), down(1), down(2))
- recognizer.pointerInputHandler.invokeOverAllPasses(*pointers)
+ recognizer::onPointerInput.invokeOverAllPasses(*pointers)
dragStartBlocked = false
// Act
@@ -148,7 +148,7 @@
0f,
2f
)
- recognizer.pointerInputHandler.invokeOverAllPasses(*pointers)
+ recognizer::onPointerInput.invokeOverAllPasses(*pointers)
// Assert
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
@@ -158,14 +158,14 @@
// Verify the circumstances under which onStart/OnDrag should be called.
@Test
- fun pointerInputHandler_unblockedAndMoveOnX_onStartAndOnDragCalledOnce() {
+ fun onPointerInput_unblockedAndMoveOnX_onStartAndOnDragCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::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
@@ -174,14 +174,14 @@
}
@Test
- fun pointerInputHandler_unblockedAndMoveOnY_oonStartAndOnDragCalledOnce() {
+ fun onPointerInput_unblockedAndMoveOnY_oonStartAndOnDragCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::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
@@ -190,14 +190,14 @@
}
@Test
- fun pointerInputHandler_unblockedAndMoveConsumedBeyond0_onStartAndOnDragCalledOnce() {
+ fun onPointerInput_unblockedAndMoveConsumedBeyond0_onStartAndOnDragCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(10.milliseconds, 1f, 0f).consume(dx = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::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
@@ -208,13 +208,13 @@
// onDrag called with correct values verification.
@Test
- fun pointerInputHandler_unblockedMove_onDragCalledWithTotalDistance() {
+ fun onPointerInput_unblockedMove_onDragCalledWithTotalDistance() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveBy(100.milliseconds, 5f, -2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
val onDragLog = log.filter { it.methodName == "onDrag" }
assertThat(onDragLog).hasSize(2)
@@ -225,26 +225,26 @@
}
@Test
- fun pointerInputHandler_unblockedMoveAndMoveConsumed_onDragCalledWithCorrectDistance() {
+ fun onPointerInput_unblockedMoveAndMoveConsumed_onDragCalledWithCorrectDistance() {
// Arrange
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
// Act
change = change.moveBy(100.milliseconds, 3f, -5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, -3f, 7f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, 11f, 13f)
.consumePositionChange(5.px, 3.px)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(100.milliseconds, -13f, -11f)
.consumePositionChange((-3).px, (-5).px)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
// Assert
@@ -263,14 +263,14 @@
}
@Test
- fun pointerInputHandler_3Down1Moves_onDragCalledWith3rdOfDistance() {
+ fun onPointerInput_3Down1Moves_onDragCalledWith3rdOfDistance() {
// Arrange
var pointer1 = down(0)
var pointer2 = down(1)
var pointer3 = down(2)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
dragStartBlocked = false
pointer1 = pointer1.moveBy(100.milliseconds, 9f, -12f)
@@ -279,7 +279,7 @@
// Act
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
// Assert
@@ -304,54 +304,54 @@
// onStop not called verification
@Test
- fun pointerInputHandler_blockedDownMoveUp_onStopNotCalled() {
+ fun onPointerInput_blockedDownMoveUp_onStopNotCalled() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.moveTo(10.milliseconds, 1f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@Test
- fun pointerInputHandler_unBlockedDownUp_onStopNotCalled() {
+ fun onPointerInput_unBlockedDownUp_onStopNotCalled() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@Test
- fun pointerInputHandler_unBlockedDownMoveAverage0Up_onStopNotCalled() {
+ fun onPointerInput_unBlockedDownMoveAverage0Up_onStopNotCalled() {
var change1 = down(1)
var change2 = down(2)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
dragStartBlocked = false
change1 = change1.moveBy(10.milliseconds, 1f, 1f)
change2 = change2.moveBy(10.milliseconds, -1f, -1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log.filter { it.methodName == "onStop" }).isEmpty()
}
// onStop called verification
@Test
- fun pointerInputHandler_unblockedDownMoveUp_onStopCalledOnce() {
+ fun onPointerInput_unblockedDownMoveUp_onStopCalledOnce() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(10.milliseconds, 1f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(1)
}
@@ -359,19 +359,19 @@
// onStop called with correct values verification
@Test
- fun pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity() {
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(0f, 1f, 0f, 100f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(0f, -1f, 0f, -100f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(1f, 0f, 100f, 0f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(-1f, 0f, -100f, 0f)
+ fun onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity() {
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(0f, 1f, 0f, 100f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(0f, -1f, 0f, -100f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(1f, 0f, 100f, 0f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(-1f, 0f, -100f, 0f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(1f, 1f, 100f, 100f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(-1f, 1f, -100f, 100f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(1f, -1f, 100f, -100f)
- pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(-1f, -1f, -100f, -100f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(1f, 1f, 100f, 100f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(-1f, 1f, -100f, 100f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(1f, -1f, 100f, -100f)
+ onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(-1f, -1f, -100f, -100f)
}
- private fun pointerInputHandler_flingBeyondSlop_onStopCalledWithCorrectVelocity(
+ private fun onPointerInput_flingBeyondSlop_onStopCalledWithCorrectVelocity(
incrementPerMilliX: Float,
incrementPerMilliY: Float,
expectedPxPerSecondDx: Float,
@@ -380,7 +380,7 @@
log.clear()
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
repeat(11) {
@@ -389,11 +389,11 @@
incrementPerMilliX,
incrementPerMilliY
)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
}
change = change.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
val loggedStops = log.filter { it.methodName == "onStop" }
assertThat(loggedStops).hasSize(1)
@@ -405,9 +405,9 @@
// Verification that callbacks occur in the correct order
@Test
- fun pointerInputHandler_unblockDownMoveUp_callBacksOccurInCorrectOrder() {
+ fun onPointerInput_unblockDownMoveUp_callBacksOccurInCorrectOrder() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -415,9 +415,9 @@
0f,
1f
)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(log).hasSize(4)
assertThat(log[0].methodName).isEqualTo("onStart")
@@ -431,23 +431,23 @@
// Verification about what events are, or aren't consumed.
@Test
- fun pointerInputHandler_down_downNotConsumed() {
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(down(0))
+ fun onPointerInput_down_downNotConsumed() {
+ val result = recognizer::onPointerInput.invokeOverAllPasses(down(0))
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_blockedDownMove_distanceChangeNotConsumed() {
+ fun onPointerInput_blockedDownMove_distanceChangeNotConsumed() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.moveTo(
10.milliseconds,
1f,
0f
)
dragObserver.dragConsume = PxPosition(7.ipx, (-11).ipx)
- var result = recognizer.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
change,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -455,7 +455,7 @@
PointerEventPass.PostUp
)
dragObserver.dragConsume = PxPosition.Origin
- result = recognizer.pointerInputHandler.invokeOverPasses(
+ result = recognizer::onPointerInput.invokeOverPasses(
result,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -467,11 +467,11 @@
}
@Test
- fun pointerInputHandler_unblockedDownMoveCallBackDoesNotConsume_distanceChangeNotConsumed() {
+ fun onPointerInput_unblockedDownMoveCallBackDoesNotConsume_distanceChangeNotConsumed() {
dragObserver.dragConsume = PxPosition.Origin
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -479,17 +479,17 @@
1f,
1f
)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(result.anyPositionChangeConsumed()).isFalse()
}
@Test
- fun pointerInputHandler_unblockedMoveOccursDefaultOnDrag_distanceChangeNotConsumed() {
+ fun onPointerInput_unblockedMoveOccursDefaultOnDrag_distanceChangeNotConsumed() {
dragObserver.dragConsume = null
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -497,15 +497,15 @@
1f,
1f
)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(result.anyPositionChangeConsumed()).isFalse()
}
@Test
- fun pointerInputHandler_moveCallBackConsumes_changeDistanceConsumedByCorrectAmount() {
+ fun onPointerInput_moveCallBackConsumes_changeDistanceConsumedByCorrectAmount() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change, IntPxSize(0.ipx, 0.ipx))
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
change,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -522,7 +522,7 @@
PointerEventPass.PostUp
)
dragObserver.dragConsume = PxPosition.Origin
- result = recognizer.pointerInputHandler.invokeOverPasses(
+ result = recognizer::onPointerInput.invokeOverPasses(
result,
PointerEventPass.PostDown
)
@@ -532,9 +532,9 @@
}
@Test
- fun pointerInputHandler_onStopConsumesUp() {
+ fun onPointerInput_onStopConsumesUp() {
var change = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
change = change.moveTo(
@@ -542,32 +542,32 @@
1f,
0f
)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
change = change.up(20.milliseconds)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(result.consumed.downChange).isTrue()
}
@Test
- fun pointerInputHandler_move_onStartCalledWithDownPosition() {
+ fun onPointerInput_move_onStartCalledWithDownPosition() {
val down = down(0, 0.milliseconds, x = 3f, y = 4f)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(Duration(milliseconds = 10), 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
.isEqualTo(PxPosition(3.px, 4.px))
}
@Test
- fun pointerInputHandler_3PointsMove_onStartCalledWithDownPositions() {
+ fun onPointerInput_3PointsMove_onStartCalledWithDownPositions() {
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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
dragStartBlocked = false
pointer1 = pointer1.moveBy(100.milliseconds, 1f, 0f)
@@ -576,7 +576,7 @@
// Act
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
// average position
@@ -586,23 +586,23 @@
// Tests that verify when onCancel should not be called.
@Test
- fun cancelHandler_downCancel_onCancelNotCalled() {
+ fun onCancel_downCancel_onCancelNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
- recognizer.cancelHandler()
+ recognizer.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@Test
- fun cancelHandler_blockedDownMoveCancel_onCancelNotCalled() {
+ fun onCancel_blockedDownMoveCancel_onCancelNotCalled() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = true
val move = down.moveBy(1.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
- recognizer.cancelHandler()
+ recognizer::onPointerInput.invokeOverAllPasses(move)
+ recognizer.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@@ -610,13 +610,13 @@
// Tests that verify when onCancel should be called.
@Test
- fun cancelHandler_downMoveCancel_onCancelCalledOnce() {
+ fun onCancel_downMoveCancel_onCancelCalledOnce() {
val down = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
dragStartBlocked = false
val move = down.moveBy(1.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
- recognizer.cancelHandler()
+ recognizer::onPointerInput.invokeOverAllPasses(move)
+ recognizer.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).hasSize(1)
}
@@ -624,30 +624,30 @@
// Tests that cancel behavior is correct.
@Test
- fun cancelHandler_downCancelDownMove_startPositionIsSecondDown() {
+ fun onCancel_downCancelDownMove_startPositionIsSecondDown() {
val down1 = down(1, x = 3f, y = 5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(down1)
+ recognizer::onPointerInput.invokeOverAllPasses(down1)
dragStartBlocked = false
- recognizer.cancelHandler()
+ recognizer.onCancel()
val down2 = down(2, x = 7f, y = 11f)
- recognizer.pointerInputHandler.invokeOverAllPasses(down2)
+ recognizer::onPointerInput.invokeOverAllPasses(down2)
val move = down2.moveBy(Duration(milliseconds = 10), 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move)
+ recognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(log.first { it.methodName == "onStart" }.pxPosition)
.isEqualTo(PxPosition(7.px, 11.px))
}
@Test
- fun cancelHandler_downMoveCancelDownMoveUp_flingIgnoresMoveBeforeCancel() {
+ fun onCancel_downMoveCancelDownMoveUp_flingIgnoresMoveBeforeCancel() {
// Act.
// Down, move, cancel.
var change = down(0, duration = 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
repeat(11) {
change = change.moveBy(
@@ -655,13 +655,13 @@
-1f,
-1f
)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
}
- recognizer.cancelHandler()
+ recognizer.onCancel()
// Down, Move, Up
change = down(1, duration = 200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
dragStartBlocked = false
repeat(11) {
change = change.moveBy(
@@ -669,10 +669,10 @@
1f,
1f
)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::onPointerInput.invokeOverAllPasses(change)
}
change = change.up(310.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change)
+ recognizer::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/RawPressStartGestureDetectorTest.kt
index 490e81e..e21e948 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/RawPressStartGestureDetectorTest.kt
@@ -56,85 +56,85 @@
// Verification of scenarios where onPressStart should not be called.
@Test
- fun pointerInputHandler_downConsumed_onPressStartNotCalled() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0).consumeDownChange())
+ fun onPointerInput_downConsumed_onPressStartNotCalled() {
+ recognizer::onPointerInput.invokeOverAllPasses(down(0).consumeDownChange())
verify(recognizer.onPressStart, never()).invoke(any())
}
@Test
- fun pointerInputHandler_downConsumedDown_onPressStartNotCalled() {
+ fun onPointerInput_downConsumedDown_onPressStartNotCalled() {
var pointer1 = down(1, duration = 0.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1)
pointer1 = pointer1.moveBy(10.milliseconds)
val pointer2 = down(2, duration = 10.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
verify(recognizer.onPressStart, never()).invoke(any())
}
@Test
- fun pointerInputHandler_disabledDown_onPressStartNotCalled() {
+ fun onPointerInput_disabledDown_onPressStartNotCalled() {
recognizer.setEnabled(false)
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0))
+ recognizer::onPointerInput.invokeOverAllPasses(down(0))
verify(recognizer.onPressStart, never()).invoke(any())
}
@Test
- fun pointerInputHandler_disabledDownEnabledDown_onPressStartNotCalled() {
+ fun onPointerInput_disabledDownEnabledDown_onPressStartNotCalled() {
recognizer.setEnabled(false)
var pointer1 = down(1, duration = 0.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1)
recognizer.setEnabled(true)
pointer1 = pointer1.moveBy(10.milliseconds)
val pointer2 = down(2, duration = 10.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
verify(recognizer.onPressStart, never()).invoke(any())
}
// Verification of scenarios where onPressStart should be called once.
@Test
- fun pointerInputHandler_down_onPressStartCalledOnce() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0))
+ fun onPointerInput_down_onPressStartCalledOnce() {
+ recognizer::onPointerInput.invokeOverAllPasses(down(0))
verify(recognizer.onPressStart).invoke(any())
}
@Test
- fun pointerInputHandler_downDown_onPressStartCalledOnce() {
+ fun onPointerInput_downDown_onPressStartCalledOnce() {
var pointer0 = down(0)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0)
pointer0 = pointer0.moveTo(1.milliseconds)
val pointer1 = down(1, 1.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onPressStart).invoke(any())
}
@Test
- fun pointerInputHandler_2Down1Up1Down_onPressStartCalledOnce() {
+ fun onPointerInput_2Down1Up1Down_onPressStartCalledOnce() {
var pointer0 = down(0)
var pointer1 = down(1)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = pointer0.up(100.milliseconds)
pointer1 = pointer1.moveTo(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
pointer0 = down(0, duration = 200.milliseconds)
pointer1 = pointer1.moveTo(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onPressStart).invoke(any())
}
@Test
- fun pointerInputHandler_1DownMoveOutside2ndDown_onPressStartOnlyCalledOnce() {
+ fun onPointerInput_1DownMoveOutside2ndDown_onPressStartOnlyCalledOnce() {
var pointer0 = down(0, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
pointer0 = pointer0.moveTo(100.milliseconds, 10f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, IntPxSize(5.ipx, 5.ipx))
pointer0 = pointer0.moveTo(200.milliseconds)
val pointer1 = down(1, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer0, pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer0, pointer1)
verify(recognizer.onPressStart).invoke(any())
}
@@ -142,35 +142,35 @@
// Verification of correct position returned by onPressStart.
@Test
- fun pointerInputHandler_down_downPositionIsCorrect() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, x = 13f, y = 17f))
+ fun onPointerInput_down_downPositionIsCorrect() {
+ recognizer::onPointerInput.invokeOverAllPasses(down(0, x = 13f, y = 17f))
verify(recognizer.onPressStart).invoke(PxPosition(13.px, 17f.px))
}
// Verification of correct consumption behavior.
@Test
- fun pointerInputHandler_disabledDown_noDownChangeConsumed() {
+ fun onPointerInput_disabledDown_noDownChangeConsumed() {
recognizer.setEnabled(false)
var pointer = down(0)
- pointer = recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ pointer = recognizer::onPointerInput.invokeOverAllPasses(pointer)
assertThat(pointer.consumed.downChange, `is`(false))
}
// Verification of correct cancellation handling.
@Test
- fun cancelHandler_justCancel_noCallbacksCalled() {
- recognizer.cancelHandler.invoke()
+ fun onCancel_justCancel_noCallbacksCalled() {
+ recognizer.onCancel()
verifyNoMoreInteractions(recognizer.onPressStart)
}
@Test
- fun cancelHandler_downCancelDown_onPressStartCalledTwice() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(id = 0, duration = 0.milliseconds))
- recognizer.cancelHandler.invoke()
- recognizer.pointerInputHandler.invokeOverAllPasses(down(id = 0, duration = 1.milliseconds))
+ fun onCancel_downCancelDown_onPressStartCalledTwice() {
+ recognizer::onPointerInput.invokeOverAllPasses(down(id = 0, duration = 0.milliseconds))
+ recognizer.onCancel()
+ recognizer::onPointerInput.invokeOverAllPasses(down(id = 0, duration = 1.milliseconds))
verify(recognizer.onPressStart, times(2)).invoke(any())
}
@@ -178,10 +178,10 @@
// Verification of correct execution pass behavior
@Test
- fun pointerInputHandler_initialDown_behaviorOccursAtCorrectTime() {
+ fun onPointerInput_initialDown_behaviorOccursAtCorrectTime() {
recognizer.setExecutionPass(PointerEventPass.InitialDown)
- val pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ val pointer = recognizer::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown
)
@@ -191,10 +191,10 @@
}
@Test
- fun pointerInputHandler_preUp_behaviorOccursAtCorrectTime() {
+ fun onPointerInput_preUp_behaviorOccursAtCorrectTime() {
recognizer.setExecutionPass(PointerEventPass.PreUp)
- var pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ var pointer = recognizer::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown
)
@@ -202,7 +202,7 @@
verify(recognizer.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ pointer = recognizer::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PreUp
)
@@ -212,10 +212,10 @@
}
@Test
- fun pointerInputHandler_preDown_behaviorOccursAtCorrectTime() {
+ fun onPointerInput_preDown_behaviorOccursAtCorrectTime() {
recognizer.setExecutionPass(PointerEventPass.PreDown)
- var pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ var pointer = recognizer::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown,
PointerEventPass.PreUp
@@ -224,7 +224,7 @@
verify(recognizer.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ pointer = recognizer::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PreDown
)
@@ -234,10 +234,10 @@
}
@Test
- fun pointerInputHandler_PostUp_behaviorOccursAtCorrectTime() {
+ fun onPointerInput_PostUp_behaviorOccursAtCorrectTime() {
recognizer.setExecutionPass(PointerEventPass.PostUp)
- var pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ var pointer = recognizer::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -247,7 +247,7 @@
verify(recognizer.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ pointer = recognizer::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PostUp
)
@@ -257,10 +257,10 @@
}
@Test
- fun pointerInputHandler_postDown_behaviorOccursAtCorrectTime() {
+ fun onPointerInput_postDown_behaviorOccursAtCorrectTime() {
recognizer.setExecutionPass(PointerEventPass.PostDown)
- var pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ var pointer = recognizer::onPointerInput.invokeOverPasses(
down(0),
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -271,7 +271,7 @@
verify(recognizer.onPressStart, never()).invoke(any())
assertThat(pointer.consumed.downChange, `is`(false))
- pointer = recognizer.pointerInputHandler.invokeOverPasses(
+ pointer = recognizer::onPointerInput.invokeOverPasses(
down(1),
PointerEventPass.PostDown
)
@@ -286,15 +286,15 @@
// state of the gesture detector to inactive such that when a new stream of events starts,
// and the 1st down is already consumed, the gesture detector won't consume the 2nd down.
@Test
- fun cancelHandler_downCancelDownConsumedDown_thirdDownNotConsumed() {
- recognizer.pointerInputHandler
+ fun onCancel_downCancelDownConsumedDown_thirdDownNotConsumed() {
+ recognizer::onPointerInput
.invokeOverAllPasses(down(id = 0, duration = 0.milliseconds))
- recognizer.cancelHandler()
+ recognizer.onCancel()
var pointer1 = down(id = 1, duration = 10.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1)
pointer1 = pointer1.moveTo(20.milliseconds, 0f, 0f)
val pointer2 = down(id = 2, duration = 20.milliseconds)
- val results = recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ val results = recognizer::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/RawScaleGestureDetectorTest.kt
index 6f0798f..273a581 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/RawScaleGestureDetectorTest.kt
@@ -61,44 +61,44 @@
// Verify the circumstances under which onStart/onScale should not be called.
@Test
- fun pointerInputHandler_blocked_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_blocked_onStartAndOnScaleNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = -1f, y = 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveBy(10.milliseconds, 1f, 1f)
pointer2 = pointer1.moveBy(10.milliseconds, -1f, -1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
}
@Test
- fun pointerInputHandler_noMove_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_noMove_onStartAndOnScaleNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = -1f, y = 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, 0f, 0f)
pointer2 = pointer1.moveBy(10.milliseconds, 0f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
}
@Test
- fun pointerInputHandler_1PointerExistsAndMoves_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_1PointerExistsAndMoves_onStartAndOnScaleNotCalled() {
val down1 = down(0)
- recognizer.pointerInputHandler.invokeOverAllPasses(down1)
+ recognizer::onPointerInput.invokeOverAllPasses(down1)
scaleStartBlocked = false
val move1 = down1.moveBy(10.milliseconds, 1f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(move1)
+ recognizer::onPointerInput.invokeOverAllPasses(move1)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -127,19 +127,19 @@
* - - - - -
*/
@Test
- fun pointerInputHandler_2PointsAvgDistanceToCenterDoesNotChange_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_2PointsAvgDistanceToCenterDoesNotChange_onStartAndOnScaleNotCalled() {
var pointer1 = down(1, x = 1f, y = 1f)
var pointer2 = down(0, x = 3f, y = 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -168,14 +168,14 @@
* - - - - -
*/
@Test
- fun pointerInputHandler_3PointsAvgDistanceToCenterDoesNotChange_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_3PointsAvgDistanceToCenterDoesNotChange_onStartAndOnScaleNotCalled() {
// Arrange
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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
// Assert
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
@@ -215,7 +215,7 @@
* - - - - - - -
*/
@Test
- fun pointerInputHandler_4PointsAvgDistanceToCenterDoesNotChange_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_4PointsAvgDistanceToCenterDoesNotChange_onStartAndOnScaleNotCalled() {
// Arrange
@@ -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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3, pointer4)
// Assert
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
@@ -264,18 +264,18 @@
* - - - - - - -
*/
@Test
- fun pointerInputHandler_movementConsumedSoAvgDistanceUnchanged_onStartAndOnScaleNotCalled() {
+ fun onPointerInput_movementConsumedSoAvgDistanceUnchanged_onStartAndOnScaleNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).isEmpty()
assertThat(log.filter { it.methodName == "onScale" }).isEmpty()
@@ -284,84 +284,84 @@
// Verify the circumstances under which onStart/onScale should be called.
@Test
- fun pointerInputHandler_2Pointers1MovesOnX_onStartAndOnScaleCalledOnce() {
+ fun onPointerInput_2Pointers1MovesOnX_onStartAndOnScaleCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
}
@Test
- fun pointerInputHandler_2Pointers1MovesOnY_onStartAndOnScaleCalledOnce() {
+ fun onPointerInput_2Pointers1MovesOnY_onStartAndOnScaleCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
}
@Test
- fun pointerInputHandler_2Pointers0Move1ConsumedOnX_onStartAndOnScaleCalledOnce() {
+ fun onPointerInput_2Pointers0Move1ConsumedOnX_onStartAndOnScaleCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
}
@Test
- fun pointerInputHandler_2Pointers0Move1ConsumedOnY_onStartAndOnScaleCalledOnce() {
+ fun onPointerInput_2Pointers0Move1ConsumedOnY_onStartAndOnScaleCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
assertThat(log.filter { it.methodName == "onScale" }).hasSize(1)
}
@Test
- fun pointerInputHandler_2Pointers1MovesTheMovesAgain_onStartOnlyCalledOnce() {
+ fun onPointerInput_2Pointers1MovesTheMovesAgain_onStartOnlyCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStart" }).hasSize(1)
}
@@ -369,15 +369,15 @@
// onScale called with correct values verification.
@Test
- fun pointerInputHandler_2PointersIncreaseDistanceOnXBy50Percent_onScaleCalledWith150Percent() {
+ fun onPointerInput_2PointersIncreaseDistanceOnXBy50Percent_onScaleCalledWith150Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 2f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 3f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val onScaleLog = log.filter { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -385,15 +385,15 @@
}
@Test
- fun pointerInputHandler_2PointersIncreaseDistanceOnYBy50Percent_onScaleCalledWith150Percent() {
+ fun onPointerInput_2PointersIncreaseDistanceOnYBy50Percent_onScaleCalledWith150Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 0f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 0f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val onScaleLog = log.filter { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -401,15 +401,15 @@
}
@Test
- fun pointerInputHandler_2PointersDecreaseDistanceOnXBy50Percent_onScaleCalledWith50Percent() {
+ fun onPointerInput_2PointersDecreaseDistanceOnXBy50Percent_onScaleCalledWith50Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 2f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val onScaleLog = log.filter { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -417,15 +417,15 @@
}
@Test
- fun pointerInputHandler_2PointersDecreaseDistanceOnYBy50Percent_onScaleCalledWith50Percent() {
+ fun onPointerInput_2PointersDecreaseDistanceOnYBy50Percent_onScaleCalledWith50Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 0f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val onScaleLog = log.filter { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -433,15 +433,15 @@
}
@Test
- fun pointerInputHandler_2PointersIncDistOnBothAxisBy300Percent_onScaleCalledWith400Percent() {
+ fun onPointerInput_2PointersIncDistOnBothAxisBy300Percent_onScaleCalledWith400Percent() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 0f, 0f)
pointer2 = pointer2.moveTo(10.milliseconds, 4f, 4f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val onScaleLog = log.filter { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -449,15 +449,15 @@
}
@Test
- fun pointerInputHandler_2PointersDecDistOnBothAxisBy75Percent_onScaleCalledWith25Percent() {
+ fun onPointerInput_2PointersDecDistOnBothAxisBy75Percent_onScaleCalledWith25Percent() {
var pointer1 = down(0, x = 0f, y = 0f)
var pointer2 = down(0, x = 4f, y = 4f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
scaleStartBlocked = false
pointer1 = pointer1.moveTo(10.milliseconds, 1f, 1f)
pointer2 = pointer2.moveTo(10.milliseconds, 2f, 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
val onScaleLog = log.filter { it.methodName == "onScale" }
assertThat(onScaleLog).hasSize(1)
@@ -467,57 +467,57 @@
// onStop not called verification
@Test
- fun pointerInputHandler_blocked2PointersScaleThenOneUp_onStopNotCalled() {
+ fun onPointerInput_blocked2PointersScaleThenOneUp_onStopNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
pointer2 = pointer2.moveBy(10.milliseconds, dx = 0f, dy = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.up(20.milliseconds)
pointer2 = pointer2.moveBy(0.milliseconds, dx = 0f, dy = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@Test
- fun pointerInputHandler_1PointerDownMoveUp_onStopNotCalled() {
+ fun onPointerInput_1PointerDownMoveUp_onStopNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1)
scaleStartBlocked = false
pointer1 = pointer1.moveBy(10.milliseconds, dx = 1f, dy = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1)
pointer1 = pointer1.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@Test
- fun pointerInputHandler_3PointersScaleThan1Up_onStopNotCalled() {
+ fun onPointerInput_3PointersScaleThan1Up_onStopNotCalled() {
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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(0)
}
@@ -525,33 +525,33 @@
// onStop called verification
@Test
- fun pointerInputHandler_unblocked2DownMove2Up_onStopCalledOnce() {
+ fun onPointerInput_unblocked2DownMove2Up_onStopCalledOnce() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log.filter { it.methodName == "onStop" }).hasSize(1)
}
@Test
- fun pointerInputHandler_unblocked2DownMove1Up_onStopNotCalled() {
+ fun onPointerInput_unblocked2DownMove1Up_onStopNotCalled() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.moveTo(20.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log.filter { it.methodName == "onStop" }).isEmpty()
}
@@ -559,17 +559,17 @@
// Verification that callbacks occur in the correct order
@Test
- fun pointerInputHandler_unblocked2DownMove2Up_callbacksCalledInCorrectOrder() {
+ fun onPointerInput_unblocked2DownMove2Up_callbacksCalledInCorrectOrder() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(log).hasSize(3)
assertThat(log[0].methodName).isEqualTo("onStart")
@@ -580,76 +580,76 @@
// Verification about what events are, or aren't consumed.
@Test
- fun pointerInputHandler_1down_downNotConsumed() {
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(down(0))
+ fun onPointerInput_1down_downNotConsumed() {
+ val result = recognizer::onPointerInput.invokeOverAllPasses(down(0))
assertThat(result.consumed.downChange).isFalse()
}
@Test
- fun pointerInputHandler_2Down_downNotConsumed() {
+ fun onPointerInput_2Down_downNotConsumed() {
val down1 = down(0, x = 1f, y = 1f)
val down2 = down(1, x = 2f, y = 2f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(down1, down2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(down1, down2)
assertThat(result.count { !it.consumed.downChange }).isEqualTo(2)
}
@Test
- fun pointerInputHandler_blocked2DownMove_distanceChangeNotConsumed() {
+ fun onPointerInput_blocked2DownMove_distanceChangeNotConsumed() {
scaleObserver.resultingScaleChange = 3f
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { !it.anyPositionChangeConsumed() }).isEqualTo(2)
}
@Test
- fun pointerInputHandler_unblocked2DownMoveCallBackDoesNotConsume_distanceChangeNotConsumed() {
+ fun onPointerInput_unblocked2DownMoveCallBackDoesNotConsume_distanceChangeNotConsumed() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { !it.anyPositionChangeConsumed() }).isEqualTo(2)
}
@Test
- fun pointerInputHandler_unblockedScaleOccursDefaultOnScale_distanceChangeNotConsumed() {
+ fun onPointerInput_unblockedScaleOccursDefaultOnScale_distanceChangeNotConsumed() {
scaleObserver.resultingScaleChange = null
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { !it.anyPositionChangeConsumed() }).isEqualTo(2)
}
@Test
- fun pointerInputHandler_onlyScaleUpXPartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_onlyScaleUpXPartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 2f, y = 0f)
var change2 = down(1, x = 4f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -659,7 +659,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -671,19 +671,19 @@
}
@Test
- fun pointerInputHandler_onlyScaleUpYPartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_onlyScaleUpYPartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 0f, y = 2f)
var change2 = down(1, x = 0f, y = 4f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -693,7 +693,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -705,16 +705,16 @@
}
@Test
- fun pointerInputHandler_onlyScaleUpXYFullyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_onlyScaleUpXYFullyConsumed_distancesConsumedByCorrectAmount() {
scaleObserver.resultingScaleChange = 3f
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.first { it.id == PointerId(0) }.consumed.positionChange)
.isEqualTo(PxPosition(-1.px, -1.px))
@@ -723,19 +723,19 @@
}
@Test
- fun pointerInputHandler_onlyScaleDownXPartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_onlyScaleDownXPartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 8f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -745,7 +745,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -757,19 +757,19 @@
}
@Test
- fun pointerInputHandler_onlyScaleDownYPartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_onlyScaleDownYPartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 0f, y = 8f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -779,7 +779,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -791,35 +791,35 @@
}
@Test
- fun pointerInputHandler_onlyScaleDownXYFullyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_onlyScaleDownXYFullyConsumed_distancesConsumedByCorrectAmount() {
scaleObserver.resultingScaleChange = .5f
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 8f, y = 8f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 2f, 2f)
change2 = change2.moveTo(10.milliseconds, 6f, 6f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::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))
}
@Test
- fun pointerInputHandler_scaleUpXTranslatePartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_scaleUpXTranslatePartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 2f, y = 0f)
var change2 = down(1, x = 4f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -829,7 +829,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(
result, listOf(PointerEventPass.PostDown)
)
@@ -843,19 +843,19 @@
}
@Test
- fun pointerInputHandler_scaleUpYTranslatePartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_scaleUpYTranslatePartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 0f, y = 2f)
var change2 = down(1, x = 0f, y = 4f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -865,7 +865,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -877,19 +877,19 @@
}
@Test
- fun pointerInputHandler_scaleDownXTranslatePartConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_scaleDownXTranslatePartConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 8f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -899,7 +899,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -911,19 +911,19 @@
}
@Test
- fun pointerInputHandler_scaleDownYTranslatePartConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_scaleDownYTranslatePartConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = 0f, y = 0f)
var change2 = down(1, x = 0f, y = 8f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -933,7 +933,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -945,19 +945,19 @@
}
@Test
- fun pointerInputHandler_scaleUpRotatePartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_scaleUpRotatePartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = -1f, y = 0f)
var change2 = down(1, x = 1f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -967,7 +967,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -979,19 +979,19 @@
}
@Test
- fun pointerInputHandler_scaleDownRotatePartiallyConsumed_distancesConsumedByCorrectAmount() {
+ fun onPointerInput_scaleDownRotatePartiallyConsumed_distancesConsumedByCorrectAmount() {
// Act
var change1 = down(0, x = -4f, y = 0f)
var change2 = down(1, x = 4f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::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.pointerInputHandler.invokeOverPasses(
+ var result = recognizer::onPointerInput.invokeOverPasses(
listOf(change1, change2),
listOf(
PointerEventPass.InitialDown,
@@ -1001,7 +1001,7 @@
)
)
scaleObserver.resultingScaleChange = 1f
- result = recognizer.pointerInputHandler
+ result = recognizer::onPointerInput
.invokeOverPasses(result, listOf(PointerEventPass.PostDown))
// Assert
@@ -1013,65 +1013,65 @@
}
@Test
- fun pointerInputHandler_blocked2DownMoveUp_upChangeNotConsumed() {
+ fun onPointerInput_blocked2DownMoveUp_upChangeNotConsumed() {
scaleObserver.resultingScaleChange = 1f
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { it.consumed.downChange }).isEqualTo(0)
}
@Test
- fun pointerInputHandler_unblocked2DownUp_upChangeNotConsumed() {
+ fun onPointerInput_unblocked2DownUp_upChangeNotConsumed() {
scaleObserver.resultingScaleChange = 1f
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { it.consumed.downChange }).isEqualTo(0)
}
@Test
- fun pointerInputHandler_scale1Up_upChangeConsumed() {
+ fun onPointerInput_scale1Up_upChangeConsumed() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.moveTo(20.milliseconds, 3f, 3f)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.first { it.id == PointerId(0) }.consumed.downChange).isTrue()
}
@Test
- fun pointerInputHandler_scale2Up_onStopConsumesUp() {
+ fun onPointerInput_scale2Up_onStopConsumesUp() {
var change1 = down(0, x = 1f, y = 1f)
var change2 = down(1, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
scaleStartBlocked = false
change1 = change1.moveTo(10.milliseconds, 0f, 0f)
change2 = change2.moveTo(10.milliseconds, 3f, 3f)
- recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
change1 = change1.up(20.milliseconds)
change2 = change2.up(20.milliseconds)
- val result = recognizer.pointerInputHandler.invokeOverAllPasses(change1, change2)
+ val result = recognizer::onPointerInput.invokeOverAllPasses(change1, change2)
assertThat(result.count { it.consumed.downChange }).isEqualTo(2)
}
@@ -1079,25 +1079,25 @@
// Tests that verify when onCancel should not be called.
@Test
- fun cancelHandler_downCancel_onCancelNotCalled() {
+ fun onCancel_downCancel_onCancelNotCalled() {
val down = down(0)
- recognizer.pointerInputHandler.invokeOverAllPasses(down)
+ recognizer::onPointerInput.invokeOverAllPasses(down)
scaleStartBlocked = false
- recognizer.cancelHandler()
+ recognizer.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@Test
- fun cancelHandler_blockedDownMoveCancel_onCancelNotCalled() {
+ fun onCancel_blockedDownMoveCancel_onCancelNotCalled() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
- recognizer.cancelHandler()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ recognizer.onCancel()
assertThat(log.filter { it.methodName == "onCancel" }).isEmpty()
}
@@ -1105,15 +1105,15 @@
// Tests that verify when onCancel should be called.
@Test
- fun cancelHandler_downMoveCancel_onCancelCalledOnce() {
+ fun onCancel_downMoveCancel_onCancelCalledOnce() {
var pointer1 = down(0, x = 1f, y = 1f)
var pointer2 = down(0, x = 2f, y = 2f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
- recognizer.cancelHandler()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
+ recognizer.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/ScaleSlopExceededGestureDetectorTest.kt
index c05a931..2304cec 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/ScaleSlopExceededGestureDetectorTest.kt
@@ -57,14 +57,14 @@
@Test
fun onPointerInputChanges_1PointerMoves10TimesScaleSlopInXAndY_onTouchSlopExceededNotCalled() {
var pointer = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveBy(
Duration(milliseconds = 10),
TestTouchSlop.toFloat() * 10,
TestTouchSlop.toFloat() * 10
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -473,7 +473,7 @@
10f,
100f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Translate, rotate and scale down.
pointer1 = pointer1.moveTo(
@@ -486,7 +486,7 @@
-40f,
75f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Translate, rotate and scale up.
pointer1 = pointer1.moveTo(
@@ -499,7 +499,7 @@
40f,
-20f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Translate, rotate and scale down.
pointer1 = pointer1.moveTo(
@@ -512,7 +512,7 @@
20f,
-80f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -537,7 +537,7 @@
0f,
30 + TinyNum
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Under
pointer1 = pointer1.moveTo(
@@ -550,7 +550,7 @@
0f,
30 - TinyNum
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Over
pointer1 = pointer1.moveTo(
@@ -563,7 +563,7 @@
0f,
30 + TinyNum
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -590,7 +590,7 @@
1f,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
}
// Verify that we have not gone over.
@@ -607,7 +607,7 @@
TinyNum,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -634,7 +634,7 @@
0f,
1f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
}
// Verify that we have not gone over.
@@ -651,7 +651,7 @@
0f,
TinyNum
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Verify we have gone over.
assertThat(onScaleSlopExceededCount).isEqualTo(1)
@@ -660,13 +660,13 @@
// Tests that verify correct cancelling behavior.
@Test
- fun cancelHandler_scaleUnderCancelScaleUnder_onScaleSlopExceededNotCalled() {
+ fun onCancel_scaleUnderCancelScaleUnder_onScaleSlopExceededNotCalled() {
// Arrange
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -678,15 +678,15 @@
11f,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
- mRecognizer.cancelHandler()
+ mRecognizer.onCancel()
pointer1 = down(0, 0.milliseconds, 0f, 0f)
pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -698,7 +698,7 @@
11f,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Assert
@@ -706,13 +706,13 @@
}
@Test
- fun cancelHandler_scalePastCancelScalePast_onScaleSlopExceededCalledTwice() {
+ fun onCancel_scalePastCancelScalePast_onScaleSlopExceededCalledTwice() {
// Arrange
var pointer1 = down(0, 0.milliseconds, 0f, 0f)
var pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -724,15 +724,15 @@
11 + TinyNum,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
- mRecognizer.cancelHandler()
+ mRecognizer.onCancel()
pointer1 = down(0, 0.milliseconds, 0f, 0f)
pointer2 = down(1, 0L.milliseconds, 1f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
pointer1 = pointer1.moveTo(
10.milliseconds,
@@ -744,7 +744,7 @@
11 + TinyNum,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
pointer1 = pointer1.moveTo(
@@ -778,7 +778,7 @@
x2e,
y2e
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2, pointer3)
// Act
pointer1 = pointer1.moveTo(
@@ -820,7 +820,7 @@
x3e,
y3e
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2, pointer3)
+ mRecognizer::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/TapGestureDetectorTest.kt
index 84c4158..49a0b4ac 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/TapGestureDetectorTest.kt
@@ -52,88 +52,88 @@
@Test
fun pointerInputHandler_down_onReleaseNotCalled() {
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
- verify(recognizer.onTap!!, never()).invoke()
+ recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downConsumedUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveConsumedUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f).consume(5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downUpConsumed_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds).consumeDownChange()
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsNegativeXUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, -1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsPositiveXUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsNegativeYUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, -1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsPositiveYUp_onReleaseNotCalled() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.onTap, never()).invoke()
}
// Verification for when onReleased should be called.
@@ -141,39 +141,39 @@
@Test
fun pointerInputHandler_downUp_onReleaseCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap!!).invoke()
+ verify(recognizer.onTap).invoke()
}
@Test
fun pointerInputHandler_downMoveUp_onReleaseCalledOnce() {
var pointer = down(0, 0.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(100.milliseconds, 5f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap!!).invoke()
+ verify(recognizer.onTap).invoke()
}
@Test
fun pointerInputHandler_downMoveOutsideBoundsUpDownUp_onReleaseCalledOnce() {
var pointer = down(0, 0.milliseconds, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = down(1, duration = 150.milliseconds, x = 0f, y = 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(200.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
- verify(recognizer.onTap!!).invoke()
+ verify(recognizer.onTap).invoke()
}
// Verification for when the down change should not be consumed.
@@ -182,7 +182,7 @@
fun pointerInputHandler_consumeDownOnStartIsFalse_downChangeNotConsumed() {
recognizer.consumeDownOnStart = false
val pointerEventChange =
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ recognizer::onPointerInput.invokeOverAllPasses(down(0, 0.milliseconds))
assertThat(pointerEventChange.consumed.downChange, `is`(false))
}
@@ -191,7 +191,7 @@
@Test
fun pointerInputHandler_consumeDownOnStartIsDefault_downChangeConsumed() {
val pointerEventChange =
- recognizer.pointerInputHandler.invokeOverAllPasses(down(0, 0.milliseconds))
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, -1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 1f, 0f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, -1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.moveTo(50.milliseconds, 0f, 1f)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::onPointerInput.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
pointer = pointer.up(100.milliseconds)
val result =
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer, IntPxSize(1.ipx, 1.ipx))
+ recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.up(100.milliseconds)
- val pointerEventChange = recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ val pointerEventChange = recognizer::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.pointerInputHandler.invokeOverPasses(
+ pointerEventChange = recognizer::onPointerInput.invokeOverPasses(
pointerEventChange,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -274,7 +274,7 @@
)
assertThat(pointerEventChange.consumed.downChange, `is`(false))
- pointerEventChange = recognizer.pointerInputHandler.invokeOverPasses(
+ pointerEventChange = recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
var pointerEventChange = pointer.up(100.milliseconds)
- pointerEventChange = recognizer.pointerInputHandler.invokeOverPasses(
+ pointerEventChange = recognizer::onPointerInput.invokeOverPasses(
pointerEventChange,
PointerEventPass.InitialDown,
PointerEventPass.PreUp,
@@ -295,7 +295,7 @@
)
assertThat(pointerEventChange.consumed.downChange, `is`(false))
- pointerEventChange = recognizer.pointerInputHandler.invokeOverPasses(
+ pointerEventChange = recognizer::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.pointerInputHandler.invokeOverAllPasses(pointer)
- recognizer.cancelHandler()
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
+ recognizer.onCancel()
pointer = pointer.up(100.milliseconds)
- recognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ recognizer::onPointerInput.invokeOverAllPasses(pointer)
- verify(recognizer.onTap!!, never()).invoke()
+ verify(recognizer.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/TouchSlopExceededGestureDetectorTest.kt
index 377496b..377fdff 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/TouchSlopExceededGestureDetectorTest.kt
@@ -75,16 +75,16 @@
@Test
fun onPointerInputChanges_down_canDragNotCalled() {
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0))
+ mRecognizer::onPointerInput.invokeOverAllPasses(down(0))
assertThat(canDragDirections).isEmpty()
}
@Test
fun onPointerInputChanges_downUp_canDragNotCalled() {
val down = down(0, duration = 0.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val up = down.up(10.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
assertThat(canDragDirections).isEmpty()
}
@@ -92,9 +92,9 @@
@Test
fun onPointerInputChanges_downMoveFullyConsumed_canDragNotCalled() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 5f).consume(3f, 5f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(canDragDirections).isEmpty()
}
@@ -104,9 +104,9 @@
@Test
fun onPointerInputChanges_downMove1Dimension_canDragCalledOnce() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 5f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 0f, 5f).consume(0f, 4f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), 3f, 5f).consume(2f, 4f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
var move = down.moveTo(10.milliseconds, 0f, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
repeat(3) {
move = move.moveBy(Duration(milliseconds = 10), 0f, 1f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
var move = down
repeat(3) {
move = move.moveBy(Duration(milliseconds = 10), 0f, thirdSlop.toFloat())
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
// Back into touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, -beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region again
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 10), dx, dy)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 10),
TestTouchSlop.toFloat(),
TestTouchSlop.toFloat()
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
}
@@ -278,13 +278,13 @@
canDragReturn = false
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 10),
beyondSlop,
beyondSlop
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
}
@@ -293,10 +293,10 @@
fun onPointerInputChanges_moveBeyondSlopButConsumeUnder_onTouchSlopExceededNotCalled() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop + TinyNum, 0f).consume(dx = 1f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
// Assert
@@ -307,10 +307,10 @@
fun onPointerInputChanges_moveUnderToPostUpThenModOverInOppDir_onTouchSlopExceededNotCalled() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop.toFloat(), 0f)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -320,7 +320,7 @@
)
)
val move2 = move.consume(dx = (TestTouchSlop * 2f + TinyNum))
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
move2,
PointerEventPass.PostDown
)
@@ -338,46 +338,46 @@
val slop = TestTouchSlop.toFloat()
var change = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// Go around the border of the touch slop area
// To top left
change = change.moveTo(10.milliseconds, -slop, -slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// To bottom left
change = change.moveTo(20.milliseconds, -slop, slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// To bottom right
change = change.moveTo(30.milliseconds, slop, slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// To top right
change = change.moveTo(40.milliseconds, slop, -slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// Jump from corner to opposite corner and back
// To bottom left
change = change.moveTo(50.milliseconds, -slop, slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// To top right
change = change.moveTo(60.milliseconds, slop, -slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// Move the other diagonal
// To top left
change = change.moveTo(70.milliseconds, -slop, -slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// Jump from corner to opposite corner and back
// To bottom right
change = change.moveTo(80.milliseconds, slop, slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
// To top left
change = change.moveTo(90.milliseconds, -slop, -slop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
}
@@ -389,13 +389,13 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 100),
beyondSlop,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -404,19 +404,19 @@
fun onPointerInputChanges_movePassedSlopIn2Events_onTouchSlopExceededCallOnce() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(
Duration(milliseconds = 100),
TestTouchSlop.toFloat(),
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
val move2 = down.moveBy(
Duration(milliseconds = 100),
1f,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move2)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -426,16 +426,16 @@
val beyondSlop = TestTouchSlop + TinyNum
var event = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
// Back into touch slop region
event = event.moveBy(Duration(milliseconds = 10), 0f, -beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
// Out of touch slop region again
event = event.moveBy(Duration(milliseconds = 10), 0f, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(event)
+ mRecognizer::onPointerInput.invokeOverAllPasses(event)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -445,9 +445,9 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0).consumeDownChange()
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(Duration(milliseconds = 100), beyondSlop, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -457,7 +457,7 @@
val beyondSlop = TestTouchSlop + TinyNum
var change = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
canDragReturn = false
change = change.moveBy(
Duration(milliseconds = 10),
@@ -468,13 +468,13 @@
assertThat(onTouchSlopExceededCallCount).isEqualTo(0)
canDragReturn = true
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
change = change.moveBy(
Duration(milliseconds = 10),
0f,
-beyondSlop
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(change)
+ mRecognizer::onPointerInput.invokeOverAllPasses(change)
assertThat(onTouchSlopExceededCallCount).isEqualTo(1)
}
@@ -488,7 +488,7 @@
var pointer1 = down(1)
var pointer2 = down(2)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Act
@@ -502,7 +502,7 @@
-beyondSlop,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer1, pointer2)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer1, pointer2)
// Assert
@@ -517,7 +517,7 @@
val beyondSlop = TestTouchSlop + TinyNum
val pointers = arrayOf(down(0), down(1), down(2))
- mRecognizer.pointerInputHandler.invokeOverAllPasses(*pointers)
+ mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
// Act
@@ -540,7 +540,7 @@
0f,
beyondSlop * 2
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(*pointers)
+ mRecognizer::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.pointerInputHandler.invokeOverAllPasses(*pointers)
+ mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
// Act
@@ -573,7 +573,7 @@
beyondSlop * -1,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(*pointers)
+ mRecognizer::onPointerInput.invokeOverAllPasses(*pointers)
// Assert
@@ -588,13 +588,13 @@
val beyondSlop = TestTouchSlop + TinyNum
var pointer = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Act
repeat(5) {
pointer = pointer.moveBy(100.milliseconds, beyondSlop, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
}
// Assert
@@ -607,10 +607,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, 0f, 0f).consume(dx = beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -630,10 +630,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -644,7 +644,7 @@
)
val moveConsumed = move.consume(dx = beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
moveConsumed,
PointerEventPass.PostDown
)
@@ -660,10 +660,10 @@
val restOfSlopAndBeyond = TestTouchSlop - halfSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, halfSlop.toFloat(), 0f)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -674,7 +674,7 @@
)
val moveConsumed = move.consume(dx = -restOfSlopAndBeyond)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
moveConsumed,
PointerEventPass.PostDown
)
@@ -689,10 +689,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, 0f)
- mRecognizer.pointerInputHandler.invokeOverPasses(
+ mRecognizer::onPointerInput.invokeOverPasses(
listOf(move),
listOf(
PointerEventPass.InitialDown,
@@ -712,7 +712,7 @@
@Test
fun onPointerInputChanges_1Down_nothingConsumed() {
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(down(0))
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(down(0))
// Assert
@@ -725,10 +725,10 @@
fun onPointerInputChanges_1MoveUnderSlop_nothingConsumed() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop.toFloat(), TestTouchSlop.toFloat())
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(move)
// Assert
@@ -741,13 +741,13 @@
fun onPointerInputChanges_1MoveUnderSlopThenUp_nothingConsumed() {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, TestTouchSlop.toFloat(), TestTouchSlop.toFloat())
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
val up = move.up(20.milliseconds)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(up)
// Assert
@@ -761,10 +761,10 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, beyondSlop)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(move)
// Assert
@@ -778,13 +778,13 @@
val beyondSlop = TestTouchSlop + TinyNum
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, beyondSlop)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
val up = move.up(20.milliseconds)
- val result = mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ val result = mRecognizer::onPointerInput.invokeOverAllPasses(up)
// Assert
@@ -801,13 +801,13 @@
repeat(2) {
val down = down(0)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(down)
+ mRecognizer::onPointerInput.invokeOverAllPasses(down)
val move = down.moveBy(10.milliseconds, beyondSlop, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(move)
+ mRecognizer::onPointerInput.invokeOverAllPasses(move)
val up = move.up(20.milliseconds)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(up)
+ mRecognizer::onPointerInput.invokeOverAllPasses(up)
}
assertThat(onTouchSlopExceededCallCount).isEqualTo(2)
@@ -816,34 +816,34 @@
// Verification that cancellation behavior is correct.
@Test
- fun cancelHandler_underSlopCancelUnderSlop_onTouchSlopExceededNotCalled() {
+ fun onCancel_underSlopCancelUnderSlop_onTouchSlopExceededNotCalled() {
val underSlop = TestTouchSlop - TinyNum
// Arrange
var pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
underSlop,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Act
- mRecognizer.cancelHandler()
+ mRecognizer.onCancel()
pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
underSlop,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Assert
@@ -851,34 +851,34 @@
}
@Test
- fun cancelHandler_pastSlopCancelPastSlop_onScaleSlopExceededCalledTwice() {
+ fun onCancel_pastSlopCancelPastSlop_onScaleSlopExceededCalledTwice() {
val overSlop = TestTouchSlop + TinyNum
// Arrange
var pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
overSlop,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Act
- mRecognizer.cancelHandler()
+ mRecognizer.onCancel()
pointer = down(0, 0.milliseconds, 0f, 0f)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
pointer = pointer.moveTo(
10.milliseconds,
overSlop,
0f
)
- mRecognizer.pointerInputHandler.invokeOverAllPasses(pointer)
+ mRecognizer::onPointerInput.invokeOverAllPasses(pointer)
// Assert
diff --git a/ui/ui-platform/api/0.1.0-dev09.txt b/ui/ui-platform/api/0.1.0-dev09.txt
index 29cc661..3a87baa 100644
--- a/ui/ui-platform/api/0.1.0-dev09.txt
+++ b/ui/ui-platform/api/0.1.0-dev09.txt
@@ -362,14 +362,10 @@
public abstract class PointerInputFilter {
ctor public PointerInputFilter();
- method public abstract kotlin.jvm.functions.Function0<kotlin.Unit> getCancelHandler();
- method public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? getCustomEventHandler();
- method public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? getInitHandler();
- method public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> getPointerInputHandler();
- property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> cancelHandler;
- property public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? customEventHandler;
- property public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? initHandler;
- property public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> pointerInputHandler;
+ method public abstract void onCancel();
+ method public void onCustomEvent(androidx.ui.core.CustomEvent customEvent, androidx.ui.core.PointerEventPass pass);
+ method public void onInit(androidx.ui.core.CustomEventDispatcher customEventDispatcher);
+ method public abstract java.util.List<androidx.ui.core.PointerInputChange> onPointerInput(java.util.List<androidx.ui.core.PointerInputChange> changes, androidx.ui.core.PointerEventPass pass, androidx.ui.unit.IntPxSize bounds);
}
public interface PointerInputModifier extends androidx.ui.core.Modifier.Element {
diff --git a/ui/ui-platform/api/current.txt b/ui/ui-platform/api/current.txt
index 29cc661..3a87baa 100644
--- a/ui/ui-platform/api/current.txt
+++ b/ui/ui-platform/api/current.txt
@@ -362,14 +362,10 @@
public abstract class PointerInputFilter {
ctor public PointerInputFilter();
- method public abstract kotlin.jvm.functions.Function0<kotlin.Unit> getCancelHandler();
- method public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? getCustomEventHandler();
- method public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? getInitHandler();
- method public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> getPointerInputHandler();
- property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> cancelHandler;
- property public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? customEventHandler;
- property public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? initHandler;
- property public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> pointerInputHandler;
+ method public abstract void onCancel();
+ method public void onCustomEvent(androidx.ui.core.CustomEvent customEvent, androidx.ui.core.PointerEventPass pass);
+ method public void onInit(androidx.ui.core.CustomEventDispatcher customEventDispatcher);
+ method public abstract java.util.List<androidx.ui.core.PointerInputChange> onPointerInput(java.util.List<androidx.ui.core.PointerInputChange> changes, androidx.ui.core.PointerEventPass pass, androidx.ui.unit.IntPxSize bounds);
}
public interface PointerInputModifier extends androidx.ui.core.Modifier.Element {
diff --git a/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt b/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt
index 3e3ed20..6ca79b3 100644
--- a/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt
+++ b/ui/ui-platform/api/public_plus_experimental_0.1.0-dev09.txt
@@ -364,14 +364,10 @@
public abstract class PointerInputFilter {
ctor public PointerInputFilter();
- method public abstract kotlin.jvm.functions.Function0<kotlin.Unit> getCancelHandler();
- method public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? getCustomEventHandler();
- method public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? getInitHandler();
- method public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> getPointerInputHandler();
- property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> cancelHandler;
- property public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? customEventHandler;
- property public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? initHandler;
- property public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> pointerInputHandler;
+ method public abstract void onCancel();
+ method public void onCustomEvent(androidx.ui.core.CustomEvent customEvent, androidx.ui.core.PointerEventPass pass);
+ method public void onInit(androidx.ui.core.CustomEventDispatcher customEventDispatcher);
+ method public abstract java.util.List<androidx.ui.core.PointerInputChange> onPointerInput(java.util.List<androidx.ui.core.PointerInputChange> changes, androidx.ui.core.PointerEventPass pass, androidx.ui.unit.IntPxSize bounds);
}
public interface PointerInputModifier extends androidx.ui.core.Modifier.Element {
diff --git a/ui/ui-platform/api/public_plus_experimental_current.txt b/ui/ui-platform/api/public_plus_experimental_current.txt
index 3e3ed20..6ca79b3 100644
--- a/ui/ui-platform/api/public_plus_experimental_current.txt
+++ b/ui/ui-platform/api/public_plus_experimental_current.txt
@@ -364,14 +364,10 @@
public abstract class PointerInputFilter {
ctor public PointerInputFilter();
- method public abstract kotlin.jvm.functions.Function0<kotlin.Unit> getCancelHandler();
- method public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? getCustomEventHandler();
- method public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? getInitHandler();
- method public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> getPointerInputHandler();
- property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> cancelHandler;
- property public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? customEventHandler;
- property public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? initHandler;
- property public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> pointerInputHandler;
+ method public abstract void onCancel();
+ method public void onCustomEvent(androidx.ui.core.CustomEvent customEvent, androidx.ui.core.PointerEventPass pass);
+ method public void onInit(androidx.ui.core.CustomEventDispatcher customEventDispatcher);
+ method public abstract java.util.List<androidx.ui.core.PointerInputChange> onPointerInput(java.util.List<androidx.ui.core.PointerInputChange> changes, androidx.ui.core.PointerEventPass pass, androidx.ui.unit.IntPxSize bounds);
}
public interface PointerInputModifier extends androidx.ui.core.Modifier.Element {
diff --git a/ui/ui-platform/api/restricted_0.1.0-dev09.txt b/ui/ui-platform/api/restricted_0.1.0-dev09.txt
index a5bad10..2c7aeb1 100644
--- a/ui/ui-platform/api/restricted_0.1.0-dev09.txt
+++ b/ui/ui-platform/api/restricted_0.1.0-dev09.txt
@@ -366,14 +366,10 @@
public abstract class PointerInputFilter {
ctor public PointerInputFilter();
- method public abstract kotlin.jvm.functions.Function0<kotlin.Unit> getCancelHandler();
- method public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? getCustomEventHandler();
- method public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? getInitHandler();
- method public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> getPointerInputHandler();
- property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> cancelHandler;
- property public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? customEventHandler;
- property public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? initHandler;
- property public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> pointerInputHandler;
+ method public abstract void onCancel();
+ method public void onCustomEvent(androidx.ui.core.CustomEvent customEvent, androidx.ui.core.PointerEventPass pass);
+ method public void onInit(androidx.ui.core.CustomEventDispatcher customEventDispatcher);
+ method public abstract java.util.List<androidx.ui.core.PointerInputChange> onPointerInput(java.util.List<androidx.ui.core.PointerInputChange> changes, androidx.ui.core.PointerEventPass pass, androidx.ui.unit.IntPxSize bounds);
}
public interface PointerInputModifier extends androidx.ui.core.Modifier.Element {
diff --git a/ui/ui-platform/api/restricted_current.txt b/ui/ui-platform/api/restricted_current.txt
index a5bad10..2c7aeb1 100644
--- a/ui/ui-platform/api/restricted_current.txt
+++ b/ui/ui-platform/api/restricted_current.txt
@@ -366,14 +366,10 @@
public abstract class PointerInputFilter {
ctor public PointerInputFilter();
- method public abstract kotlin.jvm.functions.Function0<kotlin.Unit> getCancelHandler();
- method public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? getCustomEventHandler();
- method public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? getInitHandler();
- method public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> getPointerInputHandler();
- property public abstract kotlin.jvm.functions.Function0<kotlin.Unit> cancelHandler;
- property public kotlin.jvm.functions.Function2<androidx.ui.core.CustomEvent,androidx.ui.core.PointerEventPass,kotlin.Unit>? customEventHandler;
- property public kotlin.jvm.functions.Function1<androidx.ui.core.CustomEventDispatcher,kotlin.Unit>? initHandler;
- property public abstract kotlin.jvm.functions.Function3<java.util.List<androidx.ui.core.PointerInputChange>,androidx.ui.core.PointerEventPass,androidx.ui.unit.IntPxSize,java.util.List<androidx.ui.core.PointerInputChange>> pointerInputHandler;
+ method public abstract void onCancel();
+ method public void onCustomEvent(androidx.ui.core.CustomEvent customEvent, androidx.ui.core.PointerEventPass pass);
+ method public void onInit(androidx.ui.core.CustomEventDispatcher customEventDispatcher);
+ method public abstract java.util.List<androidx.ui.core.PointerInputChange> onPointerInput(java.util.List<androidx.ui.core.PointerInputChange> changes, androidx.ui.core.PointerEventPass pass, androidx.ui.unit.IntPxSize bounds);
}
public interface PointerInputModifier extends androidx.ui.core.Modifier.Element {
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/HitPathTracker.kt b/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/HitPathTracker.kt
index 609ba0a..f80bd98 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/HitPathTracker.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/HitPathTracker.kt
@@ -66,7 +66,7 @@
// TODO(shepshapard): Is CustomEventDispatcherImpl instantiated even if initHandler is
// null?
- pointerInputFilter.initHandler?.invoke(
+ pointerInputFilter.onInit(
CustomEventDispatcherImpl(
node,
this
@@ -152,7 +152,7 @@
/**
* Dispatches cancel events to all tracked [PointerInputFilter]s to notify them that
- * [PointerInputFilter.pointerInputHandler] will not be called again until all pointers have been
+ * [PointerInputFilter.onPointerInput] will not be called again until all pointers have been
* removed from the application and then at least one is added again, and removes all tracked
* data.
*/
@@ -373,7 +373,7 @@
}
if (this != dispatchingNode) {
- pointerInputFilter.customEventHandler?.invoke(event, downPass)
+ pointerInputFilter.onCustomEvent(event, downPass)
}
// Call children recursively with the relevant changes.
@@ -382,7 +382,7 @@
}
if (upPass != null && this != dispatchingNode) {
- pointerInputFilter.customEventHandler?.invoke(event, upPass)
+ pointerInputFilter.onCustomEvent(event, upPass)
}
}
@@ -390,12 +390,12 @@
// essentially "no", but given that an order can be consistent... maybe we might as well
// set an arbitrary standard and stick to it so user expectations are maintained.
/**
- * Does a depth first traversal and invokes [PointerInputFilter.cancelHandler] during
+ * Does a depth first traversal and invokes [PointerInputFilter.onCancel] during
* backtracking.
*/
override fun dispatchCancel() {
children.forEach { it.dispatchCancel() }
- pointerInputFilter.cancelHandler.invoke()
+ pointerInputFilter.onCancel()
}
override fun toString(): String {
@@ -408,7 +408,7 @@
pass: PointerEventPass,
size: IntPxSize
) {
- filter.pointerInputHandler(values.toList(), pass, size).forEach {
+ filter.onPointerInput(values.toList(), pass, size).forEach {
this[it.id] = it
}
}
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInput.kt b/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInput.kt
index 484272a..fa572ee 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInput.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInput.kt
@@ -22,7 +22,6 @@
import androidx.ui.core.Modifier
import androidx.ui.core.PointerEventPass
import androidx.ui.core.PointerInputChange
-import androidx.ui.core.PointerInputHandler
import androidx.ui.core.PointerInputNode
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
@@ -45,37 +44,55 @@
/**
* Invoked when pointers that previously hit this [PointerInputFilter] have changed.
+ *
+ * @param changes The list of [PointerInputChange]s with positions relative to this
+ * [PointerInputFilter].
+ * @param pass The [PointerEventPass] in which this function is being called.
+ * @param bounds The width and height associated with this [PointerInputFilter].
+ * @return The list of [PointerInputChange]s after any aspect of the changes have been consumed.
+ *
+ * @see PointerInputChange
+ * @see PointerEventPass
*/
- abstract val pointerInputHandler: PointerInputHandler
+ abstract fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange>
/**
* Invoked to notify the handler that no more calls to [PointerInputFilter] will be made, until
* at least new pointers exist. This can occur for a few reasons:
- * 1. Android dispatches ACTION_CANCEL to AndroidComposeView.onTouchEvent.
- * 2. This [PointerInputFilter] is no longer associated with a Layout
+ * 1. Android dispatches ACTION_CANCEL to Compose.
+ * 2. This [PointerInputFilter] is no longer associated with a LayoutNode.
* 3. This [PointerInputFilter]'s associated LayoutNode is no longer in the composition tree.
*/
- abstract val cancelHandler: () -> Unit
+ abstract fun onCancel()
/**
* Invoked right after this [PointerInputFilter] is hit by a pointer during hit testing.
*
+ * @param customEventDispatcher The [CustomEventDispatcher] that can be used to dispatch
+ * [CustomEvent] across the tree of hit [PointerInputFilter]s.
+ *
* @See CustomEventDispatcher
*/
- open val initHandler: ((CustomEventDispatcher) -> Unit)? = null
+ open fun onInit(customEventDispatcher: CustomEventDispatcher) {}
/**
* Invoked when a [CustomEvent] is dispatched by a [PointerInputNode].
*
* Dispatch occurs over all passes of [PointerEventPass].
*
- * The [CustomEvent] is the event being dispatched. The [PointerEventPass] is the pass that
- * dispatch is currently on.
+ * @param customEvent The [CustomEvent] is the event being dispatched.
+ * @param pass The [PointerEventPass] in which this function is being called.
*
* @see CustomEvent
* @see PointerEventPass
*/
- open val customEventHandler: ((CustomEvent, PointerEventPass) -> Unit)? = null
+ open fun onCustomEvent(customEvent: CustomEvent, pass: PointerEventPass) {}
+
+ internal lateinit var layoutCoordinates: LayoutCoordinates
internal val size: IntPxSize
get() = layoutCoordinates.size
@@ -83,6 +100,4 @@
get() = layoutCoordinates.localToGlobal(PxPosition.Origin).round()
internal val isAttached: Boolean
get() = layoutCoordinates.isAttached
-
- internal lateinit var layoutCoordinates: LayoutCoordinates
}
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInputEventProcessor.kt b/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInputEventProcessor.kt
index eec7cda..fdca64d 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInputEventProcessor.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/pointerinput/PointerInputEventProcessor.kt
@@ -76,7 +76,7 @@
/**
* Responds appropriately to Android ACTION_CANCEL events.
*
- * Specifically, [PointerInputFilter.cancelHandler] is invoked on tracked [PointerInputFilter]s and
+ * Specifically, [PointerInputFilter.onCancel] is invoked on tracked [PointerInputFilter]s and
* and this [PointerInputEventProcessor] is reset such that it is no longer tracking any
* [PointerInputFilter]s and expects the next [PointerInputEvent] it processes to represent only
* new pointers.
diff --git a/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt b/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt
index 18ff616..737c30a 100644
--- a/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt
+++ b/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/HitPathTrackerTest.kt
@@ -23,6 +23,7 @@
import androidx.ui.core.LayoutCoordinates
import androidx.ui.core.PointerEventPass
import androidx.ui.core.PointerId
+import androidx.ui.core.PointerInputChange
import androidx.ui.core.PointerInputHandler
import androidx.ui.core.consumeDownChange
import androidx.ui.core.consumePositionChange
@@ -42,8 +43,8 @@
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.never
import com.nhaarman.mockitokotlin2.spy
+import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
-import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -184,24 +185,24 @@
@Test
fun addHitPath_1NodeAdded_initHandlerCalledWithValidCustomMessageDispatcher() {
- val pif = PointerInputFilterMock()
+ val pif: PointerInputFilter = mock()
hitPathTracker.addHitPath(PointerId(3), listOf(pif))
- verify(pif.initHandler)!!.invoke(any())
+ verify(pif).onInit(any())
}
@Test
fun addHitPath_3NodesAdded_allIitHandlersCalledWithValidCustomMessageDispatcher() {
- val pifParent = PointerInputFilterMock()
- val pifMiddle = PointerInputFilterMock()
- val pifChild = PointerInputFilterMock()
+ val pifParent: PointerInputFilter = mock()
+ val pifMiddle: PointerInputFilter = mock()
+ val pifChild: PointerInputFilter = mock()
hitPathTracker.addHitPath(PointerId(3), listOf(pifParent, pifMiddle, pifChild))
- verify(pifParent.initHandler)!!.invoke(any())
- verify(pifMiddle.initHandler)!!.invoke(any())
- verify(pifChild.initHandler)!!.invoke(any())
+ verify(pifParent).onInit(any())
+ verify(pifMiddle).onInit(any())
+ verify(pifChild).onInit(any())
}
@Test
@@ -211,17 +212,19 @@
@Test
fun dispatchChanges_hitResultHasSingleMatch_pointerInputHandlerCalled() {
- val pif1: PointerInputFilter = PointerInputFilterMock()
- hitPathTracker.addHitPath(PointerId(13), listOf(pif1))
+ val pif: PointerInputFilter = PointerInputFilterMock()
+ hitPathTracker.addHitPath(PointerId(13), listOf(pif))
hitPathTracker.dispatchChanges(listOf(down(13)), PointerEventPass.InitialDown)
- verify(pif1.pointerInputHandler).invoke(
+ // Verify call count
+ verify(pif).onPointerInput(any(), any(), any())
+ // Verify call values
+ verify(pif).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
- verifyNoMoreInteractions(pif1.pointerInputHandler)
}
@Test
@@ -233,28 +236,28 @@
hitPathTracker.dispatchChanges(listOf(down(13)), PointerEventPass.InitialDown)
- inOrder(pif1.pointerInputHandler, pif2.pointerInputHandler, pif3.pointerInputHandler) {
- verify(pif1.pointerInputHandler).invoke(
+ // Verify call count
+ verify(pif1).onPointerInput(any(), any(), any())
+ verify(pif2).onPointerInput(any(), any(), any())
+ verify(pif3).onPointerInput(any(), any(), any())
+ // Verify call order and values
+ inOrder(pif1, pif2, pif3) {
+ verify(pif1).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
}
- verifyNoMoreInteractions(
- pif1.pointerInputHandler,
- pif2.pointerInputHandler,
- pif3.pointerInputHandler
- )
}
@Test
@@ -270,43 +273,43 @@
PointerEventPass.PreUp
)
- inOrder(pif1.pointerInputHandler, pif2.pointerInputHandler, pif3.pointerInputHandler) {
- verify(pif1.pointerInputHandler).invoke(
+ // Verify call count
+ verify(pif1, times(2)).onPointerInput(any(), any(), any())
+ verify(pif2, times(2)).onPointerInput(any(), any(), any())
+ verify(pif3, times(2)).onPointerInput(any(), any(), any())
+ // Verify call order and values
+ inOrder(pif1, pif2, pif3) {
+ verify(pif1).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif1.pointerInputHandler).invoke(
+ verify(pif1).onPointerInput(
eq(listOf(down(13))),
eq(PointerEventPass.PreUp),
any()
)
}
- verifyNoMoreInteractions(
- pif1.pointerInputHandler,
- pif2.pointerInputHandler,
- pif3.pointerInputHandler
- )
}
@Test
@@ -326,56 +329,56 @@
PointerEventPass.PreUp
)
- inOrder(pif1.pointerInputHandler, pif2.pointerInputHandler) {
- verify(pif1.pointerInputHandler).invoke(
+ // Verify call count
+ verify(pif1, times(2)).onPointerInput(any(), any(), any())
+ verify(pif2, times(2)).onPointerInput(any(), any(), any())
+ verify(pif3, times(2)).onPointerInput(any(), any(), any())
+ verify(pif4, times(2)).onPointerInput(any(), any(), any())
+ // Verify call order and values
+ inOrder(pif1, pif2) {
+ verify(pif1).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif1.pointerInputHandler).invoke(
+ verify(pif1).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.PreUp),
any()
)
}
- inOrder(pif3.pointerInputHandler, pif4.pointerInputHandler) {
- verify(pif3.pointerInputHandler).invoke(
+ inOrder(pif3, pif4) {
+ verify(pif3).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif4.pointerInputHandler).invoke(
+ verify(pif4).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif4.pointerInputHandler).invoke(
+ verify(pif4).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.PreUp),
any()
)
}
- verifyNoMoreInteractions(
- pif1.pointerInputHandler,
- pif2.pointerInputHandler,
- pif3.pointerInputHandler,
- pif4.pointerInputHandler
- )
}
@Test
@@ -394,27 +397,32 @@
PointerEventPass.PreUp
)
+ // Verify call count
+ verify(parent, times(2)).onPointerInput(any(), any(), any())
+ verify(child1, times(2)).onPointerInput(any(), any(), any())
+ verify(child2, times(2)).onPointerInput(any(), any(), any())
+
// Verifies that the events traverse between parent and child1 in the correct order.
inOrder(
- parent.pointerInputHandler,
- child1.pointerInputHandler
+ parent,
+ child1
) {
- verify(parent.pointerInputHandler).invoke(
+ verify(parent).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.PreUp),
any()
)
- verify(parent.pointerInputHandler).invoke(
+ verify(parent).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.PreUp),
any()
@@ -423,36 +431,30 @@
// Verifies that the events traverse between parent and child2 in the correct order.
inOrder(
- parent.pointerInputHandler,
- child2.pointerInputHandler
+ parent,
+ child2
) {
- verify(parent.pointerInputHandler).invoke(
+ verify(parent).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.PreUp),
any()
)
- verify(parent.pointerInputHandler).invoke(
+ verify(parent).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.PreUp),
any()
)
}
-
- verifyNoMoreInteractions(
- parent.pointerInputHandler,
- child1.pointerInputHandler,
- child2.pointerInputHandler
- )
}
@Test
@@ -470,16 +472,20 @@
PointerEventPass.PreUp
)
+ // Verify call count
+ verify(child1, times(2)).onPointerInput(any(), any(), any())
+ verify(child2, times(2)).onPointerInput(any(), any(), any())
+
// Verify that order is correct for child1.
inOrder(
- child1.pointerInputHandler
+ child1
) {
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.PreUp),
any()
@@ -488,14 +494,14 @@
// Verify that order is correct for child2.
inOrder(
- child2.pointerInputHandler
+ child2
) {
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.PreUp),
any()
@@ -504,15 +510,15 @@
// Verify that first pass hits child1 before second pass hits child2
inOrder(
- child1.pointerInputHandler,
- child2.pointerInputHandler
+ child1,
+ child2
) {
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.PreUp),
any()
@@ -521,25 +527,20 @@
// Verify that first pass hits child2 before second pass hits child1
inOrder(
- child1.pointerInputHandler,
- child2.pointerInputHandler
+ child1,
+ child2
) {
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.PreUp),
any()
)
}
-
- verifyNoMoreInteractions(
- child1.pointerInputHandler,
- child2.pointerInputHandler
- )
}
@Test
@@ -553,7 +554,7 @@
fun dispatchChanges_hitResultHasSingleMatch_changesAreUpdatedCorrectly() {
val pif1: PointerInputFilter = PointerInputFilterMock(
pointerInputHandler =
- spy(StubPointerInputHandler { changes, pass, _ ->
+ spy(StubPointerInputHandler { changes, _, _ ->
changes.map { it.consumeDownChange() }
})
)
@@ -571,7 +572,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) 2f else 64f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
val pif2: PointerInputFilter = PointerInputFilterMock(
@@ -579,7 +581,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) 4f else 32f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
val pif3: PointerInputFilter = PointerInputFilterMock(
@@ -587,7 +590,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) 8f else 16f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
hitPathTracker.addHitPath(PointerId(13), listOf(pif1, pif2, pif3))
@@ -599,30 +603,30 @@
PointerEventPass.PreUp
)
- verify(pif1.pointerInputHandler).invoke(
+ verify(pif1).onPointerInput(
eq(listOf(change)), eq(PointerEventPass.InitialDown), any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(change.consumePositionChange(0.px, 2.px))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(change.consumePositionChange(0.px, 6.px))), // 2 + 4
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(change.consumePositionChange(0.px, 14.px))), // 2 + 4 + 8
eq(PointerEventPass.PreUp),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(change.consumePositionChange(0.px, 30.px))), // 2 + 4 + 8 + 16
eq(PointerEventPass.PreUp),
any()
)
- verify(pif1.pointerInputHandler).invoke(
+ verify(pif1).onPointerInput(
eq(listOf(change.consumePositionChange(0.px, 62.px))), // 2 + 4 + 8 + 16 + 32
eq(PointerEventPass.PreUp),
any()
@@ -645,7 +649,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) 2f else 12f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
val pif2: PointerInputFilter = PointerInputFilterMock(
@@ -653,7 +658,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) 3f else 6f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
val pif3: PointerInputFilter = PointerInputFilterMock(
@@ -661,7 +667,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) -2f else -12f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
val pif4: PointerInputFilter = PointerInputFilterMock(
@@ -669,7 +676,8 @@
spy(StubPointerInputHandler { changes, pass, _ ->
changes.map {
val yConsume = if (pass == PointerEventPass.InitialDown) -3f else -6f
- it.consumePositionChange(0.px, yConsume.px) }
+ it.consumePositionChange(0.px, yConsume.px)
+ }
})
)
hitPathTracker.addHitPath(PointerId(3), listOf(pif1, pif2))
@@ -683,43 +691,43 @@
PointerEventPass.PreUp
)
- verify(pif1.pointerInputHandler).invoke(
+ verify(pif1).onPointerInput(
eq(listOf(event1)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(event1.consumePositionChange(0.px, 2.px))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif2.pointerInputHandler).invoke(
+ verify(pif2).onPointerInput(
eq(listOf(event1.consumePositionChange(0.px, 5.px))),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif1.pointerInputHandler).invoke(
+ verify(pif1).onPointerInput(
eq(listOf(event1.consumePositionChange(0.px, 11.px))),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif4.pointerInputHandler).invoke(
+ verify(pif4).onPointerInput(
eq(listOf(event2.consumePositionChange(0.px, (-2).px))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(pif4.pointerInputHandler).invoke(
+ verify(pif4).onPointerInput(
eq(listOf(event2.consumePositionChange(0.px, (-5).px))),
eq(PointerEventPass.PreUp),
any()
)
- verify(pif3.pointerInputHandler).invoke(
+ verify(pif3).onPointerInput(
eq(listOf(event2.consumePositionChange(0.px, (-11).px))),
eq(PointerEventPass.PreUp),
any()
@@ -779,32 +787,32 @@
PointerEventPass.PreUp
)
- verify(parent.pointerInputHandler).invoke(
+ verify(parent).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1.consumePositionChange(0.px, 500.px))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event2.consumePositionChange(0.px, (-500).px))),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1.consumePositionChange(0.px, 600.px))),
eq(PointerEventPass.PreUp),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(listOf(event2.consumePositionChange(0.px, (-545).px))),
eq(PointerEventPass.PreUp),
any()
)
- verify(parent.pointerInputHandler).invoke(
+ verify(parent).onPointerInput(
eq(
listOf(
event1.consumePositionChange(0.px, 657.px),
@@ -857,12 +865,12 @@
PointerEventPass.PreUp
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(listOf(event1, event2)),
eq(PointerEventPass.InitialDown),
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(
listOf(
event1.consumePositionChange(0.px, 500.px),
@@ -873,7 +881,7 @@
any()
)
- verify(child2.pointerInputHandler).invoke(
+ verify(child2).onPointerInput(
eq(
listOf(
event1.consumePositionChange(0.px, 600.px),
@@ -883,7 +891,7 @@
eq(PointerEventPass.PreUp),
any()
)
- verify(child1.pointerInputHandler).invoke(
+ verify(child1).onPointerInput(
eq(
listOf(
event1.consumePositionChange(0.px, 657.px),
@@ -914,17 +922,15 @@
// Arrange.
- val neverCalled: () -> Unit = mock()
-
- val pif1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif4 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif5 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif6 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif7 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif8 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val pif9 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val pif1 = PointerInputFilterMock(isAttached = true)
+ val pif2 = PointerInputFilterMock(isAttached = true)
+ val pif3 = PointerInputFilterMock(isAttached = true)
+ val pif4 = PointerInputFilterMock(isAttached = true)
+ val pif5 = PointerInputFilterMock(isAttached = true)
+ val pif6 = PointerInputFilterMock(isAttached = true)
+ val pif7 = PointerInputFilterMock(isAttached = true)
+ val pif8 = PointerInputFilterMock(isAttached = true)
+ val pif9 = PointerInputFilterMock(isAttached = true)
val pointerId1 = PointerId(1)
val pointerId2 = PointerId(2)
@@ -975,34 +981,42 @@
})
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verifyNoMoreInteractions(neverCalled)
+
+ verify(pif1, never()).onCancel()
+ verify(pif2, never()).onCancel()
+ verify(pif3, never()).onCancel()
+ verify(pif4, never()).onCancel()
+ verify(pif5, never()).onCancel()
+ verify(pif7, never()).onCancel()
+ verify(pif8, never()).onCancel()
+ verify(pif9, never()).onCancel()
}
// compositionRoot, root -> middle -> leaf
@Test
fun removeDetachedPointerInputFilters_1PathRootDetached_allRemovedAndCorrectCancels() {
- val root = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root = PointerInputFilterMock(isAttached = false)
+ val middle = PointerInputFilterMock(isAttached = false)
+ val leaf = PointerInputFilterMock(isAttached = false)
hitPathTracker.addHitPath(PointerId(0), listOf(root, middle, leaf))
hitPathTracker.removeDetachedPointerInputFilters()
assertThat(areEqual(hitPathTracker.root, NodeParent())).isTrue()
- inOrder(leaf.cancelHandler, middle.cancelHandler, root.cancelHandler) {
- verify(leaf.cancelHandler).invoke()
- verify(middle.cancelHandler).invoke()
- verify(root.cancelHandler).invoke()
+ inOrder(leaf, middle, root) {
+ verify(leaf).onCancel()
+ verify(middle).onCancel()
+ verify(root).onCancel()
}
}
// compositionRoot -> root, middle -> child
@Test
fun removeDetachedPointerInputFilters_1PathMiddleDetached_removesAndCancelsCorrect() {
- val root = PointerInputFilterMock(cancelHandler = mock(), isAttached = true)
- val middle = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val child = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root = PointerInputFilterMock(isAttached = true)
+ val middle = PointerInputFilterMock(isAttached = false)
+ val child = PointerInputFilterMock(isAttached = false)
val pointerId = PointerId(0)
hitPathTracker.addHitPath(pointerId, listOf(root, middle, child))
@@ -1016,19 +1030,19 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(child.cancelHandler, middle.cancelHandler) {
- verify(child.cancelHandler).invoke()
- verify(middle.cancelHandler).invoke()
+ inOrder(child, middle) {
+ verify(child).onCancel()
+ verify(middle).onCancel()
}
- verify(root.cancelHandler, never()).invoke()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root -> middle, leaf
@Test
fun removeDetachedPointerInputFilters_1PathLeafDetached_removesAndCancelsCorrect() {
- val root = PointerInputFilterMock(cancelHandler = mock(), isAttached = true)
- val middle = PointerInputFilterMock(cancelHandler = mock(), isAttached = true)
- val leaf = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root = PointerInputFilterMock(isAttached = true)
+ val middle = PointerInputFilterMock(isAttached = true)
+ val leaf = PointerInputFilterMock(isAttached = false)
val pointerId = PointerId(0)
hitPathTracker.addHitPath(pointerId, listOf(root, middle, leaf))
@@ -1045,8 +1059,9 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf.cancelHandler).invoke()
- verifyNoMoreInteractions(middle.cancelHandler, root.cancelHandler)
+ verify(leaf).onCancel()
+ verify(middle, never()).onCancel()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root1 -> middle1 -> leaf1
@@ -1055,19 +1070,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots1Detached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = true)
+ val leaf1 = PointerInputFilterMock(isAttached = true)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = true)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val root3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = false)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1101,12 +1114,18 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf3.cancelHandler, middle3.cancelHandler, root3.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
- verify(root3.cancelHandler).invoke()
+
+ verify(leaf1, never()).onCancel()
+ verify(middle1, never()).onCancel()
+ verify(root1, never()).onCancel()
+ verify(leaf2, never()).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(root2, never()).onCancel()
+ inOrder(leaf3, middle3, root3) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
+ verify(root3).onCancel()
}
- verify(neverCalled, never()).invoke()
}
// compositionRoot -> root1, middle1 -> leaf1
@@ -1115,19 +1134,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots1MiddleDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = true)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = true)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1164,11 +1181,17 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
+ inOrder(leaf1, middle1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
}
- verify(neverCalled, never()).invoke()
+ verify(root1, never()).onCancel()
+ verify(leaf2, never()).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(root2, never()).onCancel()
+ verify(leaf3, never()).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root3, never()).onCancel()
}
// compositionRoot -> root1 -> middle1 -> leaf1
@@ -1177,19 +1200,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots1LeafDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = true)
+ val leaf1 = PointerInputFilterMock(isAttached = true)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = true)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1229,8 +1250,15 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf2.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(leaf1, never()).onCancel()
+ verify(middle1, never()).onCancel()
+ verify(root1, never()).onCancel()
+ verify(leaf2).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(root2, never()).onCancel()
+ verify(leaf3, never()).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root3, never()).onCancel()
}
// compositionRoot, root1 -> middle1 -> leaf1
@@ -1239,19 +1267,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots2Detached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = false)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = true)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val root3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = false)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1277,17 +1303,19 @@
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler, root1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
- verify(root1.cancelHandler).invoke()
+ inOrder(leaf1, middle1, root1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
+ verify(root1).onCancel()
}
- inOrder(leaf3.cancelHandler, middle3.cancelHandler, root3.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
- verify(root3.cancelHandler).invoke()
+ verify(leaf2, never()).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(root2, never()).onCancel()
+ inOrder(leaf3, middle3, root3) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
+ verify(root3).onCancel()
}
- verify(neverCalled, never()).invoke()
}
// compositionRoot -> root1, middle1 -> leaf1
@@ -1296,19 +1324,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots2MiddlesDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = true)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1340,15 +1366,19 @@
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
+ inOrder(leaf1, middle1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
+ verify(root1, never()).onCancel()
+ inOrder(leaf2, middle2) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
}
- verify(neverCalled, never()).invoke()
+ verify(root2, never()).onCancel()
+ verify(leaf3, never()).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root3, never()).onCancel()
}
// compositionRoot -> root1 -> middle1 -> leaf1
@@ -1357,19 +1387,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots2LeafsDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = true)
+ val leaf1 = PointerInputFilterMock(isAttached = true)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1406,9 +1434,15 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf2.cancelHandler).invoke()
- verify(leaf3.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(leaf1, never()).onCancel()
+ verify(middle1, never()).onCancel()
+ verify(root1, never()).onCancel()
+ verify(leaf2).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(root2, never()).onCancel()
+ verify(leaf3).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root3, never()).onCancel()
}
// compositionRoot, root1 -> middle1 -> leaf1
@@ -1416,17 +1450,17 @@
// compositionRoot, root3 -> middle3 -> leaf3
@Test
fun removeDetachedPointerInputFilters_3Roots3Detached_allRemovedAndCancelsCorrect() {
- val root1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root1 = PointerInputFilterMock(isAttached = false)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = false)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = false)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
hitPathTracker.addHitPath(PointerId(3), listOf(root1, middle1, leaf1))
hitPathTracker.addHitPath(PointerId(5), listOf(root2, middle2, leaf2))
@@ -1437,20 +1471,20 @@
val expectedRoot = NodeParent()
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler, root1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
- verify(root1.cancelHandler).invoke()
+ inOrder(leaf1, middle1, root1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
+ verify(root1).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler, root2.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
- verify(root2.cancelHandler).invoke()
+ inOrder(leaf2, middle2, root2) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
+ verify(root2).onCancel()
}
- inOrder(leaf3.cancelHandler, middle3.cancelHandler, root3.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
- verify(root3.cancelHandler).invoke()
+ inOrder(leaf3, middle3, root3) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
+ verify(root3).onCancel()
}
}
@@ -1460,19 +1494,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots3MiddlesDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1497,19 +1529,21 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
+ inOrder(leaf1, middle1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
+ verify(root1, never()).onCancel()
+ inOrder(leaf2, middle2) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
}
- inOrder(leaf3.cancelHandler, middle3.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
+ verify(root2, never()).onCancel()
+ inOrder(leaf3, middle3) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
}
- verify(neverCalled, never()).invoke()
+ verify(root3, never()).onCancel()
}
// compositionRoot -> root1 -> middle1, leaf1
@@ -1518,19 +1552,17 @@
@Test
fun removeDetachedPointerInputFilters_3Roots3LeafsDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = true)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1564,10 +1596,15 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf1.cancelHandler).invoke()
- verify(leaf2.cancelHandler).invoke()
- verify(leaf3.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(leaf1).onCancel()
+ verify(middle1, never()).onCancel()
+ verify(root1, never()).onCancel()
+ verify(leaf2).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(root2, never()).onCancel()
+ verify(leaf3).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root3, never()).onCancel()
}
// compositionRoot, root1 -> middle1 -> leaf1
@@ -1576,19 +1613,17 @@
@Test
fun removeDetachedPointerInputFilters_3RootsStaggeredDetached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root1 = PointerInputFilterMock(isAttached = false)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val root1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root2 = PointerInputFilterMock(isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val root2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val root3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root3 = PointerInputFilterMock(isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1613,17 +1648,19 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler, root1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
- verify(root1.cancelHandler).invoke()
+ inOrder(leaf1, middle1, root1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
+ verify(root1).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
+ inOrder(leaf2, middle2) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
}
- verify(leaf3.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(root2, never()).onCancel()
+ verify(leaf3).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root3, never()).onCancel()
}
// compositionRoot, root ->
@@ -1632,16 +1669,16 @@
// middle3 -> leaf3
@Test
fun removeDetachedPointerInputFilters_rootWith3MiddlesDetached_allRemovedAndCorrectCancels() {
- val root = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val root = PointerInputFilterMock(isAttached = false)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
hitPathTracker.addHitPath(PointerId(3), listOf(root, middle1, leaf1))
hitPathTracker.addHitPath(PointerId(5), listOf(root, middle2, leaf2))
@@ -1652,20 +1689,20 @@
val expectedRoot = NodeParent()
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler, root.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
- verify(root.cancelHandler).invoke()
+ inOrder(leaf1, middle1, root) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
+ verify(root).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler, root.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
- verify(root.cancelHandler).invoke()
+ inOrder(leaf2, middle2, root) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
+ verify(root).onCancel()
}
- inOrder(leaf3.cancelHandler, middle3.cancelHandler, root.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
- verify(root.cancelHandler).invoke()
+ inOrder(leaf3, middle3, root) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
+ verify(root).onCancel()
}
}
@@ -1676,18 +1713,16 @@
@Test
fun removeDetachedPointerInputFilters_rootWith3Middles1Detached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root = PointerInputFilterMock(isAttached = true)
- val root = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = true)
+ val leaf1 = PointerInputFilterMock(isAttached = true)
- val middle1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle2 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = true)
- val middle2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1720,11 +1755,15 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf3.cancelHandler, middle3.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
+ inOrder(leaf3, middle3) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
}
- verify(neverCalled, never()).invoke()
+ verify(leaf2, never()).onCancel()
+ verify(middle2, never()).onCancel()
+ verify(leaf1, never()).onCancel()
+ verify(middle1, never()).onCancel()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root
@@ -1734,18 +1773,16 @@
@Test
fun removeDetachedPointerInputFilters_rootWith3Middles2Detached_removesAndCancelsCorrect() {
- val neverCalled: () -> Unit = mock()
+ val root = PointerInputFilterMock(isAttached = true)
- val root = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val middle3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle3 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = true)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1772,15 +1809,17 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
+ inOrder(leaf1, middle1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
+ inOrder(leaf2, middle2) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
}
- verify(neverCalled, never()).invoke()
+ verify(leaf3, never()).onCancel()
+ verify(middle3, never()).onCancel()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root
@@ -1790,18 +1829,16 @@
@Test
fun removeDetachedPointerInputFilters_rootWith3MiddlesAllDetached_allMiddlesRemoved() {
- val neverCalled: () -> Unit = mock()
+ val root = PointerInputFilterMock(isAttached = true)
- val root = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle1 = PointerInputFilterMock(isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
- val middle1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle2 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
- val middle2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
-
- val middle3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val middle3 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1822,19 +1859,19 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- inOrder(leaf1.cancelHandler, middle1.cancelHandler) {
- verify(leaf1.cancelHandler).invoke()
- verify(middle1.cancelHandler).invoke()
+ inOrder(leaf1, middle1) {
+ verify(leaf1).onCancel()
+ verify(middle1).onCancel()
}
- inOrder(leaf2.cancelHandler, middle2.cancelHandler) {
- verify(leaf2.cancelHandler).invoke()
- verify(middle2.cancelHandler).invoke()
+ inOrder(leaf2, middle2) {
+ verify(leaf2).onCancel()
+ verify(middle2).onCancel()
}
- inOrder(leaf3.cancelHandler, middle3.cancelHandler) {
- verify(leaf3.cancelHandler).invoke()
- verify(middle3.cancelHandler).invoke()
+ inOrder(leaf3, middle3) {
+ verify(leaf3).onCancel()
+ verify(middle3).onCancel()
}
- verify(neverCalled, never()).invoke()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root -> middle
@@ -1844,15 +1881,13 @@
@Test
fun removeDetachedPointerInputFilters_middleWith3Leafs1Detached_correctLeafRemoved() {
- val neverCalled: () -> Unit = mock()
+ val root = PointerInputFilterMock(isAttached = true)
- val root = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle = PointerInputFilterMock(isAttached = true)
- val middle = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val leaf1 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val leaf1 = PointerInputFilterMock(isAttached = true)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = true)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1884,8 +1919,11 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf2.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(leaf1, never()).onCancel()
+ verify(leaf2).onCancel()
+ verify(leaf3, never()).onCancel()
+ verify(middle, never()).onCancel()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root -> middle
@@ -1895,15 +1933,13 @@
@Test
fun removeDetachedPointerInputFilters_middleWith3Leafs2Detached_correctLeafsRemoved() {
- val neverCalled: () -> Unit = mock()
+ val root = PointerInputFilterMock(isAttached = true)
- val root = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle = PointerInputFilterMock(isAttached = true)
- val middle = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = true)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1932,9 +1968,11 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf1.cancelHandler).invoke()
- verify(leaf3.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(leaf1).onCancel()
+ verify(leaf2, never()).onCancel()
+ verify(leaf3).onCancel()
+ verify(middle, never()).onCancel()
+ verify(root, never()).onCancel()
}
// compositionRoot -> root -> middle
@@ -1944,15 +1982,13 @@
@Test
fun removeDetachedPointerInputFilters_middleWith3LeafsAllDetached_allLeafsRemoved() {
- val neverCalled: () -> Unit = mock()
+ val root = PointerInputFilterMock(isAttached = true)
- val root = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
+ val middle = PointerInputFilterMock(isAttached = true)
- val middle = PointerInputFilterMock(cancelHandler = neverCalled, isAttached = true)
-
- val leaf1 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf2 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
- val leaf3 = PointerInputFilterMock(cancelHandler = mock(), isAttached = false)
+ val leaf1 = PointerInputFilterMock(isAttached = false)
+ val leaf2 = PointerInputFilterMock(isAttached = false)
+ val leaf3 = PointerInputFilterMock(isAttached = false)
val pointerId1 = PointerId(3)
val pointerId2 = PointerId(5)
@@ -1978,10 +2014,11 @@
}
assertThat(areEqual(hitPathTracker.root, expectedRoot)).isTrue()
- verify(leaf1.cancelHandler).invoke()
- verify(leaf2.cancelHandler).invoke()
- verify(leaf3.cancelHandler).invoke()
- verify(neverCalled, never()).invoke()
+ verify(leaf1).onCancel()
+ verify(leaf2).onCancel()
+ verify(leaf3).onCancel()
+ verify(middle, never()).onCancel()
+ verify(root, never()).onCancel()
}
// arrange: root(3) -> middle(3) -> leaf(3)
@@ -2241,7 +2278,7 @@
hitPathTracker.processCancel()
- verify(pointerInputNode.cancelHandler).invoke()
+ verify(pointerInputNode).onCancel()
}
// Pin -> Pin -> Pin
@@ -2258,13 +2295,13 @@
hitPathTracker.processCancel()
inOrder(
- pointerInputNodeParent.cancelHandler,
- pointerInputNodeMiddle.cancelHandler,
- pointerInputNodeChild.cancelHandler
+ pointerInputNodeParent,
+ pointerInputNodeMiddle,
+ pointerInputNodeChild
) {
- verify(pointerInputNodeChild.cancelHandler).invoke()
- verify(pointerInputNodeMiddle.cancelHandler).invoke()
- verify(pointerInputNodeParent.cancelHandler).invoke()
+ verify(pointerInputNodeChild).onCancel()
+ verify(pointerInputNodeMiddle).onCancel()
+ verify(pointerInputNodeParent).onCancel()
}
}
@@ -2282,20 +2319,14 @@
hitPathTracker.processCancel()
- inOrder(pifParent1.cancelHandler, pifChild1.cancelHandler) {
- verify(pifChild1.cancelHandler).invoke()
- verify(pifParent1.cancelHandler).invoke()
+ inOrder(pifParent1, pifChild1) {
+ verify(pifChild1).onCancel()
+ verify(pifParent1).onCancel()
}
- inOrder(pifParent2.cancelHandler, pifChild2.cancelHandler) {
- verify(pifChild2.cancelHandler).invoke()
- verify(pifParent2.cancelHandler).invoke()
+ inOrder(pifParent2, pifChild2) {
+ verify(pifChild2).onCancel()
+ verify(pifParent2).onCancel()
}
- verifyNoMoreInteractions(
- pifParent1.cancelHandler,
- pifChild1.cancelHandler,
- pifParent2.cancelHandler,
- pifChild2.cancelHandler
- )
}
// PIN -> PIN
@@ -2310,19 +2341,14 @@
hitPathTracker.processCancel()
- inOrder(pifParent.cancelHandler, pifChild1.cancelHandler) {
- verify(pifChild1.cancelHandler).invoke()
- verify(pifParent.cancelHandler).invoke()
+ inOrder(pifParent, pifChild1) {
+ verify(pifChild1).onCancel()
+ verify(pifParent).onCancel()
}
- inOrder(pifParent.cancelHandler, pifChild2.cancelHandler) {
- verify(pifChild2.cancelHandler).invoke()
- verify(pifParent.cancelHandler).invoke()
+ inOrder(pifParent, pifChild2) {
+ verify(pifChild2).onCancel()
+ verify(pifParent).onCancel()
}
- verifyNoMoreInteractions(
- pifParent.cancelHandler,
- pifChild1.cancelHandler,
- pifChild2.cancelHandler
- )
}
// Pin -> Ln
@@ -2404,7 +2430,7 @@
// Assert
- verifyNoMoreInteractions(pif.customEventHandler!!)
+ verify(pif, never()).onCustomEvent(any(), any())
}
@Test
@@ -2436,35 +2462,41 @@
lateinit var middlePif: PointerInputFilter
lateinit var childPif: PointerInputFilter
- val dispatchingHandler: (CustomEvent, PointerEventPass) -> Unit = mock()
- val seniorHandler: (CustomEvent, PointerEventPass) -> Unit = mock()
- val juniorHandler: (CustomEvent, PointerEventPass) -> Unit = mock()
+ lateinit var pifThatDispatches: PointerInputFilter
+ lateinit var seniorPif: PointerInputFilter
+ lateinit var juniorPif: PointerInputFilter
val dispatcherInitHandler: (CustomEventDispatcher) -> Unit = { dispatcher = it }
when (dispatchingPif) {
DispatchingPif.Parent -> {
parentPif = PointerInputFilterMock(
- customEventHandler = dispatchingHandler,
initHandler = dispatcherInitHandler
)
- middlePif = PointerInputFilterMock(customEventHandler = seniorHandler)
- childPif = PointerInputFilterMock(customEventHandler = juniorHandler)
+ pifThatDispatches = parentPif
+ middlePif = PointerInputFilterMock()
+ seniorPif = middlePif
+ childPif = PointerInputFilterMock()
+ juniorPif = childPif
}
DispatchingPif.Middle -> {
- parentPif = PointerInputFilterMock(customEventHandler = seniorHandler)
+ parentPif = PointerInputFilterMock()
+ seniorPif = parentPif
middlePif = PointerInputFilterMock(
- customEventHandler = dispatchingHandler,
initHandler = dispatcherInitHandler
)
- childPif = PointerInputFilterMock(customEventHandler = juniorHandler)
+ pifThatDispatches = middlePif
+ childPif = PointerInputFilterMock()
+ juniorPif = childPif
}
DispatchingPif.Child -> {
- parentPif = PointerInputFilterMock(customEventHandler = seniorHandler)
- middlePif = PointerInputFilterMock(customEventHandler = juniorHandler)
+ parentPif = PointerInputFilterMock()
+ seniorPif = parentPif
+ middlePif = PointerInputFilterMock()
+ juniorPif = middlePif
childPif = PointerInputFilterMock(
- customEventHandler = dispatchingHandler,
initHandler = dispatcherInitHandler
)
+ pifThatDispatches = childPif
}
}
@@ -2478,20 +2510,21 @@
// Assert
- inOrder(seniorHandler, juniorHandler) {
- verify(seniorHandler).invoke(event, PointerEventPass.InitialDown)
- verify(juniorHandler).invoke(event, PointerEventPass.InitialDown)
- verify(juniorHandler).invoke(event, PointerEventPass.PreUp)
- verify(seniorHandler).invoke(event, PointerEventPass.PreUp)
- verify(seniorHandler).invoke(event, PointerEventPass.PreDown)
- verify(juniorHandler).invoke(event, PointerEventPass.PreDown)
- verify(juniorHandler).invoke(event, PointerEventPass.PostUp)
- verify(seniorHandler).invoke(event, PointerEventPass.PostUp)
- verify(seniorHandler).invoke(event, PointerEventPass.PostDown)
- verify(juniorHandler).invoke(event, PointerEventPass.PostDown)
+ verify(seniorPif, times(5)).onCustomEvent(any(), any())
+ verify(juniorPif, times(5)).onCustomEvent(any(), any())
+ inOrder(seniorPif, juniorPif) {
+ verify(seniorPif).onCustomEvent(event, PointerEventPass.InitialDown)
+ verify(juniorPif).onCustomEvent(event, PointerEventPass.InitialDown)
+ verify(juniorPif).onCustomEvent(event, PointerEventPass.PreUp)
+ verify(seniorPif).onCustomEvent(event, PointerEventPass.PreUp)
+ verify(seniorPif).onCustomEvent(event, PointerEventPass.PreDown)
+ verify(juniorPif).onCustomEvent(event, PointerEventPass.PreDown)
+ verify(juniorPif).onCustomEvent(event, PointerEventPass.PostUp)
+ verify(seniorPif).onCustomEvent(event, PointerEventPass.PostUp)
+ verify(seniorPif).onCustomEvent(event, PointerEventPass.PostDown)
+ verify(juniorPif).onCustomEvent(event, PointerEventPass.PostDown)
}
-
- verifyNoMoreInteractions(seniorHandler, juniorHandler, dispatchingHandler)
+ verify(pifThatDispatches, never()).onCustomEvent(any(), any())
}
@Test
@@ -2499,15 +2532,9 @@
lateinit var dispatcher: CustomEventDispatcher
- val parentHandler: (CustomEvent, PointerEventPass) -> Unit = mock()
- val childHandler1: (CustomEvent, PointerEventPass) -> Unit = mock()
- val childHandler2: (CustomEvent, PointerEventPass) -> Unit = mock()
-
- val parentPin = PointerInputFilterMock(initHandler = {
- dispatcher = it
- })
- val childPin1 = PointerInputFilterMock(customEventHandler = childHandler1)
- val childPin2 = PointerInputFilterMock(customEventHandler = childHandler2)
+ val parentPin = PointerInputFilterMock(initHandler = { dispatcher = it })
+ val childPin1 = PointerInputFilterMock()
+ val childPin2 = PointerInputFilterMock()
hitPathTracker.addHitPath(PointerId(3), listOf(parentPin, childPin1))
hitPathTracker.addHitPath(PointerId(4), listOf(parentPin, childPin2))
@@ -2519,23 +2546,21 @@
dispatcher.dispatchCustomEvent(event)
// Assert
- inOrder(childHandler1) {
- verify(childHandler1).invoke(event, PointerEventPass.InitialDown)
- verify(childHandler1).invoke(event, PointerEventPass.PreUp)
- verify(childHandler1).invoke(event, PointerEventPass.PreDown)
- verify(childHandler1).invoke(event, PointerEventPass.PostUp)
- verify(childHandler1).invoke(event, PointerEventPass.PostDown)
+ inOrder(childPin1) {
+ verify(childPin1).onCustomEvent(event, PointerEventPass.InitialDown)
+ verify(childPin1).onCustomEvent(event, PointerEventPass.PreUp)
+ verify(childPin1).onCustomEvent(event, PointerEventPass.PreDown)
+ verify(childPin1).onCustomEvent(event, PointerEventPass.PostUp)
+ verify(childPin1).onCustomEvent(event, PointerEventPass.PostDown)
}
-
- inOrder(childHandler2) {
- verify(childHandler2).invoke(event, PointerEventPass.InitialDown)
- verify(childHandler2).invoke(event, PointerEventPass.PreUp)
- verify(childHandler2).invoke(event, PointerEventPass.PreDown)
- verify(childHandler2).invoke(event, PointerEventPass.PostUp)
- verify(childHandler2).invoke(event, PointerEventPass.PostDown)
+ inOrder(childPin2) {
+ verify(childPin2).onCustomEvent(event, PointerEventPass.InitialDown)
+ verify(childPin2).onCustomEvent(event, PointerEventPass.PreUp)
+ verify(childPin2).onCustomEvent(event, PointerEventPass.PreDown)
+ verify(childPin2).onCustomEvent(event, PointerEventPass.PostUp)
+ verify(childPin2).onCustomEvent(event, PointerEventPass.PostDown)
}
-
- verifyNoMoreInteractions(parentHandler, childHandler1, childHandler2)
+ verify(parentPin, never()).onCustomEvent(any(), any())
}
@Test
@@ -2557,11 +2582,7 @@
) {
// Arrange
- val parentHandler: (CustomEvent, PointerEventPass) -> Unit = mock()
- val childHandler1: (CustomEvent, PointerEventPass) -> Unit = mock()
- val childHandler2: (CustomEvent, PointerEventPass) -> Unit = mock()
-
- val parentPif = PointerInputFilterMock(customEventHandler = parentHandler)
+ val parentPif = PointerInputFilterMock()
lateinit var childPif1: PointerInputFilter
lateinit var childPif2: PointerInputFilter
@@ -2570,15 +2591,13 @@
if (firstChildDispatches) {
childPif1 = PointerInputFilterMock(
- initHandler = initHandler,
- customEventHandler = childHandler1
+ initHandler = initHandler
)
- childPif2 = PointerInputFilterMock(customEventHandler = childHandler2)
+ childPif2 = PointerInputFilterMock()
} else {
- childPif1 = PointerInputFilterMock(customEventHandler = childHandler1)
+ childPif1 = PointerInputFilterMock()
childPif2 = PointerInputFilterMock(
- initHandler = initHandler, customEventHandler =
- childHandler2
+ initHandler = initHandler
)
}
@@ -2592,15 +2611,15 @@
dispatcher.dispatchCustomEvent(event)
// Assert
- inOrder(parentHandler) {
- verify(parentHandler).invoke(event, PointerEventPass.InitialDown)
- verify(parentHandler).invoke(event, PointerEventPass.PreUp)
- verify(parentHandler).invoke(event, PointerEventPass.PreDown)
- verify(parentHandler).invoke(event, PointerEventPass.PostUp)
- verify(parentHandler).invoke(event, PointerEventPass.PostDown)
+ inOrder(parentPif) {
+ verify(parentPif).onCustomEvent(event, PointerEventPass.InitialDown)
+ verify(parentPif).onCustomEvent(event, PointerEventPass.PreUp)
+ verify(parentPif).onCustomEvent(event, PointerEventPass.PreDown)
+ verify(parentPif).onCustomEvent(event, PointerEventPass.PostUp)
+ verify(parentPif).onCustomEvent(event, PointerEventPass.PostDown)
}
-
- verifyNoMoreInteractions(parentHandler, childHandler1, childHandler2)
+ verify(childPif1, never()).onCustomEvent(any(), any())
+ verify(childPif1, never()).onCustomEvent(any(), any())
}
private fun areEqual(actualNode: NodeParent, expectedNode: NodeParent): Boolean {
@@ -2650,27 +2669,38 @@
fun PointerInputFilterMock(
initHandler: (CustomEventDispatcher) -> Unit = mock(),
pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler()),
- customEventHandler: (CustomEvent, PointerEventPass) -> Unit = mock(),
- cancelHandler: () -> Unit = mock(),
isAttached: Boolean = true
): PointerInputFilter =
spy(
PointerInputFilterStub(
pointerInputHandler,
- cancelHandler,
- initHandler,
- customEventHandler
+ initHandler
).apply {
layoutCoordinates = LayoutCoordinatesStub(isAttached)
}
)
open class PointerInputFilterStub(
- override val pointerInputHandler: PointerInputHandler,
- override val cancelHandler: () -> Unit,
- override val initHandler: (CustomEventDispatcher) -> Unit = { _ -> },
- override val customEventHandler: (CustomEvent, PointerEventPass) -> Unit = { _, _ -> }
-) : PointerInputFilter()
+ val pointerInputHandler: PointerInputHandler,
+ val initHandler: (CustomEventDispatcher) -> Unit
+) : PointerInputFilter() {
+
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+ return pointerInputHandler(changes, pass, bounds)
+ }
+
+ override fun onCancel() {}
+
+ override fun onInit(customEventDispatcher: CustomEventDispatcher) {
+ initHandler(customEventDispatcher)
+ }
+
+ override fun onCustomEvent(customEvent: CustomEvent, pass: PointerEventPass) {}
+}
internal data class TestCustomEvent(val value: String) : CustomEvent
diff --git a/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt b/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt
index e0d5709..613f792 100644
--- a/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt
+++ b/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/PointerInputEventProcessorTest.kt
@@ -22,8 +22,6 @@
import androidx.ui.core.Modifier
import androidx.ui.core.Owner
import androidx.ui.core.PointerEventPass
-import androidx.ui.core.PointerEventPass.InitialDown
-import androidx.ui.core.PointerEventPass.PreUp
import androidx.ui.core.PointerId
import androidx.ui.core.PointerInputChange
import androidx.ui.core.PointerInputData
@@ -43,7 +41,6 @@
import com.nhaarman.mockitokotlin2.spy
import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
-import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -92,14 +89,14 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
0,
0,
500,
500,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler)
+ pointerInputFilter
)
)
@@ -141,10 +138,17 @@
// Assert
- inOrder(pointerInputHandler) {
+ // Verify call count
+ verify(
+ pointerInputFilter,
+ times(PointerEventPass.values().size * expectedChanges.size)
+ ).onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter) {
for (expected in expectedChanges) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expected)),
eq(pass),
any()
@@ -160,11 +164,11 @@
// Arrange
val childOffset = PxPosition(100.px, 200.px)
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
100, 200, 301, 401,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler)
+ pointerInputFilter
)
)
@@ -202,15 +206,17 @@
// Assert
- verify(pointerInputHandler, times(4)).invoke(
+ // Verify call count
+ verify(pointerInputFilter, times(expectedChanges.size)).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
+ // Verify call values
for (expected in expectedChanges) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expected)),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
}
@@ -221,11 +227,11 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
100, 200, 301, 401,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler)
+ pointerInputFilter
)
)
@@ -254,7 +260,7 @@
// Assert
- verify(pointerInputHandler, never()).invoke(any(), any(), any())
+ verify(pointerInputFilter, never()).onPointerInput(any(), any(), any())
}
@Test
@@ -275,22 +281,22 @@
private fun process_partialTreeHits(numberOfChildrenHit: Int) {
// Arrange
- val childPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val middlePointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val parentPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter: PointerInputFilter = spy()
+ val middlePointerInputFilter: PointerInputFilter = spy()
+ val parentPointerInputFilter: PointerInputFilter = spy()
val childLayoutNode =
LayoutNode(
100, 100, 200, 200,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler)
+ childPointerInputFilter
)
)
val middleLayoutNode: LayoutNode =
LayoutNode(
100, 100, 400, 400,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = middlePointerInputHandler)
+ middlePointerInputFilter
)
).apply {
insertAt(0, childLayoutNode)
@@ -299,7 +305,7 @@
LayoutNode(
0, 0, 500, 500,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = parentPointerInputHandler)
+ parentPointerInputFilter
)
).apply {
insertAt(0, middleLayoutNode)
@@ -323,51 +329,51 @@
when (numberOfChildrenHit) {
3 -> {
- verify(parentPointerInputHandler).invoke(
+ verify(parentPointerInputFilter).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
- verify(middlePointerInputHandler).invoke(
+ verify(middlePointerInputFilter).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
- verify(childPointerInputHandler).invoke(
+ verify(childPointerInputFilter).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
}
2 -> {
- verify(parentPointerInputHandler).invoke(
+ verify(parentPointerInputFilter).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
- verify(middlePointerInputHandler).invoke(
+ verify(middlePointerInputFilter).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
- verify(childPointerInputHandler, never()).invoke(
+ verify(childPointerInputFilter, never()).onPointerInput(
any(),
any(),
any()
)
}
1 -> {
- verify(parentPointerInputHandler).invoke(
+ verify(parentPointerInputFilter).onPointerInput(
any(),
- eq(InitialDown),
+ eq(PointerEventPass.InitialDown),
any()
)
- verify(middlePointerInputHandler, never()).invoke(
+ verify(middlePointerInputFilter, never()).onPointerInput(
any(),
any(),
any()
)
- verify(childPointerInputHandler, never()).invoke(
+ verify(childPointerInputFilter, never()).onPointerInput(
any(),
any(),
any()
@@ -403,20 +409,23 @@
consumed = ConsumedData(positionChange = PxPosition(13.px, 0.px))
)
- val pointerInputHandler: PointerInputHandler =
- spy(StubPointerInputHandler { changes, pass, _ ->
- if (changes == listOf(input) &&
- pass == InitialDown
- ) {
- listOf(output)
- } else {
- changes
+ val pointerInputFilter: PointerInputFilter =
+ spy(
+ TestPointerInputFilter { changes, pass, _ ->
+ if (changes == listOf(input) &&
+ pass == PointerEventPass.InitialDown
+ ) {
+ listOf(output)
+ } else {
+ changes
+ }
}
- })
+ )
+
val layoutNode = LayoutNode(
0, 0, 500, 500,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler)
+ pointerInputFilter
)
)
@@ -438,15 +447,15 @@
// Act
pointerInputEventProcessor.process(down)
- reset(pointerInputHandler)
+ reset(pointerInputFilter)
pointerInputEventProcessor.process(move)
// Assert
- verify(pointerInputHandler)
- .invoke(eq(listOf(input)), eq(InitialDown), any())
- verify(pointerInputHandler)
- .invoke(eq(listOf(output)), eq(PreUp), any())
+ verify(pointerInputFilter)
+ .onPointerInput(eq(listOf(input)), eq(PointerEventPass.InitialDown), any())
+ verify(pointerInputFilter)
+ .onPointerInput(eq(listOf(output)), eq(PointerEventPass.PreUp), any())
}
@Test
@@ -504,22 +513,22 @@
// Arrange
- val childPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val middlePointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val parentPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter: PointerInputFilter = spy()
+ val middlePointerInputFilter: PointerInputFilter = spy()
+ val parentPointerInputFilter: PointerInputFilter = spy()
val childOffset = PxPosition(cX1.px, cY1.px)
val childLayoutNode = LayoutNode(
cX1, cY1, cX2, cY2,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler)
+ childPointerInputFilter
)
)
val middleOffset = PxPosition(mX1.px, mY1.px)
val middleLayoutNode: LayoutNode = LayoutNode(
mX1, mY1, mX2, mY2,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = middlePointerInputHandler)
+ middlePointerInputFilter
)
).apply {
insertAt(0, childLayoutNode)
@@ -527,7 +536,7 @@
val parentLayoutNode: LayoutNode = LayoutNode(
pX1, pY1, pX2, pY2,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = parentPointerInputHandler)
+ parentPointerInputFilter
)
).apply {
insertAt(0, middleLayoutNode)
@@ -544,9 +553,9 @@
val down = PointerInputEvent(0, Uptime.Boot + 7.milliseconds, offset, true)
val pointerInputHandlers = arrayOf(
- parentPointerInputHandler,
- middlePointerInputHandler,
- childPointerInputHandler
+ parentPointerInputFilter,
+ middlePointerInputFilter,
+ childPointerInputFilter
)
val expectedPointerInputChanges = arrayOf(
@@ -594,9 +603,18 @@
// Assert
+ // Verify call count
+ pointerInputHandlers.forEach {
+ verify(it, times(PointerEventPass.values().size)).onPointerInput(
+ any(),
+ any(),
+ any()
+ )
+ }
+ // Verify call values
for (pass in PointerEventPass.values()) {
for (i in pointerInputHandlers.indices) {
- verify(pointerInputHandlers[i]).invoke(
+ verify(pointerInputHandlers[i]).onPointerInput(
listOf(expectedPointerInputChanges[i]),
pass,
expectedSizes[i]
@@ -628,21 +646,21 @@
// Arrange
- val childPointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val childPointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter1: PointerInputFilter = spy()
+ val childPointerInputFilter2: PointerInputFilter = spy()
val childLayoutNode1 =
LayoutNode(
0, 0, 50, 50,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler1)
+ childPointerInputFilter1
)
)
val childLayoutNode2 =
LayoutNode(
50, 50, 100, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler2)
+ childPointerInputFilter2
)
)
root.apply {
@@ -684,24 +702,27 @@
// Assert
+ // Verify call count
+ verify(childPointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(childPointerInputHandler1)
- .invoke(
+ verify(childPointerInputFilter1)
+ .onPointerInput(
listOf(expectedChange1),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
- verify(childPointerInputHandler2)
- .invoke(
+ verify(childPointerInputFilter2)
+ .onPointerInput(
listOf(expectedChange2),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
}
- verifyNoMoreInteractions(
- childPointerInputHandler1,
- childPointerInputHandler2
- )
}
/**
@@ -729,26 +750,26 @@
@Test
fun process_3DownOnOverlappingPointerNodes_hitAndDispatchInfoAreCorrect() {
- val childPointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val childPointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
- val childPointerInputHandler3: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter1: PointerInputFilter = spy()
+ val childPointerInputFilter2: PointerInputFilter = spy()
+ val childPointerInputFilter3: PointerInputFilter = spy()
val childLayoutNode1 = LayoutNode(
0, 0, 100, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler1)
+ childPointerInputFilter1
)
)
val childLayoutNode2 = LayoutNode(
50, 50, 150, 150,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler2)
+ childPointerInputFilter2
)
)
val childLayoutNode3 = LayoutNode(
100, 100, 200, 200,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler3)
+ childPointerInputFilter3
)
)
@@ -804,19 +825,35 @@
// Assert
+ // Verify call count
+ verify(childPointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter3, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(childPointerInputHandler1)
- .invoke(listOf(expectedChange1), pointerEventPass, IntPxSize(100.ipx, 100.ipx))
- verify(childPointerInputHandler2)
- .invoke(listOf(expectedChange2), pointerEventPass, IntPxSize(100.ipx, 100.ipx))
- verify(childPointerInputHandler3)
- .invoke(listOf(expectedChange3), pointerEventPass, IntPxSize(100.ipx, 100.ipx))
+ verify(childPointerInputFilter1)
+ .onPointerInput(
+ listOf(expectedChange1),
+ pointerEventPass,
+ IntPxSize(100.ipx, 100.ipx)
+ )
+ verify(childPointerInputFilter2)
+ .onPointerInput(
+ listOf(expectedChange2),
+ pointerEventPass,
+ IntPxSize(100.ipx, 100.ipx)
+ )
+ verify(childPointerInputFilter3)
+ .onPointerInput(
+ listOf(expectedChange3),
+ pointerEventPass,
+ IntPxSize(100.ipx, 100.ipx)
+ )
}
- verifyNoMoreInteractions(
- childPointerInputHandler1,
- childPointerInputHandler2,
- childPointerInputHandler3
- )
}
/**
@@ -843,19 +880,19 @@
@Test
fun process_3DownOnFloatingPointerNodeV_hitAndDispatchInfoAreCorrect() {
- val childPointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val childPointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter1: PointerInputFilter = spy()
+ val childPointerInputFilter2: PointerInputFilter = spy()
val childLayoutNode1 = LayoutNode(
0, 0, 100, 150,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler1)
+ childPointerInputFilter1
)
)
val childLayoutNode2 = LayoutNode(
25, 50, 75, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler2)
+ childPointerInputFilter2
)
)
@@ -906,24 +943,27 @@
// Assert
+ // Verify call count
+ verify(childPointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(childPointerInputHandler1)
- .invoke(
+ verify(childPointerInputFilter1)
+ .onPointerInput(
listOf(expectedChange1, expectedChange3),
pointerEventPass,
IntPxSize(100.ipx, 150.ipx)
)
- verify(childPointerInputHandler2)
- .invoke(
+ verify(childPointerInputFilter2)
+ .onPointerInput(
listOf(expectedChange2),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
}
- verifyNoMoreInteractions(
- childPointerInputHandler1,
- childPointerInputHandler2
- )
}
/**
@@ -945,19 +985,19 @@
*/
@Test
fun process_3DownOnFloatingPointerNodeH_hitAndDispatchInfoAreCorrect() {
- val childPointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val childPointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter1: PointerInputFilter = spy()
+ val childPointerInputFilter2: PointerInputFilter = spy()
val childLayoutNode1 = LayoutNode(
0, 0, 150, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler1)
+ childPointerInputFilter1
)
)
val childLayoutNode2 = LayoutNode(
50, 25, 100, 75,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = childPointerInputHandler2)
+ childPointerInputFilter2
)
)
@@ -1008,24 +1048,27 @@
// Assert
+ // Verify call count
+ verify(childPointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(childPointerInputHandler1)
- .invoke(
+ verify(childPointerInputFilter1)
+ .onPointerInput(
listOf(expectedChange1, expectedChange3),
pointerEventPass,
IntPxSize(150.ipx, 100.ipx)
)
- verify(childPointerInputHandler2)
- .invoke(
+ verify(childPointerInputFilter2)
+ .onPointerInput(
listOf(expectedChange2),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
}
- verifyNoMoreInteractions(
- childPointerInputHandler1,
- childPointerInputHandler2
- )
}
/**
@@ -1055,30 +1098,33 @@
// Arrange
- val singlePointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter1: PointerInputFilter = spy()
+ val pointerInputFilter2: PointerInputFilter = spy()
+ val pointerInputFilter3: PointerInputFilter = spy()
+ val pointerInputFilter4: PointerInputFilter = spy()
val layoutNode1 = LayoutNode(
-1, -1, 1, 1,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = singlePointerInputHandler)
+ pointerInputFilter1
)
)
val layoutNode2 = LayoutNode(
2, -1, 4, 1,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = singlePointerInputHandler)
+ pointerInputFilter2
)
)
val layoutNode3 = LayoutNode(
-1, 2, 1, 4,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = singlePointerInputHandler)
+ pointerInputFilter3
)
)
val layoutNode4 = LayoutNode(
2, 2, 4, 4,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = singlePointerInputHandler)
+ pointerInputFilter4
)
)
@@ -1140,18 +1186,48 @@
consumed = ConsumedData()
)
}
+
+ // Verify call count
+ verify(
+ pointerInputFilter1,
+ times(PointerEventPass.values().size)
+ ).onPointerInput(any(), any(), any())
+ verify(
+ pointerInputFilter2,
+ times(PointerEventPass.values().size)
+ ).onPointerInput(any(), any(), any())
+ verify(
+ pointerInputFilter3,
+ times(PointerEventPass.values().size)
+ ).onPointerInput(any(), any(), any())
+ verify(
+ pointerInputFilter4,
+ times(PointerEventPass.values().size)
+ ).onPointerInput(any(), any(), any())
+
+ // Verify call values
PointerEventPass.values().forEach { pointerEventPass ->
- expectedChanges.forEach { change ->
- verify(singlePointerInputHandler).invoke(
- eq(listOf(change)),
- eq(pointerEventPass),
- any()
- )
- }
+ verify(pointerInputFilter1).onPointerInput(
+ eq(listOf(expectedChanges[0])),
+ eq(pointerEventPass),
+ any()
+ )
+ verify(pointerInputFilter2).onPointerInput(
+ eq(listOf(expectedChanges[1])),
+ eq(pointerEventPass),
+ any()
+ )
+ verify(pointerInputFilter3).onPointerInput(
+ eq(listOf(expectedChanges[2])),
+ eq(pointerEventPass),
+ any()
+ )
+ verify(pointerInputFilter4).onPointerInput(
+ eq(listOf(expectedChanges[3])),
+ eq(pointerEventPass),
+ any()
+ )
}
- verifyNoMoreInteractions(
- singlePointerInputHandler
- )
}
/**
@@ -1178,11 +1254,11 @@
fun process_rootIsOffset_onlyCorrectPointersHit() {
// Arrange
- val singlePointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val singlePointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
0, 0, 2, 2,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = singlePointerInputHandler)
+ singlePointerInputFilter
)
)
root.apply {
@@ -1229,35 +1305,31 @@
consumed = ConsumedData()
)
}
+
+ // Verify call count
+ verify(singlePointerInputFilter, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
PointerEventPass.values().forEach { pointerEventPass ->
- verify(singlePointerInputHandler).invoke(
+ verify(singlePointerInputFilter).onPointerInput(
eq(expectedChanges),
eq(pointerEventPass),
any()
)
}
- verifyNoMoreInteractions(
- singlePointerInputHandler
- )
}
@Test
fun process_downOn3NestedPointerInputModifiers_hitAndDispatchInfoAreCorrect() {
- val pointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val pointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
- val pointerInputHandler3: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter1: PointerInputFilter = spy()
+ val pointerInputFilter2: PointerInputFilter = spy()
+ val pointerInputFilter3: PointerInputFilter = spy()
- val modifier =
- PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler1)
- ) +
- PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler2)
- ) +
- PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler3)
- )
+ val modifier = PointerInputModifierImpl(pointerInputFilter1) +
+ PointerInputModifierImpl(pointerInputFilter2) +
+ PointerInputModifierImpl(pointerInputFilter3)
val layoutNode = LayoutNode(
25, 50, 75, 100,
@@ -1294,40 +1366,46 @@
// Assert
+ // Verify call count
+ verify(pointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(pointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(pointerInputFilter3, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(pointerInputHandler1)
- .invoke(
+ verify(pointerInputFilter1)
+ .onPointerInput(
listOf(expectedChange),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
- verify(pointerInputHandler2)
- .invoke(
+ verify(pointerInputFilter2)
+ .onPointerInput(
listOf(expectedChange),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
- verify(pointerInputHandler3)
- .invoke(
+ verify(pointerInputFilter3)
+ .onPointerInput(
listOf(expectedChange),
pointerEventPass,
IntPxSize(50.ipx, 50.ipx)
)
}
- verifyNoMoreInteractions(pointerInputHandler1, pointerInputHandler2, pointerInputHandler3)
}
@Test
fun process_downOnDeeplyNestedPointerInputModifier_hitAndDispatchInfoAreCorrect() {
- val pointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode1 =
LayoutNode(
1, 5, 500, 500,
- PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler1)
- )
+ PointerInputModifierImpl(pointerInputFilter)
)
val layoutNode2: LayoutNode = LayoutNode(2, 6, 500, 500).apply {
insertAt(0, layoutNode1)
@@ -1368,31 +1446,35 @@
// Assert
+ // Verify call count
+ verify(pointerInputFilter, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(pointerInputHandler1)
- .invoke(
+ verify(pointerInputFilter)
+ .onPointerInput(
listOf(expectedChange),
pointerEventPass,
IntPxSize(499.ipx, 495.ipx)
)
}
- verifyNoMoreInteractions(pointerInputHandler1)
}
@Test
fun process_downOnComplexPointerAndLayoutNodePath_hitAndDispatchInfoAreCorrect() {
- val pointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
- val pointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val pointerInputHandler3: PointerInputHandler = spy(StubPointerInputHandler())
- val pointerInputHandler4: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter1: PointerInputFilter = spy()
+ val pointerInputFilter2: PointerInputFilter = spy()
+ val pointerInputFilter3: PointerInputFilter = spy()
+ val pointerInputFilter4: PointerInputFilter = spy()
val layoutNode1 = LayoutNode(
1, 6, 500, 500,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler1)
+ pointerInputFilter1
) + PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler2)
+ pointerInputFilter2
)
)
val layoutNode2: LayoutNode = LayoutNode(2, 7, 500, 500).apply {
@@ -1401,11 +1483,8 @@
val layoutNode3 =
LayoutNode(
3, 8, 500, 500,
- PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler3)
- ) + PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler4)
- )
+ PointerInputModifierImpl(pointerInputFilter3) +
+ PointerInputModifierImpl(pointerInputFilter4)
).apply {
insertAt(0, layoutNode2)
}
@@ -1460,56 +1539,62 @@
// Assert
+ // Verify call count
+ verify(pointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(pointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(pointerInputFilter3, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(pointerInputFilter4, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ PointerEventPass.values()
+
+ // Verify call values
for (pointerEventPass in PointerEventPass.values()) {
- verify(pointerInputHandler1)
- .invoke(
+ verify(pointerInputFilter1)
+ .onPointerInput(
listOf(expectedChange1),
pointerEventPass,
IntPxSize(499.ipx, 494.ipx)
)
- verify(pointerInputHandler2)
- .invoke(
+ verify(pointerInputFilter2)
+ .onPointerInput(
listOf(expectedChange1),
pointerEventPass,
IntPxSize(499.ipx, 494.ipx)
)
- verify(pointerInputHandler3)
- .invoke(
+ verify(pointerInputFilter3)
+ .onPointerInput(
listOf(expectedChange2),
pointerEventPass,
IntPxSize(497.ipx, 492.ipx)
)
- verify(pointerInputHandler4)
- .invoke(
+ verify(pointerInputFilter4)
+ .onPointerInput(
listOf(expectedChange2),
pointerEventPass,
IntPxSize(497.ipx, 492.ipx)
)
}
- verifyNoMoreInteractions(
- pointerInputHandler1,
- pointerInputHandler2,
- pointerInputHandler3,
- pointerInputHandler4
- )
}
@Test
fun process_downOnFullyOverlappingPointerInputModifiers_onlyTopPointerInputModifierReceives() {
- val pointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val pointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter1: PointerInputFilter = spy()
+ val pointerInputFilter2: PointerInputFilter = spy()
val layoutNode1 = LayoutNode(
0, 0, 100, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler1)
+ pointerInputFilter1
)
)
val layoutNode2 = LayoutNode(
0, 0, 100, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler2)
+ pointerInputFilter2
)
)
@@ -1527,20 +1612,18 @@
pointerInputEventProcessor.process(down)
// Assert
- verify(pointerInputHandler2, times(5)).invoke(any(), any(), any())
- verify(pointerInputHandler1, never()).invoke(any(), any(), any())
+ verify(pointerInputFilter2, times(5)).onPointerInput(any(), any(), any())
+ verify(pointerInputFilter1, never()).onPointerInput(any(), any(), any())
}
@Test
fun process_downOnPointerInputModifierInLayoutNodeWithNoSize_downNotReceived() {
- val pointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter1: PointerInputFilter = spy()
val layoutNode1 = LayoutNode(
0, 0, 0, 0,
- PointerInputModifierImpl(
- TestPointerInputFilter(pointerInputHandler = pointerInputHandler1)
- )
+ PointerInputModifierImpl(pointerInputFilter1)
)
root.apply {
@@ -1555,7 +1638,7 @@
pointerInputEventProcessor.process(down)
// Assert
- verify(pointerInputHandler1, never()).invoke(any(), any(), any())
+ verify(pointerInputFilter1, never()).onPointerInput(any(), any(), any())
}
// Cancel Handlers
@@ -1570,17 +1653,11 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val cancelHandler: () -> Unit = spy()
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
0, 0, 500, 500,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler,
- cancelHandler = cancelHandler
- )
- )
+ PointerInputModifierImpl(pointerInputFilter)
)
root.insertAt(0, layoutNode)
@@ -1612,20 +1689,21 @@
// Assert
- inOrder(pointerInputHandler, cancelHandler) {
+ // Verify call count
+ verify(pointerInputFilter, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expectedChange)),
eq(pass),
any()
)
}
- verify(cancelHandler).invoke()
+ verify(pointerInputFilter).onCancel()
}
- verifyNoMoreInteractions(
- pointerInputHandler,
- cancelHandler
- )
}
@Test
@@ -1633,16 +1711,12 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val cancelHandler: () -> Unit = spy()
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
0, 0, 500, 500,
PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler,
- cancelHandler = cancelHandler
- )
+ pointerInputFilter
)
)
@@ -1725,27 +1799,28 @@
// Assert
- inOrder(pointerInputHandler, cancelHandler) {
+ // Verify call count
+ verify(pointerInputFilter, times(PointerEventPass.values().size * 2))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(expectedChanges1),
eq(pass),
any()
)
}
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(expectedChanges2),
eq(pass),
any()
)
}
- verify(cancelHandler).invoke()
+ verify(pointerInputFilter).onCancel()
}
- verifyNoMoreInteractions(
- pointerInputHandler,
- cancelHandler
- )
}
@Test
@@ -1753,28 +1828,16 @@
// Arrange
- val pointerInputHandler1: PointerInputHandler = spy(StubPointerInputHandler())
- val cancelHandler1: () -> Unit = spy()
+ val pointerInputFilter1: PointerInputFilter = spy()
val layoutNode1 = LayoutNode(
0, 0, 199, 199,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler1,
- cancelHandler = cancelHandler1
- )
- )
+ PointerInputModifierImpl(pointerInputFilter1)
)
- val pointerInputHandler2: PointerInputHandler = spy(StubPointerInputHandler())
- val cancelHandler2: () -> Unit = spy()
+ val pointerInputFilter2: PointerInputFilter = spy()
val layoutNode2 = LayoutNode(
200, 200, 399, 399,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler2,
- cancelHandler = cancelHandler2
- )
- )
+ PointerInputModifierImpl(pointerInputFilter2)
)
root.insertAt(0, layoutNode1)
@@ -1832,32 +1895,33 @@
// Assert
- inOrder(pointerInputHandler1, cancelHandler1) {
+ // Verify call count
+ verify(pointerInputFilter1, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+ verify(pointerInputFilter2, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter1) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler1).invoke(
+ verify(pointerInputFilter1).onPointerInput(
eq(listOf(expectedChange1)),
eq(pass),
any()
)
}
- verify(cancelHandler1).invoke()
+ verify(pointerInputFilter1).onCancel()
}
- inOrder(pointerInputHandler2, cancelHandler2) {
+ inOrder(pointerInputFilter2) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler2).invoke(
+ verify(pointerInputFilter2).onPointerInput(
eq(listOf(expectedChange2)),
eq(pass),
any()
)
}
- verify(cancelHandler2).invoke()
+ verify(pointerInputFilter2).onCancel()
}
- verifyNoMoreInteractions(
- pointerInputHandler1,
- cancelHandler1,
- pointerInputHandler2,
- cancelHandler2
- )
}
@Test
@@ -1865,16 +1929,11 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val pointerInputFilter: PointerInputFilter = spy()
val cancelHandler: () -> Unit = spy()
val layoutNode = LayoutNode(
0, 0, 500, 500,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler,
- cancelHandler = cancelHandler
- )
- )
+ PointerInputModifierImpl(pointerInputFilter)
)
root.insertAt(0, layoutNode)
@@ -1931,27 +1990,28 @@
// Assert
- inOrder(pointerInputHandler, cancelHandler) {
+ // Verify call count
+ verify(pointerInputFilter, times(PointerEventPass.values().size * 2))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expectedDown)),
eq(pass),
any()
)
}
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expectedMove)),
eq(pass),
any()
)
}
- verify(cancelHandler).invoke()
+ verify(pointerInputFilter).onCancel()
}
- verifyNoMoreInteractions(
- pointerInputHandler,
- cancelHandler
- )
}
@Test
@@ -1959,16 +2019,10 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val cancelHandler: () -> Unit = spy()
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
0, 0, 500, 500,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler,
- cancelHandler = cancelHandler
- )
- )
+ PointerInputModifierImpl(pointerInputFilter)
)
root.insertAt(0, layoutNode)
@@ -2000,20 +2054,21 @@
// Assert
- inOrder(pointerInputHandler, cancelHandler) {
+ // Verify call count
+ verify(pointerInputFilter, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expectedDown)),
eq(pass),
any()
)
}
- verify(cancelHandler).invoke()
+ verify(pointerInputFilter).onCancel()
}
- verifyNoMoreInteractions(
- pointerInputHandler,
- cancelHandler
- )
}
@Test
@@ -2021,15 +2076,11 @@
// Arrange
- val pointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
- val cancelHandler: () -> Unit = spy()
+ val pointerInputFilter: PointerInputFilter = spy()
val layoutNode = LayoutNode(
0, 0, 500, 500,
PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = pointerInputHandler,
- cancelHandler = cancelHandler
- )
+ pointerInputFilter
)
)
@@ -2083,27 +2134,28 @@
// Assert
- inOrder(pointerInputHandler, cancelHandler) {
+ // Verify call count
+ verify(pointerInputFilter, times(PointerEventPass.values().size * 2))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
+ inOrder(pointerInputFilter) {
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expectedDown1)),
eq(pass),
any()
)
}
- verify(cancelHandler).invoke()
+ verify(pointerInputFilter).onCancel()
for (pass in PointerEventPass.values()) {
- verify(pointerInputHandler).invoke(
+ verify(pointerInputFilter).onPointerInput(
eq(listOf(expectedDown2)),
eq(pass),
any()
)
}
}
- verifyNoMoreInteractions(
- pointerInputHandler,
- cancelHandler
- )
}
@Test
@@ -2111,24 +2163,16 @@
// Arrange
- val childPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter: PointerInputFilter = spy()
val childLayoutNode = LayoutNode(
0, 0, 100, 100,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = childPointerInputHandler
- )
- )
+ PointerInputModifierImpl(childPointerInputFilter)
)
- val parentPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val parentPointerInputFilter: PointerInputFilter = spy()
val parentLayoutNode: LayoutNode = LayoutNode(
0, 0, 100, 100,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = parentPointerInputHandler
- )
- )
+ PointerInputModifierImpl(parentPointerInputFilter)
).apply {
insertAt(0, childLayoutNode)
}
@@ -2162,16 +2206,21 @@
// Assert
+ // Verify call count
+ verify(parentPointerInputFilter, times(PointerEventPass.values().size * 2))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
PointerEventPass.values().forEach {
- verify(parentPointerInputHandler)
- .invoke(eq(listOf(expectedDownChange)), eq(it), any())
- verify(childPointerInputHandler)
- .invoke(eq(listOf(expectedDownChange)), eq(it), any())
- verify(parentPointerInputHandler)
- .invoke(eq(listOf(expectedUpChange)), eq(it), any())
+ verify(parentPointerInputFilter)
+ .onPointerInput(eq(listOf(expectedDownChange)), eq(it), any())
+ verify(childPointerInputFilter)
+ .onPointerInput(eq(listOf(expectedDownChange)), eq(it), any())
+ verify(parentPointerInputFilter)
+ .onPointerInput(eq(listOf(expectedUpChange)), eq(it), any())
}
- verifyNoMoreInteractions(parentPointerInputHandler)
- verifyNoMoreInteractions(childPointerInputHandler)
}
@Test
@@ -2179,24 +2228,16 @@
// Arrange
- val childCancelHandler: () -> Unit = spy()
+ val childPointerInputFilter: PointerInputFilter = spy()
val childLayoutNode = LayoutNode(
0, 0, 100, 100,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- cancelHandler = childCancelHandler
- )
- )
+ PointerInputModifierImpl(childPointerInputFilter)
)
- val parentCancelHandler: () -> Unit = spy()
+ val parentPointerInputFilter: PointerInputFilter = spy()
val parentLayoutNode: LayoutNode = LayoutNode(
0, 0, 100, 100,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- cancelHandler = parentCancelHandler
- )
- )
+ PointerInputModifierImpl(parentPointerInputFilter)
).apply {
insertAt(0, childLayoutNode)
}
@@ -2215,8 +2256,8 @@
pointerInputEventProcessor.process(up)
// Assert
- verify(childCancelHandler).invoke()
- verify(parentCancelHandler, never()).invoke()
+ verify(childPointerInputFilter).onCancel()
+ verify(parentPointerInputFilter, never()).onCancel()
}
@Test
@@ -2224,23 +2265,19 @@
// Arrange
- val childPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val childPointerInputFilter: PointerInputFilter = spy()
val childLayoutNode = LayoutNode(
0, 0, 100, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = childPointerInputHandler
- )
+ childPointerInputFilter
)
)
- val parentPointerInputHandler: PointerInputHandler = spy(StubPointerInputHandler())
+ val parentPointerInputFilter: PointerInputFilter = spy()
val parentLayoutNode: LayoutNode = LayoutNode(
0, 0, 100, 100,
PointerInputModifierImpl(
- TestPointerInputFilter(
- pointerInputHandler = parentPointerInputHandler
- )
+ parentPointerInputFilter
)
).apply {
insertAt(0, childLayoutNode)
@@ -2275,16 +2312,21 @@
// Assert
+ // Verify call count
+ verify(parentPointerInputFilter, times(PointerEventPass.values().size * 2))
+ .onPointerInput(any(), any(), any())
+ verify(childPointerInputFilter, times(PointerEventPass.values().size))
+ .onPointerInput(any(), any(), any())
+
+ // Verify call values
PointerEventPass.values().forEach {
- verify(parentPointerInputHandler)
- .invoke(eq(listOf(expectedDownChange)), eq(it), any())
- verify(childPointerInputHandler)
- .invoke(eq(listOf(expectedDownChange)), eq(it), any())
- verify(parentPointerInputHandler)
- .invoke(eq(listOf(expectedUpChange)), eq(it), any())
+ verify(parentPointerInputFilter)
+ .onPointerInput(eq(listOf(expectedDownChange)), eq(it), any())
+ verify(childPointerInputFilter)
+ .onPointerInput(eq(listOf(expectedDownChange)), eq(it), any())
+ verify(parentPointerInputFilter)
+ .onPointerInput(eq(listOf(expectedUpChange)), eq(it), any())
}
- verifyNoMoreInteractions(parentPointerInputHandler)
- verifyNoMoreInteractions(childPointerInputHandler)
}
@Test
@@ -2292,24 +2334,16 @@
// Arrange
- val childCancelHandler: () -> Unit = spy()
+ val childPointerInputFilter: PointerInputFilter = spy()
val childLayoutNode = LayoutNode(
0, 0, 100, 100,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- cancelHandler = childCancelHandler
- )
- )
+ PointerInputModifierImpl(childPointerInputFilter)
)
- val parentCancelHandler: () -> Unit = spy()
+ val parentPointerInputFilter: PointerInputFilter = spy()
val parentLayoutNode: LayoutNode = LayoutNode(
0, 0, 100, 100,
- PointerInputModifierImpl(
- TestPointerInputFilter(
- cancelHandler = parentCancelHandler
- )
- )
+ PointerInputModifierImpl(parentPointerInputFilter)
).apply {
insertAt(0, childLayoutNode)
}
@@ -2328,8 +2362,8 @@
pointerInputEventProcessor.process(up)
// Assert
- verify(childCancelHandler).invoke()
- verify(parentCancelHandler, never()).invoke()
+ verify(childPointerInputFilter).onCancel()
+ verify(parentPointerInputFilter, never()).onCancel()
}
}
@@ -2338,10 +2372,20 @@
override fun calculatePosition() = position
}
-class TestPointerInputFilter(
- override val pointerInputHandler: PointerInputHandler = { changes, _, _ -> changes },
- override val cancelHandler: () -> Unit = {}
-) : PointerInputFilter()
+open class TestPointerInputFilter(
+ val pointerInputHandler: PointerInputHandler = { changes, _, _ -> changes }
+) : PointerInputFilter() {
+
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+ return pointerInputHandler(changes, pass, bounds)
+ }
+
+ override fun onCancel() {}
+}
private class PointerInputModifierImpl(override val pointerInputFilter: PointerInputFilter) :
PointerInputModifier
\ No newline at end of file
diff --git a/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/TestUtils.kt b/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/TestUtils.kt
index 7b40f7c..ca4ebf3 100644
--- a/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/TestUtils.kt
+++ b/ui/ui-platform/src/test/java/androidx/ui/core/pointerinput/TestUtils.kt
@@ -27,7 +27,6 @@
import androidx.ui.core.PointerInputData
import androidx.ui.core.PointerInputHandler
import androidx.ui.unit.IntPx
-import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.Uptime
@@ -51,10 +50,6 @@
}
}
-open class StubCancelHandler : () -> Unit {
- override fun invoke() {}
-}
-
internal fun LayoutNode(x: Int, y: Int, x2: Int, y2: Int, modifier: Modifier = Modifier.None) =
LayoutNode().apply {
this.modifier = modifier
@@ -62,12 +57,6 @@
place(x.ipx, y.ipx)
}
-internal fun LayoutNode(position: IntPxPosition, size: IntPxSize) =
- LayoutNode().apply {
- resize(size.width, size.height)
- place(position.x, position.y)
- }
-
internal fun LayoutNode.resize(width: IntPx, height: IntPx) {
handleLayoutResult(
object : MeasureScope.LayoutResult {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt
index 1504208..e06a6a0 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/SendClickTest.kt
@@ -25,7 +25,7 @@
import androidx.test.filters.MediumTest
import androidx.ui.core.DensityAmbient
import androidx.ui.core.PointerEventPass
-import androidx.ui.core.PointerInputHandler
+import androidx.ui.core.PointerInputChange
import androidx.ui.core.TestTag
import androidx.ui.core.changedToUp
import androidx.ui.core.pointerinput.PointerInputFilter
@@ -37,6 +37,7 @@
import androidx.ui.layout.preferredSize
import androidx.ui.semantics.Semantics
import androidx.ui.test.android.AndroidComposeTestRule
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
@@ -110,18 +111,24 @@
val pointerInputModifier =
object : PointerInputModifier {
override val pointerInputFilter = object : PointerInputFilter() {
- override val pointerInputHandler: PointerInputHandler =
- { changes, pass, _ ->
- if (pass == PointerEventPass.InitialDown) {
- changes.filter { it.changedToUp() }.forEach {
- recordedClicks.add(
- ClickData(i, it.current.position!!)
- )
- }
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+ if (pass == PointerEventPass.InitialDown) {
+ changes.filter { it.changedToUp() }.forEach {
+ recordedClicks.add(
+ ClickData(i, it.current.position!!)
+ )
}
- changes
}
- override val cancelHandler: () -> Unit = {}
+ return changes
+ }
+
+ override fun onCancel() {
+ // Do nothing
+ }
}
}
squareSize.toDp()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
index 836c8fb..3c25ab5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/util/PointerInputs.kt
@@ -18,13 +18,14 @@
import androidx.ui.core.PointerEventPass
import androidx.ui.core.PointerId
+import androidx.ui.core.PointerInputChange
import androidx.ui.core.PointerInputData
-import androidx.ui.core.PointerInputHandler
import androidx.ui.core.gesture.util.VelocityTracker
import androidx.ui.core.pointerinput.PointerInputFilter
import androidx.ui.core.pointerinput.PointerInputModifier
import androidx.ui.test.util.PointerInputRecorder.DataPoint
import androidx.ui.unit.Duration
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import com.google.common.truth.Truth.assertThat
@@ -46,17 +47,23 @@
override val pointerInputFilter: PointerInputFilter =
object : PointerInputFilter() {
- override val pointerInputHandler: PointerInputHandler =
- { changes, pass, _ ->
- if (pass == PointerEventPass.InitialDown) {
- changes.forEach {
- _events.add(DataPoint(it.id, it.current))
- velocityTracker.addPosition(it.current.uptime!!, it.current.position!!)
- }
+ override fun onPointerInput(
+ changes: List<PointerInputChange>,
+ pass: PointerEventPass,
+ bounds: IntPxSize
+ ): List<PointerInputChange> {
+ if (pass == PointerEventPass.InitialDown) {
+ changes.forEach {
+ _events.add(DataPoint(it.id, it.current))
+ velocityTracker.addPosition(it.current.uptime!!, it.current.position!!)
}
- changes
}
- override val cancelHandler: () -> Unit = {}
+ return changes
+ }
+
+ override fun onCancel() {
+ // Do nothing
+ }
}
}