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/test/thread_test_helper.h" | 5 #include "base/test/thread_test_helper.h" |
6 | 6 |
| 7 #include "base/location.h" |
| 8 |
7 namespace base { | 9 namespace base { |
8 | 10 |
9 ThreadTestHelper::ThreadTestHelper(MessageLoopProxy* target_thread) | 11 ThreadTestHelper::ThreadTestHelper(MessageLoopProxy* target_thread) |
10 : test_result_(false), | 12 : test_result_(false), |
11 target_thread_(target_thread), | 13 target_thread_(target_thread), |
12 done_event_(false, false) { | 14 done_event_(false, false) { |
13 } | 15 } |
14 | 16 |
15 bool ThreadTestHelper::Run() { | 17 bool ThreadTestHelper::Run() { |
16 if (!target_thread_->PostTask(FROM_HERE, NewRunnableMethod( | 18 if (!target_thread_->PostTask(FROM_HERE, NewRunnableMethod( |
17 this, &ThreadTestHelper::RunInThread))) { | 19 this, &ThreadTestHelper::RunInThread))) { |
18 return false; | 20 return false; |
19 } | 21 } |
20 done_event_.Wait(); | 22 done_event_.Wait(); |
21 return test_result_; | 23 return test_result_; |
22 } | 24 } |
23 | 25 |
24 void ThreadTestHelper::RunTest() { set_test_result(true); } | 26 void ThreadTestHelper::RunTest() { set_test_result(true); } |
25 | 27 |
26 ThreadTestHelper::~ThreadTestHelper() {} | 28 ThreadTestHelper::~ThreadTestHelper() {} |
27 | 29 |
28 void ThreadTestHelper::RunInThread() { | 30 void ThreadTestHelper::RunInThread() { |
29 RunTest(); | 31 RunTest(); |
30 done_event_.Signal(); | 32 done_event_.Signal(); |
31 } | 33 } |
32 | 34 |
33 } // namespace base | 35 } // namespace base |
OLD | NEW |