Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fix "unexpected masked action" assertion crash #37584

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}