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/message_loop_proxy_impl.h" | 5 #include "base/message_loop/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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 MessageLoopProxy::current()); | 31 MessageLoopProxy::current()); |
32 } | 32 } |
33 | 33 |
34 void AssertOnFileThread() const { | 34 void AssertOnFileThread() const { |
35 ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread()); | 35 ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread()); |
36 ASSERT_EQ(file_thread_->message_loop_proxy(), | 36 ASSERT_EQ(file_thread_->message_loop_proxy(), |
37 MessageLoopProxy::current()); | 37 MessageLoopProxy::current()); |
38 } | 38 } |
39 | 39 |
40 protected: | 40 protected: |
41 virtual void SetUp() override { | 41 void SetUp() override { |
42 io_thread_.reset(new Thread("MessageLoopProxyImplTest_IO")); | 42 io_thread_.reset(new Thread("MessageLoopProxyImplTest_IO")); |
43 file_thread_.reset(new Thread("MessageLoopProxyImplTest_File")); | 43 file_thread_.reset(new Thread("MessageLoopProxyImplTest_File")); |
44 io_thread_->Start(); | 44 io_thread_->Start(); |
45 file_thread_->Start(); | 45 file_thread_->Start(); |
46 } | 46 } |
47 | 47 |
48 virtual void TearDown() override { | 48 void TearDown() override { |
49 io_thread_->Stop(); | 49 io_thread_->Stop(); |
50 file_thread_->Stop(); | 50 file_thread_->Stop(); |
51 } | 51 } |
52 | 52 |
53 static void BasicFunction(MessageLoopProxyImplTest* test) { | 53 static void BasicFunction(MessageLoopProxyImplTest* test) { |
54 test->AssertOnFileThread(); | 54 test->AssertOnFileThread(); |
55 test->Quit(); | 55 test->Quit(); |
56 } | 56 } |
57 | 57 |
58 static void AssertNotRun() { | 58 static void AssertNotRun() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 test_thread->Start(); | 120 test_thread->Start(); |
121 message_loop_proxy = test_thread->message_loop_proxy(); | 121 message_loop_proxy = test_thread->message_loop_proxy(); |
122 } | 122 } |
123 bool ret = message_loop_proxy->PostTask( | 123 bool ret = message_loop_proxy->PostTask( |
124 FROM_HERE, | 124 FROM_HERE, |
125 Bind(&MessageLoopProxyImplTest::AssertNotRun)); | 125 Bind(&MessageLoopProxyImplTest::AssertNotRun)); |
126 EXPECT_FALSE(ret); | 126 EXPECT_FALSE(ret); |
127 } | 127 } |
128 | 128 |
129 } // namespace base | 129 } // namespace base |
OLD | NEW |