Fix unexpected masked action (flutter/engine#37584)

This commit is contained in:
Callum Moffat
2022-11-14 14:34:42 -05:00
committed by GitHub
parent 8dc723b758
commit 0ea43fbe3e
2 changed files with 13 additions and 1 deletions

View File

@@ -389,7 +389,7 @@ public class AndroidTouchProcessor {
if (maskedAction == MotionEvent.ACTION_SCROLL) {
return PointerChange.HOVER;
}
throw new AssertionError("Unexpected masked action");
return -1;
}
@PointerChange

View File

@@ -3,6 +3,8 @@ package io.flutter.embedding.android;
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;
@@ -206,4 +208,14 @@ public class AndroidTouchProcessorTest {
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);
}
}