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

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

Issue 23796002: cc: Implement deadine scheduling disabled by default (Closed) Base URL: http://git.chromium.org/chromium/src.git@schedReadback4
Patch Set: Fix context lost race conditions Created 7 years, 3 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
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
5 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
6 5
7 #include <string> 6 #include <string>
8 #include <vector> 7 #include <vector>
9 8
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
12 #include "cc/test/scheduler_test_common.h" 11 #include "cc/test/scheduler_test_common.h"
13 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 13 matching lines...) Expand all
28 27
29 namespace cc { 28 namespace cc {
30 namespace { 29 namespace {
31 30
32 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler) { 31 void InitializeOutputSurfaceAndFirstCommit(Scheduler* scheduler) {
33 scheduler->DidCreateAndInitializeOutputSurface(); 32 scheduler->DidCreateAndInitializeOutputSurface();
34 scheduler->SetNeedsCommit(); 33 scheduler->SetNeedsCommit();
35 scheduler->FinishCommit(); 34 scheduler->FinishCommit();
36 // Go through the motions to draw the commit. 35 // Go through the motions to draw the commit.
37 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 36 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
38 // We need another BeginFrame so scheduler calls SetNeedsBeginFrame(false). 37 scheduler->OnBeginFrameDeadline();
38 // We need another BeginFrame so Scheduler calls SetNeedsBeginFrame(false).
39 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 39 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
40 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 40 scheduler->OnBeginFrameDeadline();
41 } 41 }
42 42
43 class FakeSchedulerClient : public SchedulerClient { 43 class FakeSchedulerClient : public SchedulerClient {
44 public: 44 public:
45 FakeSchedulerClient() 45 FakeSchedulerClient()
46 : needs_begin_frame_(false) { 46 : needs_begin_frame_(false) {
47 Reset(); 47 Reset();
48 } 48 }
49 49
50 void Reset() { 50 void Reset() {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE { 141 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE {
142 return base::TimeDelta(); 142 return base::TimeDelta();
143 } 143 }
144 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() OVERRIDE { 144 virtual base::TimeDelta BeginFrameToCommitDurationEstimate() OVERRIDE {
145 return base::TimeDelta(); 145 return base::TimeDelta();
146 } 146 }
147 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE { 147 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE {
148 return base::TimeDelta(); 148 return base::TimeDelta();
149 } 149 }
150 150
151 virtual void PostBeginFrameDeadline(const base::Closure& closure,
152 base::TimeTicks deadline) OVERRIDE {
153 actions_.push_back("PostBeginFrameDeadlineTask");
154 states_.push_back(scheduler_->StateAsValue().release());
155 }
156
157 virtual void DidBeginFrameDeadlineOnImplThread() OVERRIDE {}
158
151 protected: 159 protected:
152 bool needs_begin_frame_; 160 bool needs_begin_frame_;
153 bool draw_will_happen_; 161 bool draw_will_happen_;
154 bool swap_will_happen_if_draw_happens_; 162 bool swap_will_happen_if_draw_happens_;
155 int num_draws_; 163 int num_draws_;
156 std::vector<const char*> actions_; 164 std::vector<const char*> actions_;
157 ScopedVector<base::Value> states_; 165 ScopedVector<base::Value> states_;
158 scoped_ptr<Scheduler> scheduler_; 166 scoped_ptr<Scheduler> scheduler_;
159 }; 167 };
160 168
(...skipping 15 matching lines...) Expand all
176 FakeSchedulerClient client; 184 FakeSchedulerClient client;
177 SchedulerSettings default_scheduler_settings; 185 SchedulerSettings default_scheduler_settings;
178 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 186 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
179 scheduler->SetCanStart(); 187 scheduler->SetCanStart();
180 scheduler->SetVisible(true); 188 scheduler->SetVisible(true);
181 scheduler->SetCanDraw(true); 189 scheduler->SetCanDraw(true);
182 190
183 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 191 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
184 InitializeOutputSurfaceAndFirstCommit(scheduler); 192 InitializeOutputSurfaceAndFirstCommit(scheduler);
185 193
186 // SetNeedsCommit should begin the frame. 194 // SetNeedsCommit should begin the frame on the next BeginFrame.
187 client.Reset(); 195 client.Reset();
188 scheduler->SetNeedsCommit(); 196 scheduler->SetNeedsCommit();
189 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
190 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
191 EXPECT_TRUE(client.needs_begin_frame()); 197 EXPECT_TRUE(client.needs_begin_frame());
192 client.Reset(); 198 client.Reset();
193 199
200 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
201 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
202 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
203 EXPECT_TRUE(client.needs_begin_frame());
204 client.Reset();
205
206 // If we don't swap on the deadline, we need to request another BeginFrame.
207 scheduler->OnBeginFrameDeadline();
208 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
209 EXPECT_TRUE(client.needs_begin_frame());
210 client.Reset();
211
194 // FinishCommit should commit 212 // FinishCommit should commit
195 scheduler->FinishCommit(); 213 scheduler->FinishCommit();
196 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 214 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
197 EXPECT_TRUE(client.needs_begin_frame()); 215 EXPECT_TRUE(client.needs_begin_frame());
198 client.Reset(); 216 client.Reset();
199 217
200 // BeginFrame should draw. 218 // BeginFrame should prepare the draw.
201 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 219 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
202 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 220 EXPECT_SINGLE_ACTION("PostBeginFrameDeadlineTask", client);
203 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 221 EXPECT_TRUE(client.needs_begin_frame());
222 client.Reset();
223
224 // BeginFrame deadline should draw.
225 scheduler->OnBeginFrameDeadline();
226 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client);
227 client.Reset();
228
229 // The following BeginFrame deadline should SetNeedsBeginFrame(false) to avoid
230 // excessive toggles.
231 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
232 EXPECT_SINGLE_ACTION("PostBeginFrameDeadlineTask", client);
233 client.Reset();
234
235 scheduler->OnBeginFrameDeadline();
236 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
204 EXPECT_FALSE(client.needs_begin_frame()); 237 EXPECT_FALSE(client.needs_begin_frame());
205 client.Reset(); 238 client.Reset();
206 } 239 }
207 240
208 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) { 241 TEST(SchedulerTest, RequestCommitAfterBeginFrameSentToMainThread) {
209 FakeSchedulerClient client; 242 FakeSchedulerClient client;
210 SchedulerSettings default_scheduler_settings; 243 SchedulerSettings default_scheduler_settings;
211 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 244 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
212 scheduler->SetCanStart(); 245 scheduler->SetCanStart();
213 scheduler->SetVisible(true); 246 scheduler->SetVisible(true);
214 scheduler->SetCanDraw(true); 247 scheduler->SetCanDraw(true);
215 248
216 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 249 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
217 InitializeOutputSurfaceAndFirstCommit(scheduler); 250 InitializeOutputSurfaceAndFirstCommit(scheduler);
218 client.Reset(); 251 client.Reset();
219 252
220 // SetNedsCommit should begin the frame. 253 // SetNeddsCommit should begin the frame.
221 scheduler->SetNeedsCommit(); 254 scheduler->SetNeedsCommit();
255 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
256 client.Reset();
257 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
222 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); 258 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
223 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 259 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
260 EXPECT_TRUE(client.needs_begin_frame());
224 client.Reset(); 261 client.Reset();
225 262
226 // Now SetNeedsCommit again. Calling here means we need a second frame. 263 // Now SetNeedsCommit again. Calling here means we need a second commit.
227 scheduler->SetNeedsCommit(); 264 scheduler->SetNeedsCommit();
228 265 EXPECT_EQ(client.num_actions_(), 0);
229 // Finish the commit for the first frame.
230 scheduler->FinishCommit();
231 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client);
232 client.Reset(); 266 client.Reset();
233 267
234 // Tick should draw but then begin another frame for the second commit. 268 // Finish the first commit.
235 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 269 scheduler->FinishCommit();
236 EXPECT_TRUE(client.needs_begin_frame()); 270 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
237 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 271 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
238 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2); 272 client.Reset();
273 scheduler->OnBeginFrameDeadline();
274 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client);
239 client.Reset(); 275 client.Reset();
240 276
241 // Finish the second commit to go back to quiescent state and verify we no 277 // Since another commit is needed, the next BeginFrame should initiate
242 // longer request BeginFrames. 278 // the second commit.
279 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
280 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
281 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
282 client.Reset();
283
284 // Finishing the commit before the deadline should post a new deadline task
285 // to trigger the deadline early.
243 scheduler->FinishCommit(); 286 scheduler->FinishCommit();
287 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
288 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
289 client.Reset();
290 scheduler->OnBeginFrameDeadline();
291 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client);
292 EXPECT_TRUE(client.needs_begin_frame());
293
294 // On the next BeginFrame, go back to quiescent state and verify we no longer
295 // request BeginFrames.
244 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 296 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
297 scheduler->OnBeginFrameDeadline();
245 EXPECT_FALSE(client.needs_begin_frame()); 298 EXPECT_FALSE(client.needs_begin_frame());
299 client.Reset();
246 } 300 }
247 301
248 TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) { 302 TEST(SchedulerTest, TextureAcquisitionCausesCommitInsteadOfDraw) {
249 FakeSchedulerClient client; 303 FakeSchedulerClient client;
250 SchedulerSettings default_scheduler_settings; 304 SchedulerSettings default_scheduler_settings;
251 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 305 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
252 scheduler->SetCanStart(); 306 scheduler->SetCanStart();
253 scheduler->SetVisible(true); 307 scheduler->SetVisible(true);
254 scheduler->SetCanDraw(true); 308 scheduler->SetCanDraw(true);
255 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 309 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
256 310
257 InitializeOutputSurfaceAndFirstCommit(scheduler); 311 InitializeOutputSurfaceAndFirstCommit(scheduler);
258 client.Reset(); 312 client.Reset();
259 scheduler->SetNeedsRedraw(); 313 scheduler->SetNeedsRedraw();
260 EXPECT_TRUE(scheduler->RedrawPending()); 314 EXPECT_TRUE(scheduler->RedrawPending());
261 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client); 315 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
262 EXPECT_TRUE(client.needs_begin_frame()); 316 EXPECT_TRUE(client.needs_begin_frame());
263 317
264 client.Reset(); 318 client.Reset();
265 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 319 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
266 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 320 EXPECT_SINGLE_ACTION("PostBeginFrameDeadlineTask", client);
267 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 321
322 client.Reset();
323 scheduler->OnBeginFrameDeadline();
324 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client);
268 EXPECT_FALSE(scheduler->RedrawPending()); 325 EXPECT_FALSE(scheduler->RedrawPending());
269 EXPECT_FALSE(client.needs_begin_frame());
270 326
271 client.Reset(); 327 client.Reset();
272 scheduler->SetMainThreadNeedsLayerTextures(); 328 scheduler->SetMainThreadNeedsLayerTextures();
273 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 329 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
274 client); 330 client);
275 331
276 // We should request a BeginFrame in anticipation of a draw. 332 // We should request a BeginFrame in anticipation of a draw.
277 client.Reset(); 333 client.Reset();
278 scheduler->SetNeedsRedraw(); 334 scheduler->SetNeedsRedraw();
279 EXPECT_TRUE(scheduler->RedrawPending()); 335 EXPECT_TRUE(scheduler->RedrawPending());
280 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client); 336 EXPECT_EQ(0, client.num_actions_());
281 EXPECT_TRUE(client.needs_begin_frame());
282 337
283 // No draw happens since the textures are acquired by the main thread. 338 // No draw happens since the textures are acquired by the main thread.
284 client.Reset(); 339 client.Reset();
285 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 340 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
341 EXPECT_SINGLE_ACTION("PostBeginFrameDeadlineTask", client);
342
343 client.Reset();
344 scheduler->OnBeginFrameDeadline();
286 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client); 345 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
287 EXPECT_TRUE(scheduler->RedrawPending()); 346 EXPECT_TRUE(scheduler->RedrawPending());
288 EXPECT_TRUE(client.needs_begin_frame()); 347 EXPECT_TRUE(client.needs_begin_frame());
289 348
349 client.Reset();
290 scheduler->SetNeedsCommit(); 350 scheduler->SetNeedsCommit();
291 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 0, 2); 351 EXPECT_EQ(0, client.num_actions_());
292 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 1, 2); 352
293 EXPECT_TRUE(client.needs_begin_frame()); 353 client.Reset();
354 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
355 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
356 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
294 357
295 // Commit will release the texture. 358 // Commit will release the texture.
296 client.Reset(); 359 client.Reset();
297 scheduler->FinishCommit(); 360 scheduler->FinishCommit();
298 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client); 361 EXPECT_ACTION("ScheduledActionCommit", client, 0, 2);
362 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
299 EXPECT_TRUE(scheduler->RedrawPending()); 363 EXPECT_TRUE(scheduler->RedrawPending());
300 EXPECT_TRUE(client.needs_begin_frame());
301 364
302 // Now we can draw again after the commit happens. 365 // Now we can draw again after the commit happens.
303 client.Reset(); 366 client.Reset();
367 scheduler->OnBeginFrameDeadline();
368 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client);
369 EXPECT_FALSE(scheduler->RedrawPending());
370
371 // SetNeedsBeginFrame(false) should be deferred to the end of the next
372 // BeginFrame to avoid excessive toggling.
373 EXPECT_TRUE(client.needs_begin_frame());
304 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 374 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
305 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2); 375 scheduler->OnBeginFrameDeadline();
306 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2);
307 EXPECT_FALSE(scheduler->RedrawPending());
308 EXPECT_FALSE(client.needs_begin_frame()); 376 EXPECT_FALSE(client.needs_begin_frame());
309 client.Reset();
310 } 377 }
311 378
312 TEST(SchedulerTest, TextureAcquisitionCollision) { 379 TEST(SchedulerTest, TextureAcquisitionCollision) {
313 FakeSchedulerClient client; 380 FakeSchedulerClient client;
314 SchedulerSettings default_scheduler_settings; 381 SchedulerSettings default_scheduler_settings;
315 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 382 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
316 scheduler->SetCanStart(); 383 scheduler->SetCanStart();
317 scheduler->SetVisible(true); 384 scheduler->SetVisible(true);
318 scheduler->SetCanDraw(true); 385 scheduler->SetCanDraw(true);
319 386
320 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 387 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
321 InitializeOutputSurfaceAndFirstCommit(scheduler); 388 InitializeOutputSurfaceAndFirstCommit(scheduler);
322 389
323 client.Reset(); 390 client.Reset();
324 scheduler->SetNeedsCommit(); 391 scheduler->SetNeedsCommit();
325 scheduler->SetMainThreadNeedsLayerTextures(); 392 scheduler->SetMainThreadNeedsLayerTextures();
326 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 3); 393 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 0, 2);
327 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 3);
328 EXPECT_ACTION( 394 EXPECT_ACTION(
329 "ScheduledActionAcquireLayerTexturesForMainThread", client, 2, 3); 395 "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 2);
396
330 client.Reset(); 397 client.Reset();
398 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
399 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
400 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
401
402 client.Reset();
403 scheduler->OnBeginFrameDeadline();
404 EXPECT_SINGLE_ACTION("SetNeedsBeginFrameOnImplThread", client);
331 405
332 // Although the compositor cannot draw because textures are locked by main 406 // Although the compositor cannot draw because textures are locked by main
333 // thread, we continue requesting SetNeedsBeginFrame in anticipation of the 407 // thread, we continue requesting SetNeedsBeginFrame in anticipation of the
334 // unlock. 408 // unlock.
335 EXPECT_TRUE(client.needs_begin_frame()); 409 EXPECT_TRUE(client.needs_begin_frame());
336 410
337 // Trigger the commit 411 // Trigger the commit
338 scheduler->FinishCommit(); 412 scheduler->FinishCommit();
339 EXPECT_TRUE(client.needs_begin_frame()); 413 EXPECT_TRUE(client.needs_begin_frame());
340 client.Reset();
341 414
342 // Between commit and draw, texture acquisition for main thread delayed, 415 // Between commit and draw, texture acquisition for main thread delayed,
343 // and main thread blocks. 416 // and main thread blocks.
417 client.Reset();
344 scheduler->SetMainThreadNeedsLayerTextures(); 418 scheduler->SetMainThreadNeedsLayerTextures();
345 EXPECT_EQ(0, client.num_actions_()); 419 EXPECT_EQ(0, client.num_actions_());
346 client.Reset();
347 420
348 // No implicit commit is expected. 421 // No implicit commit is expected.
422 client.Reset();
349 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 423 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
350 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 3); 424 EXPECT_SINGLE_ACTION("PostBeginFrameDeadlineTask", client);
351 EXPECT_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 425
352 client,
353 1,
354 3);
355 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 2, 3);
356 client.Reset(); 426 client.Reset();
427 scheduler->OnBeginFrameDeadline();
428 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client, 0, 2);
429 EXPECT_ACTION(
430 "ScheduledActionAcquireLayerTexturesForMainThread", client, 1, 2);
357 431
358 // Compositor not scheduled to draw because textures are locked by main 432 // Although the compositor is not scheduled to draw because textures are
359 // thread. 433 // locked by main thread, we proactively request the begin frame.
360 EXPECT_FALSE(client.needs_begin_frame()); 434 EXPECT_TRUE(client.needs_begin_frame());
361 435
362 // Needs an explicit commit from the main thread. 436 // Needs an explicit commit from the main thread.
437 client.Reset();
363 scheduler->SetNeedsCommit(); 438 scheduler->SetNeedsCommit();
439 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
364 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); 440 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
365 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 441 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
366 client.Reset(); 442 client.Reset();
367 443
368 // Trigger the commit 444 // Trigger the commit
369 scheduler->FinishCommit(); 445 scheduler->FinishCommit();
370 EXPECT_TRUE(client.needs_begin_frame()); 446 EXPECT_TRUE(client.needs_begin_frame());
371 } 447 }
372 448
373 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) { 449 TEST(SchedulerTest, VisibilitySwitchWithTextureAcquisition) {
374 FakeSchedulerClient client; 450 FakeSchedulerClient client;
375 SchedulerSettings default_scheduler_settings; 451 SchedulerSettings default_scheduler_settings;
376 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 452 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
377 scheduler->SetCanStart(); 453 scheduler->SetCanStart();
378 scheduler->SetVisible(true); 454 scheduler->SetVisible(true);
379 scheduler->SetCanDraw(true); 455 scheduler->SetCanDraw(true);
380 456
381 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 457 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
382 client.Reset(); 458 client.Reset();
383 scheduler->DidCreateAndInitializeOutputSurface(); 459 scheduler->DidCreateAndInitializeOutputSurface();
384 460
385 scheduler->SetNeedsCommit(); 461 scheduler->SetNeedsCommit();
462 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
463 scheduler->OnBeginFrameDeadline();
386 scheduler->FinishCommit(); 464 scheduler->FinishCommit();
387 scheduler->SetMainThreadNeedsLayerTextures(); 465 scheduler->SetMainThreadNeedsLayerTextures();
388 scheduler->SetNeedsCommit(); 466 scheduler->SetNeedsCommit();
389 client.Reset(); 467 client.Reset();
390 // Verify that pending texture acquisition fires when visibility 468 // Verify that pending texture acquisition fires when visibility
391 // is lost in order to avoid a deadlock. 469 // is lost in order to avoid a deadlock.
392 scheduler->SetVisible(false); 470 scheduler->SetVisible(false);
393 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread", 471 EXPECT_SINGLE_ACTION("ScheduledActionAcquireLayerTexturesForMainThread",
394 client); 472 client);
395 client.Reset();
396 473
397 // Already sent a begin frame on this current frame, so wait. 474 // Already sent a begin frame on this current frame, so wait.
475 client.Reset();
398 scheduler->SetVisible(true); 476 scheduler->SetVisible(true);
399 EXPECT_EQ(0, client.num_actions_()); 477 EXPECT_EQ(0, client.num_actions_());
400 client.Reset(); 478 EXPECT_TRUE(client.needs_begin_frame());
401 479
402 // Regaining visibility with textures acquired by main thread while 480 // Regaining visibility with textures acquired by main thread while
403 // compositor is waiting for first draw should result in a request 481 // compositor is waiting for first draw should result in a request
404 // for a new frame in order to escape a deadlock. 482 // for a new frame in order to escape a deadlock.
483 client.Reset();
405 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 484 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
406 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2); 485 EXPECT_ACTION("ScheduledActionSendBeginFrameToMainThread", client, 0, 2);
407 EXPECT_ACTION("SetNeedsBeginFrameOnImplThread", client, 1, 2); 486 EXPECT_ACTION("PostBeginFrameDeadlineTask", client, 1, 2);
408 } 487 }
409 488
410 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient { 489 class SchedulerClientThatsetNeedsDrawInsideDraw : public FakeSchedulerClient {
411 public: 490 public:
412 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {} 491 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE {}
413 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() 492 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible()
414 OVERRIDE { 493 OVERRIDE {
415 // Only SetNeedsRedraw the first time this is called 494 // Only SetNeedsRedraw the first time this is called
416 if (!num_draws_) 495 if (!num_draws_)
417 scheduler_->SetNeedsRedraw(); 496 scheduler_->SetNeedsRedraw();
(...skipping 26 matching lines...) Expand all
444 scheduler->SetCanDraw(true); 523 scheduler->SetCanDraw(true);
445 InitializeOutputSurfaceAndFirstCommit(scheduler); 524 InitializeOutputSurfaceAndFirstCommit(scheduler);
446 client.Reset(); 525 client.Reset();
447 526
448 scheduler->SetNeedsRedraw(); 527 scheduler->SetNeedsRedraw();
449 EXPECT_TRUE(scheduler->RedrawPending()); 528 EXPECT_TRUE(scheduler->RedrawPending());
450 EXPECT_TRUE(client.needs_begin_frame()); 529 EXPECT_TRUE(client.needs_begin_frame());
451 EXPECT_EQ(0, client.num_draws()); 530 EXPECT_EQ(0, client.num_draws());
452 531
453 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 532 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
533 scheduler->OnBeginFrameDeadline();
454 EXPECT_EQ(1, client.num_draws()); 534 EXPECT_EQ(1, client.num_draws());
455 EXPECT_TRUE(scheduler->RedrawPending()); 535 EXPECT_TRUE(scheduler->RedrawPending());
456 EXPECT_TRUE(client.needs_begin_frame()); 536 EXPECT_TRUE(client.needs_begin_frame());
457 537
458 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 538 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
539 scheduler->OnBeginFrameDeadline();
459 EXPECT_EQ(2, client.num_draws()); 540 EXPECT_EQ(2, client.num_draws());
460 EXPECT_FALSE(scheduler->RedrawPending()); 541 EXPECT_FALSE(scheduler->RedrawPending());
542 EXPECT_TRUE(client.needs_begin_frame());
543
544 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
545 scheduler->OnBeginFrameDeadline();
461 EXPECT_FALSE(client.needs_begin_frame()); 546 EXPECT_FALSE(client.needs_begin_frame());
462 } 547 }
463 548
464 // Test that requesting redraw inside a failed draw doesn't lose the request. 549 // Test that requesting redraw inside a failed draw doesn't lose the request.
465 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) { 550 TEST(SchedulerTest, RequestRedrawInsideFailedDraw) {
466 SchedulerClientThatsetNeedsDrawInsideDraw client; 551 SchedulerClientThatsetNeedsDrawInsideDraw client;
467 SchedulerSettings default_scheduler_settings; 552 SchedulerSettings default_scheduler_settings;
468 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 553 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
469 scheduler->SetCanStart(); 554 scheduler->SetCanStart();
470 scheduler->SetVisible(true); 555 scheduler->SetVisible(true);
471 scheduler->SetCanDraw(true); 556 scheduler->SetCanDraw(true);
472 InitializeOutputSurfaceAndFirstCommit(scheduler); 557 InitializeOutputSurfaceAndFirstCommit(scheduler);
473 client.Reset(); 558 client.Reset();
474 559
475 client.SetDrawWillHappen(false); 560 client.SetDrawWillHappen(false);
476 561
477 scheduler->SetNeedsRedraw(); 562 scheduler->SetNeedsRedraw();
478 EXPECT_TRUE(scheduler->RedrawPending()); 563 EXPECT_TRUE(scheduler->RedrawPending());
479 EXPECT_TRUE(client.needs_begin_frame()); 564 EXPECT_TRUE(client.needs_begin_frame());
480 EXPECT_EQ(0, client.num_draws()); 565 EXPECT_EQ(0, client.num_draws());
481 566
482 // Fail the draw. 567 // Fail the draw.
483 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 568 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
569 scheduler->OnBeginFrameDeadline();
484 EXPECT_EQ(1, client.num_draws()); 570 EXPECT_EQ(1, client.num_draws());
485 571
486 // We have a commit pending and the draw failed, and we didn't lose the redraw 572 // We have a commit pending and the draw failed, and we didn't lose the redraw
487 // request. 573 // request.
488 EXPECT_TRUE(scheduler->CommitPending()); 574 EXPECT_TRUE(scheduler->CommitPending());
489 EXPECT_TRUE(scheduler->RedrawPending()); 575 EXPECT_TRUE(scheduler->RedrawPending());
490 EXPECT_TRUE(client.needs_begin_frame()); 576 EXPECT_TRUE(client.needs_begin_frame());
491 577
492 // Fail the draw again. 578 // Fail the draw again.
493 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 579 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
580 scheduler->OnBeginFrameDeadline();
494 EXPECT_EQ(2, client.num_draws()); 581 EXPECT_EQ(2, client.num_draws());
495 EXPECT_TRUE(scheduler->CommitPending()); 582 EXPECT_TRUE(scheduler->CommitPending());
496 EXPECT_TRUE(scheduler->RedrawPending()); 583 EXPECT_TRUE(scheduler->RedrawPending());
497 EXPECT_TRUE(client.needs_begin_frame()); 584 EXPECT_TRUE(client.needs_begin_frame());
498 585
499 // Draw successfully. 586 // Draw successfully.
500 client.SetDrawWillHappen(true); 587 client.SetDrawWillHappen(true);
501 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 588 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
589 scheduler->OnBeginFrameDeadline();
502 EXPECT_EQ(3, client.num_draws()); 590 EXPECT_EQ(3, client.num_draws());
503 EXPECT_TRUE(scheduler->CommitPending()); 591 EXPECT_TRUE(scheduler->CommitPending());
504 EXPECT_FALSE(scheduler->RedrawPending()); 592 EXPECT_FALSE(scheduler->RedrawPending());
505 EXPECT_TRUE(client.needs_begin_frame()); 593 EXPECT_TRUE(client.needs_begin_frame());
506 } 594 }
507 595
508 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient { 596 class SchedulerClientThatSetNeedsCommitInsideDraw : public FakeSchedulerClient {
509 public: 597 public:
510 SchedulerClientThatSetNeedsCommitInsideDraw() 598 SchedulerClientThatSetNeedsCommitInsideDraw()
511 : set_needs_commit_on_next_draw_(false) {} 599 : set_needs_commit_on_next_draw_(false) {}
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 TEST(SchedulerTest, RequestCommitInsideDraw) { 632 TEST(SchedulerTest, RequestCommitInsideDraw) {
545 SchedulerClientThatSetNeedsCommitInsideDraw client; 633 SchedulerClientThatSetNeedsCommitInsideDraw client;
546 SchedulerSettings default_scheduler_settings; 634 SchedulerSettings default_scheduler_settings;
547 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 635 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
548 scheduler->SetCanStart(); 636 scheduler->SetCanStart();
549 scheduler->SetVisible(true); 637 scheduler->SetVisible(true);
550 scheduler->SetCanDraw(true); 638 scheduler->SetCanDraw(true);
551 InitializeOutputSurfaceAndFirstCommit(scheduler); 639 InitializeOutputSurfaceAndFirstCommit(scheduler);
552 client.Reset(); 640 client.Reset();
553 641
642 EXPECT_FALSE(client.needs_begin_frame());
554 scheduler->SetNeedsRedraw(); 643 scheduler->SetNeedsRedraw();
555 EXPECT_TRUE(scheduler->RedrawPending()); 644 EXPECT_TRUE(scheduler->RedrawPending());
556 EXPECT_EQ(0, client.num_draws()); 645 EXPECT_EQ(0, client.num_draws());
557 EXPECT_TRUE(client.needs_begin_frame()); 646 EXPECT_TRUE(client.needs_begin_frame());
558 647
559 client.SetNeedsCommitOnNextDraw(); 648 client.SetNeedsCommitOnNextDraw();
560 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 649 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
650 client.SetNeedsCommitOnNextDraw();
651 scheduler->OnBeginFrameDeadline();
561 EXPECT_EQ(1, client.num_draws()); 652 EXPECT_EQ(1, client.num_draws());
562 EXPECT_TRUE(scheduler->CommitPending()); 653 EXPECT_TRUE(scheduler->CommitPending());
563 EXPECT_TRUE(client.needs_begin_frame()); 654 EXPECT_TRUE(client.needs_begin_frame());
564 scheduler->FinishCommit(); 655 scheduler->FinishCommit();
565 656
566 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 657 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
567 EXPECT_EQ(2, client.num_draws());; 658 scheduler->OnBeginFrameDeadline();
659 EXPECT_EQ(2, client.num_draws());
660
568 EXPECT_FALSE(scheduler->RedrawPending()); 661 EXPECT_FALSE(scheduler->RedrawPending());
569 EXPECT_FALSE(scheduler->CommitPending()); 662 EXPECT_FALSE(scheduler->CommitPending());
663 EXPECT_TRUE(client.needs_begin_frame());
664
665 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
666 scheduler->OnBeginFrameDeadline();
570 EXPECT_FALSE(client.needs_begin_frame()); 667 EXPECT_FALSE(client.needs_begin_frame());
571 } 668 }
572 669
573 // Tests that when a draw fails then the pending commit should not be dropped. 670 // Tests that when a draw fails then the pending commit should not be dropped.
574 TEST(SchedulerTest, RequestCommitInsideFailedDraw) { 671 TEST(SchedulerTest, RequestCommitInsideFailedDraw) {
575 SchedulerClientThatsetNeedsDrawInsideDraw client; 672 SchedulerClientThatsetNeedsDrawInsideDraw client;
576 SchedulerSettings default_scheduler_settings; 673 SchedulerSettings default_scheduler_settings;
577 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 674 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
578 scheduler->SetCanStart(); 675 scheduler->SetCanStart();
579 scheduler->SetVisible(true); 676 scheduler->SetVisible(true);
580 scheduler->SetCanDraw(true); 677 scheduler->SetCanDraw(true);
581 InitializeOutputSurfaceAndFirstCommit(scheduler); 678 InitializeOutputSurfaceAndFirstCommit(scheduler);
582 client.Reset(); 679 client.Reset();
583 680
584 client.SetDrawWillHappen(false); 681 client.SetDrawWillHappen(false);
585 682
586 scheduler->SetNeedsRedraw(); 683 scheduler->SetNeedsRedraw();
587 EXPECT_TRUE(scheduler->RedrawPending()); 684 EXPECT_TRUE(scheduler->RedrawPending());
588 EXPECT_TRUE(client.needs_begin_frame()); 685 EXPECT_TRUE(client.needs_begin_frame());
589 EXPECT_EQ(0, client.num_draws()); 686 EXPECT_EQ(0, client.num_draws());
590 687
591 // Fail the draw. 688 // Fail the draw.
592 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 689 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
690 scheduler->OnBeginFrameDeadline();
593 EXPECT_EQ(1, client.num_draws()); 691 EXPECT_EQ(1, client.num_draws());
594 692
595 // We have a commit pending and the draw failed, and we didn't lose the commit 693 // We have a commit pending and the draw failed, and we didn't lose the commit
596 // request. 694 // request.
597 EXPECT_TRUE(scheduler->CommitPending()); 695 EXPECT_TRUE(scheduler->CommitPending());
598 EXPECT_TRUE(scheduler->RedrawPending()); 696 EXPECT_TRUE(scheduler->RedrawPending());
599 EXPECT_TRUE(client.needs_begin_frame()); 697 EXPECT_TRUE(client.needs_begin_frame());
600 698
601 // Fail the draw again. 699 // Fail the draw again.
602 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 700 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
701 scheduler->OnBeginFrameDeadline();
603 EXPECT_EQ(2, client.num_draws()); 702 EXPECT_EQ(2, client.num_draws());
604 EXPECT_TRUE(scheduler->CommitPending()); 703 EXPECT_TRUE(scheduler->CommitPending());
605 EXPECT_TRUE(scheduler->RedrawPending()); 704 EXPECT_TRUE(scheduler->RedrawPending());
606 EXPECT_TRUE(client.needs_begin_frame()); 705 EXPECT_TRUE(client.needs_begin_frame());
607 706
608 // Draw successfully. 707 // Draw successfully.
609 client.SetDrawWillHappen(true); 708 client.SetDrawWillHappen(true);
610 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 709 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
710 scheduler->OnBeginFrameDeadline();
611 EXPECT_EQ(3, client.num_draws()); 711 EXPECT_EQ(3, client.num_draws());
612 EXPECT_TRUE(scheduler->CommitPending()); 712 EXPECT_TRUE(scheduler->CommitPending());
613 EXPECT_FALSE(scheduler->RedrawPending()); 713 EXPECT_FALSE(scheduler->RedrawPending());
614 EXPECT_TRUE(client.needs_begin_frame()); 714 EXPECT_TRUE(client.needs_begin_frame());
615 } 715 }
616 716
617 TEST(SchedulerTest, NoSwapWhenDrawFails) { 717 TEST(SchedulerTest, NoSwapWhenDrawFails) {
618 SchedulerClientThatSetNeedsCommitInsideDraw client; 718 SchedulerClientThatSetNeedsCommitInsideDraw client;
619 SchedulerSettings default_scheduler_settings; 719 SchedulerSettings default_scheduler_settings;
620 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 720 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
621 scheduler->SetCanStart(); 721 scheduler->SetCanStart();
622 scheduler->SetVisible(true); 722 scheduler->SetVisible(true);
623 scheduler->SetCanDraw(true); 723 scheduler->SetCanDraw(true);
624 InitializeOutputSurfaceAndFirstCommit(scheduler); 724 InitializeOutputSurfaceAndFirstCommit(scheduler);
625 client.Reset(); 725 client.Reset();
626 726
627 scheduler->SetNeedsRedraw(); 727 scheduler->SetNeedsRedraw();
628 EXPECT_TRUE(scheduler->RedrawPending()); 728 EXPECT_TRUE(scheduler->RedrawPending());
629 EXPECT_TRUE(client.needs_begin_frame()); 729 EXPECT_TRUE(client.needs_begin_frame());
630 EXPECT_EQ(0, client.num_draws()); 730 EXPECT_EQ(0, client.num_draws());
631 731
632 // Draw successfully, this starts a new frame. 732 // Draw successfully, this starts a new frame.
633 client.SetNeedsCommitOnNextDraw(); 733 client.SetNeedsCommitOnNextDraw();
634 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 734 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
735 scheduler->OnBeginFrameDeadline();
635 EXPECT_EQ(1, client.num_draws()); 736 EXPECT_EQ(1, client.num_draws());
636 737
637 scheduler->SetNeedsRedraw(); 738 scheduler->SetNeedsRedraw();
638 EXPECT_TRUE(scheduler->RedrawPending()); 739 EXPECT_TRUE(scheduler->RedrawPending());
639 EXPECT_TRUE(client.needs_begin_frame()); 740 EXPECT_TRUE(client.needs_begin_frame());
640 741
641 // Fail to draw, this should not start a frame. 742 // Fail to draw, this should not start a frame.
642 client.SetDrawWillHappen(false); 743 client.SetDrawWillHappen(false);
643 client.SetNeedsCommitOnNextDraw(); 744 client.SetNeedsCommitOnNextDraw();
644 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting()); 745 scheduler->BeginFrame(BeginFrameArgs::CreateForTesting());
746 scheduler->OnBeginFrameDeadline();
645 EXPECT_EQ(2, client.num_draws()); 747 EXPECT_EQ(2, client.num_draws());
646 } 748 }
647 749
648 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) { 750 TEST(SchedulerTest, NoSwapWhenSwapFailsDuringForcedCommit) {
649 FakeSchedulerClient client; 751 FakeSchedulerClient client;
650 SchedulerSettings default_scheduler_settings; 752 SchedulerSettings default_scheduler_settings;
651 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 753 Scheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
652 754
653 // Tell the client that it will fail to swap. 755 // Tell the client that it will fail to swap.
654 client.SetDrawWillHappen(true); 756 client.SetDrawWillHappen(true);
(...skipping 27 matching lines...) Expand all
682 scheduler->FinishCommit(); 784 scheduler->FinishCommit();
683 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback")); 785 EXPECT_TRUE(client.HasAction("ScheduledActionDrawAndReadback"));
684 786
685 // The replacement commit comes in after 2 readbacks. 787 // The replacement commit comes in after 2 readbacks.
686 client.Reset(); 788 client.Reset();
687 scheduler->FinishCommit(); 789 scheduler->FinishCommit();
688 } 790 }
689 791
690 } // namespace 792 } // namespace
691 } // namespace cc 793 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698