Skip to content

Commit

Permalink
Fix unexpected masked action (flutter#37584)
Browse files Browse the repository at this point in the history
  • Loading branch information
moffatman authored Nov 14, 2022
1 parent 9cf107b commit 8c73fff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private int getPointerChangeForAction(int maskedAction) {
if (maskedAction == MotionEvent.ACTION_SCROLL) {
return PointerChange.HOVER;
}
throw new AssertionError("Unexpected masked action");
return -1;
}

@PointerChange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static junit.framework.TestCase.assertEquals;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.annotation.TargetApi;
Expand Down Expand Up @@ -206,4 +208,14 @@ public void mouse() {
assertEquals(5.0, readPointerPhysicalY(packet));
inOrder.verifyNoMoreInteractions();
}

@Test
public void unexpectedMaskedAction() {
// Regression test for https://github.com/flutter/flutter/issues/111068
MotionEventMocker mocker =
new MotionEventMocker(1, InputDevice.SOURCE_STYLUS, MotionEvent.TOOL_TYPE_STYLUS);
// ACTION_BUTTON_PRESS is not handled by AndroidTouchProcessor, nothing should be dispatched.
touchProcessor.onTouchEvent(mocker.mockEvent(MotionEvent.ACTION_BUTTON_PRESS, 0.0f, 0.0f, 0));
verify(mockRenderer, never()).dispatchPointerDataPacket(ByteBuffer.allocate(0), 0);
}
}

0 comments on commit 8c73fff

Please sign in to comment.