| Index: base/message_loop_unittest.cc
|
| diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
|
| index 15f825b7ac992eb791ecc2332819e7a03b160896..7167c5ea4f386cab0bb1a207d074a0ddb515c03c 100644
|
| --- a/base/message_loop_unittest.cc
|
| +++ b/base/message_loop_unittest.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/logging.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/message_loop.h"
|
| +#include "base/thread_task_runner_handle.h"
|
| #include "base/threading/platform_thread.h"
|
| #include "base/threading/thread.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -1689,3 +1690,25 @@ TEST(MessageLoopTest, DestructionObserverTest) {
|
| EXPECT_TRUE(task_destroyed);
|
| EXPECT_TRUE(destruction_observer_called);
|
| }
|
| +
|
| +
|
| +// Verify that MessageLoop sets ThreadMainTaskRunner::current() and it
|
| +// posts tasks on that message loop.
|
| +TEST(MessageLoopTest, ThreadMainTaskRunner) {
|
| + MessageLoop loop;
|
| +
|
| + scoped_refptr<Foo> foo(new Foo());
|
| + std::string a("a");
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, base::Bind(
|
| + &Foo::Test1ConstRef, foo.get(), a));
|
| +
|
| + // Post quit task;
|
| + MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
|
| + &MessageLoop::Quit, base::Unretained(MessageLoop::current())));
|
| +
|
| + // Now kick things off
|
| + MessageLoop::current()->Run();
|
| +
|
| + EXPECT_EQ(foo->test_count(), 1);
|
| + EXPECT_EQ(foo->result(), "a");
|
| +}
|
|
|