OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/scheduler/child/task_queue_manager.h" | 5 #include "components/scheduler/child/task_queue_manager.h" |
6 | 6 |
| 7 #include "base/location.h" |
| 8 #include "base/single_thread_task_runner.h" |
7 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
8 #include "cc/test/ordered_simple_task_runner.h" | 10 #include "cc/test/ordered_simple_task_runner.h" |
9 #include "cc/test/test_now_source.h" | 11 #include "cc/test/test_now_source.h" |
10 #include "components/scheduler/child/nestable_task_runner_for_test.h" | 12 #include "components/scheduler/child/nestable_task_runner_for_test.h" |
11 #include "components/scheduler/child/scheduler_message_loop_delegate.h" | 13 #include "components/scheduler/child/scheduler_message_loop_delegate.h" |
12 #include "components/scheduler/child/task_queue_selector.h" | 14 #include "components/scheduler/child/task_queue_selector.h" |
13 #include "components/scheduler/child/test_time_source.h" | 15 #include "components/scheduler/child/test_time_source.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
15 | 17 |
16 using testing::ElementsAre; | 18 using testing::ElementsAre; |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 689 |
688 TEST_F(TaskQueueManagerTest, PostFromThread) { | 690 TEST_F(TaskQueueManagerTest, PostFromThread) { |
689 InitializeWithRealMessageLoop(1u, SelectorType::Automatic); | 691 InitializeWithRealMessageLoop(1u, SelectorType::Automatic); |
690 | 692 |
691 std::vector<int> run_order; | 693 std::vector<int> run_order; |
692 scoped_refptr<base::SingleThreadTaskRunner> runner = | 694 scoped_refptr<base::SingleThreadTaskRunner> runner = |
693 manager_->TaskRunnerForQueue(0); | 695 manager_->TaskRunnerForQueue(0); |
694 | 696 |
695 base::Thread thread("TestThread"); | 697 base::Thread thread("TestThread"); |
696 thread.Start(); | 698 thread.Start(); |
697 thread.message_loop()->PostTask( | 699 thread.task_runner()->PostTask( |
698 FROM_HERE, base::Bind(&PostTaskToRunner, runner, &run_order)); | 700 FROM_HERE, base::Bind(&PostTaskToRunner, runner, &run_order)); |
699 thread.Stop(); | 701 thread.Stop(); |
700 | 702 |
701 message_loop_->RunUntilIdle(); | 703 message_loop_->RunUntilIdle(); |
702 EXPECT_THAT(run_order, ElementsAre(1)); | 704 EXPECT_THAT(run_order, ElementsAre(1)); |
703 } | 705 } |
704 | 706 |
705 void RePostingTestTask(scoped_refptr<base::SingleThreadTaskRunner> runner, | 707 void RePostingTestTask(scoped_refptr<base::SingleThreadTaskRunner> runner, |
706 int* run_count) { | 708 int* run_count) { |
707 (*run_count)++; | 709 (*run_count)++; |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 manager_->GetQueueState(1)); | 1235 manager_->GetQueueState(1)); |
1234 | 1236 |
1235 test_task_runner_->RunUntilIdle(); | 1237 test_task_runner_->RunUntilIdle(); |
1236 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, | 1238 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, |
1237 manager_->GetQueueState(0)); | 1239 manager_->GetQueueState(0)); |
1238 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, | 1240 EXPECT_EQ(TaskQueueManager::QueueState::EMPTY, |
1239 manager_->GetQueueState(1)); | 1241 manager_->GetQueueState(1)); |
1240 } | 1242 } |
1241 | 1243 |
1242 } // namespace scheduler | 1244 } // namespace scheduler |
OLD | NEW |