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_task_runner.h" | 5 #include "base/message_loop/message_loop_task_runner.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/debug/leak_annotations.h" | 11 #include "base/debug/leak_annotations.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/message_loop/message_loop_task_runner.h" | 13 #include "base/message_loop/message_loop_task_runner.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 class MessageLoopTaskRunnerTest : public testing::Test { | 22 class MessageLoopTaskRunnerTest : public testing::Test { |
23 public: | 23 public: |
24 MessageLoopTaskRunnerTest() | 24 MessageLoopTaskRunnerTest() |
25 : current_loop_(new MessageLoop()), | 25 : current_loop_(new MessageLoop()), |
26 task_thread_("task_thread"), | 26 task_thread_("task_thread"), |
27 thread_sync_(true, false) {} | 27 thread_sync_(WaitableEvent::ResetPolicy::MANUAL, |
| 28 WaitableEvent::InitialState::NOT_SIGNALED) {} |
28 | 29 |
29 void DeleteCurrentMessageLoop() { current_loop_.reset(); } | 30 void DeleteCurrentMessageLoop() { current_loop_.reset(); } |
30 | 31 |
31 protected: | 32 protected: |
32 void SetUp() override { | 33 void SetUp() override { |
33 // Use SetUp() instead of the constructor to avoid posting a task to a | 34 // Use SetUp() instead of the constructor to avoid posting a task to a |
34 // partially constructed object. | 35 // partially constructed object. |
35 task_thread_.Start(); | 36 task_thread_.Start(); |
36 | 37 |
37 // Allow us to pause the |task_thread_|'s MessageLoop. | 38 // Allow us to pause the |task_thread_|'s MessageLoop. |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy")); | 351 new Thread("MessageLoopTaskRunnerThreadingTest_Dummy")); |
351 test_thread->Start(); | 352 test_thread->Start(); |
352 task_runner = test_thread->task_runner(); | 353 task_runner = test_thread->task_runner(); |
353 } | 354 } |
354 bool ret = task_runner->PostTask( | 355 bool ret = task_runner->PostTask( |
355 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun)); | 356 FROM_HERE, Bind(&MessageLoopTaskRunnerThreadingTest::AssertNotRun)); |
356 EXPECT_FALSE(ret); | 357 EXPECT_FALSE(ret); |
357 } | 358 } |
358 | 359 |
359 } // namespace base | 360 } // namespace base |
OLD | NEW |