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

Side by Side Diff: components/scheduler/child/worker_scheduler_impl_unittest.cc

Issue 1178423008: Provision to start base::SimpleTestTickClock at initial ticks Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 11 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/child/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/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 WorkerSchedulerImpl::IsNotQuiescent(); 84 WorkerSchedulerImpl::IsNotQuiescent();
85 } 85 }
86 86
87 base::SimpleTestTickClock* clock_; // NOT OWNED 87 base::SimpleTestTickClock* clock_; // NOT OWNED
88 std::vector<std::string>* timeline_; // NOT OWNED 88 std::vector<std::string>* timeline_; // NOT OWNED
89 }; 89 };
90 90
91 class WorkerSchedulerImplTest : public testing::Test { 91 class WorkerSchedulerImplTest : public testing::Test {
92 public: 92 public:
93 WorkerSchedulerImplTest() 93 WorkerSchedulerImplTest()
94 : clock_(new base::SimpleTestTickClock()), 94 : clock_(new base::SimpleTestTickClock(
95 base::TimeTicks() + base::TimeDelta::FromMicroseconds(5000))),
95 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_.get(), true)), 96 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_.get(), true)),
96 main_task_runner_(SchedulerTqmDelegateForTest::Create( 97 main_task_runner_(SchedulerTqmDelegateForTest::Create(
97 mock_task_runner_, 98 mock_task_runner_,
98 make_scoped_ptr(new TestTimeSource(clock_.get())))), 99 make_scoped_ptr(new TestTimeSource(clock_.get())))),
99 scheduler_( 100 scheduler_(
100 new WorkerSchedulerImplForTest(main_task_runner_, clock_.get())), 101 new WorkerSchedulerImplForTest(main_task_runner_, clock_.get())),
101 timeline_(nullptr) { 102 timeline_(nullptr) {}
102 clock_->Advance(base::TimeDelta::FromMicroseconds(5000));
103 }
104 103
105 ~WorkerSchedulerImplTest() override {} 104 ~WorkerSchedulerImplTest() override {}
106 105
107 void TearDown() override { 106 void TearDown() override {
108 // Check that all tests stop posting tasks. 107 // Check that all tests stop posting tasks.
109 while (mock_task_runner_->RunUntilIdle()) { 108 while (mock_task_runner_->RunUntilIdle()) {
110 } 109 }
111 } 110 }
112 111
113 void Init() { 112 void Init() {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 "run RecordTimelineTask @ 55", 374 "run RecordTimelineTask @ 55",
376 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. 375 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence.
377 "CanEnterLongIdlePeriod @ 355", 376 "CanEnterLongIdlePeriod @ 355",
378 "run TimelineIdleTestTask deadline 405", 377 "run TimelineIdleTestTask deadline 405",
379 "RunUntilIdle end @ 355"}; 378 "RunUntilIdle end @ 355"};
380 379
381 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); 380 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline));
382 } 381 }
383 382
384 } // namespace scheduler 383 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698