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

Commit bc656056 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android (Google) Code Review
Browse files

Merge "InputTracingTest: Fix test flakiness" into main

parents a89ee5d3 6c0de2bb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ void ThreadedBackend<Backend>::traceMotionEvent(const TracedMotionEvent& event,
                                                const TracedEventMetadata& metadata) {
    std::scoped_lock lock(mLock);
    mQueue.emplace_back(event, metadata);
    setIdleStatus(false);
    mThreadWakeCondition.notify_all();
}

@@ -65,6 +66,7 @@ void ThreadedBackend<Backend>::traceKeyEvent(const TracedKeyEvent& event,
                                             const TracedEventMetadata& metadata) {
    std::scoped_lock lock(mLock);
    mQueue.emplace_back(event, metadata);
    setIdleStatus(false);
    mThreadWakeCondition.notify_all();
}

@@ -73,6 +75,7 @@ void ThreadedBackend<Backend>::traceWindowDispatch(const WindowDispatchArgs& dis
                                                   const TracedEventMetadata& metadata) {
    std::scoped_lock lock(mLock);
    mQueue.emplace_back(dispatchArgs, metadata);
    setIdleStatus(false);
    mThreadWakeCondition.notify_all();
}

@@ -84,7 +87,9 @@ void ThreadedBackend<Backend>::threadLoop() {
        std::unique_lock lock(mLock);
        base::ScopedLockAssertion assumeLocked(mLock);

        if (mQueue.empty()) {
            setIdleStatus(true);
        }

        // Wait until we need to process more events or exit.
        mThreadWakeCondition.wait(lock,
@@ -94,8 +99,6 @@ void ThreadedBackend<Backend>::threadLoop() {
            return;
        }

        setIdleStatus(false);

        mQueue.swap(entries);
    } // release lock

+2 −0
Original line number Diff line number Diff line
@@ -626,6 +626,8 @@ TEST_F(InputTracingTest, TraceWindowDispatch) {
    consumed = window->consumeMotionEvent(WithMotionAction(ACTION_CANCEL));
    s.expectMotionTraced(Level::NONE, *consumed);
    s.expectDispatchTraced(Level::REDACTED, {*consumed, window});

    waitForTracerIdle();
}

TEST_F(InputTracingTest, SimultaneousTracingSessions) {