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

Commit 4616abce authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Increase wait timeout for InputReader tests" into main

parents 74457ef7 42a145f0
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;