| 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/scheduler_helper.h" | 5 #include "components/scheduler/child/scheduler_helper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/test/simple_test_tick_clock.h" | 9 #include "base/test/simple_test_tick_clock.h" |
| 10 #include "cc/test/ordered_simple_task_runner.h" | 10 #include "cc/test/ordered_simple_task_runner.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 RunUntilIdle(); | 105 RunUntilIdle(); |
| 106 EXPECT_THAT(run_order, | 106 EXPECT_THAT(run_order, |
| 107 testing::ElementsAre(std::string("D1"), std::string("D2"), | 107 testing::ElementsAre(std::string("D1"), std::string("D2"), |
| 108 std::string("D3"), std::string("D4"))); | 108 std::string("D3"), std::string("D4"))); |
| 109 } | 109 } |
| 110 | 110 |
| 111 TEST_F(SchedulerHelperTest, TestRentrantTask) { | 111 TEST_F(SchedulerHelperTest, TestRentrantTask) { |
| 112 int count = 0; | 112 int count = 0; |
| 113 std::vector<int> run_order; | 113 std::vector<int> run_order; |
| 114 default_task_runner_->PostTask( | 114 default_task_runner_->PostTask( |
| 115 FROM_HERE, base::Bind(AppendToVectorReentrantTask, default_task_runner_, | 115 FROM_HERE, base::Bind(AppendToVectorReentrantTask, |
| 116 &run_order, &count, 5)); | 116 base::RetainedRef(default_task_runner_), &run_order, |
| 117 &count, 5)); |
| 117 RunUntilIdle(); | 118 RunUntilIdle(); |
| 118 | 119 |
| 119 EXPECT_THAT(run_order, testing::ElementsAre(0, 1, 2, 3, 4)); | 120 EXPECT_THAT(run_order, testing::ElementsAre(0, 1, 2, 3, 4)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 TEST_F(SchedulerHelperTest, IsShutdown) { | 123 TEST_F(SchedulerHelperTest, IsShutdown) { |
| 123 EXPECT_FALSE(scheduler_helper_->IsShutdown()); | 124 EXPECT_FALSE(scheduler_helper_->IsShutdown()); |
| 124 | 125 |
| 125 scheduler_helper_->Shutdown(); | 126 scheduler_helper_->Shutdown(); |
| 126 EXPECT_TRUE(scheduler_helper_->IsShutdown()); | 127 EXPECT_TRUE(scheduler_helper_->IsShutdown()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 task_queue->SetQueueEnabled(false); | 216 task_queue->SetQueueEnabled(false); |
| 216 task_queue->PostTask(FROM_HERE, base::Bind(&NopTask)); | 217 task_queue->PostTask(FROM_HERE, base::Bind(&NopTask)); |
| 217 | 218 |
| 218 EXPECT_CALL(observer, OnTriedToExecuteBlockedTask(_, _)).Times(1); | 219 EXPECT_CALL(observer, OnTriedToExecuteBlockedTask(_, _)).Times(1); |
| 219 RunUntilIdle(); | 220 RunUntilIdle(); |
| 220 | 221 |
| 221 scheduler_helper_->SetObserver(nullptr); | 222 scheduler_helper_->SetObserver(nullptr); |
| 222 } | 223 } |
| 223 | 224 |
| 224 } // namespace scheduler | 225 } // namespace scheduler |
| OLD | NEW |