Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1620)

Unified Diff: mojo/public/cpp/system/tests/watcher_unittest.cc

Issue 1811433002: [mojo-edk] Expose notification source to MojoWatch callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698