Loading services/inputflinger/tests/InputDispatcher_test.cpp +39 −31 Original line number Original line Diff line number Diff line Loading @@ -365,8 +365,8 @@ public: class FakeInputReceiver { class FakeInputReceiver { public: public: void consumeEvent(int32_t expectedEventType, int32_t expectedDisplayId, void consumeEvent(int32_t expectedEventType, int32_t expectedAction, int32_t expectedDisplayId, int32_t expectedFlags = 0) { int32_t expectedFlags) { uint32_t consumeSeq; uint32_t consumeSeq; InputEvent* event; InputEvent* event; status_t status = mConsumer->consume(&mEventFactory, false /*consumeBatches*/, -1, status_t status = mConsumer->consume(&mEventFactory, false /*consumeBatches*/, -1, Loading @@ -379,33 +379,41 @@ public: ASSERT_EQ(expectedEventType, event->getType()) ASSERT_EQ(expectedEventType, event->getType()) << mName.c_str() << ": event type should match."; << mName.c_str() << ": event type should match."; ASSERT_EQ(expectedDisplayId, event->getDisplayId()) EXPECT_EQ(expectedDisplayId, event->getDisplayId()); << mName.c_str() << ": event displayId should be the same as expected."; int32_t flags; switch (expectedEventType) { switch (expectedEventType) { case AINPUT_EVENT_TYPE_KEY: { case AINPUT_EVENT_TYPE_KEY: { KeyEvent* typedEvent = static_cast<KeyEvent*>(event); const KeyEvent& keyEvent = static_cast<const KeyEvent&>(*event); flags = typedEvent->getFlags(); EXPECT_EQ(expectedAction, keyEvent.getAction()); EXPECT_EQ(expectedFlags, keyEvent.getFlags()); break; break; } } case AINPUT_EVENT_TYPE_MOTION: { case AINPUT_EVENT_TYPE_MOTION: { MotionEvent* typedEvent = static_cast<MotionEvent*>(event); const MotionEvent& motionEvent = static_cast<const MotionEvent&>(*event); flags = typedEvent->getFlags(); EXPECT_EQ(expectedAction, motionEvent.getAction()); EXPECT_EQ(expectedFlags, motionEvent.getFlags()); break; break; } } default: { default: { FAIL() << mName.c_str() << ": invalid event type: " << expectedEventType; FAIL() << mName.c_str() << ": invalid event type: " << expectedEventType; } } } } ASSERT_EQ(expectedFlags, flags) << mName.c_str() << ": event flags should be the same as expected."; status = mConsumer->sendFinishedSignal(consumeSeq, handled()); status = mConsumer->sendFinishedSignal(consumeSeq, handled()); ASSERT_EQ(OK, status) ASSERT_EQ(OK, status) << mName.c_str() << ": consumer sendFinishedSignal should return OK."; << mName.c_str() << ": consumer sendFinishedSignal should return OK."; } } void consumeKeyDown(int32_t expectedDisplayId, int32_t expectedFlags = 0) { consumeEvent(AINPUT_EVENT_TYPE_KEY, AKEY_EVENT_ACTION_DOWN, expectedDisplayId, expectedFlags); } void consumeMotionDown(int32_t expectedDisplayId, int32_t expectedFlags = 0) { consumeEvent(AINPUT_EVENT_TYPE_MOTION, AMOTION_EVENT_ACTION_DOWN, expectedDisplayId, expectedFlags); } void assertNoEvents() { void assertNoEvents() { uint32_t consumeSeq; uint32_t consumeSeq; InputEvent* event; InputEvent* event; Loading Loading @@ -611,7 +619,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_SingleWindowTouch) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; // Window should receive motion event. // Window should receive motion event. window->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); window->consumeMotionDown(ADISPLAY_ID_DEFAULT); } } // The foreground window should receive the first touch down event. // The foreground window should receive the first touch down event. Loading @@ -632,7 +640,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_MultiWindowsTouch) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; // Top window should receive the touch down event. Second window should not receive anything. // Top window should receive the touch down event. Second window should not receive anything. windowTop->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowTop->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowSecond->assertNoEvents(); windowSecond->assertNoEvents(); } } Loading @@ -658,7 +666,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_FocusedWindow) { // Focused window should receive event. // Focused window should receive event. windowTop->assertNoEvents(); windowTop->assertNoEvents(); windowSecond->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowSecond->consumeKeyDown(ADISPLAY_ID_NONE); } } TEST_F(InputDispatcherTest, SetInputWindow_FocusPriority) { TEST_F(InputDispatcherTest, SetInputWindow_FocusPriority) { Loading @@ -683,7 +691,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_FocusPriority) { << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; // Top focused window should receive event. // Top focused window should receive event. windowTop->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowTop->consumeKeyDown(ADISPLAY_ID_NONE); windowSecond->assertNoEvents(); windowSecond->assertNoEvents(); } } Loading Loading @@ -713,7 +721,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_InputWindowInfo) { // Top window is invalid, so it should not receive any input event. // Top window is invalid, so it should not receive any input event. windowTop->assertNoEvents(); windowTop->assertNoEvents(); windowSecond->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowSecond->consumeKeyDown(ADISPLAY_ID_NONE); } } TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { Loading @@ -738,7 +746,7 @@ TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionEvent(mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE, injectMotionEvent(mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE, ADISPLAY_ID_DEFAULT, 610, 400, 599, 400)); ADISPLAY_ID_DEFAULT, 610, 400, 599, 400)); windowLeft->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowLeft->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowRight->assertNoEvents(); windowRight->assertNoEvents(); } } Loading Loading @@ -794,7 +802,7 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowInSecondary->assertNoEvents(); windowInSecondary->assertNoEvents(); // Test touch down on second display. // Test touch down on second display. Loading @@ -802,28 +810,28 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID)) AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID)) << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, SECOND_DISPLAY_ID); windowInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); } } TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) { TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) { // Test inject a key down with display id specified. // Test inject a key down with display id specified. ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher, ADISPLAY_ID_DEFAULT)) ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher, ADISPLAY_ID_DEFAULT)) << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_DEFAULT); windowInPrimary->consumeKeyDown(ADISPLAY_ID_DEFAULT); windowInSecondary->assertNoEvents(); windowInSecondary->assertNoEvents(); // Test inject a key down without display id specified. // Test inject a key down without display id specified. ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher)) ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher)) << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowInSecondary->consumeKeyDown(ADISPLAY_ID_NONE); // Remove secondary display. // Remove secondary display. std::vector<sp<InputWindowHandle>> noWindows; std::vector<sp<InputWindowHandle>> noWindows; mDispatcher->setInputWindows(noWindows, SECOND_DISPLAY_ID); mDispatcher->setInputWindows(noWindows, SECOND_DISPLAY_ID); // Expect old focus should receive a cancel event. // Expect old focus should receive a cancel event. windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE, windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, AKEY_EVENT_ACTION_UP, ADISPLAY_ID_NONE, AKEY_EVENT_FLAG_CANCELED); AKEY_EVENT_FLAG_CANCELED); // Test inject a key down, should timeout because of no target window. // Test inject a key down, should timeout because of no target window. Loading Loading @@ -853,8 +861,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); monitorInPrimary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); monitorInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowInSecondary->assertNoEvents(); windowInSecondary->assertNoEvents(); monitorInSecondary->assertNoEvents(); monitorInSecondary->assertNoEvents(); Loading @@ -864,8 +872,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, SECOND_DISPLAY_ID); windowInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); monitorInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, SECOND_DISPLAY_ID); monitorInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); // Test inject a non-pointer motion event. // Test inject a non-pointer motion event. // If specific a display, it will dispatch to the focused window of particular display, // If specific a display, it will dispatch to the focused window of particular display, Loading @@ -875,8 +883,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_NONE); windowInSecondary->consumeMotionDown(ADISPLAY_ID_NONE); monitorInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_NONE); monitorInSecondary->consumeMotionDown(ADISPLAY_ID_NONE); } } // Test per-display input monitors for key event. // Test per-display input monitors for key event. Loading @@ -892,8 +900,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorKeyEvent_MultiDisplay) { << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowInSecondary->consumeKeyDown(ADISPLAY_ID_NONE); monitorInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); monitorInSecondary->consumeKeyDown(ADISPLAY_ID_NONE); } } class InputFilterTest : public InputDispatcherTest { class InputFilterTest : public InputDispatcherTest { Loading Loading
services/inputflinger/tests/InputDispatcher_test.cpp +39 −31 Original line number Original line Diff line number Diff line Loading @@ -365,8 +365,8 @@ public: class FakeInputReceiver { class FakeInputReceiver { public: public: void consumeEvent(int32_t expectedEventType, int32_t expectedDisplayId, void consumeEvent(int32_t expectedEventType, int32_t expectedAction, int32_t expectedDisplayId, int32_t expectedFlags = 0) { int32_t expectedFlags) { uint32_t consumeSeq; uint32_t consumeSeq; InputEvent* event; InputEvent* event; status_t status = mConsumer->consume(&mEventFactory, false /*consumeBatches*/, -1, status_t status = mConsumer->consume(&mEventFactory, false /*consumeBatches*/, -1, Loading @@ -379,33 +379,41 @@ public: ASSERT_EQ(expectedEventType, event->getType()) ASSERT_EQ(expectedEventType, event->getType()) << mName.c_str() << ": event type should match."; << mName.c_str() << ": event type should match."; ASSERT_EQ(expectedDisplayId, event->getDisplayId()) EXPECT_EQ(expectedDisplayId, event->getDisplayId()); << mName.c_str() << ": event displayId should be the same as expected."; int32_t flags; switch (expectedEventType) { switch (expectedEventType) { case AINPUT_EVENT_TYPE_KEY: { case AINPUT_EVENT_TYPE_KEY: { KeyEvent* typedEvent = static_cast<KeyEvent*>(event); const KeyEvent& keyEvent = static_cast<const KeyEvent&>(*event); flags = typedEvent->getFlags(); EXPECT_EQ(expectedAction, keyEvent.getAction()); EXPECT_EQ(expectedFlags, keyEvent.getFlags()); break; break; } } case AINPUT_EVENT_TYPE_MOTION: { case AINPUT_EVENT_TYPE_MOTION: { MotionEvent* typedEvent = static_cast<MotionEvent*>(event); const MotionEvent& motionEvent = static_cast<const MotionEvent&>(*event); flags = typedEvent->getFlags(); EXPECT_EQ(expectedAction, motionEvent.getAction()); EXPECT_EQ(expectedFlags, motionEvent.getFlags()); break; break; } } default: { default: { FAIL() << mName.c_str() << ": invalid event type: " << expectedEventType; FAIL() << mName.c_str() << ": invalid event type: " << expectedEventType; } } } } ASSERT_EQ(expectedFlags, flags) << mName.c_str() << ": event flags should be the same as expected."; status = mConsumer->sendFinishedSignal(consumeSeq, handled()); status = mConsumer->sendFinishedSignal(consumeSeq, handled()); ASSERT_EQ(OK, status) ASSERT_EQ(OK, status) << mName.c_str() << ": consumer sendFinishedSignal should return OK."; << mName.c_str() << ": consumer sendFinishedSignal should return OK."; } } void consumeKeyDown(int32_t expectedDisplayId, int32_t expectedFlags = 0) { consumeEvent(AINPUT_EVENT_TYPE_KEY, AKEY_EVENT_ACTION_DOWN, expectedDisplayId, expectedFlags); } void consumeMotionDown(int32_t expectedDisplayId, int32_t expectedFlags = 0) { consumeEvent(AINPUT_EVENT_TYPE_MOTION, AMOTION_EVENT_ACTION_DOWN, expectedDisplayId, expectedFlags); } void assertNoEvents() { void assertNoEvents() { uint32_t consumeSeq; uint32_t consumeSeq; InputEvent* event; InputEvent* event; Loading Loading @@ -611,7 +619,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_SingleWindowTouch) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; // Window should receive motion event. // Window should receive motion event. window->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); window->consumeMotionDown(ADISPLAY_ID_DEFAULT); } } // The foreground window should receive the first touch down event. // The foreground window should receive the first touch down event. Loading @@ -632,7 +640,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_MultiWindowsTouch) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; // Top window should receive the touch down event. Second window should not receive anything. // Top window should receive the touch down event. Second window should not receive anything. windowTop->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowTop->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowSecond->assertNoEvents(); windowSecond->assertNoEvents(); } } Loading @@ -658,7 +666,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_FocusedWindow) { // Focused window should receive event. // Focused window should receive event. windowTop->assertNoEvents(); windowTop->assertNoEvents(); windowSecond->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowSecond->consumeKeyDown(ADISPLAY_ID_NONE); } } TEST_F(InputDispatcherTest, SetInputWindow_FocusPriority) { TEST_F(InputDispatcherTest, SetInputWindow_FocusPriority) { Loading @@ -683,7 +691,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_FocusPriority) { << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; // Top focused window should receive event. // Top focused window should receive event. windowTop->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowTop->consumeKeyDown(ADISPLAY_ID_NONE); windowSecond->assertNoEvents(); windowSecond->assertNoEvents(); } } Loading Loading @@ -713,7 +721,7 @@ TEST_F(InputDispatcherTest, SetInputWindow_InputWindowInfo) { // Top window is invalid, so it should not receive any input event. // Top window is invalid, so it should not receive any input event. windowTop->assertNoEvents(); windowTop->assertNoEvents(); windowSecond->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowSecond->consumeKeyDown(ADISPLAY_ID_NONE); } } TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { Loading @@ -738,7 +746,7 @@ TEST_F(InputDispatcherTest, DispatchMouseEventsUnderCursor) { ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionEvent(mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE, injectMotionEvent(mDispatcher, AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_MOUSE, ADISPLAY_ID_DEFAULT, 610, 400, 599, 400)); ADISPLAY_ID_DEFAULT, 610, 400, 599, 400)); windowLeft->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowLeft->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowRight->assertNoEvents(); windowRight->assertNoEvents(); } } Loading Loading @@ -794,7 +802,7 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowInSecondary->assertNoEvents(); windowInSecondary->assertNoEvents(); // Test touch down on second display. // Test touch down on second display. Loading @@ -802,28 +810,28 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayTouch) AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID)) AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID)) << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, SECOND_DISPLAY_ID); windowInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); } } TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) { TEST_F(InputDispatcherFocusOnTwoDisplaysTest, SetInputWindow_MultiDisplayFocus) { // Test inject a key down with display id specified. // Test inject a key down with display id specified. ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher, ADISPLAY_ID_DEFAULT)) ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher, ADISPLAY_ID_DEFAULT)) << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_DEFAULT); windowInPrimary->consumeKeyDown(ADISPLAY_ID_DEFAULT); windowInSecondary->assertNoEvents(); windowInSecondary->assertNoEvents(); // Test inject a key down without display id specified. // Test inject a key down without display id specified. ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher)) ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectKeyDown(mDispatcher)) << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowInSecondary->consumeKeyDown(ADISPLAY_ID_NONE); // Remove secondary display. // Remove secondary display. std::vector<sp<InputWindowHandle>> noWindows; std::vector<sp<InputWindowHandle>> noWindows; mDispatcher->setInputWindows(noWindows, SECOND_DISPLAY_ID); mDispatcher->setInputWindows(noWindows, SECOND_DISPLAY_ID); // Expect old focus should receive a cancel event. // Expect old focus should receive a cancel event. windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE, windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, AKEY_EVENT_ACTION_UP, ADISPLAY_ID_NONE, AKEY_EVENT_FLAG_CANCELED); AKEY_EVENT_FLAG_CANCELED); // Test inject a key down, should timeout because of no target window. // Test inject a key down, should timeout because of no target window. Loading Loading @@ -853,8 +861,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, ASSERT_EQ(INPUT_EVENT_INJECTION_SUCCEEDED, injectMotionDown(mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT)) << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); windowInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); monitorInPrimary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_DEFAULT); monitorInPrimary->consumeMotionDown(ADISPLAY_ID_DEFAULT); windowInSecondary->assertNoEvents(); windowInSecondary->assertNoEvents(); monitorInSecondary->assertNoEvents(); monitorInSecondary->assertNoEvents(); Loading @@ -864,8 +872,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, SECOND_DISPLAY_ID); windowInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); monitorInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, SECOND_DISPLAY_ID); monitorInSecondary->consumeMotionDown(SECOND_DISPLAY_ID); // Test inject a non-pointer motion event. // Test inject a non-pointer motion event. // If specific a display, it will dispatch to the focused window of particular display, // If specific a display, it will dispatch to the focused window of particular display, Loading @@ -875,8 +883,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorMotionEvent_MultiDisplay) { << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject motion event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_NONE); windowInSecondary->consumeMotionDown(ADISPLAY_ID_NONE); monitorInSecondary->consumeEvent(AINPUT_EVENT_TYPE_MOTION, ADISPLAY_ID_NONE); monitorInSecondary->consumeMotionDown(ADISPLAY_ID_NONE); } } // Test per-display input monitors for key event. // Test per-display input monitors for key event. Loading @@ -892,8 +900,8 @@ TEST_F(InputDispatcherFocusOnTwoDisplaysTest, MonitorKeyEvent_MultiDisplay) { << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; << "Inject key event should return INPUT_EVENT_INJECTION_SUCCEEDED"; windowInPrimary->assertNoEvents(); windowInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); monitorInPrimary->assertNoEvents(); windowInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); windowInSecondary->consumeKeyDown(ADISPLAY_ID_NONE); monitorInSecondary->consumeEvent(AINPUT_EVENT_TYPE_KEY, ADISPLAY_ID_NONE); monitorInSecondary->consumeKeyDown(ADISPLAY_ID_NONE); } } class InputFilterTest : public InputDispatcherTest { class InputFilterTest : public InputDispatcherTest { Loading