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

Unified Diff: mojo/common/handle_watcher_unittest.cc

Issue 282823003: Mojo: cancel pending AsyncWait calls when the callers thread exits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace fix Created 6 years, 7 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
« mojo/common/handle_watcher.cc ('K') | « mojo/common/handle_watcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/handle_watcher_unittest.cc
diff --git a/mojo/common/handle_watcher_unittest.cc b/mojo/common/handle_watcher_unittest.cc
index 5cc8cfa82079f94c7402b5c95bbd3071e69c7658..cf17c4438f11c4992524131620944b651b220b52 100644
--- a/mojo/common/handle_watcher_unittest.cc
+++ b/mojo/common/handle_watcher_unittest.cc
@@ -20,6 +20,12 @@ namespace mojo {
namespace common {
namespace test {
+void ObserveCallback(bool* was_signaled, MojoResult* result_observed,
sky 2014/05/13 21:22:42 nit: one param per line when you wrap.
+ MojoResult result) {
+ *was_signaled = true;
+ *result_observed = result;
+}
+
void RunUntilIdle() {
base::RunLoop run_loop;
run_loop.RunUntilIdle();
@@ -315,6 +321,29 @@ TEST_F(HandleWatcherTest, DeleteInCallback) {
EXPECT_TRUE(callback_helper.got_callback());
}
+TEST(HandleWatcherCleanEnvironmentTest, AbortedOnMessageLoopDestruction) {
+ bool was_signaled = false;
+ MojoResult result;
sky 2014/05/13 21:22:42 nit: initialize this to something.
+
+ Environment env;
+
+ MessagePipe pipe;
+ HandleWatcher watcher;
+ {
+ base::MessageLoop loop;
+
+ watcher.Start(pipe.handle0.get(),
+ MOJO_WAIT_FLAG_READABLE,
+ MOJO_DEADLINE_INDEFINITE,
+ base::Bind(&ObserveCallback, &was_signaled, &result));
+
+ // Now, let the MessageLoop get torn down. We expect our callback to run.
+ }
+
+ EXPECT_TRUE(was_signaled);
+ EXPECT_EQ(MOJO_RESULT_ABORTED, result);
+}
+
} // namespace test
} // namespace common
} // namespace mojo
« mojo/common/handle_watcher.cc ('K') | « mojo/common/handle_watcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698