| 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 "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 "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 "cc/test/test_now_source.h" |
| 11 #include "content/child/scheduler/nestable_task_runner_for_test.h" | 11 #include "components/scheduler/child/nestable_task_runner_for_test.h" |
| 12 #include "content/child/scheduler/scheduler_message_loop_delegate.h" | 12 #include "components/scheduler/child/scheduler_message_loop_delegate.h" |
| 13 #include "content/test/test_time_source.h" | 13 #include "components/scheduler/child/test_time_source.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using testing::ElementsAreArray; | 17 using testing::ElementsAreArray; |
| 18 | 18 |
| 19 namespace content { | 19 namespace scheduler { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 void NopTask() { | 22 void NopTask() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 int TimeTicksToIntMs(const base::TimeTicks& time) { | 25 int TimeTicksToIntMs(const base::TimeTicks& time) { |
| 26 return static_cast<int>((time - base::TimeTicks()).InMilliseconds()); | 26 return static_cast<int>((time - base::TimeTicks()).InMilliseconds()); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void WakeUpTask(std::vector<std::string>* timeline, cc::TestNowSource* clock) { | 29 void WakeUpTask(std::vector<std::string>* timeline, cc::TestNowSource* clock) { |
| 30 if (timeline) { | 30 if (timeline) { |
| 31 timeline->push_back(base::StringPrintf( | 31 timeline->push_back(base::StringPrintf("run WakeUpTask @ %d", |
| 32 "run WakeUpTask @ %d", TimeTicksToIntMs(clock->Now()))); | 32 TimeTicksToIntMs(clock->Now()))); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 void RecordTimelineTask(std::vector<std::string>* timeline, | 36 void RecordTimelineTask(std::vector<std::string>* timeline, |
| 37 cc::TestNowSource* clock) { | 37 cc::TestNowSource* clock) { |
| 38 timeline->push_back(base::StringPrintf( | 38 timeline->push_back(base::StringPrintf("run RecordTimelineTask @ %d", |
| 39 "run RecordTimelineTask @ %d", TimeTicksToIntMs(clock->Now()))); | 39 TimeTicksToIntMs(clock->Now()))); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void AppendToVectorTestTask(std::vector<std::string>* vector, | 42 void AppendToVectorTestTask(std::vector<std::string>* vector, |
| 43 std::string value) { | 43 std::string value) { |
| 44 vector->push_back(value); | 44 vector->push_back(value); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void AppendToVectorIdleTestTask(std::vector<std::string>* vector, | 47 void AppendToVectorIdleTestTask(std::vector<std::string>* vector, |
| 48 std::string value, | 48 std::string value, |
| 49 base::TimeTicks deadline) { | 49 base::TimeTicks deadline) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 "run RecordTimelineTask @ 55", | 416 "run RecordTimelineTask @ 55", |
| 417 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. | 417 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. |
| 418 "CanEnterLongIdlePeriod @ 355", | 418 "CanEnterLongIdlePeriod @ 355", |
| 419 "run TimelineIdleTestTask deadline 405", | 419 "run TimelineIdleTestTask deadline 405", |
| 420 "CanEnterLongIdlePeriod @ 405", | 420 "CanEnterLongIdlePeriod @ 405", |
| 421 "RunUntilIdle end @ 455"}; | 421 "RunUntilIdle end @ 455"}; |
| 422 | 422 |
| 423 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); | 423 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace content | 426 } // namespace scheduler |
| OLD | NEW |