| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/scheduler/frame_rate_controller.h" | 5 #include "cc/scheduler/frame_rate_controller.h" |
| 6 | 6 |
| 7 #include "cc/test/scheduler_test_common.h" | 7 #include "cc/test/scheduler_test_common.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled) { | 129 TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled) { |
| 130 FakeThread thread; | 130 FakeThread thread; |
| 131 FakeFrameRateControllerClient client; | 131 FakeFrameRateControllerClient client; |
| 132 FrameRateController controller(&thread); | 132 FrameRateController controller(&thread); |
| 133 | 133 |
| 134 controller.SetClient(&client); | 134 controller.SetClient(&client); |
| 135 controller.SetMaxFramesPending(2); | 135 controller.SetMaxFramesPending(2); |
| 136 | 136 |
| 137 // setActive triggers 1st frame, make sure the vsync callback is called | 137 // SetActive triggers 1st frame, make sure the vsync callback is called |
| 138 controller.SetActive(true); | 138 controller.SetActive(true); |
| 139 thread.RunPendingTask(); | 139 thread.RunPendingTask(); |
| 140 EXPECT_TRUE(client.VSyncTicked()); | 140 EXPECT_TRUE(client.VSyncTicked()); |
| 141 client.Reset(); | 141 client.Reset(); |
| 142 | 142 |
| 143 // Even if we don't call DidBeginFrame, FrameRateController should | 143 // Even if we don't call DidBeginFrame, FrameRateController should |
| 144 // still attempt to vsync tick multiple times until it does result in | 144 // still attempt to vsync tick multiple times until it does result in |
| 145 // a DidBeginFrame. | 145 // a DidBeginFrame. |
| 146 thread.RunPendingTask(); | 146 thread.RunPendingTask(); |
| 147 EXPECT_TRUE(client.VSyncTicked()); | 147 EXPECT_TRUE(client.VSyncTicked()); |
| 148 client.Reset(); | 148 client.Reset(); |
| 149 | 149 |
| 150 thread.RunPendingTask(); | 150 thread.RunPendingTask(); |
| 151 EXPECT_TRUE(client.VSyncTicked()); | 151 EXPECT_TRUE(client.VSyncTicked()); |
| 152 client.Reset(); | 152 client.Reset(); |
| 153 | 153 |
| 154 // DidBeginFrame triggers 2nd frame, make sure the vsync callback is called | 154 // DidBeginFrame triggers 2nd frame, make sure the vsync callback is called |
| 155 controller.DidBeginFrame(); | 155 controller.DidBeginFrame(); |
| 156 thread.RunPendingTask(); | 156 thread.RunPendingTask(); |
| 157 EXPECT_TRUE(client.VSyncTicked()); | 157 EXPECT_TRUE(client.VSyncTicked()); |
| 158 client.Reset(); | 158 client.Reset(); |
| 159 | 159 |
| 160 // DidBeginFrame triggers 3rd frame (> maxFramesPending), | 160 // DidBeginFrame triggers 3rd frame (> max_frames_pending), |
| 161 // make sure the vsync callback is NOT called | 161 // make sure the vsync callback is NOT called |
| 162 controller.DidBeginFrame(); | 162 controller.DidBeginFrame(); |
| 163 thread.RunPendingTask(); | 163 thread.RunPendingTask(); |
| 164 EXPECT_FALSE(client.VSyncTicked()); | 164 EXPECT_FALSE(client.VSyncTicked()); |
| 165 client.Reset(); | 165 client.Reset(); |
| 166 | 166 |
| 167 // Make sure there is no pending task since we can't do anything until we | 167 // Make sure there is no pending task since we can't do anything until we |
| 168 // receive a DidFinishFrame anyway. | 168 // receive a DidFinishFrame anyway. |
| 169 EXPECT_FALSE(thread.HasPendingTask()); | 169 EXPECT_FALSE(thread.HasPendingTask()); |
| 170 | 170 |
| 171 // DidFinishFrame triggers a frame, make sure the vsync callback is called | 171 // DidFinishFrame triggers a frame, make sure the vsync callback is called |
| 172 controller.DidFinishFrame(); | 172 controller.DidFinishFrame(); |
| 173 thread.RunPendingTask(); | 173 thread.RunPendingTask(); |
| 174 EXPECT_TRUE(client.VSyncTicked()); | 174 EXPECT_TRUE(client.VSyncTicked()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace | 177 } // namespace |
| 178 } // namespace cc | 178 } // namespace cc |
| OLD | NEW |