| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/message_loop_proxy_impl.h" | 5 #include "base/message_loop_proxy_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
| 14 | 14 |
| 15 | 15 |
| 16 class MessageLoopProxyImplTest : public testing::Test { | 16 class MessageLoopProxyImplTest : public testing::Test { |
| 17 public: | 17 public: |
| 18 void Release() const { | 18 void Release() const { |
| 19 AssertOnIOThread(); | 19 AssertOnIOThread(); |
| 20 Quit(); | 20 Quit(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void Quit() const { | 23 void Quit() const { |
| 24 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); | 24 loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void AssertOnIOThread() const { | 27 void AssertOnIOThread() const { |
| 28 ASSERT_TRUE(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); | 28 ASSERT_TRUE(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); |
| 29 ASSERT_EQ(io_thread_->message_loop_proxy(), | 29 ASSERT_EQ(io_thread_->message_loop_proxy(), |
| 30 base::MessageLoopProxy::current()); | 30 base::MessageLoopProxy::current()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void AssertOnFileThread() const { | 33 void AssertOnFileThread() const { |
| 34 ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread()); | 34 ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 scoped_ptr<base::Thread> test_thread( | 168 scoped_ptr<base::Thread> test_thread( |
| 169 new base::Thread("MessageLoopProxyImplTest_Dummy")); | 169 new base::Thread("MessageLoopProxyImplTest_Dummy")); |
| 170 test_thread->Start(); | 170 test_thread->Start(); |
| 171 message_loop_proxy = test_thread->message_loop_proxy(); | 171 message_loop_proxy = test_thread->message_loop_proxy(); |
| 172 } | 172 } |
| 173 bool ret = message_loop_proxy->PostTask( | 173 bool ret = message_loop_proxy->PostTask( |
| 174 FROM_HERE, | 174 FROM_HERE, |
| 175 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); | 175 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); |
| 176 EXPECT_FALSE(ret); | 176 EXPECT_FALSE(ret); |
| 177 } | 177 } |
| OLD | NEW |