Skip to content

Commit 3ef3c4d

Browse files
committed
ExternalStylusIntegrationTest: Reduce likelihood for flake
In the test, an event will be generated after a 72ms timeout, and we assert that no event is generated before that timeout. Since this is a racy assertion, just wait for 1ms to ensure that an event isn't immediately generated. If this is not enough to bring the flakes rates to an acceptable level, we will need to refactor the tests to remove the race altogether. Bug: 386801813 Change-Id: Id223930925ce724e216e61a9e68e1da79bed6f04 Test: Presubmit Flag: TEST_ONLY
1 parent edc7146 commit 3ef3c4d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

services/inputflinger/tests/InputReader_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,10 +2474,10 @@ TEST_F(ExternalStylusIntegrationTest, FusedExternalStylusPressureNotReported) {
24742474
const auto syncTime = std::chrono::system_clock::now();
24752475
// After 72 ms, the event *will* be generated. If we wait the full 72 ms to check that NO event
24762476
// is generated in that period, there will be a race condition between the event being generated
2477-
// and the test's wait timeout expiring. Thus, we wait for a shorter duration in the test, which
2478-
// will reduce the liklihood of the race condition occurring.
2479-
const auto waitUntilTimeForNoEvent =
2480-
syncTime + std::chrono::milliseconds(ns2ms(EXTERNAL_STYLUS_DATA_TIMEOUT / 2));
2477+
// and the test's wait timeout expiring. Thus, we wait for a shorter duration in the test to
2478+
// ensure the event is not immediately generated, which should reduce the liklihood of the race
2479+
// condition occurring.
2480+
const auto waitUntilTimeForNoEvent = syncTime + std::chrono::milliseconds(1);
24812481
mDevice->sendSync();
24822482
ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasNotCalled(waitUntilTimeForNoEvent));
24832483

0 commit comments

Comments
 (0)