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

Side by Side Diff: cc/scheduler/frame_rate_controller_unittest.cc

Issue 12623026: cc: Chromify TimeSource, DelayBasedTimeSource and test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Back to doubles Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/scheduler/frame_rate_controller.cc ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs()); 43 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
44 timeSource->setNow(elapsed); 44 timeSource->setNow(elapsed);
45 thread.runPendingTask(); 45 thread.runPendingTask();
46 EXPECT_TRUE(client.vsyncTicked()); 46 EXPECT_TRUE(client.vsyncTicked());
47 client.reset(); 47 client.reset();
48 48
49 // Tell the controller we drew 49 // Tell the controller we drew
50 controller.DidBeginFrame(); 50 controller.DidBeginFrame();
51 51
52 // Tell the controller the frame ended 5ms later 52 // Tell the controller the frame ended 5ms later
53 timeSource->setNow(timeSource->now() + base::TimeDelta::FromMilliseconds(5)) ; 53 timeSource->setNow(timeSource->Now() + base::TimeDelta::FromMilliseconds(5)) ;
54 controller.DidFinishFrame(); 54 controller.DidFinishFrame();
55 55
56 // Trigger another frame, make sure vsync runs again 56 // Trigger another frame, make sure vsync runs again
57 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs()); 57 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
58 EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous cod e didn't move time backward. 58 EXPECT_TRUE(elapsed >= timeSource->Now()); // Sanity check that previous cod e didn't move time backward.
59 timeSource->setNow(elapsed); 59 timeSource->setNow(elapsed);
60 thread.runPendingTask(); 60 thread.runPendingTask();
61 EXPECT_TRUE(client.vsyncTicked()); 61 EXPECT_TRUE(client.vsyncTicked());
62 } 62 }
63 63
64 TEST(FrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight) 64 TEST(FrameRateControllerTest, TestFrameThrottling_TwoFramesInFlight)
65 { 65 {
66 FakeThread thread; 66 FakeThread thread;
67 FakeFrameRateControllerClient client; 67 FakeFrameRateControllerClient client;
68 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(base::Time::kMi crosecondsPerSecond / 60); 68 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(base::Time::kMi crosecondsPerSecond / 60);
(...skipping 11 matching lines...) Expand all
80 timeSource->setNow(elapsed); 80 timeSource->setNow(elapsed);
81 thread.runPendingTask(); 81 thread.runPendingTask();
82 EXPECT_TRUE(client.vsyncTicked()); 82 EXPECT_TRUE(client.vsyncTicked());
83 client.reset(); 83 client.reset();
84 84
85 // Tell the controller we drew 85 // Tell the controller we drew
86 controller.DidBeginFrame(); 86 controller.DidBeginFrame();
87 87
88 // Trigger another frame, make sure vsync callback runs again 88 // Trigger another frame, make sure vsync callback runs again
89 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs()); 89 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
90 EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous cod e didn't move time backward. 90 EXPECT_TRUE(elapsed >= timeSource->Now()); // Sanity check that previous cod e didn't move time backward.
91 timeSource->setNow(elapsed); 91 timeSource->setNow(elapsed);
92 thread.runPendingTask(); 92 thread.runPendingTask();
93 EXPECT_TRUE(client.vsyncTicked()); 93 EXPECT_TRUE(client.vsyncTicked());
94 client.reset(); 94 client.reset();
95 95
96 // Tell the controller we drew, again. 96 // Tell the controller we drew, again.
97 controller.DidBeginFrame(); 97 controller.DidBeginFrame();
98 98
99 // Trigger another frame. Since two frames are pending, we should not draw. 99 // Trigger another frame. Since two frames are pending, we should not draw.
100 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs()); 100 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
101 EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous cod e didn't move time backward. 101 EXPECT_TRUE(elapsed >= timeSource->Now()); // Sanity check that previous cod e didn't move time backward.
102 timeSource->setNow(elapsed); 102 timeSource->setNow(elapsed);
103 thread.runPendingTask(); 103 thread.runPendingTask();
104 EXPECT_FALSE(client.vsyncTicked()); 104 EXPECT_FALSE(client.vsyncTicked());
105 105
106 // Tell the controller the first frame ended 5ms later 106 // Tell the controller the first frame ended 5ms later
107 timeSource->setNow(timeSource->now() + base::TimeDelta::FromMilliseconds(5)) ; 107 timeSource->setNow(timeSource->Now() + base::TimeDelta::FromMilliseconds(5)) ;
108 controller.DidFinishFrame(); 108 controller.DidFinishFrame();
109 109
110 // Tick should not have been called 110 // Tick should not have been called
111 EXPECT_FALSE(client.vsyncTicked()); 111 EXPECT_FALSE(client.vsyncTicked());
112 112
113 // Trigger yet another frame. Since one frames is pending, another vsync cal lback should run. 113 // Trigger yet another frame. Since one frames is pending, another vsync cal lback should run.
114 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs()); 114 elapsed += base::TimeDelta::FromMilliseconds(thread.pendingDelayMs());
115 EXPECT_TRUE(elapsed >= timeSource->now()); // Sanity check that previous cod e didn't move time backward. 115 EXPECT_TRUE(elapsed >= timeSource->Now()); // Sanity check that previous cod e didn't move time backward.
116 timeSource->setNow(elapsed); 116 timeSource->setNow(elapsed);
117 thread.runPendingTask(); 117 thread.runPendingTask();
118 EXPECT_TRUE(client.vsyncTicked()); 118 EXPECT_TRUE(client.vsyncTicked());
119 } 119 }
120 120
121 TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled) 121 TEST(FrameRateControllerTest, TestFrameThrottling_Unthrottled)
122 { 122 {
123 FakeThread thread; 123 FakeThread thread;
124 FakeFrameRateControllerClient client; 124 FakeFrameRateControllerClient client;
125 FrameRateController controller(&thread); 125 FrameRateController controller(&thread);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 EXPECT_FALSE(thread.hasPendingTask()); 160 EXPECT_FALSE(thread.hasPendingTask());
161 161
162 // didFinishFrame triggers a frame, make sure the vsync callback is called 162 // didFinishFrame triggers a frame, make sure the vsync callback is called
163 controller.DidFinishFrame(); 163 controller.DidFinishFrame();
164 thread.runPendingTask(); 164 thread.runPendingTask();
165 EXPECT_TRUE(client.vsyncTicked()); 165 EXPECT_TRUE(client.vsyncTicked());
166 } 166 }
167 167
168 } // namespace 168 } // namespace
169 } // namespace cc 169 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/frame_rate_controller.cc ('k') | cc/scheduler/scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698