| Index: base/message_loop_proxy_impl_unittest.cc
|
| diff --git a/base/message_loop_proxy_impl_unittest.cc b/base/message_loop_proxy_impl_unittest.cc
|
| index 558cd93278b1aa9d078fdb2582d6056423a797ab..d635acb1a7c4b38d26206fcc6ccbe965bf06d3f1 100644
|
| --- a/base/message_loop_proxy_impl_unittest.cc
|
| +++ b/base/message_loop_proxy_impl_unittest.cc
|
| @@ -2,9 +2,11 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/message_loop_proxy_impl.h"
|
| +
|
| +#include "base/bind.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop.h"
|
| -#include "base/message_loop_proxy_impl.h"
|
| #include "base/threading/thread.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "testing/platform_test.h"
|
| @@ -47,6 +49,10 @@ class MessageLoopProxyImplTest : public testing::Test {
|
| test->Quit();
|
| }
|
|
|
| + static void AssertNotRun() {
|
| + FAIL() << "Callback Should not get executed.";
|
| + }
|
| +
|
| class DummyTask : public Task {
|
| public:
|
| explicit DummyTask(bool* deleted) : deleted_(deleted) { }
|
| @@ -83,7 +89,7 @@ class MessageLoopProxyImplTest : public testing::Test {
|
| };
|
|
|
|
|
| -TEST_F(MessageLoopProxyImplTest, PostTask) {
|
| +TEST_F(MessageLoopProxyImplTest, LegacyPostTask) {
|
| EXPECT_TRUE(file_thread_->message_loop_proxy()->PostTask(
|
| FROM_HERE, NewRunnableFunction(&BasicFunction, this)));
|
| MessageLoop::current()->Run();
|
| @@ -101,7 +107,7 @@ TEST_F(MessageLoopProxyImplTest, Delete) {
|
| MessageLoop::current()->Run();
|
| }
|
|
|
| -TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadExits) {
|
| +TEST_F(MessageLoopProxyImplTest, LegacyPostTaskAfterThreadExits) {
|
| scoped_ptr<base::Thread> test_thread(
|
| new base::Thread("MessageLoopProxyImplTest_Dummy"));
|
| test_thread->Start();
|
| @@ -116,7 +122,7 @@ TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadExits) {
|
| EXPECT_TRUE(deleted);
|
| }
|
|
|
| -TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadIsDeleted) {
|
| +TEST_F(MessageLoopProxyImplTest, LegacyPostTaskAfterThreadIsDeleted) {
|
| scoped_refptr<base::MessageLoopProxy> message_loop_proxy;
|
| {
|
| scoped_ptr<base::Thread> test_thread(
|
| @@ -130,3 +136,37 @@ TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadIsDeleted) {
|
| EXPECT_TRUE(deleted);
|
| }
|
|
|
| +TEST_F(MessageLoopProxyImplTest, PostTask) {
|
| + EXPECT_TRUE(file_thread_->message_loop_proxy()->PostTask(
|
| + FROM_HERE, base::Bind(&MessageLoopProxyImplTest::BasicFunction,
|
| + base::Unretained(this))));
|
| + MessageLoop::current()->Run();
|
| +}
|
| +
|
| +TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadExits) {
|
| + scoped_ptr<base::Thread> test_thread(
|
| + new base::Thread("MessageLoopProxyImplTest_Dummy"));
|
| + test_thread->Start();
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
|
| + test_thread->message_loop_proxy();
|
| + test_thread->Stop();
|
| +
|
| + bool ret = message_loop_proxy->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&MessageLoopProxyImplTest::AssertNotRun));
|
| + EXPECT_FALSE(ret);
|
| +}
|
| +
|
| +TEST_F(MessageLoopProxyImplTest, PostTaskAfterThreadIsDeleted) {
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy;
|
| + {
|
| + scoped_ptr<base::Thread> test_thread(
|
| + new base::Thread("MessageLoopProxyImplTest_Dummy"));
|
| + test_thread->Start();
|
| + message_loop_proxy = test_thread->message_loop_proxy();
|
| + }
|
| + bool ret = message_loop_proxy->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&MessageLoopProxyImplTest::AssertNotRun));
|
| + EXPECT_FALSE(ret);
|
| +}
|
|
|