Index: mojo/public/cpp/system/tests/watcher_unittest.cc |
diff --git a/mojo/public/cpp/system/tests/watcher_unittest.cc b/mojo/public/cpp/system/tests/watcher_unittest.cc |
index f72f495fd683874e325ba24976226e03508f1649..2d23cbf3a56565eebcb313f4ea88746b2eb2aec9 100644 |
--- a/mojo/public/cpp/system/tests/watcher_unittest.cc |
+++ b/mojo/public/cpp/system/tests/watcher_unittest.cc |
@@ -202,5 +202,30 @@ TEST_F(WatcherTest, CloseAndCancel) { |
base::RunLoop().RunUntilIdle(); |
} |
+TEST_F(WatcherTest, SyncDispatch) { |
+ ScopedMessagePipeHandle a, b; |
+ CreateMessagePipe(nullptr, &a, &b); |
+ |
+ bool notified = false; |
+ Watcher b_watcher; |
+ EXPECT_EQ(MOJO_RESULT_OK, |
+ b_watcher.Start(b.get(), MOJO_HANDLE_SIGNAL_READABLE, |
+ OnReady([&] (MojoResult result) { |
+ EXPECT_EQ(MOJO_RESULT_OK, result); |
+ notified = true; |
+ }))); |
+ EXPECT_TRUE(b_watcher.IsWatching()); |
+ |
+ b_watcher.EnableImmediateDispatchOfEventsFromSameThread(true); |
+ EXPECT_EQ(MOJO_RESULT_OK, WriteMessageRaw(a.get(), "hello", 5, nullptr, 0, |
+ MOJO_WRITE_MESSAGE_FLAG_NONE)); |
+ |
+ // We don't spin the MessageLoop but should have been notified anyway. |
+ |
+ EXPECT_TRUE(notified); |
+ |
+ b_watcher.Cancel(); |
+} |
+ |
} // namespace |
} // namespace mojo |