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 "platform/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" |
11 #include "components/scheduler/base/task_queue_impl.h" | 11 #include "platform/scheduler/base/task_queue_impl.h" |
12 #include "components/scheduler/base/task_queue_manager.h" | 12 #include "platform/scheduler/base/task_queue_manager.h" |
13 #include "components/scheduler/base/task_queue_manager_delegate_for_test.h" | 13 #include "platform/scheduler/base/task_queue_manager_delegate_for_test.h" |
14 #include "components/scheduler/base/test_time_source.h" | 14 #include "platform/scheduler/base/test_time_source.h" |
15 #include "components/scheduler/base/work_queue.h" | 15 #include "platform/scheduler/base/work_queue.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
18 using testing::_; | 18 using testing::_; |
19 using testing::AnyNumber; | 19 using testing::AnyNumber; |
20 using testing::Mock; | 20 using testing::Mock; |
21 | 21 |
| 22 namespace blink { |
22 namespace scheduler { | 23 namespace scheduler { |
23 | 24 |
24 class MockTimeDomain : public TimeDomain { | 25 class MockTimeDomain : public TimeDomain { |
25 public: | 26 public: |
26 explicit MockTimeDomain(TimeDomain::Observer* observer) | 27 explicit MockTimeDomain(TimeDomain::Observer* observer) |
27 : TimeDomain(observer), | 28 : TimeDomain(observer), |
28 now_(base::TimeTicks() + base::TimeDelta::FromSeconds(1)) {} | 29 now_(base::TimeTicks() + base::TimeDelta::FromSeconds(1)) {} |
29 | 30 |
30 ~MockTimeDomain() override {} | 31 ~MockTimeDomain() override {} |
31 | 32 |
(...skipping 14 matching lines...) Expand all Loading... |
46 | 47 |
47 bool MaybeAdvanceTime() override { return false; } | 48 bool MaybeAdvanceTime() override { return false; } |
48 const char* GetName() const override { return "Test"; } | 49 const char* GetName() const override { return "Test"; } |
49 void OnRegisterWithTaskQueueManager( | 50 void OnRegisterWithTaskQueueManager( |
50 TaskQueueManager* task_queue_manager) override {} | 51 TaskQueueManager* task_queue_manager) override {} |
51 | 52 |
52 MOCK_METHOD2(RequestWakeup, void(base::TimeTicks now, base::TimeDelta delay)); | 53 MOCK_METHOD2(RequestWakeup, void(base::TimeTicks now, base::TimeDelta delay)); |
53 | 54 |
54 void SetNow(base::TimeTicks now) { now_ = now; } | 55 void SetNow(base::TimeTicks now) { now_ = now; } |
55 | 56 |
56 | |
57 private: | 57 private: |
58 base::TimeTicks now_; | 58 base::TimeTicks now_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(MockTimeDomain); | 60 DISALLOW_COPY_AND_ASSIGN(MockTimeDomain); |
61 }; | 61 }; |
62 | 62 |
63 class TimeDomainTest : public testing::Test { | 63 class TimeDomainTest : public testing::Test { |
64 public: | 64 public: |
65 void SetUp() final { | 65 void SetUp() final { |
66 time_domain_ = base::WrapUnique(CreateMockTimeDomain()); | 66 time_domain_ = base::WrapUnique(CreateMockTimeDomain()); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) { | 224 TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) { |
225 EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork()); | 225 EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork()); |
226 EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _)); | 226 EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _)); |
227 base::TimeTicks now = time_domain_->Now(); | 227 base::TimeTicks now = time_domain_->Now(); |
228 time_domain_->ScheduleDelayedWork( | 228 time_domain_->ScheduleDelayedWork( |
229 task_queue_.get(), now + base::TimeDelta::FromMilliseconds(10), now); | 229 task_queue_.get(), now + base::TimeDelta::FromMilliseconds(10), now); |
230 } | 230 } |
231 | 231 |
232 } // namespace scheduler | 232 } // namespace scheduler |
| 233 } // namespace blink |
OLD | NEW |