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

Side by Side Diff: components/scheduler/renderer/deadline_task_runner_unittest.cc

Issue 1178423008: Provision to start base::SimpleTestTickClock at initial ticks Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 "base/test/simple_test_tick_clock.h" 5 #include "base/test/simple_test_tick_clock.h"
6 #include "components/scheduler/renderer/deadline_task_runner.h" 6 #include "components/scheduler/renderer/deadline_task_runner.h"
7 7
8 #include "cc/test/ordered_simple_task_runner.h" 8 #include "cc/test/ordered_simple_task_runner.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace scheduler { 12 namespace scheduler {
13 13
14 class DeadlineTaskRunnerTest : public testing::Test { 14 class DeadlineTaskRunnerTest : public testing::Test {
15 public: 15 public:
16 DeadlineTaskRunnerTest() {} 16 DeadlineTaskRunnerTest() {}
17 ~DeadlineTaskRunnerTest() override {} 17 ~DeadlineTaskRunnerTest() override {}
18 18
19 void SetUp() override { 19 void SetUp() override {
20 clock_.reset(new base::SimpleTestTickClock()); 20 clock_.reset(new base::SimpleTestTickClock());
21 clock_->Advance(base::TimeDelta::FromMicroseconds(5000));
22 mock_task_runner_ = new cc::OrderedSimpleTaskRunner(clock_.get(), true); 21 mock_task_runner_ = new cc::OrderedSimpleTaskRunner(clock_.get(), true);
23 deadline_task_runner_.reset(new DeadlineTaskRunner( 22 deadline_task_runner_.reset(new DeadlineTaskRunner(
24 base::Bind(&DeadlineTaskRunnerTest::TestTask, base::Unretained(this)), 23 base::Bind(&DeadlineTaskRunnerTest::TestTask, base::Unretained(this)),
25 mock_task_runner_)); 24 mock_task_runner_));
26 run_times_.clear(); 25 run_times_.clear();
27 } 26 }
28 27
29 bool RunUntilIdle() { return mock_task_runner_->RunUntilIdle(); } 28 bool RunUntilIdle() { return mock_task_runner_->RunUntilIdle(); }
30 29
31 void TestTask() { run_times_.push_back(clock_->NowTicks()); } 30 void TestTask() { run_times_.push_back(clock_->NowTicks()); }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 FROM_HERE, base::TimeDelta::FromMilliseconds(10), clock_->NowTicks()); 89 FROM_HERE, base::TimeDelta::FromMilliseconds(10), clock_->NowTicks());
91 90
92 // Deleting the pending task should cancel it. 91 // Deleting the pending task should cancel it.
93 deadline_task_runner_.reset(nullptr); 92 deadline_task_runner_.reset(nullptr);
94 RunUntilIdle(); 93 RunUntilIdle();
95 94
96 EXPECT_TRUE(run_times_.empty()); 95 EXPECT_TRUE(run_times_.empty());
97 }; 96 };
98 97
99 } // namespace scheduler 98 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698