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/task_cost_estimator.h" | 6 #include "components/scheduler/renderer/task_cost_estimator.h" |
7 | 7 |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 TEST_F(TaskCostEstimatorTest, BasicEstimation) { | 37 TEST_F(TaskCostEstimatorTest, BasicEstimation) { |
38 TaskCostEstimatorForTest estimator(&clock_, 1, 100); | 38 TaskCostEstimatorForTest estimator(&clock_, 1, 100); |
39 base::PendingTask task(FROM_HERE, base::Closure()); | 39 base::PendingTask task(FROM_HERE, base::Closure()); |
40 | 40 |
41 estimator.WillProcessTask(task); | 41 estimator.WillProcessTask(task); |
42 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); | 42 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); |
43 estimator.DidProcessTask(task); | 43 estimator.DidProcessTask(task); |
44 | 44 |
45 EXPECT_EQ(base::TimeDelta::FromMilliseconds(500), | 45 EXPECT_EQ(base::TimeDelta::FromMilliseconds(500), |
46 estimator.expected_task_duration()); | 46 estimator.expected_task_duration()); |
47 }; | 47 } |
| 48 |
| 49 TEST_F(TaskCostEstimatorTest, Clear) { |
| 50 TaskCostEstimatorForTest estimator(&clock_, 1, 100); |
| 51 base::PendingTask task(FROM_HERE, base::Closure()); |
| 52 |
| 53 estimator.WillProcessTask(task); |
| 54 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); |
| 55 estimator.DidProcessTask(task); |
| 56 |
| 57 estimator.Clear(); |
| 58 |
| 59 EXPECT_EQ(base::TimeDelta(), estimator.expected_task_duration()); |
| 60 } |
48 | 61 |
49 TEST_F(TaskCostEstimatorTest, NestedRunLoop) { | 62 TEST_F(TaskCostEstimatorTest, NestedRunLoop) { |
50 TaskCostEstimatorForTest estimator(&clock_, 1, 100); | 63 TaskCostEstimatorForTest estimator(&clock_, 1, 100); |
51 base::PendingTask task(FROM_HERE, base::Closure()); | 64 base::PendingTask task(FROM_HERE, base::Closure()); |
52 | 65 |
53 // Make sure we ignore the tasks inside the nested run loop. | 66 // Make sure we ignore the tasks inside the nested run loop. |
54 estimator.WillProcessTask(task); | 67 estimator.WillProcessTask(task); |
55 estimator.WillProcessTask(task); | 68 estimator.WillProcessTask(task); |
56 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); | 69 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); |
57 estimator.DidProcessTask(task); | 70 estimator.DidProcessTask(task); |
58 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); | 71 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); |
59 estimator.DidProcessTask(task); | 72 estimator.DidProcessTask(task); |
60 | 73 |
61 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), | 74 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), |
62 estimator.expected_task_duration()); | 75 estimator.expected_task_duration()); |
63 }; | 76 } |
64 | 77 |
65 } // namespace scheduler | 78 } // namespace scheduler |
OLD | NEW |