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

Commit 85c2ee61 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Wait longer for configuration change" into rvc-dev

parents 538eebb1 f0db5b8c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1748,7 +1748,8 @@ protected:

    virtual void SetUp() override {
        mFakePolicy = new FakeInputReaderPolicy();
        mTestListener = new TestInputListener(50ms);
        mTestListener = new TestInputListener(2000ms /*eventHappenedTimeout*/,
                                              30ms /*eventDidNotHappenTimeout*/);

        mReader = new InputReader(std::make_shared<EventHub>(), mFakePolicy, mTestListener);
        ASSERT_EQ(mReader->start(), OK);
+10 −7
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@ namespace android {

// --- TestInputListener ---

TestInputListener::TestInputListener(const std::chrono::milliseconds timeout) : mTimeout(timeout) {}
TestInputListener::TestInputListener(std::chrono::milliseconds eventHappenedTimeout,
                                     std::chrono::milliseconds eventDidNotHappenTimeout)
      : mEventHappenedTimeout(eventHappenedTimeout),
        mEventDidNotHappenTimeout(eventDidNotHappenTimeout) {}

TestInputListener::~TestInputListener() { }

@@ -86,9 +89,9 @@ void TestInputListener::assertCalled(NotifyArgsType* outEventArgs, std::string m

    std::vector<NotifyArgsType>& queue = std::get<std::vector<NotifyArgsType>>(mQueues);
    if (queue.empty()) {
        const bool eventReceived = mCondition.wait_for(lock, mTimeout, [&queue]() REQUIRES(mLock) {
            return !queue.empty();
        });
        const bool eventReceived =
                mCondition.wait_for(lock, mEventHappenedTimeout,
                                    [&queue]() REQUIRES(mLock) { return !queue.empty(); });
        if (!eventReceived) {
            FAIL() << "Timed out waiting for event: " << message.c_str();
        }
@@ -105,9 +108,9 @@ void TestInputListener::assertNotCalled(std::string message) {
    base::ScopedLockAssertion assumeLocked(mLock);

    std::vector<NotifyArgsType>& queue = std::get<std::vector<NotifyArgsType>>(mQueues);
    const bool eventReceived = mCondition.wait_for(lock, mTimeout, [&queue]() REQUIRES(mLock) {
        return !queue.empty();
    });
    const bool eventReceived =
            mCondition.wait_for(lock, mEventDidNotHappenTimeout,
                                [&queue]() REQUIRES(mLock) { return !queue.empty(); });
    if (eventReceived) {
        FAIL() << "Unexpected event: " << message.c_str();
    }
+4 −2
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ protected:
    virtual ~TestInputListener();

public:
    TestInputListener(const std::chrono::milliseconds timeout = 5ms);
    TestInputListener(std::chrono::milliseconds eventHappenedTimeout = 0ms,
                      std::chrono::milliseconds eventDidNotHappenTimeout = 0ms);

    void assertNotifyConfigurationChangedWasCalled(
            NotifyConfigurationChangedArgs* outEventArgs = nullptr);
@@ -75,7 +76,8 @@ private:

    std::mutex mLock;
    std::condition_variable mCondition;
    const std::chrono::milliseconds mTimeout;
    const std::chrono::milliseconds mEventHappenedTimeout;
    const std::chrono::milliseconds mEventDidNotHappenTimeout;

    std::tuple<std::vector<NotifyConfigurationChangedArgs>, //
               std::vector<NotifyDeviceResetArgs>,          //