OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
(...skipping 19 matching lines...) Expand all Loading... |
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()); |
35 ASSERT_EQ(file_thread_->message_loop_proxy(), | 35 ASSERT_EQ(file_thread_->message_loop_proxy(), |
36 base::MessageLoopProxy::current()); | 36 base::MessageLoopProxy::current()); |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 virtual void SetUp() { | 40 virtual void SetUp() OVERRIDE { |
41 io_thread_.reset(new base::Thread("MessageLoopProxyImplTest_IO")); | 41 io_thread_.reset(new base::Thread("MessageLoopProxyImplTest_IO")); |
42 file_thread_.reset(new base::Thread("MessageLoopProxyImplTest_File")); | 42 file_thread_.reset(new base::Thread("MessageLoopProxyImplTest_File")); |
43 io_thread_->Start(); | 43 io_thread_->Start(); |
44 file_thread_->Start(); | 44 file_thread_->Start(); |
45 } | 45 } |
46 | 46 |
47 virtual void TearDown() { | 47 virtual void TearDown() OVERRIDE { |
48 io_thread_->Stop(); | 48 io_thread_->Stop(); |
49 file_thread_->Stop(); | 49 file_thread_->Stop(); |
50 } | 50 } |
51 | 51 |
52 static void BasicFunction(MessageLoopProxyImplTest* test) { | 52 static void BasicFunction(MessageLoopProxyImplTest* test) { |
53 test->AssertOnFileThread(); | 53 test->AssertOnFileThread(); |
54 test->Quit(); | 54 test->Quit(); |
55 } | 55 } |
56 | 56 |
57 static void AssertNotRun() { | 57 static void AssertNotRun() { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 scoped_ptr<base::Thread> test_thread( | 117 scoped_ptr<base::Thread> test_thread( |
118 new base::Thread("MessageLoopProxyImplTest_Dummy")); | 118 new base::Thread("MessageLoopProxyImplTest_Dummy")); |
119 test_thread->Start(); | 119 test_thread->Start(); |
120 message_loop_proxy = test_thread->message_loop_proxy(); | 120 message_loop_proxy = test_thread->message_loop_proxy(); |
121 } | 121 } |
122 bool ret = message_loop_proxy->PostTask( | 122 bool ret = message_loop_proxy->PostTask( |
123 FROM_HERE, | 123 FROM_HERE, |
124 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); | 124 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); |
125 EXPECT_FALSE(ret); | 125 EXPECT_FALSE(ret); |
126 } | 126 } |
OLD | NEW |