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 "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)); | 21 base::TimeTicks() + base::TimeDelta::FromMicroseconds(1))); |
22 mock_task_runner_ = new cc::OrderedSimpleTaskRunner(clock_.get(), true); | 22 mock_task_runner_ = new cc::OrderedSimpleTaskRunner(clock_.get(), true); |
23 deadline_task_runner_.reset(new DeadlineTaskRunner( | 23 deadline_task_runner_.reset(new DeadlineTaskRunner( |
24 base::Bind(&DeadlineTaskRunnerTest::TestTask, base::Unretained(this)), | 24 base::Bind(&DeadlineTaskRunnerTest::TestTask, base::Unretained(this)), |
25 mock_task_runner_)); | 25 mock_task_runner_)); |
26 run_times_.clear(); | 26 run_times_.clear(); |
27 } | 27 } |
28 | 28 |
29 bool RunUntilIdle() { return mock_task_runner_->RunUntilIdle(); } | 29 bool RunUntilIdle() { return mock_task_runner_->RunUntilIdle(); } |
30 | 30 |
31 void TestTask() { run_times_.push_back(clock_->NowTicks()); } | 31 void TestTask() { run_times_.push_back(clock_->NowTicks()); } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 FROM_HERE, base::TimeDelta::FromMilliseconds(10), clock_->NowTicks()); | 90 FROM_HERE, base::TimeDelta::FromMilliseconds(10), clock_->NowTicks()); |
91 | 91 |
92 // Deleting the pending task should cancel it. | 92 // Deleting the pending task should cancel it. |
93 deadline_task_runner_.reset(nullptr); | 93 deadline_task_runner_.reset(nullptr); |
94 RunUntilIdle(); | 94 RunUntilIdle(); |
95 | 95 |
96 EXPECT_TRUE(run_times_.empty()); | 96 EXPECT_TRUE(run_times_.empty()); |
97 }; | 97 }; |
98 | 98 |
99 } // namespace scheduler | 99 } // namespace scheduler |
OLD | NEW |