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" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 MessageLoopProxyImplTest* test_; | 86 MessageLoopProxyImplTest* test_; |
87 }; | 87 }; |
88 | 88 |
89 scoped_ptr<base::Thread> io_thread_; | 89 scoped_ptr<base::Thread> io_thread_; |
90 scoped_ptr<base::Thread> file_thread_; | 90 scoped_ptr<base::Thread> file_thread_; |
91 | 91 |
92 private: | 92 private: |
93 mutable MessageLoop loop_; | 93 mutable MessageLoop loop_; |
94 }; | 94 }; |
95 | 95 |
96 | |
97 TEST_F(MessageLoopProxyImplTest, LegacyPostTask) { | |
98 EXPECT_TRUE(file_thread_->message_loop_proxy()->PostTask( | |
99 FROM_HERE, NewRunnableFunction(&BasicFunction, this))); | |
100 MessageLoop::current()->Run(); | |
101 } | |
102 | |
103 TEST_F(MessageLoopProxyImplTest, Release) { | 96 TEST_F(MessageLoopProxyImplTest, Release) { |
104 EXPECT_TRUE(io_thread_->message_loop_proxy()->ReleaseSoon(FROM_HERE, this)); | 97 EXPECT_TRUE(io_thread_->message_loop_proxy()->ReleaseSoon(FROM_HERE, this)); |
105 MessageLoop::current()->Run(); | 98 MessageLoop::current()->Run(); |
106 } | 99 } |
107 | 100 |
108 TEST_F(MessageLoopProxyImplTest, Delete) { | 101 TEST_F(MessageLoopProxyImplTest, Delete) { |
109 DeletedOnFile* deleted_on_file = new DeletedOnFile(this); | 102 DeletedOnFile* deleted_on_file = new DeletedOnFile(this); |
110 EXPECT_TRUE(file_thread_->message_loop_proxy()->DeleteSoon( | 103 EXPECT_TRUE(file_thread_->message_loop_proxy()->DeleteSoon( |
111 FROM_HERE, deleted_on_file)); | 104 FROM_HERE, deleted_on_file)); |
112 MessageLoop::current()->Run(); | 105 MessageLoop::current()->Run(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 scoped_ptr<base::Thread> test_thread( | 161 scoped_ptr<base::Thread> test_thread( |
169 new base::Thread("MessageLoopProxyImplTest_Dummy")); | 162 new base::Thread("MessageLoopProxyImplTest_Dummy")); |
170 test_thread->Start(); | 163 test_thread->Start(); |
171 message_loop_proxy = test_thread->message_loop_proxy(); | 164 message_loop_proxy = test_thread->message_loop_proxy(); |
172 } | 165 } |
173 bool ret = message_loop_proxy->PostTask( | 166 bool ret = message_loop_proxy->PostTask( |
174 FROM_HERE, | 167 FROM_HERE, |
175 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); | 168 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); |
176 EXPECT_FALSE(ret); | 169 EXPECT_FALSE(ret); |
177 } | 170 } |
OLD | NEW |