| 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..37fde23ef05b2c63a7a42b590535491caf083a3d 100644
|
| --- a/mojo/common/handle_watcher_unittest.cc
|
| +++ b/mojo/common/handle_watcher_unittest.cc
|
| @@ -20,6 +20,13 @@ namespace mojo {
|
| namespace common {
|
| namespace test {
|
|
|
| +void ObserveCallback(bool* was_signaled,
|
| + MojoResult* result_observed,
|
| + MojoResult result) {
|
| + *was_signaled = true;
|
| + *result_observed = result;
|
| +}
|
| +
|
| void RunUntilIdle() {
|
| base::RunLoop run_loop;
|
| run_loop.RunUntilIdle();
|
| @@ -101,14 +108,6 @@ class HandleWatcherTest : public testing::Test {
|
| test::SetTickClockForTest(NULL);
|
| }
|
|
|
| - virtual void SetUp() OVERRIDE {
|
| - environment_.reset(new Environment);
|
| - }
|
| -
|
| - virtual void TearDown() OVERRIDE {
|
| - environment_.reset();
|
| - }
|
| -
|
| protected:
|
| void InstallTickClock() {
|
| test::SetTickClockForTest(&tick_clock_);
|
| @@ -117,8 +116,8 @@ class HandleWatcherTest : public testing::Test {
|
| base::SimpleTestTickClock tick_clock_;
|
|
|
| private:
|
| + Environment environment_;
|
| base::MessageLoop message_loop_;
|
| - scoped_ptr<Environment> environment_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(HandleWatcherTest);
|
| };
|
| @@ -315,6 +314,29 @@ TEST_F(HandleWatcherTest, DeleteInCallback) {
|
| EXPECT_TRUE(callback_helper.got_callback());
|
| }
|
|
|
| +TEST(HandleWatcherCleanEnvironmentTest, AbortedOnMessageLoopDestruction) {
|
| + bool was_signaled = false;
|
| + MojoResult result = MOJO_RESULT_OK;
|
| +
|
| + 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
|
|
|