Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42a145f0 authored by Arpit Singh's avatar Arpit Singh
Browse files

Increase wait timeout for InputReader tests

Current timeout is not sufficient for some events on cuttlefish devices.
Increase the timeout and account for hardware multiplier to reduce
flakiness.

Test: atest inputflinger_tests:TouchIntegrationTest --rerun-until-failure 1000
Bug: 303677628
Flag: TEST_ONLY
Change-Id: I72a8b2e6884492192842bf9f6b192573cd408084
parent 9659e345
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#include "FakeInputReaderPolicy.h"

#include <android-base/properties.h>
#include <android-base/thread_annotations.h>
#include <gtest/gtest.h>

@@ -24,6 +25,12 @@

namespace android {

namespace {

static const int HW_TIMEOUT_MULTIPLIER = base::GetIntProperty("ro.hw_timeout_multiplier", 1);

} // namespace

void FakeInputReaderPolicy::assertInputDevicesChanged() {
    waitForInputDevices([](bool devicesChanged) {
        if (!devicesChanged) {
@@ -241,7 +248,9 @@ void FakeInputReaderPolicy::waitForInputDevices(std::function<void(bool)> proces
    base::ScopedLockAssertion assumeLocked(mLock);

    const bool devicesChanged =
            mDevicesChangedCondition.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) {
            mDevicesChangedCondition.wait_for(lock,
                                              ADD_INPUT_DEVICE_TIMEOUT * HW_TIMEOUT_MULTIPLIER,
                                              [this]() REQUIRES(mLock) {
                                                  return mInputDevicesChanged;
                                              });
    ASSERT_NO_FATAL_FAILURE(processDevicesChanged(devicesChanged));
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ namespace android {

using std::chrono_literals::operator""ms;

// Timeout for waiting for an input device to be added and processed
static constexpr std::chrono::duration ADD_INPUT_DEVICE_TIMEOUT = 500ms;

// Timeout for waiting for an expected event
static constexpr std::chrono::duration WAIT_TIMEOUT = 100ms;