Consume batches in dispatcher tests
We are currently calling consume with consumeBatches=false. But that
means we don't want to consume any batched events. As a result, when
events are simply stored internally in inputconsumer, they are not
returned to callers of consume(..).
We never had tests that included MOVE events, and since DOWN events are
never batched, we did not encounter this case.
Now that we are adding a MOVE test, we need to ensure batches are
consumed as well.
Bug: none
Test: atest inputflinger_tests
Change-Id: Ieb13e1bb43bbf96f7f9352a283387ffdb11ba54a
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 0701f3b..994010b 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -418,7 +418,7 @@
std::chrono::time_point start = std::chrono::steady_clock::now();
status_t status = WOULD_BLOCK;
while (status == WOULD_BLOCK) {
- status = mConsumer->consume(&mEventFactory, false /*consumeBatches*/, -1, &consumeSeq,
+ status = mConsumer->consume(&mEventFactory, true /*consumeBatches*/, -1, &consumeSeq,
&event);
std::chrono::duration elapsed = std::chrono::steady_clock::now() - start;
if (elapsed > 100ms) {
@@ -932,6 +932,32 @@
monitor->consumeMotionUp(ADISPLAY_ID_DEFAULT);
}
+TEST_F(InputDispatcherTest, TestMoveEvent) {
+ sp<FakeApplicationHandle> application = new FakeApplicationHandle();
+ sp<FakeWindowHandle> window =
+ new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
+
+ mDispatcher->setInputWindows({window}, ADISPLAY_ID_DEFAULT);
+
+ NotifyMotionArgs motionArgs =
+ generateMotionArgs(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN,
+ ADISPLAY_ID_DEFAULT);
+
+ mDispatcher->notifyMotion(&motionArgs);
+ // Window should receive motion down event.
+ window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
+
+ motionArgs.action = AMOTION_EVENT_ACTION_MOVE;
+ motionArgs.sequenceNum += 1;
+ motionArgs.eventTime = systemTime(SYSTEM_TIME_MONOTONIC);
+ motionArgs.pointerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
+ motionArgs.pointerCoords[0].getX() - 10);
+
+ mDispatcher->notifyMotion(&motionArgs);
+ window->consumeEvent(AINPUT_EVENT_TYPE_MOTION, AMOTION_EVENT_ACTION_MOVE, ADISPLAY_ID_DEFAULT,
+ 0 /*expectedFlags*/);
+}
+
/* Test InputDispatcher for MultiDisplay */
class InputDispatcherFocusOnTwoDisplaysTest : public InputDispatcherTest {
public: