| 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 ebeebf6777888a67aeeba7af1b6bf0290cd2d312..5cb3ed23b7799571da5820a1d81492791b8267f1 100644
|
| --- a/mojo/public/cpp/system/tests/watcher_unittest.cc
|
| +++ b/mojo/public/cpp/system/tests/watcher_unittest.cc
|
| @@ -8,7 +8,6 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| -#include "base/macros.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/run_loop.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| @@ -36,10 +35,16 @@
|
| WatcherTest() {}
|
| ~WatcherTest() override {}
|
|
|
| - private:
|
| - base::MessageLoop message_loop_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(WatcherTest);
|
| + void SetUp() override {
|
| + message_loop_.reset(new base::MessageLoop);
|
| + }
|
| +
|
| + void TearDown() override {
|
| + message_loop_.reset();
|
| + }
|
| +
|
| + protected:
|
| + std::unique_ptr<base::MessageLoop> message_loop_;
|
| };
|
|
|
| TEST_F(WatcherTest, WatchBasic) {
|
| @@ -157,6 +162,28 @@
|
| run_loop.Run();
|
| }
|
|
|
| +TEST_F(WatcherTest, NotifyOnMessageLoopDestruction) {
|
| + 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_ABORTED, result);
|
| + notified = true;
|
| + })));
|
| + EXPECT_TRUE(b_watcher.IsWatching());
|
| +
|
| + message_loop_.reset();
|
| +
|
| + EXPECT_TRUE(notified);
|
| +
|
| + EXPECT_TRUE(b_watcher.IsWatching());
|
| + b_watcher.Cancel();
|
| +}
|
| +
|
| TEST_F(WatcherTest, CloseAndCancel) {
|
| ScopedMessagePipeHandle a, b;
|
| CreateMessagePipe(nullptr, &a, &b);
|
|
|