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

Unified Diff: mojo/public/cpp/utility/tests/run_loop_unittest.cc

Issue 588593002: mojo: Allow basic RunLoop to be quit from a posted task. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow review Created 6 years, 3 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/utility/tests/run_loop_unittest.cc
diff --git a/mojo/public/cpp/utility/tests/run_loop_unittest.cc b/mojo/public/cpp/utility/tests/run_loop_unittest.cc
index d9f754c66d3fde8245fbc03651a34a5a1829ff36..58d317ceccccb4173f4c045c3b265c41ec3f2cb0 100644
--- a/mojo/public/cpp/utility/tests/run_loop_unittest.cc
+++ b/mojo/public/cpp/utility/tests/run_loop_unittest.cc
@@ -413,5 +413,25 @@ TEST_F(RunLoopTest, DelayedTaskOrder) {
EXPECT_EQ(3, sequence[2]);
}
+struct QuittingTask {
+ QuittingTask(RunLoop* run_loop) : run_loop(run_loop) {}
+
+ void Run() const { run_loop->Quit(); }
+
+ RunLoop* run_loop;
+};
+
+TEST_F(RunLoopTest, QuitFromDelayedTask) {
+ TestRunLoopHandler handler;
+ MessagePipe test_pipe;
+ RunLoop run_loop;
+ run_loop.AddHandler(&handler,
+ test_pipe.handle0.get(),
+ MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE);
+ run_loop.PostDelayedTask(Closure(QuittingTask(&run_loop)), 0);
+ run_loop.Run();
+}
+
} // namespace
} // namespace mojo
« mojo/public/cpp/utility/lib/run_loop.cc ('K') | « mojo/public/cpp/utility/run_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698