| 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 "content/child/scheduler/worker_scheduler_impl.h" | 5 #include "content/child/scheduler/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 "cc/test/ordered_simple_task_runner.h" | 9 #include "cc/test/ordered_simple_task_runner.h" |
| 10 #include "cc/test/test_now_source.h" |
| 10 #include "content/child/scheduler/nestable_task_runner_for_test.h" | 11 #include "content/child/scheduler/nestable_task_runner_for_test.h" |
| 11 #include "content/child/scheduler/scheduler_message_loop_delegate.h" | 12 #include "content/child/scheduler/scheduler_message_loop_delegate.h" |
| 13 #include "content/test/test_time_source.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 16 |
| 15 using testing::ElementsAreArray; | 17 using testing::ElementsAreArray; |
| 16 | 18 |
| 17 namespace content { | 19 namespace content { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 void NopTask() { | 22 void NopTask() { |
| 21 } | 23 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 class WorkerSchedulerImplTest : public testing::Test { | 98 class WorkerSchedulerImplTest : public testing::Test { |
| 97 public: | 99 public: |
| 98 WorkerSchedulerImplTest() | 100 WorkerSchedulerImplTest() |
| 99 : clock_(cc::TestNowSource::Create(5000)), | 101 : clock_(cc::TestNowSource::Create(5000)), |
| 100 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_, true)), | 102 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_, true)), |
| 101 nestable_task_runner_( | 103 nestable_task_runner_( |
| 102 NestableTaskRunnerForTest::Create(mock_task_runner_)), | 104 NestableTaskRunnerForTest::Create(mock_task_runner_)), |
| 103 scheduler_( | 105 scheduler_( |
| 104 new WorkerSchedulerImplForTest(nestable_task_runner_, clock_)), | 106 new WorkerSchedulerImplForTest(nestable_task_runner_, clock_)), |
| 105 timeline_(nullptr) { | 107 timeline_(nullptr) { |
| 106 scheduler_->SetTimeSourceForTesting(clock_); | 108 scheduler_->SetTimeSourceForTesting( |
| 109 make_scoped_ptr(new TestTimeSource(clock_))); |
| 107 } | 110 } |
| 108 | 111 |
| 109 ~WorkerSchedulerImplTest() override {} | 112 ~WorkerSchedulerImplTest() override {} |
| 110 | 113 |
| 111 void TearDown() override { | 114 void TearDown() override { |
| 112 // Check that all tests stop posting tasks. | 115 // Check that all tests stop posting tasks. |
| 113 while (mock_task_runner_->RunUntilIdle()) { | 116 while (mock_task_runner_->RunUntilIdle()) { |
| 114 } | 117 } |
| 115 } | 118 } |
| 116 | 119 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. | 414 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. |
| 412 "CanEnterLongIdlePeriod @ 355", | 415 "CanEnterLongIdlePeriod @ 355", |
| 413 "run TimelineIdleTestTask deadline 405", | 416 "run TimelineIdleTestTask deadline 405", |
| 414 "CanEnterLongIdlePeriod @ 405", | 417 "CanEnterLongIdlePeriod @ 405", |
| 415 "RunUntilIdle end @ 455"}; | 418 "RunUntilIdle end @ 455"}; |
| 416 | 419 |
| 417 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); | 420 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); |
| 418 } | 421 } |
| 419 | 422 |
| 420 } // namespace content | 423 } // namespace content |
| OLD | NEW |