Address comments for ag/26028243
Address comments for Change-Id:
Ic748082383119b465caa41da8301746fefea2be9
Bug: 314702448
Test: atest inputflinger_tests
Change-Id: I1c3ec9a327c701fcbd1cb44cbc0d8ca001468cce
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index dba5401..094e957 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -6178,16 +6178,12 @@
window->consumeMotionDown();
monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
- secondMonitor.assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID,
{100, 200}))
- << "The down event injected into the second display should failed";
- // Foreground window and monitor on the first display should not receive any events.
- window->assertNoEvents();
- monitor.assertNoEvents();
- secondMonitor.assertNoEvents();
+ << "The down event injected into the second display should fail since there's no "
+ "touchable window";
// Continue to inject event to first display.
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -6197,7 +6193,6 @@
window->consumeMotionMove();
monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT);
- secondMonitor.assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
@@ -6206,6 +6201,9 @@
window->consumeMotionUp();
monitor.consumeMotionUp(ADISPLAY_ID_DEFAULT);
+
+ window->assertNoEvents();
+ monitor.assertNoEvents();
secondMonitor.assertNoEvents();
}
@@ -6244,16 +6242,12 @@
window->consumeMotionDown(ADISPLAY_ID_DEFAULT);
monitor.consumeMotionDown(ADISPLAY_ID_DEFAULT);
- secondWindow->assertNoEvents();
- secondMonitor.assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionDown(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID,
{100, 200}))
<< "The down event injected into the second display should succeed";
- window->assertNoEvents();
- monitor.assertNoEvents();
secondWindow->consumeMotionDown(SECOND_DISPLAY_ID);
secondMonitor.consumeMotionDown(SECOND_DISPLAY_ID);
@@ -6262,21 +6256,16 @@
// The gone window should receive a cancel, and the monitor on the second display should not
// receive any events.
- window->assertNoEvents();
- monitor.assertNoEvents();
secondWindow->consumeMotionCancel(SECOND_DISPLAY_ID);
secondMonitor.assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
SECOND_DISPLAY_ID, {110, 220}))
- << "The move event injected into the second display should failed";
+ << "The move event injected into the second display should fail because there's no "
+ "touchable window";
// Now the monitor on the second display should receive a cancel event.
secondMonitor.consumeMotionCancel(SECOND_DISPLAY_ID);
- // Other windows and monitors should not receive any events.
- window->assertNoEvents();
- monitor.assertNoEvents();
- secondWindow->assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
@@ -6285,18 +6274,12 @@
window->consumeMotionMove();
monitor.consumeMotionMove(ADISPLAY_ID_DEFAULT);
- secondWindow->assertNoEvents();
- secondMonitor.assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::FAILED,
- injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID, {110,
- 220}))
- << "The up event injected into the second display should failed";
-
- window->assertNoEvents();
- monitor.assertNoEvents();
- secondWindow->assertNoEvents();
- secondMonitor.assertNoEvents();
+ injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, SECOND_DISPLAY_ID,
+ {110, 220}))
+ << "The up event injected into the second display should fail because there's no "
+ "touchable window";
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
injectMotionUp(*mDispatcher, AINPUT_SOURCE_TOUCHSCREEN, ADISPLAY_ID_DEFAULT,
@@ -6305,8 +6288,11 @@
window->consumeMotionUp(ADISPLAY_ID_DEFAULT);
monitor.consumeMotionUp(ADISPLAY_ID_DEFAULT);
+
window->assertNoEvents();
monitor.assertNoEvents();
+ secondWindow->assertNoEvents();
+ secondMonitor.assertNoEvents();
}
/**
@@ -6355,9 +6341,8 @@
// Let foreground window gone
mDispatcher->onWindowInfosChanged({{}, {displayInfo}, 0, 0});
- // Foreground window should receive a cancel event, but monitor not.
+ // Foreground window should receive a cancel event, but not the monitor.
window->consumeMotionCancel();
- monitor.assertNoEvents();
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN,
@@ -6365,7 +6350,6 @@
<< "The move event injected should failed";
// Now foreground should not receive any events, but monitor should receive a cancel event
// with transform that same as display's display.
- window->assertNoEvents();
std::unique_ptr<MotionEvent> cancelMotionEvent = monitor.consumeMotion();
EXPECT_EQ(transform, cancelMotionEvent->getTransform());
EXPECT_EQ(ADISPLAY_ID_DEFAULT, cancelMotionEvent->getDisplayId());
@@ -6375,7 +6359,7 @@
ASSERT_EQ(InputEventInjectionResult::FAILED,
injectMotionEvent(*mDispatcher, AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN,
ADISPLAY_ID_DEFAULT, {110, 220}))
- << "The up event injected should failed";
+ << "The up event injected should fail because the touched window was removed";
window->assertNoEvents();
monitor.assertNoEvents();
}