Merge "Add tests for ending TouchExplorer dragging"
This commit is contained in:
@@ -301,7 +301,7 @@ class EventDispatcher {
|
||||
* @param policyFlags The policy flags associated with the event.
|
||||
*/
|
||||
void sendUpForInjectedDownPointers(MotionEvent prototype, int policyFlags) {
|
||||
int pointerIdBits = 0;
|
||||
int pointerIdBits = prototype.getPointerIdBits();
|
||||
final int pointerCount = prototype.getPointerCount();
|
||||
for (int i = 0; i < pointerCount; i++) {
|
||||
final int pointerId = prototype.getPointerId(i);
|
||||
@@ -309,10 +309,10 @@ class EventDispatcher {
|
||||
if (!isInjectedPointerDown(pointerId)) {
|
||||
continue;
|
||||
}
|
||||
pointerIdBits |= (1 << pointerId);
|
||||
final int action = computeInjectionAction(MotionEvent.ACTION_UP, i);
|
||||
final int action = computeInjectionAction(MotionEvent.ACTION_POINTER_UP, i);
|
||||
sendMotionEvent(
|
||||
prototype, action, mState.getLastReceivedEvent(), pointerIdBits, policyFlags);
|
||||
pointerIdBits &= ~(1 << pointerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,9 +89,12 @@ public class TouchExplorerTest {
|
||||
|
||||
@Override
|
||||
public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
|
||||
MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent);
|
||||
mEvents.add(0, event.copy());
|
||||
assertThat(rawEvent, lastEventMatcher);
|
||||
// LastEvent may not match if we're clearing the state
|
||||
if (mLastEvent != null) {
|
||||
MotionEventMatcher lastEventMatcher = new MotionEventMatcher(mLastEvent);
|
||||
assertThat(rawEvent, lastEventMatcher);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,6 +128,31 @@ public class TouchExplorerTest {
|
||||
assertCapturedEventsNoHistory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upEventWhenInTwoFingerMove_clearsState() {
|
||||
goFromStateClearTo(STATE_MOVING_2FINGERS);
|
||||
|
||||
send(upEvent());
|
||||
assertState(STATE_CLEAR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clearEventsWhenInTwoFingerMove_clearsStateAndSendsUp() {
|
||||
goFromStateClearTo(STATE_MOVING_2FINGERS);
|
||||
|
||||
// Clear last event so we don't try to match against anything when cleanup events are sent
|
||||
// for the clear
|
||||
mLastEvent = null;
|
||||
mTouchExplorer.clearEvents(InputDevice.SOURCE_TOUCHSCREEN);
|
||||
assertState(STATE_CLEAR);
|
||||
List<MotionEvent> events = getCapturedEvents();
|
||||
assertCapturedEvents(
|
||||
MotionEvent.ACTION_DOWN,
|
||||
MotionEvent.ACTION_POINTER_DOWN,
|
||||
MotionEvent.ACTION_POINTER_UP,
|
||||
MotionEvent.ACTION_UP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoFingersDrag_shouldDraggingAndActionDown() {
|
||||
goFromStateClearTo(STATE_DRAGGING_2FINGERS);
|
||||
@@ -268,6 +296,12 @@ public class TouchExplorerTest {
|
||||
DEFAULT_Y, 0));
|
||||
}
|
||||
|
||||
private MotionEvent upEvent() {
|
||||
MotionEvent event = downEvent();
|
||||
event.setAction(MotionEvent.ACTION_UP);
|
||||
return event;
|
||||
}
|
||||
|
||||
private MotionEvent pointerDownEvent() {
|
||||
final int secondPointerId = 0x0100;
|
||||
final int action = MotionEvent.ACTION_POINTER_DOWN | secondPointerId;
|
||||
|
||||
Reference in New Issue
Block a user