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

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

Issue 1098033002: Remove dependency on cc::TestNowSource from scheduler code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 8 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
« no previous file with comments | « content/child/scheduler/worker_scheduler_impl.cc ('k') | content/content_child.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/child/scheduler/worker_scheduler_impl.h" 5 #include "content/child/scheduler/worker_scheduler_impl.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "cc/test/ordered_simple_task_runner.h" 9 #include "cc/test/ordered_simple_task_runner.h"
10 #include "cc/test/test_now_source.h"
10 #include "content/child/scheduler/nestable_task_runner_for_test.h" 11 #include "content/child/scheduler/nestable_task_runner_for_test.h"
11 #include "content/child/scheduler/scheduler_message_loop_delegate.h" 12 #include "content/child/scheduler/scheduler_message_loop_delegate.h"
13 #include "content/test/test_time_source.h"
12 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 using testing::ElementsAreArray; 17 using testing::ElementsAreArray;
16 18
17 namespace content { 19 namespace content {
18 20
19 namespace { 21 namespace {
20 void NopTask() { 22 void NopTask() {
21 } 23 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 class WorkerSchedulerImplTest : public testing::Test { 98 class WorkerSchedulerImplTest : public testing::Test {
97 public: 99 public:
98 WorkerSchedulerImplTest() 100 WorkerSchedulerImplTest()
99 : clock_(cc::TestNowSource::Create(5000)), 101 : clock_(cc::TestNowSource::Create(5000)),
100 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_, true)), 102 mock_task_runner_(new cc::OrderedSimpleTaskRunner(clock_, true)),
101 nestable_task_runner_( 103 nestable_task_runner_(
102 NestableTaskRunnerForTest::Create(mock_task_runner_)), 104 NestableTaskRunnerForTest::Create(mock_task_runner_)),
103 scheduler_( 105 scheduler_(
104 new WorkerSchedulerImplForTest(nestable_task_runner_, clock_)), 106 new WorkerSchedulerImplForTest(nestable_task_runner_, clock_)),
105 timeline_(nullptr) { 107 timeline_(nullptr) {
106 scheduler_->SetTimeSourceForTesting(clock_); 108 scheduler_->GetSchedulerHelperForTesting()->SetTimeSourceForTesting(
109 make_scoped_ptr(new TestTimeSource(clock_)));
110 scheduler_->GetSchedulerHelperForTesting()
111 ->GetTaskQueueManagerForTesting()
112 ->SetTimeSourceForTesting(make_scoped_ptr(new TestTimeSource(clock_)));
107 } 113 }
108 114
109 ~WorkerSchedulerImplTest() override {} 115 ~WorkerSchedulerImplTest() override {}
110 116
111 void TearDown() override { 117 void TearDown() override {
112 // Check that all tests stop posting tasks. 118 // Check that all tests stop posting tasks.
113 while (mock_task_runner_->RunUntilIdle()) { 119 while (mock_task_runner_->RunUntilIdle()) {
114 } 120 }
115 } 121 }
116 122
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence. 417 "IsNotQuiescent @ 55", // NOTE we have to wait for quiescence.
412 "CanEnterLongIdlePeriod @ 355", 418 "CanEnterLongIdlePeriod @ 355",
413 "run TimelineIdleTestTask deadline 405", 419 "run TimelineIdleTestTask deadline 405",
414 "CanEnterLongIdlePeriod @ 405", 420 "CanEnterLongIdlePeriod @ 405",
415 "RunUntilIdle end @ 455"}; 421 "RunUntilIdle end @ 455"};
416 422
417 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline)); 423 EXPECT_THAT(timeline, ElementsAreArray(expected_timeline));
418 } 424 }
419 425
420 } // namespace content 426 } // namespace content
OLDNEW
« no previous file with comments | « content/child/scheduler/worker_scheduler_impl.cc ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698