Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/time_domain_unittest.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another GYP fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 19 matching lines...) Expand all
51 52
52 bool MaybeAdvanceTime() override { return false; } 53 bool MaybeAdvanceTime() override { return false; }
53 const char* GetName() const override { return "Test"; } 54 const char* GetName() const override { return "Test"; }
54 void OnRegisterWithTaskQueueManager( 55 void OnRegisterWithTaskQueueManager(
55 TaskQueueManager* task_queue_manager) override {} 56 TaskQueueManager* task_queue_manager) override {}
56 57
57 MOCK_METHOD2(RequestWakeup, void(base::TimeTicks now, base::TimeDelta delay)); 58 MOCK_METHOD2(RequestWakeup, void(base::TimeTicks now, base::TimeDelta delay));
58 59
59 void SetNow(base::TimeTicks now) { now_ = now; } 60 void SetNow(base::TimeTicks now) { now_ = now; }
60 61
61
62 private: 62 private:
63 base::TimeTicks now_; 63 base::TimeTicks now_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(MockTimeDomain); 65 DISALLOW_COPY_AND_ASSIGN(MockTimeDomain);
66 }; 66 };
67 67
68 class TimeDomainTest : public testing::Test { 68 class TimeDomainTest : public testing::Test {
69 public: 69 public:
70 void SetUp() final { 70 void SetUp() final {
71 time_domain_ = base::WrapUnique(CreateMockTimeDomain()); 71 time_domain_ = base::WrapUnique(CreateMockTimeDomain());
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) { 229 TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) {
230 EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork()); 230 EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork());
231 EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _)); 231 EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _));
232 base::TimeTicks now = time_domain_->Now(); 232 base::TimeTicks now = time_domain_->Now();
233 time_domain_->ScheduleDelayedWork( 233 time_domain_->ScheduleDelayedWork(
234 task_queue_.get(), now + base::TimeDelta::FromMilliseconds(10), now); 234 task_queue_.get(), now + base::TimeDelta::FromMilliseconds(10), now);
235 } 235 }
236 236
237 } // namespace scheduler 237 } // namespace scheduler
238 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698