| 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 "platform/Timer.h" | 5 #include "platform/Timer.h" |
| 6 | 6 |
| 7 #include "platform/scheduler/base/task_queue_impl.h" | 7 #include "platform/scheduler/base/task_queue_impl.h" |
| 8 #include "platform/scheduler/child/web_task_runner_impl.h" | 8 #include "platform/scheduler/child/web_task_runner_impl.h" |
| 9 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" | 9 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
| 10 #include "platform/testing/TestingPlatformSupport.h" | 10 #include "platform/testing/TestingPlatformSupport.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 class TimerTest : public testing::Test { | 28 class TimerTest : public testing::Test { |
| 29 public: | 29 public: |
| 30 void SetUp() override { | 30 void SetUp() override { |
| 31 m_runTimes.clear(); | 31 m_runTimes.clear(); |
| 32 m_platform.advanceClockSeconds(10.0); | 32 m_platform.advanceClockSeconds(10.0); |
| 33 m_startTime = monotonicallyIncreasingTime(); | 33 m_startTime = monotonicallyIncreasingTime(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void countingTask(TimerBase*) { | 36 void countingTask(TimerBase*) { |
| 37 m_runTimes.append(monotonicallyIncreasingTime()); | 37 m_runTimes.push_back(monotonicallyIncreasingTime()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void recordNextFireTimeTask(TimerBase* timer) { | 40 void recordNextFireTimeTask(TimerBase* timer) { |
| 41 m_nextFireTimes.append(monotonicallyIncreasingTime() + | 41 m_nextFireTimes.push_back(monotonicallyIncreasingTime() + |
| 42 timer->nextFireInterval()); | 42 timer->nextFireInterval()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void runUntilDeadline(double deadline) { | 45 void runUntilDeadline(double deadline) { |
| 46 double period = deadline - monotonicallyIncreasingTime(); | 46 double period = deadline - monotonicallyIncreasingTime(); |
| 47 EXPECT_GE(period, 0.0); | 47 EXPECT_GE(period, 0.0); |
| 48 m_platform.runForPeriodSeconds(period); | 48 m_platform.runForPeriodSeconds(period); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Returns false if there are no pending delayed tasks, otherwise sets |time| | 51 // Returns false if there are no pending delayed tasks, otherwise sets |time| |
| 52 // to the delay in seconds till the next pending delayed task is scheduled to | 52 // to the delay in seconds till the next pending delayed task is scheduled to |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 &TimerTest::countingTask); | 712 &TimerTest::countingTask); |
| 713 | 713 |
| 714 m_platform.runUntilIdle(); | 714 m_platform.runUntilIdle(); |
| 715 EXPECT_TRUE(!m_runTimes.size()); | 715 EXPECT_TRUE(!m_runTimes.size()); |
| 716 EXPECT_TRUE(taskRunner1->IsEmpty()); | 716 EXPECT_TRUE(taskRunner1->IsEmpty()); |
| 717 EXPECT_TRUE(taskRunner2->IsEmpty()); | 717 EXPECT_TRUE(taskRunner2->IsEmpty()); |
| 718 } | 718 } |
| 719 | 719 |
| 720 } // namespace | 720 } // namespace |
| 721 } // namespace blink | 721 } // namespace blink |
| OLD | NEW |