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

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

Issue 16833003: cc: Emulate BeginFrame in OutputSurfaces that don't support it natively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/scheduler/vsync_time_source.h » ('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/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 } while (false) 23 } while (false)
24 24
25 #define EXPECT_SINGLE_ACTION(action, client) \ 25 #define EXPECT_SINGLE_ACTION(action, client) \
26 EXPECT_ACTION(action, client, 0, 1) 26 EXPECT_ACTION(action, client, 0, 1)
27 27
28 namespace cc { 28 namespace cc {
29 namespace { 29 namespace {
30 30
31 class FakeSchedulerClient : public SchedulerClient { 31 class FakeSchedulerClient : public SchedulerClient {
32 public: 32 public:
33 FakeSchedulerClient() { Reset(); } 33 FakeSchedulerClient()
34 : needs_begin_frame_(false) {
35 Reset();
36 }
37
34 void Reset() { 38 void Reset() {
35 actions_.clear(); 39 actions_.clear();
36 states_.clear(); 40 states_.clear();
37 draw_will_happen_ = true; 41 draw_will_happen_ = true;
38 swap_will_happen_if_draw_happens_ = true; 42 swap_will_happen_if_draw_happens_ = true;
39 num_draws_ = 0; 43 num_draws_ = 0;
40 } 44 }
41 45
42 Scheduler* CreateScheduler( 46 Scheduler* CreateScheduler(const SchedulerSettings& settings) {
43 scoped_ptr<FrameRateController> frame_rate_controller, 47 scheduler_ = Scheduler::Create(this, settings);
44 const SchedulerSettings& settings) {
45 scheduler_ =
46 Scheduler::Create(this, frame_rate_controller.Pass(), settings);
47 return scheduler_.get(); 48 return scheduler_.get();
48 } 49 }
49 50
50 51 bool needs_begin_frame() { return needs_begin_frame_; }
51 int num_draws() const { return num_draws_; } 52 int num_draws() const { return num_draws_; }
52 int num_actions_() const { return static_cast<int>(actions_.size()); } 53 int num_actions_() const { return static_cast<int>(actions_.size()); }
53 const char* Action(int i) const { return actions_[i]; } 54 const char* Action(int i) const { return actions_[i]; }
54 std::string StateForAction(int i) const { return states_[i]; } 55 std::string StateForAction(int i) const { return states_[i]; }
55 56
56 bool HasAction(const char* action) const { 57 bool HasAction(const char* action) const {
57 for (size_t i = 0; i < actions_.size(); i++) 58 for (size_t i = 0; i < actions_.size(); i++)
58 if (!strcmp(actions_[i], action)) 59 if (!strcmp(actions_[i], action))
59 return true; 60 return true;
60 return false; 61 return false;
61 } 62 }
62 63
63 void SetDrawWillHappen(bool draw_will_happen) { 64 void SetDrawWillHappen(bool draw_will_happen) {
64 draw_will_happen_ = draw_will_happen; 65 draw_will_happen_ = draw_will_happen;
65 } 66 }
66 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) { 67 void SetSwapWillHappenIfDrawHappens(bool swap_will_happen_if_draw_happens) {
67 swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens; 68 swap_will_happen_if_draw_happens_ = swap_will_happen_if_draw_happens;
68 } 69 }
69 70
70 // Scheduler Implementation. 71 // Scheduler Implementation.
72 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE {
73 actions_.push_back("SetNeedsBeginFrameOnImplThread");
74 states_.push_back(scheduler_->StateAsStringForTesting());
75 needs_begin_frame_ = enable;
76 }
71 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE { 77 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {
72 actions_.push_back("ScheduledActionSendBeginFrameToMainThread"); 78 actions_.push_back("ScheduledActionSendBeginFrameToMainThread");
73 states_.push_back(scheduler_->StateAsStringForTesting()); 79 states_.push_back(scheduler_->StateAsStringForTesting());
74 } 80 }
75 virtual ScheduledActionDrawAndSwapResult 81 virtual ScheduledActionDrawAndSwapResult
76 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { 82 ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
77 actions_.push_back("ScheduledActionDrawAndSwapIfPossible"); 83 actions_.push_back("ScheduledActionDrawAndSwapIfPossible");
78 states_.push_back(scheduler_->StateAsStringForTesting()); 84 states_.push_back(scheduler_->StateAsStringForTesting());
79 num_draws_++; 85 num_draws_++;
80 return ScheduledActionDrawAndSwapResult(draw_will_happen_, 86 return ScheduledActionDrawAndSwapResult(draw_will_happen_,
(...skipping 23 matching lines...) Expand all
104 actions_.push_back("ScheduledActionBeginOutputSurfaceCreation"); 110 actions_.push_back("ScheduledActionBeginOutputSurfaceCreation");
105 states_.push_back(scheduler_->StateAsStringForTesting()); 111 states_.push_back(scheduler_->StateAsStringForTesting());
106 } 112 }
107 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE { 113 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE {
108 actions_.push_back("ScheduledActionAcquireLayerTexturesForMainThread"); 114 actions_.push_back("ScheduledActionAcquireLayerTexturesForMainThread");
109 states_.push_back(scheduler_->StateAsStringForTesting()); 115 states_.push_back(scheduler_->StateAsStringForTesting());
110 } 116 }
111 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} 117 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}
112 118
113 protected: 119 protected:
120 bool needs_begin_frame_;
114 bool draw_will_happen_; 121 bool draw_will_happen_;
115 bool swap_will_happen_if_draw_happens_; 122 bool swap_will_happen_if_draw_happens_;
116 int num_draws_; 123 int num_draws_;
117 std::vector<const char*> actions_; 124 std::vector<const char*> actions_;
118 std::vector<std::string> states_; 125 std::vector<std::string> states_;
119 scoped_ptr<Scheduler> scheduler_; 126 scoped_ptr<Scheduler> scheduler_;
120 }; 127 };
121 128
122 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginFrame) { 129 TEST(SchedulerTest, InitializeOutputSurfaceDoesNotBeginFrame) {
123 FakeSchedulerClient client; 130 FakeSchedulerClient client;
124 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
125 SchedulerSettings default_scheduler_settings; 131 SchedulerSettings default_scheduler_settings;
126 Scheduler* scheduler = client.CreateScheduler( 132 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
127 make_scoped_ptr(new FrameRateController(time_source)),
128 default_scheduler_settings);
129 scheduler->SetCanStart(); 133 scheduler->SetCanStart();
130 scheduler->SetVisible(true); 134 scheduler->SetVisible(true);
131 scheduler->SetCanDraw(true); 135 scheduler->SetCanDraw(true);
132 136
133 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 137 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
134 client.Reset(); 138 client.Reset();
135 scheduler->DidCreateAndInitializeOutputSurface(); 139 scheduler->DidCreateAndInitializeOutputSurface();
136 EXPECT_EQ(0, client.num_actions_()); 140 EXPECT_EQ(0, client.num_actions_());
137 } 141 }
138 142
139 TEST(SchedulerTest, RequestCommit) { 143 TEST(SchedulerTest, RequestCommit) {
140 FakeSchedulerClient client; 144 FakeSchedulerClient client;
141 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
142 SchedulerSettings default_scheduler_settings; 145 SchedulerSettings default_scheduler_settings;
143 Scheduler* scheduler = client.CreateScheduler( 146 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
144 make_scoped_ptr(new FrameRateController(time_source)),
145 default_scheduler_settings);
146 scheduler->SetCanStart(); 147 scheduler->SetCanStart();
147 scheduler->SetVisible(true); 148 scheduler->SetVisible(true);
148 scheduler->SetCanDraw(true); 149 scheduler->SetCanDraw(true);
149 150
150 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 151 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
151 client.Reset(); 152 client.Reset();
152 scheduler->DidCreateAndInitializeOutputSurface(); 153 scheduler->DidCreateAndInitializeOutputSurface();
153 154
154 // SetNeedsCommit should begin the frame. 155 // SetNeedsCommit should begin the frame.
155 scheduler->SetNeedsCommit(); 156 scheduler->SetNeedsCommit();
156 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client); 157 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
157 EXPECT_FALSE(time_source->Active()); 158 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
159 EXPECT_TRUE(client.needs_begin_frame());
158 client.Reset(); 160 client.Reset();
159 161
160 // FinishCommit should commit 162 // FinishCommit should commit
161 scheduler->FinishCommit(); 163 scheduler->FinishCommit();
162 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 164 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
163 EXPECT_TRUE(time_source->Active()); 165 EXPECT_TRUE(client.needs_begin_frame());
164 client.Reset(); 166 client.Reset();
165 167
166 // Tick should draw. 168 // BeginFrame should draw.
167 time_source->Tick(); 169 scheduler->BeginFrame(base::TimeTicks::Now());
168 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client); 170 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
169 EXPECT_FALSE(time_source->Active()); 171 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
172 EXPECT_FALSE(client.needs_begin_frame());
170 client.Reset(); 173 client.Reset();
171
172 // Timer should be off.
173 EXPECT_FALSE(time_source->Active());
174 } 174 }
175 175
176 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) { 176 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) {
177 FakeSchedulerClient client; 177 FakeSchedulerClient client;
178 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
179 SchedulerSettings default_scheduler_settings; 178 SchedulerSettings default_scheduler_settings;
180 Scheduler* scheduler = client.CreateScheduler( 179 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
181 make_scoped_ptr(new FrameRateController(time_source)),
182 default_scheduler_settings);
183 scheduler->SetCanStart(); 180 scheduler->SetCanStart();
184 scheduler->SetVisible(true); 181 scheduler->SetVisible(true);
185 scheduler->SetCanDraw(true); 182 scheduler->SetCanDraw(true);
186 183
187 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 184 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
188 client.Reset(); 185 client.Reset();
189 scheduler->DidCreateAndInitializeOutputSurface(); 186 scheduler->DidCreateAndInitializeOutputSurface();
190 187
191 // SetNedsCommit should begin the frame. 188 // SetNedsCommit should begin the frame.
192 scheduler->SetNeedsCommit(); 189 scheduler->SetNeedsCommit();
193 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginFrameToMainThread", client); 190 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
191 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
194 client.Reset(); 192 client.Reset();
195 193
196 // Now SetNeedsCommit again. Calling here means we need a second frame. 194 // Now SetNeedsCommit again. Calling here means we need a second frame.
197 scheduler->SetNeedsCommit(); 195 scheduler->SetNeedsCommit();
198 196
199 // Since another commit is needed, FinishCommit should commit, 197 // Since another commit is needed, FinishCommit should commit,
200 // then begin another frame. 198 // then begin another frame.
201 scheduler->FinishCommit(); 199 scheduler->FinishCommit();
202 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 200 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
203 client.Reset(); 201 client.Reset();
204 202
205 // Tick should draw but then begin another frame. 203 // Tick should draw but then begin another frame.
206 time_source->Tick(); 204 scheduler->BeginFrame(base::TimeTicks::Now());
207 EXPECT_FALSE(time_source->Active()); 205 EXPECT_TRUE(client.needs_begin_frame());
208 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 206 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
209 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2); 207 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2);
210 client.Reset(); 208 client.Reset();
209
210 // Go back to quiescent state and verify we no longer request BeginFrames.
211 scheduler->FinishCommit();
212 scheduler->BeginFrame(base::TimeTicks::Now());
213 EXPECT_FALSE(client.needs_begin_frame());
211 } 214 }
212 215
213 TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { 216 TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) {
214 FakeSchedulerClient client; 217 FakeSchedulerClient client;
215 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
216 SchedulerSettings default_scheduler_settings; 218 SchedulerSettings default_scheduler_settings;
217 Scheduler* scheduler = client.CreateScheduler( 219 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
218 make_scoped_ptr(new FrameRateController(time_source)),
219 default_scheduler_settings);
220 scheduler->SetCanStart(); 220 scheduler->SetCanStart();
221 scheduler->SetVisible(true); 221 scheduler->SetVisible(true);
222 scheduler->SetCanDraw(true); 222 scheduler->SetCanDraw(true);
223 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
223 224
224 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
225 client.Reset(); 225 client.Reset();
226 scheduler->DidCreateAndInitializeOutputSurface(); 226 scheduler->DidCreateAndInitializeOutputSurface();
227
228 scheduler->SetNeedsRedraw(); 227 scheduler->SetNeedsRedraw();
229 EXPECT_TRUE(scheduler->RedrawPending()); 228 EXPECT_TRUE(scheduler->RedrawPending());
230 EXPECT_TRUE(time_source->Active()); 229 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
230 EXPECT_TRUE(client.needs_begin_frame());
231 231
232 time_source->Tick(); 232 client.Reset();
233 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 233 scheduler->BeginFrame(base::TimeTicks::Now());
234 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
235 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
234 EXPECT_FALSE(scheduler->RedrawPending()); 236 EXPECT_FALSE(scheduler->RedrawPending());
235 EXPECT_FALSE(time_source->Active()); 237 EXPECT_FALSE(client.needs_begin_frame());
238
236 client.Reset(); 239 client.Reset();
237
238 scheduler->SetMainThreadNeedsLayerTextures(); 240 scheduler->SetMainThreadNeedsLayerTextures();
239 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 241 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
240 client, 242 client,
241 0, 243 0,
242 2); 244 3);
243 // A commit was started by SetMainThreadNeedsLayerTextures(). 245 // A commit was started by SetMainThreadNeedsLayerTextures().
244 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2); 246 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 3);
247 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 2, 3);
248
249 // We should request a BeginFrame in anticipation of a draw.
245 client.Reset(); 250 client.Reset();
246
247 scheduler->SetNeedsRedraw(); 251 scheduler->SetNeedsRedraw();
248 EXPECT_TRUE(scheduler->RedrawPending()); 252 EXPECT_TRUE(scheduler->RedrawPending());
249 EXPECT_TRUE(time_source->Active()); 253 EXPECT_TRUE(client.needs_begin_frame());
250 254
251 // No draw happens since the textures are acquired by the main thread. 255 // No draw happens since the textures are acquired by the main thread.
252 time_source->Tick(); 256 client.Reset();
253 EXPECT_EQ(0, client.num_actions_()); 257 scheduler->BeginFrame(base::TimeTicks::Now());
258 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
254 EXPECT_TRUE(scheduler->RedrawPending()); 259 EXPECT_TRUE(scheduler->RedrawPending());
255 EXPECT_TRUE(time_source->Active()); 260 EXPECT_TRUE(client.needs_begin_frame());
256 261
262 // Commit will release the texture.
263 client.Reset();
257 scheduler->FinishCommit(); 264 scheduler->FinishCommit();
258 EXPECT_ACTION("ScheduledActionCommit", client, 0, 1); 265 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
259 EXPECT_TRUE(scheduler->RedrawPending()); 266 EXPECT_TRUE(scheduler->RedrawPending());
260 EXPECT_TRUE(time_source->Active()); 267 EXPECT_TRUE(client.needs_begin_frame());
261 client.Reset();
262 268
263 // Now we can draw again after the commit happens. 269 // Now we can draw again after the commit happens.
264 time_source->Tick(); 270 client.Reset();
265 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 1); 271 scheduler->BeginFrame(base::TimeTicks::Now());
272 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
273 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
266 EXPECT_FALSE(scheduler->RedrawPending()); 274 EXPECT_FALSE(scheduler->RedrawPending());
267 EXPECT_FALSE(time_source->Active()); 275 EXPECT_FALSE(client.needs_begin_frame());
268 client.Reset(); 276 client.Reset();
269 } 277 }
270 278
271 TEST(SchedulerTest, TextureAcquisitionCollision) { 279 TEST(SchedulerTest, TextureAcquisitionCollision) {
272 FakeSchedulerClient client; 280 FakeSchedulerClient client;
273 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
274 SchedulerSettings default_scheduler_settings; 281 SchedulerSettings default_scheduler_settings;
275 Scheduler* scheduler = client.CreateScheduler( 282 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
276 make_scoped_ptr(new FrameRateController(time_source)),
277 default_scheduler_settings);
278 scheduler->SetCanStart(); 283 scheduler->SetCanStart();
279 scheduler->SetVisible(true); 284 scheduler->SetVisible(true);
280 scheduler->SetCanDraw(true); 285 scheduler->SetCanDraw(true);
281 286
282 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 287 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
283 client.Reset(); 288 client.Reset();
284 scheduler->DidCreateAndInitializeOutputSurface(); 289 scheduler->DidCreateAndInitializeOutputSurface();
285 290
286 scheduler->SetNeedsCommit(); 291 scheduler->SetNeedsCommit();
287 scheduler->SetMainThreadNeedsLayerTextures(); 292 scheduler->SetMainThreadNeedsLayerTextures();
288 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); 293 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 3);
294 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 3);
289 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 295 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
290 client, 296 client,
291 1, 297 2,
292 2); 298 3);
293 client.Reset(); 299 client.Reset();
294 300
295 // Compositor not scheduled to draw because textures are locked by main thread 301 // Although the compositor cannot draw because textures are locked by main
296 EXPECT_FALSE(time_source->Active()); 302 // thread, we continue requesting SetNeedsBeginFrame in anticipation of the
303 // unlock.
304 EXPECT_TRUE(client.needs_begin_frame());
297 305
298 // Trigger the commit 306 // Trigger the commit
299 scheduler->FinishCommit(); 307 scheduler->FinishCommit();
300 EXPECT_TRUE(time_source->Active()); 308 EXPECT_TRUE(client.needs_begin_frame());
301 client.Reset(); 309 client.Reset();
302 310
303 // Between commit and draw, texture acquisition for main thread delayed, 311 // Between commit and draw, texture acquisition for main thread delayed,
304 // and main thread blocks. 312 // and main thread blocks.
305 scheduler->SetMainThreadNeedsLayerTextures(); 313 scheduler->SetMainThreadNeedsLayerTextures();
306 EXPECT_EQ(0, client.num_actions_()); 314 EXPECT_EQ(0, client.num_actions_());
307 client.Reset(); 315 client.Reset();
308 316
309 // Once compositor draw complete, the delayed texture acquisition fires. 317 // Once compositor draw complete, the delayed texture acquisition fires.
310 time_source->Tick(); 318 scheduler->BeginFrame(base::TimeTicks::Now());
311 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); 319 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3);
312 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 320 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
313 client, 321 client,
314 1, 322 1,
315 3); 323 3);
316 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 2, 3); 324 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 2, 3);
317 client.Reset(); 325 client.Reset();
318 } 326 }
319 327
320 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { 328 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
321 FakeSchedulerClient client; 329 FakeSchedulerClient client;
322 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
323 SchedulerSettings default_scheduler_settings; 330 SchedulerSettings default_scheduler_settings;
324 Scheduler* scheduler = client.CreateScheduler( 331 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
325 make_scoped_ptr(new FrameRateController(time_source)),
326 default_scheduler_settings);
327 scheduler->SetCanStart(); 332 scheduler->SetCanStart();
328 scheduler->SetVisible(true); 333 scheduler->SetVisible(true);
329 scheduler->SetCanDraw(true); 334 scheduler->SetCanDraw(true);
330 335
331 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 336 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
332 client.Reset(); 337 client.Reset();
333 scheduler->DidCreateAndInitializeOutputSurface(); 338 scheduler->DidCreateAndInitializeOutputSurface();
334 339
335 scheduler->SetNeedsCommit(); 340 scheduler->SetNeedsCommit();
336 scheduler->FinishCommit(); 341 scheduler->FinishCommit();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} 377 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {}
373 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} 378 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}
374 }; 379 };
375 380
376 // Tests for two different situations: 381 // Tests for two different situations:
377 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside 382 // 1. the scheduler dropping SetNeedsRedraw requests that happen inside
378 // a ScheduledActionDrawAndSwap 383 // a ScheduledActionDrawAndSwap
379 // 2. the scheduler drawing twice inside a single tick 384 // 2. the scheduler drawing twice inside a single tick
380 TEST(SchedulerTest, RequestRedrawInsideDraw) { 385 TEST(SchedulerTest, RequestRedrawInsideDraw) {
381 SchedulerClientThatsetNeedsDrawInsideDraw client; 386 SchedulerClientThatsetNeedsDrawInsideDraw client;
382 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
383 SchedulerSettings default_scheduler_settings; 387 SchedulerSettings default_scheduler_settings;
384 Scheduler* scheduler = client.CreateScheduler( 388 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
385 make_scoped_ptr(new FrameRateController(time_source)),
386 default_scheduler_settings);
387 scheduler->SetCanStart(); 389 scheduler->SetCanStart();
388 scheduler->SetVisible(true); 390 scheduler->SetVisible(true);
389 scheduler->SetCanDraw(true); 391 scheduler->SetCanDraw(true);
390 scheduler->DidCreateAndInitializeOutputSurface(); 392 scheduler->DidCreateAndInitializeOutputSurface();
391 393
392 scheduler->SetNeedsRedraw(); 394 scheduler->SetNeedsRedraw();
393 EXPECT_TRUE(scheduler->RedrawPending()); 395 EXPECT_TRUE(scheduler->RedrawPending());
394 EXPECT_TRUE(time_source->Active()); 396 EXPECT_TRUE(client.needs_begin_frame());
395 EXPECT_EQ(0, client.num_draws()); 397 EXPECT_EQ(0, client.num_draws());
396 398
397 time_source->Tick(); 399 scheduler->BeginFrame(base::TimeTicks::Now());
398 EXPECT_EQ(1, client.num_draws()); 400 EXPECT_EQ(1, client.num_draws());
399 EXPECT_TRUE(scheduler->RedrawPending()); 401 EXPECT_TRUE(scheduler->RedrawPending());
400 EXPECT_TRUE(time_source->Active()); 402 EXPECT_TRUE(client.needs_begin_frame());
401 403
402 time_source->Tick(); 404 scheduler->BeginFrame(base::TimeTicks::Now());
403 EXPECT_EQ(2, client.num_draws()); 405 EXPECT_EQ(2, client.num_draws());
404 EXPECT_FALSE(scheduler->RedrawPending()); 406 EXPECT_FALSE(scheduler->RedrawPending());
405 EXPECT_FALSE(time_source->Active()); 407 EXPECT_FALSE(client.needs_begin_frame());
406 } 408 }
407 409
408 // Test that requesting redraw inside a failed draw doesn't lose the request. 410 // Test that requesting redraw inside a failed draw doesn't lose the request.
409 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { 411 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
410 SchedulerClientThatsetNeedsDrawInsideDraw client; 412 SchedulerClientThatsetNeedsDrawInsideDraw client;
411 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
412 SchedulerSettings default_scheduler_settings; 413 SchedulerSettings default_scheduler_settings;
413 Scheduler* scheduler = client.CreateScheduler( 414 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
414 make_scoped_ptr(new FrameRateController(time_source)),
415 default_scheduler_settings);
416 scheduler->SetCanStart(); 415 scheduler->SetCanStart();
417 scheduler->SetVisible(true); 416 scheduler->SetVisible(true);
418 scheduler->SetCanDraw(true); 417 scheduler->SetCanDraw(true);
419 scheduler->DidCreateAndInitializeOutputSurface(); 418 scheduler->DidCreateAndInitializeOutputSurface();
420 419
421 client.SetDrawWillHappen(false); 420 client.SetDrawWillHappen(false);
422 421
423 scheduler->SetNeedsRedraw(); 422 scheduler->SetNeedsRedraw();
424 EXPECT_TRUE(scheduler->RedrawPending()); 423 EXPECT_TRUE(scheduler->RedrawPending());
425 EXPECT_TRUE(time_source->Active()); 424 EXPECT_TRUE(client.needs_begin_frame());
426 EXPECT_EQ(0, client.num_draws()); 425 EXPECT_EQ(0, client.num_draws());
427 426
428 // Fail the draw. 427 // Fail the draw.
429 time_source->Tick(); 428 scheduler->BeginFrame(base::TimeTicks::Now());
430 EXPECT_EQ(1, client.num_draws()); 429 EXPECT_EQ(1, client.num_draws());
431 430
432 // We have a commit pending and the draw failed, and we didn't lose the redraw 431 // We have a commit pending and the draw failed, and we didn't lose the redraw
433 // request. 432 // request.
434 EXPECT_TRUE(scheduler->CommitPending()); 433 EXPECT_TRUE(scheduler->CommitPending());
435 EXPECT_TRUE(scheduler->RedrawPending()); 434 EXPECT_TRUE(scheduler->RedrawPending());
436 EXPECT_TRUE(time_source->Active()); 435 EXPECT_TRUE(client.needs_begin_frame());
437 436
438 // Fail the draw again. 437 // Fail the draw again.
439 time_source->Tick(); 438 scheduler->BeginFrame(base::TimeTicks::Now());
440 EXPECT_EQ(2, client.num_draws()); 439 EXPECT_EQ(2, client.num_draws());
441 EXPECT_TRUE(scheduler->CommitPending()); 440 EXPECT_TRUE(scheduler->CommitPending());
442 EXPECT_TRUE(scheduler->RedrawPending()); 441 EXPECT_TRUE(scheduler->RedrawPending());
443 EXPECT_TRUE(time_source->Active()); 442 EXPECT_TRUE(client.needs_begin_frame());
444 443
445 // Draw successfully. 444 // Draw successfully.
446 client.SetDrawWillHappen(true); 445 client.SetDrawWillHappen(true);
447 time_source->Tick(); 446 scheduler->BeginFrame(base::TimeTicks::Now());
448 EXPECT_EQ(3, client.num_draws()); 447 EXPECT_EQ(3, client.num_draws());
449 EXPECT_TRUE(scheduler->CommitPending()); 448 EXPECT_TRUE(scheduler->CommitPending());
450 EXPECT_FALSE(scheduler->RedrawPending()); 449 EXPECT_FALSE(scheduler->RedrawPending());
451 EXPECT_FALSE(time_source->Active()); 450 EXPECT_TRUE(client.needs_begin_frame());
452 } 451 }
453 452
454 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient { 453 class SchedulerClientThatsetNeedsCommitInsideDraw : public FakeSchedulerClient {
455 public: 454 public:
456 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {} 455 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {}
457 virtual ScheduledActionDrawAndSwapResult 456 virtual ScheduledActionDrawAndSwapResult
458 ScheduledActionDrawAndSwapIfPossible() OVERRIDE { 457 ScheduledActionDrawAndSwapIfPossible() OVERRIDE {
459 // Only SetNeedsCommit the first time this is called 458 // Only SetNeedsCommit the first time this is called
460 if (!num_draws_) 459 if (!num_draws_)
461 scheduler_->SetNeedsCommit(); 460 scheduler_->SetNeedsCommit();
462 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible(); 461 return FakeSchedulerClient::ScheduledActionDrawAndSwapIfPossible();
463 } 462 }
464 463
465 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() 464 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced()
466 OVERRIDE { 465 OVERRIDE {
467 NOTREACHED(); 466 NOTREACHED();
468 return ScheduledActionDrawAndSwapResult(true, true); 467 return ScheduledActionDrawAndSwapResult(true, true);
469 } 468 }
470 469
471 virtual void ScheduledActionCommit() OVERRIDE {} 470 virtual void ScheduledActionCommit() OVERRIDE {}
472 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {} 471 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {}
473 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {} 472 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks) OVERRIDE {}
474 }; 473 };
475 474
476 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that 475 // Tests for the scheduler infinite-looping on SetNeedsCommit requests that
477 // happen inside a ScheduledActionDrawAndSwap 476 // happen inside a ScheduledActionDrawAndSwap
478 TEST(SchedulerTest, RequestCommitInsideDraw) { 477 TEST(SchedulerTest, RequestCommitInsideDraw) {
479 SchedulerClientThatsetNeedsCommitInsideDraw client; 478 SchedulerClientThatsetNeedsCommitInsideDraw client;
480 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
481 SchedulerSettings default_scheduler_settings; 479 SchedulerSettings default_scheduler_settings;
482 Scheduler* scheduler = client.CreateScheduler( 480 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
483 make_scoped_ptr(new FrameRateController(time_source)),
484 default_scheduler_settings);
485 scheduler->SetCanStart(); 481 scheduler->SetCanStart();
486 scheduler->SetVisible(true); 482 scheduler->SetVisible(true);
487 scheduler->SetCanDraw(true); 483 scheduler->SetCanDraw(true);
488 scheduler->DidCreateAndInitializeOutputSurface(); 484 scheduler->DidCreateAndInitializeOutputSurface();
489 485
490 scheduler->SetNeedsRedraw(); 486 scheduler->SetNeedsRedraw();
491 EXPECT_TRUE(scheduler->RedrawPending()); 487 EXPECT_TRUE(scheduler->RedrawPending());
492 EXPECT_EQ(0, client.num_draws()); 488 EXPECT_EQ(0, client.num_draws());
493 EXPECT_TRUE(time_source->Active()); 489 EXPECT_TRUE(client.needs_begin_frame());
494 490
495 time_source->Tick(); 491 scheduler->BeginFrame(base::TimeTicks::Now());
496 EXPECT_FALSE(time_source->Active());
497 EXPECT_EQ(1, client.num_draws()); 492 EXPECT_EQ(1, client.num_draws());
498 EXPECT_TRUE(scheduler->CommitPending()); 493 EXPECT_TRUE(scheduler->CommitPending());
494 EXPECT_TRUE(client.needs_begin_frame());
499 scheduler->FinishCommit(); 495 scheduler->FinishCommit();
500 496
501 time_source->Tick(); 497 scheduler->BeginFrame(base::TimeTicks::Now());
502 EXPECT_EQ(2, client.num_draws()); 498 EXPECT_EQ(2, client.num_draws());;
503 EXPECT_FALSE(time_source->Active());
504 EXPECT_FALSE(scheduler->RedrawPending()); 499 EXPECT_FALSE(scheduler->RedrawPending());
500 EXPECT_FALSE(scheduler->CommitPending());
501 EXPECT_FALSE(client.needs_begin_frame());
505 } 502 }
506 503
507 // Tests that when a draw fails then the pending commit should not be dropped. 504 // Tests that when a draw fails then the pending commit should not be dropped.
508 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { 505 TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
509 SchedulerClientThatsetNeedsDrawInsideDraw client; 506 SchedulerClientThatsetNeedsDrawInsideDraw client;
510 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
511 SchedulerSettings default_scheduler_settings; 507 SchedulerSettings default_scheduler_settings;
512 Scheduler* scheduler = client.CreateScheduler( 508 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
513 make_scoped_ptr(new FrameRateController(time_source)),
514 default_scheduler_settings);
515 scheduler->SetCanStart(); 509 scheduler->SetCanStart();
516 scheduler->SetVisible(true); 510 scheduler->SetVisible(true);
517 scheduler->SetCanDraw(true); 511 scheduler->SetCanDraw(true);
518 scheduler->DidCreateAndInitializeOutputSurface(); 512 scheduler->DidCreateAndInitializeOutputSurface();
519 513
520 client.SetDrawWillHappen(false); 514 client.SetDrawWillHappen(false);
521 515
522 scheduler->SetNeedsRedraw(); 516 scheduler->SetNeedsRedraw();
523 EXPECT_TRUE(scheduler->RedrawPending()); 517 EXPECT_TRUE(scheduler->RedrawPending());
524 EXPECT_TRUE(time_source->Active()); 518 EXPECT_TRUE(client.needs_begin_frame());
525 EXPECT_EQ(0, client.num_draws()); 519 EXPECT_EQ(0, client.num_draws());
526 520
527 // Fail the draw. 521 // Fail the draw.
528 time_source->Tick(); 522 scheduler->BeginFrame(base::TimeTicks::Now());
529 EXPECT_EQ(1, client.num_draws()); 523 EXPECT_EQ(1, client.num_draws());
530 524
531 // We have a commit pending and the draw failed, and we didn't lose the commit 525 // We have a commit pending and the draw failed, and we didn't lose the commit
532 // request. 526 // request.
533 EXPECT_TRUE(scheduler->CommitPending()); 527 EXPECT_TRUE(scheduler->CommitPending());
534 EXPECT_TRUE(scheduler->RedrawPending()); 528 EXPECT_TRUE(scheduler->RedrawPending());
535 EXPECT_TRUE(time_source->Active()); 529 EXPECT_TRUE(client.needs_begin_frame());
536 530
537 // Fail the draw again. 531 // Fail the draw again.
538 time_source->Tick(); 532 scheduler->BeginFrame(base::TimeTicks::Now());
539 EXPECT_EQ(2, client.num_draws()); 533 EXPECT_EQ(2, client.num_draws());
540 EXPECT_TRUE(scheduler->CommitPending()); 534 EXPECT_TRUE(scheduler->CommitPending());
541 EXPECT_TRUE(scheduler->RedrawPending()); 535 EXPECT_TRUE(scheduler->RedrawPending());
542 EXPECT_TRUE(time_source->Active()); 536 EXPECT_TRUE(client.needs_begin_frame());
543 537
544 // Draw successfully. 538 // Draw successfully.
545 client.SetDrawWillHappen(true); 539 client.SetDrawWillHappen(true);
546 time_source->Tick(); 540 scheduler->BeginFrame(base::TimeTicks::Now());
547 EXPECT_EQ(3, client.num_draws()); 541 EXPECT_EQ(3, client.num_draws());
548 EXPECT_TRUE(scheduler->CommitPending()); 542 EXPECT_TRUE(scheduler->CommitPending());
549 EXPECT_FALSE(scheduler->RedrawPending()); 543 EXPECT_FALSE(scheduler->RedrawPending());
550 EXPECT_FALSE(time_source->Active()); 544 EXPECT_TRUE(client.needs_begin_frame());
551 } 545 }
552 546
553 TEST(SchedulerTest, NoSwapWhenDrawFails) { 547 TEST(SchedulerTest, NoSwapWhenDrawFails) {
554 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
555 SchedulerClientThatsetNeedsCommitInsideDraw client; 548 SchedulerClientThatsetNeedsCommitInsideDraw client;
556 scoped_ptr<FakeFrameRateController> controller(
557 new FakeFrameRateController(time_source));
558 FakeFrameRateController* controller_ptr = controller.get();
559 SchedulerSettings default_scheduler_settings; 549 SchedulerSettings default_scheduler_settings;
560 Scheduler* scheduler = client.CreateScheduler( 550 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
561 controller.PassAs<FrameRateController>(),
562 default_scheduler_settings);
563 scheduler->SetCanStart(); 551 scheduler->SetCanStart();
564 scheduler->SetVisible(true); 552 scheduler->SetVisible(true);
565 scheduler->SetCanDraw(true); 553 scheduler->SetCanDraw(true);
566 scheduler->DidCreateAndInitializeOutputSurface(); 554 scheduler->DidCreateAndInitializeOutputSurface();
567 555
568 EXPECT_EQ(0, controller_ptr->NumFramesPending()); 556 scheduler->SetNeedsRedraw();
557 EXPECT_TRUE(scheduler->RedrawPending());
558 EXPECT_TRUE(client.needs_begin_frame());
559 EXPECT_EQ(0, client.num_draws());
560
561 // Draw successfully, this starts a new frame.
562 scheduler->BeginFrame(base::TimeTicks::Now());
563 EXPECT_EQ(1, client.num_draws());
569 564
570 scheduler->SetNeedsRedraw(); 565 scheduler->SetNeedsRedraw();
571 EXPECT_TRUE(scheduler->RedrawPending()); 566 EXPECT_TRUE(scheduler->RedrawPending());
572 EXPECT_TRUE(time_source->Active()); 567 EXPECT_TRUE(client.needs_begin_frame());
573 EXPECT_EQ(0, client.num_draws());
574
575 // Draw successfully, this starts a new frame.
576 time_source->Tick();
577 EXPECT_EQ(1, client.num_draws());
578 EXPECT_EQ(1, controller_ptr->NumFramesPending());
579 scheduler->DidSwapBuffersComplete();
580 EXPECT_EQ(0, controller_ptr->NumFramesPending());
581
582 scheduler->SetNeedsRedraw();
583 EXPECT_TRUE(scheduler->RedrawPending());
584 EXPECT_TRUE(time_source->Active());
585 568
586 // Fail to draw, this should not start a frame. 569 // Fail to draw, this should not start a frame.
587 client.SetDrawWillHappen(false); 570 client.SetDrawWillHappen(false);
588 time_source->Tick(); 571 scheduler->BeginFrame(base::TimeTicks::Now());
589 EXPECT_EQ(2, client.num_draws()); 572 EXPECT_EQ(2, client.num_draws());
590 EXPECT_EQ(0, controller_ptr->NumFramesPending());
591 } 573 }
592 574
593 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) { 575 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
594 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
595 FakeSchedulerClient client; 576 FakeSchedulerClient client;
596 scoped_ptr<FakeFrameRateController> controller(
597 new FakeFrameRateController(time_source));
598 FakeFrameRateController* controller_ptr = controller.get();
599 SchedulerSettings default_scheduler_settings; 577 SchedulerSettings default_scheduler_settings;
600 Scheduler* scheduler = client.CreateScheduler( 578 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
601 controller.PassAs<FrameRateController>(),
602 default_scheduler_settings);
603
604 EXPECT_EQ(0, controller_ptr->NumFramesPending());
605 579
606 // Tell the client that it will fail to swap. 580 // Tell the client that it will fail to swap.
607 client.SetDrawWillHappen(true); 581 client.SetDrawWillHappen(true);
608 client.SetSwapWillHappenIfDrawHappens(false); 582 client.SetSwapWillHappenIfDrawHappens(false);
609 583
610 // Get the compositor to do a ScheduledActionDrawAndSwapForced. 584 // Get the compositor to do a ScheduledActionDrawAndSwapForced.
585 scheduler->SetCanDraw(true);
611 scheduler->SetNeedsRedraw(); 586 scheduler->SetNeedsRedraw();
612 scheduler->SetNeedsForcedRedraw(); 587 scheduler->SetNeedsForcedRedraw();
613 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapForced")); 588 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndSwapForced"));
614
615 // We should not have told the frame rate controller that we began a frame.
616 EXPECT_EQ(0, controller_ptr->NumFramesPending());
617 }
618
619 TEST(SchedulerTest, RecreateOutputSurfaceClearsPendingDrawCount) {
620 scoped_refptr<FakeTimeSource> time_source(new FakeTimeSource());
621 FakeSchedulerClient client;
622 scoped_ptr<FakeFrameRateController> controller(
623 new FakeFrameRateController(time_source));
624 FakeFrameRateController* controller_ptr = controller.get();
625 SchedulerSettings default_scheduler_settings;
626 Scheduler* scheduler = client.CreateScheduler(
627 controller.PassAs<FrameRateController>(),
628 default_scheduler_settings);
629
630 scheduler->SetCanStart();
631 scheduler->SetVisible(true);
632 scheduler->SetCanDraw(true);
633 scheduler->DidCreateAndInitializeOutputSurface();
634
635 // Draw successfully, this starts a new frame.
636 scheduler->SetNeedsRedraw();
637 time_source->Tick();
638 EXPECT_EQ(1, controller_ptr->NumFramesPending());
639
640 scheduler->DidLoseOutputSurface();
641 // Verifying that it's 1 so that we know that it's reset on recreate.
642 EXPECT_EQ(1, controller_ptr->NumFramesPending());
643
644 scheduler->DidCreateAndInitializeOutputSurface();
645 EXPECT_EQ(0, controller_ptr->NumFramesPending());
646 } 589 }
647 590
648 } // namespace 591 } // namespace
649 } // namespace cc 592 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/scheduler/vsync_time_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698