diff options
author | Prabir Pradhan <prabirmsp@google.com> | 2022-08-05 22:26:56 +0000 |
---|---|---|
committer | Prabir Pradhan <prabirmsp@google.com> | 2022-09-01 16:40:04 +0000 |
commit | 366904197bc619c00e36403faf2b17ffc1b5c204 (patch) | |
tree | d5e641b57f9848a7430f6d1f66a2824d2461adde | |
parent | e74b35ffd574e4ddccb2112efcb9e337653cd9a6 (diff) | |
download | native-366904197bc619c00e36403faf2b17ffc1b5c204.tar.gz |
Fix issues with InputMapper tests
- When an input device is added, a device reset notification is sent.
This should be consumed when the device is added so that it does
not need to be consumed in every test case.
- The above change exposed an issue with a CursorInputMapper test case,
where it was consuming the wrong device reset notification.
- When a device is configured, it may produce device reset
notifications. After configuring, we should loop the input reader so
that the queued input listener is flushed so that these args can be
sent out.
Bug: 234662773
Test: atest inputflinger_tests
Change-Id: Ic4979b91207a6abf4c4ac65fd3db30307cb53729
Merged-In: Ic4979b91207a6abf4c4ac65fd3db30307cb53729
(cherry picked from commit b5174de1a9ede697dfd2bf65e65b294321f9444d)
-rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index 8065ad645c..2c8afc7b89 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -2938,6 +2938,8 @@ protected: mReader = std::make_unique<InstrumentedInputReader>(mFakeEventHub, mFakePolicy, *mFakeListener); mDevice = newDevice(DEVICE_ID, DEVICE_NAME, DEVICE_LOCATION, EVENTHUB_ID, classes); + // Consume the device reset notification generated when adding a new device. + mFakeListener->assertNotifyDeviceResetWasCalled(); } void SetUp() override { @@ -2962,6 +2964,8 @@ protected: mReader->loopOnce(); } mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), changes); + // Loop the reader to flush the input listener queue. + mReader->loopOnce(); } std::shared_ptr<InputDevice> newDevice(int32_t deviceId, const std::string& name, @@ -2985,6 +2989,8 @@ protected: configureDevice(0); mDevice->reset(ARBITRARY_TIME); mapper.reset(ARBITRARY_TIME); + // Loop the reader to flush the input listener queue. + mReader->loopOnce(); return mapper; } @@ -3010,6 +3016,7 @@ protected: event.code = code; event.value = value; mapper.process(&event); + // Loop the reader to flush the input listener queue. mReader->loopOnce(); } @@ -4907,7 +4914,6 @@ TEST_F(CursorInputMapperTest, Process_PointerCapture) { ASSERT_TRUE(mReader->getContext()->getGeneration() != generation); ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs)); - ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime); ASSERT_EQ(DEVICE_ID, resetArgs.deviceId); process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10); |