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

Side by Side Diff: cc/test/layer_tree_test_common.cc

Issue 11478039: cc: Force layer tree tests to go idle before exiting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/test/layer_tree_test_common.h ('k') | cc/thread_proxy.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/test/layer_tree_test_common.h" 5 #include "cc/test/layer_tree_test_common.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "cc/active_animation.h" 8 #include "cc/active_animation.h"
9 #include "cc/content_layer.h" 9 #include "cc/content_layer.h"
10 #include "cc/font_atlas.h" 10 #include "cc/font_atlas.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 private: 265 private:
266 explicit ThreadedMockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks (testHooks) { } 266 explicit ThreadedMockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks (testHooks) { }
267 267
268 TestHooks* m_testHooks; 268 TestHooks* m_testHooks;
269 }; 269 };
270 270
271 ThreadedTest::ThreadedTest() 271 ThreadedTest::ThreadedTest()
272 : m_beginning(false) 272 : m_beginning(false)
273 , m_endWhenBeginReturns(false) 273 , m_endWhenBeginReturns(false)
274 , m_timedOut(false) 274 , m_timedOut(false)
275 , m_finished(false)
276 , m_scheduled(false) 275 , m_scheduled(false)
277 , m_started(false) 276 , m_started(false)
278 , m_implThread(0) 277 , m_implThread(0)
279 { 278 {
280 } 279 }
281 280
282 ThreadedTest::~ThreadedTest() 281 ThreadedTest::~ThreadedTest()
283 { 282 {
284 } 283 }
285 284
286 void ThreadedTest::endTest() 285 void ThreadedTest::endTest()
287 { 286 {
288 m_finished = true;
289
290 // For the case where we endTest during beginTest(), set a flag to indicate that 287 // For the case where we endTest during beginTest(), set a flag to indicate that
291 // the test should end the second beginTest regains control. 288 // the test should end the second beginTest regains control.
292 if (m_beginning) 289 if (m_beginning)
293 m_endWhenBeginReturns = true; 290 m_endWhenBeginReturns = true;
294 else 291 else
295 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::realEnd Test, base::Unretained(this))); 292 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::realEnd Test, base::Unretained(this)));
296 } 293 }
297 294
298 void ThreadedTest::endTestAfterDelay(int delayMilliseconds) 295 void ThreadedTest::endTestAfterDelay(int delayMilliseconds)
299 { 296 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 364 }
368 365
369 void ThreadedTest::timeout() 366 void ThreadedTest::timeout()
370 { 367 {
371 m_timedOut = true; 368 m_timedOut = true;
372 endTest(); 369 endTest();
373 } 370 }
374 371
375 void ThreadedTest::scheduleComposite() 372 void ThreadedTest::scheduleComposite()
376 { 373 {
377 if (!m_started || m_scheduled || m_finished) 374 if (!m_started || m_scheduled)
378 return; 375 return;
379 m_scheduled = true; 376 m_scheduled = true;
380 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchCom posite, base::Unretained(this))); 377 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::dispatchCom posite, base::Unretained(this)));
381 } 378 }
382 379
383 void ThreadedTest::realEndTest() 380 void ThreadedTest::realEndTest()
384 { 381 {
382 if (m_layerTreeHost && m_layerTreeHost->proxy()->commitPendingForTesting()) {
383 m_mainThreadProxy->postTask(FROM_HERE, base::Bind(&ThreadedTest::realEnd Test, base::Unretained(this)));
384 return;
385 }
386
385 MessageLoop::current()->Quit(); 387 MessageLoop::current()->Quit();
386 } 388 }
387 389
388 void ThreadedTest::dispatchSetNeedsAnimate() 390 void ThreadedTest::dispatchSetNeedsAnimate()
389 { 391 {
390 DCHECK(!proxy() || proxy()->isMainThread()); 392 DCHECK(!proxy() || proxy()->isMainThread());
391 393
392 if (m_finished)
393 return;
394
395 if (m_layerTreeHost.get()) 394 if (m_layerTreeHost.get())
396 m_layerTreeHost->setNeedsAnimate(); 395 m_layerTreeHost->setNeedsAnimate();
397 } 396 }
398 397
399 void ThreadedTest::dispatchAddInstantAnimation() 398 void ThreadedTest::dispatchAddInstantAnimation()
400 { 399 {
401 DCHECK(!proxy() || proxy()->isMainThread()); 400 DCHECK(!proxy() || proxy()->isMainThread());
402 401
403 if (m_finished)
404 return;
405
406 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer()) 402 if (m_layerTreeHost.get() && m_layerTreeHost->rootLayer())
407 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, fa lse); 403 addOpacityTransitionToLayer(*m_layerTreeHost->rootLayer(), 0, 0, 0.5, fa lse);
408 } 404 }
409 405
410 void ThreadedTest::dispatchAddAnimation(Layer* layerToReceiveAnimation) 406 void ThreadedTest::dispatchAddAnimation(Layer* layerToReceiveAnimation)
411 { 407 {
412 DCHECK(!proxy() || proxy()->isMainThread()); 408 DCHECK(!proxy() || proxy()->isMainThread());
413 409
414 if (m_finished)
415 return;
416
417 if (layerToReceiveAnimation) 410 if (layerToReceiveAnimation)
418 addOpacityTransitionToLayer(*layerToReceiveAnimation, 10, 0, 0.5, true); 411 addOpacityTransitionToLayer(*layerToReceiveAnimation, 10, 0, 0.5, true);
419 } 412 }
420 413
421 void ThreadedTest::dispatchSetNeedsCommit() 414 void ThreadedTest::dispatchSetNeedsCommit()
422 { 415 {
423 DCHECK(!proxy() || proxy()->isMainThread()); 416 DCHECK(!proxy() || proxy()->isMainThread());
424 417
425 if (m_finished)
426 return;
427
428 if (m_layerTreeHost.get()) 418 if (m_layerTreeHost.get())
429 m_layerTreeHost->setNeedsCommit(); 419 m_layerTreeHost->setNeedsCommit();
430 } 420 }
431 421
432 void ThreadedTest::dispatchAcquireLayerTextures() 422 void ThreadedTest::dispatchAcquireLayerTextures()
433 { 423 {
434 DCHECK(!proxy() || proxy()->isMainThread()); 424 DCHECK(!proxy() || proxy()->isMainThread());
435 425
436 if (m_finished)
437 return;
438
439 if (m_layerTreeHost.get()) 426 if (m_layerTreeHost.get())
440 m_layerTreeHost->acquireLayerTextures(); 427 m_layerTreeHost->acquireLayerTextures();
441 } 428 }
442 429
443 void ThreadedTest::dispatchSetNeedsRedraw() 430 void ThreadedTest::dispatchSetNeedsRedraw()
444 { 431 {
445 DCHECK(!proxy() || proxy()->isMainThread()); 432 DCHECK(!proxy() || proxy()->isMainThread());
446 433
447 if (m_finished)
448 return;
449
450 if (m_layerTreeHost.get()) 434 if (m_layerTreeHost.get())
451 m_layerTreeHost->setNeedsRedraw(); 435 m_layerTreeHost->setNeedsRedraw();
452 } 436 }
453 437
454 void ThreadedTest::dispatchSetVisible(bool visible) 438 void ThreadedTest::dispatchSetVisible(bool visible)
455 { 439 {
456 DCHECK(!proxy() || proxy()->isMainThread()); 440 DCHECK(!proxy() || proxy()->isMainThread());
457 441
458 if (m_finished)
459 return;
460
461 if (m_layerTreeHost.get()) 442 if (m_layerTreeHost.get())
462 m_layerTreeHost->setVisible(visible); 443 m_layerTreeHost->setVisible(visible);
463 } 444 }
464 445
465 void ThreadedTest::dispatchComposite() 446 void ThreadedTest::dispatchComposite()
466 { 447 {
467 m_scheduled = false; 448 m_scheduled = false;
468 if (m_layerTreeHost.get() && !m_finished) 449 if (m_layerTreeHost.get())
469 m_layerTreeHost->composite(); 450 m_layerTreeHost->composite();
470 } 451 }
471 452
472 void ThreadedTest::dispatchDidAddAnimation() 453 void ThreadedTest::dispatchDidAddAnimation()
473 { 454 {
474 DCHECK(!proxy() || proxy()->isMainThread()); 455 DCHECK(!proxy() || proxy()->isMainThread());
475 456
476 if (m_finished)
477 return;
478
479 if (m_layerTreeHost.get()) 457 if (m_layerTreeHost.get())
480 m_layerTreeHost->didAddAnimation(); 458 m_layerTreeHost->didAddAnimation();
481 } 459 }
482 460
483 void ThreadedTest::runTest(bool threaded) 461 void ThreadedTest::runTest(bool threaded)
484 { 462 {
485 if (threaded) { 463 if (threaded) {
486 m_implThread.reset(new base::Thread("ThreadedTest")); 464 m_implThread.reset(new base::Thread("ThreadedTest"));
487 ASSERT_TRUE(m_implThread->Start()); 465 ASSERT_TRUE(m_implThread->Start());
488 } 466 }
(...skipping 16 matching lines...) Expand all
505 ASSERT_FALSE(m_layerTreeHost.get()); 483 ASSERT_FALSE(m_layerTreeHost.get());
506 m_client.reset(); 484 m_client.reset();
507 if (m_timedOut) { 485 if (m_timedOut) {
508 FAIL() << "Test timed out"; 486 FAIL() << "Test timed out";
509 return; 487 return;
510 } 488 }
511 afterTest(); 489 afterTest();
512 } 490 }
513 491
514 } // namespace cc 492 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test_common.h ('k') | cc/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698