| 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/base/time_domain.h" | 5 #include "components/scheduler/base/time_domain.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.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 22 matching lines...) Expand all Loading... |
| 33 using TimeDomain::NextScheduledRunTime; | 33 using TimeDomain::NextScheduledRunTime; |
| 34 using TimeDomain::NextScheduledTaskQueue; | 34 using TimeDomain::NextScheduledTaskQueue; |
| 35 using TimeDomain::ScheduleDelayedWork; | 35 using TimeDomain::ScheduleDelayedWork; |
| 36 using TimeDomain::UnregisterQueue; | 36 using TimeDomain::UnregisterQueue; |
| 37 using TimeDomain::UpdateWorkQueues; | 37 using TimeDomain::UpdateWorkQueues; |
| 38 using TimeDomain::RegisterAsUpdatableTaskQueue; | 38 using TimeDomain::RegisterAsUpdatableTaskQueue; |
| 39 | 39 |
| 40 // TimeSource implementation: | 40 // TimeSource implementation: |
| 41 LazyNow CreateLazyNow() const override { return LazyNow(now_); } | 41 LazyNow CreateLazyNow() const override { return LazyNow(now_); } |
| 42 base::TimeTicks Now() const override { return now_; } | 42 base::TimeTicks Now() const override { return now_; } |
| 43 | 43 base::TimeTicks BlinkNow() const override { return now_; } |
| 44 base::TimeTicks ComputeDelayedRunTime(base::TimeTicks time_domain_now, | |
| 45 base::TimeDelta delay) const override { | |
| 46 return time_domain_now + delay; | |
| 47 } | |
| 48 | 44 |
| 49 void AsValueIntoInternal( | 45 void AsValueIntoInternal( |
| 50 base::trace_event::TracedValue* state) const override {} | 46 base::trace_event::TracedValue* state) const override {} |
| 51 | 47 |
| 52 bool MaybeAdvanceTime() override { return false; } | 48 bool MaybeAdvanceTime() override { return false; } |
| 53 const char* GetName() const override { return "Test"; } | 49 const char* GetName() const override { return "Test"; } |
| 54 void OnRegisterWithTaskQueueManager( | 50 void OnRegisterWithTaskQueueManager( |
| 55 TaskQueueManager* task_queue_manager) override {} | 51 TaskQueueManager* task_queue_manager) override {} |
| 56 | 52 |
| 57 MOCK_METHOD2(RequestWakeup, void(base::TimeTicks now, base::TimeDelta delay)); | 53 MOCK_METHOD2(RequestWakeup, void(base::TimeTicks now, base::TimeDelta delay)); |
| 58 | 54 |
| 59 void SetNow(base::TimeTicks now) { now_ = now; } | 55 void SetNow(base::TimeTicks now) { now_ = now; } |
| 60 | 56 |
| 61 | |
| 62 private: | 57 private: |
| 63 base::TimeTicks now_; | 58 base::TimeTicks now_; |
| 64 | 59 |
| 65 DISALLOW_COPY_AND_ASSIGN(MockTimeDomain); | 60 DISALLOW_COPY_AND_ASSIGN(MockTimeDomain); |
| 66 }; | 61 }; |
| 67 | 62 |
| 68 class TimeDomainTest : public testing::Test { | 63 class TimeDomainTest : public testing::Test { |
| 69 public: | 64 public: |
| 70 void SetUp() final { | 65 void SetUp() final { |
| 71 time_domain_ = base::WrapUnique(CreateMockTimeDomain()); | 66 time_domain_ = base::WrapUnique(CreateMockTimeDomain()); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 223 |
| 229 TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) { | 224 TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) { |
| 230 EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork()); | 225 EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork()); |
| 231 EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _)); | 226 EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _)); |
| 232 base::TimeTicks now = time_domain_->Now(); | 227 base::TimeTicks now = time_domain_->Now(); |
| 233 time_domain_->ScheduleDelayedWork( | 228 time_domain_->ScheduleDelayedWork( |
| 234 task_queue_.get(), now + base::TimeDelta::FromMilliseconds(10), now); | 229 task_queue_.get(), now + base::TimeDelta::FromMilliseconds(10), now); |
| 235 } | 230 } |
| 236 | 231 |
| 237 } // namespace scheduler | 232 } // namespace scheduler |
| OLD | NEW |