@@ -41,15 +41,21 @@ void FakeInputReaderPolicy::assertInputDevicesNotChanged() {
4141}
4242
4343void FakeInputReaderPolicy::assertStylusGestureNotified (int32_t deviceId) {
44- std::scoped_lock lock (mLock );
45- ASSERT_TRUE (mStylusGestureNotified );
46- ASSERT_EQ (deviceId, *mStylusGestureNotified );
47- mStylusGestureNotified .reset ();
44+ std::unique_lock lock (mLock );
45+ base::ScopedLockAssertion assumeLocked (mLock );
46+
47+ const bool success =
48+ mStylusGestureNotifiedCondition .wait_for (lock, WAIT_TIMEOUT, [this ]() REQUIRES (mLock ) {
49+ return mDeviceIdOfNotifiedStylusGesture .has_value ();
50+ });
51+ ASSERT_TRUE (success) << " Timed out waiting for stylus gesture to be notified" ;
52+ ASSERT_EQ (deviceId, *mDeviceIdOfNotifiedStylusGesture );
53+ mDeviceIdOfNotifiedStylusGesture .reset ();
4854}
4955
5056void FakeInputReaderPolicy::assertStylusGestureNotNotified () {
5157 std::scoped_lock lock (mLock );
52- ASSERT_FALSE (mStylusGestureNotified );
58+ ASSERT_FALSE (mDeviceIdOfNotifiedStylusGesture );
5359}
5460
5561void FakeInputReaderPolicy::clearViewports () {
@@ -258,7 +264,8 @@ void FakeInputReaderPolicy::waitForInputDevices(std::function<void(bool)> proces
258264
259265void FakeInputReaderPolicy::notifyStylusGestureStarted (int32_t deviceId, nsecs_t eventTime) {
260266 std::scoped_lock lock (mLock );
261- mStylusGestureNotified = deviceId;
267+ mDeviceIdOfNotifiedStylusGesture = deviceId;
268+ mStylusGestureNotifiedCondition .notify_all ();
262269}
263270
264271std::optional<DisplayViewport> FakeInputReaderPolicy::getPointerViewportForAssociatedDisplay (
0 commit comments