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 } | |
61 | 48 |
62 TEST_F(TaskCostEstimatorTest, NestedRunLoop) { | 49 TEST_F(TaskCostEstimatorTest, NestedRunLoop) { |
63 TaskCostEstimatorForTest estimator(&clock_, 1, 100); | 50 TaskCostEstimatorForTest estimator(&clock_, 1, 100); |
64 base::PendingTask task(FROM_HERE, base::Closure()); | 51 base::PendingTask task(FROM_HERE, base::Closure()); |
65 | 52 |
66 // Make sure we ignore the tasks inside the nested run loop. | 53 // Make sure we ignore the tasks inside the nested run loop. |
67 estimator.WillProcessTask(task); | 54 estimator.WillProcessTask(task); |
68 estimator.WillProcessTask(task); | 55 estimator.WillProcessTask(task); |
69 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); | 56 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); |
70 estimator.DidProcessTask(task); | 57 estimator.DidProcessTask(task); |
71 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); | 58 clock_.Advance(base::TimeDelta::FromMilliseconds(500)); |
72 estimator.DidProcessTask(task); | 59 estimator.DidProcessTask(task); |
73 | 60 |
74 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), | 61 EXPECT_EQ(base::TimeDelta::FromMilliseconds(1000), |
75 estimator.expected_task_duration()); | 62 estimator.expected_task_duration()); |
76 } | 63 }; |
77 | 64 |
78 } // namespace scheduler | 65 } // namespace scheduler |
OLD | NEW |