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

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

Merge "InputReader_test: Wait for stylus gesture to be notified" into main

parents 9de2d94c 40aee53b
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -41,15 +41,21 @@ void FakeInputReaderPolicy::assertInputDevicesNotChanged() {
}

void FakeInputReaderPolicy::assertStylusGestureNotified(int32_t deviceId) {
    std::scoped_lock lock(mLock);
    ASSERT_TRUE(mStylusGestureNotified);
    ASSERT_EQ(deviceId, *mStylusGestureNotified);
    mStylusGestureNotified.reset();
    std::unique_lock lock(mLock);
    base::ScopedLockAssertion assumeLocked(mLock);

    const bool success =
            mStylusGestureNotifiedCondition.wait_for(lock, WAIT_TIMEOUT, [this]() REQUIRES(mLock) {
                return mDeviceIdOfNotifiedStylusGesture.has_value();
            });
    ASSERT_TRUE(success) << "Timed out waiting for stylus gesture to be notified";
    ASSERT_EQ(deviceId, *mDeviceIdOfNotifiedStylusGesture);
    mDeviceIdOfNotifiedStylusGesture.reset();
}

void FakeInputReaderPolicy::assertStylusGestureNotNotified() {
    std::scoped_lock lock(mLock);
    ASSERT_FALSE(mStylusGestureNotified);
    ASSERT_FALSE(mDeviceIdOfNotifiedStylusGesture);
}

void FakeInputReaderPolicy::clearViewports() {
@@ -258,7 +264,8 @@ void FakeInputReaderPolicy::waitForInputDevices(std::function<void(bool)> proces

void FakeInputReaderPolicy::notifyStylusGestureStarted(int32_t deviceId, nsecs_t eventTime) {
    std::scoped_lock lock(mLock);
    mStylusGestureNotified = deviceId;
    mDeviceIdOfNotifiedStylusGesture = deviceId;
    mStylusGestureNotifiedCondition.notify_all();
}

std::optional<DisplayViewport> FakeInputReaderPolicy::getPointerViewportForAssociatedDisplay(
+3 −1
Original line number Diff line number Diff line
@@ -102,9 +102,11 @@ private:
    bool mInputDevicesChanged GUARDED_BY(mLock){false};
    std::vector<DisplayViewport> mViewports;
    TouchAffineTransformation transform;
    std::optional<int32_t /*deviceId*/> mStylusGestureNotified GUARDED_BY(mLock){};
    bool mIsInputMethodConnectionActive{false};

    std::condition_variable mStylusGestureNotifiedCondition;
    std::optional<DeviceId> mDeviceIdOfNotifiedStylusGesture GUARDED_BY(mLock){};

    uint32_t mNextPointerCaptureSequenceNumber{0};
};