| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 WorkerSchedulerImpl::IsNotQuiescent(); | 84 WorkerSchedulerImpl::IsNotQuiescent(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 base::SimpleTestTickClock* clock_; // NOT OWNED | 87 base::SimpleTestTickClock* clock_; // NOT OWNED |
| 88 std::vector<std::string>* timeline_; // NOT OWNED | 88 std::vector<std::string>* timeline_; // NOT OWNED |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 class WorkerSchedulerImplTest : public testing::Test { | 91 class WorkerSchedulerImplTest : public testing::Test { |
| 92 public: | 92 public: |
| 93 WorkerSchedulerImplTest() | 93 WorkerSchedulerImplTest() |
| 94 : clock_(new base::SimpleTestTickClock()), | 94 : clock_(new base::SimpleTestTickClock( |
| 95 base::TimeTicks() + base::TimeDelta::FromMicroseconds(5000))), |
| 95 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_.get(), true)), | 96 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_.get(), true)), |
| 96 nestable_task_runner_( | 97 nestable_task_runner_( |
| 97 NestableTaskRunnerForTest::Create(mock_task_runner_)), | 98 NestableTaskRunnerForTest::Create(mock_task_runner_)), |
| 98 scheduler_(new WorkerSchedulerImplForTest(nestable_task_runner_, | 99 scheduler_(new WorkerSchedulerImplForTest(nestable_task_runner_, |
| 99 clock_.get())), | 100 clock_.get())), |
| 100 timeline_(nullptr) { | 101 timeline_(nullptr) { |
| 101 clock_->Advance(base::TimeDelta::FromMicroseconds(5000)); | |
| 102 scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( | 102 scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting( |
| 103 make_scoped_ptr(new TestTimeSource(clock_.get()))); | 103 make_scoped_ptr(new TestTimeSource(clock_.get()))); |
| 104 scheduler_->GetSchedulerHelperForTesting() | 104 scheduler_->GetSchedulerHelperForTesting() |
| 105 ->GetTaskQueueManagerForTesting() | 105 ->GetTaskQueueManagerForTesting() |
| 106 ->SetTimeSourceForTesting( | 106 ->SetTimeSourceForTesting( |
| 107 make_scoped_ptr(new TestTimeSource(clock_.get()))); | 107 make_scoped_ptr(new TestTimeSource(clock_.get()))); |
| 108 } | 108 } |
| 109 | 109 |
| 110 ~WorkerSchedulerImplTest() override {} | 110 ~WorkerSchedulerImplTest() override {} |
| 111 | 111 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 "run RecordTimelineTask @ 55", | 380 "run RecordTimelineTask @ 55", |
| 381 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. | 381 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. |
| 382 "CanEnterLongIdlePeriod @ 355", | 382 "CanEnterLongIdlePeriod @ 355", |
| 383 "run TimelineIdleTestTask deadline 405", | 383 "run TimelineIdleTestTask deadline 405", |
| 384 "RunUntilIdle end @ 355"}; | 384 "RunUntilIdle end @ 355"}; |
| 385 | 385 |
| 386 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); | 386 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); |
| 387 } | 387 } |
| 388 | 388 |
| 389 } // namespace scheduler | 389 } // namespace scheduler |
| OLD | NEW |