Chromium Code Reviews| 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 |