| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/worker_scheduler_impl.h" | 5 #include "components/scheduler/child/worker_scheduler_impl.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 base::SimpleTestTickClock* clock_; // NOT OWNED | 86 base::SimpleTestTickClock* clock_; // NOT OWNED |
| 87 std::vector<std::string>* timeline_; // NOT OWNED | 87 std::vector<std::string>* timeline_; // NOT OWNED |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class WorkerSchedulerImplTest : public testing::Test { | 90 class WorkerSchedulerImplTest : public testing::Test { |
| 91 public: | 91 public: |
| 92 WorkerSchedulerImplTest() | 92 WorkerSchedulerImplTest() |
| 93 : clock_(new base::SimpleTestTickClock()), | 93 : clock_(new base::SimpleTestTickClock()), |
| 94 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_.get(), true)), | 94 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_.get(), true)), |
| 95 main_task_runner_( | 95 main_task_runner_(SchedulerTaskRunnerDelegateForTest::Create( |
| 96 SchedulerTaskRunnerDelegateForTest::Create(mock_task_runner_)), | 96 mock_task_runner_, |
| 97 make_scoped_ptr(new TestTimeSource(clock_.get())))), |
| 97 scheduler_( | 98 scheduler_( |
| 98 new WorkerSchedulerImplForTest(main_task_runner_, clock_.get())), | 99 new WorkerSchedulerImplForTest(main_task_runner_, clock_.get())), |
| 99 timeline_(nullptr) { | 100 timeline_(nullptr) { |
| 100 clock_->Advance(base::TimeDelta::FromMicroseconds(5000)); | 101 clock_->Advance(base::TimeDelta::FromMicroseconds(5000)); |
| 101 scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( | |
| 102 make_scoped_ptr(new TestTimeSource(clock_.get()))); | |
| 103 scheduler_->GetSchedulerHelperForTesting() | |
| 104 ->GetTaskQueueManagerForTesting() | |
| 105 ->SetTimeSourceForTesting( | |
| 106 make_scoped_ptr(new TestTimeSource(clock_.get()))); | |
| 107 } | 102 } |
| 108 | 103 |
| 109 ~WorkerSchedulerImplTest() override {} | 104 ~WorkerSchedulerImplTest() override {} |
| 110 | 105 |
| 111 void TearDown() override { | 106 void TearDown() override { |
| 112 // Check that all tests stop posting tasks. | 107 // Check that all tests stop posting tasks. |
| 113 while (mock_task_runner_->RunUntilIdle()) { | 108 while (mock_task_runner_->RunUntilIdle()) { |
| 114 } | 109 } |
| 115 } | 110 } |
| 116 | 111 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 "run RecordTimelineTask @ 55", | 374 "run RecordTimelineTask @ 55", |
| 380 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. | 375 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. |
| 381 "CanEnterLongIdlePeriod @ 355", | 376 "CanEnterLongIdlePeriod @ 355", |
| 382 "run TimelineIdleTestTask deadline 405", | 377 "run TimelineIdleTestTask deadline 405", |
| 383 "RunUntilIdle end @ 355"}; | 378 "RunUntilIdle end @ 355"}; |
| 384 | 379 |
| 385 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); | 380 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); |
| 386 } | 381 } |
| 387 | 382 |
| 388 } // namespace scheduler | 383 } // namespace scheduler |
| OLD | NEW |