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

Side by Side Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 14925009: Run all LayerTreeHost tests with a delegating renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/base/thread_impl.h" 8 #include "cc/base/thread_impl.h"
9 #include "cc/layers/content_layer.h" 9 #include "cc/layers/content_layer.h"
10 #include "cc/layers/heads_up_display_layer.h" 10 #include "cc/layers/heads_up_display_layer.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 472 }
473 473
474 protected: 474 protected:
475 bool use_surface_; 475 bool use_surface_;
476 FakeContentLayerClient client_; 476 FakeContentLayerClient client_;
477 scoped_refptr<Layer> root_; 477 scoped_refptr<Layer> root_;
478 scoped_refptr<ContentLayer> content_; 478 scoped_refptr<ContentLayer> content_;
479 }; 479 };
480 480
481 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, 481 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
482 NoSurface_SingleThread) { 482 NoSurface_SingleThread_DirectRenderer) {
483 use_surface_ = false; 483 use_surface_ = false;
484 RunTest(false); 484 RunTest(false, false);
485 } 485 }
486 486
487 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, 487 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
488 NoSurface_MultiThread) { 488 NoSurface_SingleThread_DelegatingRenderer) {
489 use_surface_ = false; 489 use_surface_ = false;
490 RunTest(true); 490 RunTest(false, true);
491 } 491 }
492 492
493 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, 493 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
494 WithSurface_SingleThread) { 494 NoSurface_MultiThread_DirectRenderer) {
495 use_surface_ = true; 495 use_surface_ = false;
496 RunTest(false); 496 RunTest(true, false);
497 } 497 }
498 498
499 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent, 499 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
500 WithSurface_MultiThread) { 500 NoSurface_MultiThread_DelegatingRenderer) {
501 use_surface_ = false;
502 RunTest(true, true);
503 }
504
505 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
506 WithSurface_SingleThread_DirectRenderer) {
501 use_surface_ = true; 507 use_surface_ = true;
502 RunTest(true); 508 RunTest(false, false);
509 }
510
511 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
512 WithSurface_SingleThread_DelegatingRenderer) {
513 use_surface_ = true;
514 RunTest(false, true);
515 }
516
517 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
518 WithSurface_MultiThread_DirectRenderer) {
519 use_surface_ = true;
520 RunTest(true, false);
521 }
522
523 TEST_F(LayerTreeHostContextTestLostContextSucceedsWithContent,
524 WithSurface_MultiThread_DelegatingRenderer) {
525 use_surface_ = true;
526 RunTest(true, true);
503 } 527 }
504 528
505 class LayerTreeHostContextTestOffscreenContextFails 529 class LayerTreeHostContextTestOffscreenContextFails
506 : public LayerTreeHostContextTest { 530 : public LayerTreeHostContextTest {
507 public: 531 public:
508 virtual void SetupTree() OVERRIDE { 532 virtual void SetupTree() OVERRIDE {
509 root_ = Layer::Create(); 533 root_ = Layer::Create();
510 root_->SetBounds(gfx::Size(10, 10)); 534 root_->SetBounds(gfx::Size(10, 10));
511 root_->SetAnchorPoint(gfx::PointF()); 535 root_->SetAnchorPoint(gfx::PointF());
512 root_->SetIsDrawable(true); 536 root_->SetIsDrawable(true);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 619 }
596 620
597 virtual void AfterTest() OVERRIDE {} 621 virtual void AfterTest() OVERRIDE {}
598 622
599 private: 623 private:
600 int num_commits_; 624 int num_commits_;
601 bool first_initialized_; 625 bool first_initialized_;
602 }; 626 };
603 627
604 TEST_F(LayerTreeHostContextTestLostContextFails, 628 TEST_F(LayerTreeHostContextTestLostContextFails,
605 FailReinitialize100_SingleThread) { 629 FailReinitialize100_SingleThread_DirectRenderer) {
606 times_to_fail_reinitialize_ = 100; 630 times_to_fail_reinitialize_ = 100;
607 times_to_fail_recreate_ = 0; 631 times_to_fail_recreate_ = 0;
608 times_to_lose_on_recreate_ = 0; 632 times_to_lose_on_recreate_ = 0;
609 RunTest(false); 633 RunTest(false, false);
610 } 634 }
611 635
612 TEST_F(LayerTreeHostContextTestLostContextFails, 636 TEST_F(LayerTreeHostContextTestLostContextFails,
613 FailReinitialize100_MultiThread) { 637 FailReinitialize100_SingleThread_DelegatingRenderer) {
614 times_to_fail_reinitialize_ = 100; 638 times_to_fail_reinitialize_ = 100;
615 times_to_fail_recreate_ = 0; 639 times_to_fail_recreate_ = 0;
616 times_to_lose_on_recreate_ = 0; 640 times_to_lose_on_recreate_ = 0;
617 RunTest(true); 641 RunTest(false, true);
618 } 642 }
619 643
620 TEST_F(LayerTreeHostContextTestLostContextFails, 644 TEST_F(LayerTreeHostContextTestLostContextFails,
621 FailRecreate100_SingleThread) { 645 FailReinitialize100_MultiThread_DirectRenderer) {
646 times_to_fail_reinitialize_ = 100;
647 times_to_fail_recreate_ = 0;
648 times_to_lose_on_recreate_ = 0;
649 RunTest(true, false);
650 }
651
652 TEST_F(LayerTreeHostContextTestLostContextFails,
653 FailReinitialize100_MultiThread_DelegatingRenderer) {
654 times_to_fail_reinitialize_ = 100;
655 times_to_fail_recreate_ = 0;
656 times_to_lose_on_recreate_ = 0;
657 RunTest(true, true);
658 }
659
660 TEST_F(LayerTreeHostContextTestLostContextFails,
661 FailRecreate100_SingleThread_DirectRenderer) {
622 times_to_fail_reinitialize_ = 0; 662 times_to_fail_reinitialize_ = 0;
623 times_to_fail_recreate_ = 100; 663 times_to_fail_recreate_ = 100;
624 times_to_lose_on_recreate_ = 0; 664 times_to_lose_on_recreate_ = 0;
625 RunTest(false); 665 RunTest(false, false);
626 } 666 }
627 667
628 TEST_F(LayerTreeHostContextTestLostContextFails, 668 TEST_F(LayerTreeHostContextTestLostContextFails,
629 FailRecreate100_MultiThread) { 669 FailRecreate100_SingleThread_DelegatingRenderer) {
630 times_to_fail_reinitialize_ = 0; 670 times_to_fail_reinitialize_ = 0;
631 times_to_fail_recreate_ = 100; 671 times_to_fail_recreate_ = 100;
632 times_to_lose_on_recreate_ = 0; 672 times_to_lose_on_recreate_ = 0;
633 RunTest(true); 673 RunTest(false, true);
634 } 674 }
635 675
636 TEST_F(LayerTreeHostContextTestLostContextFails, 676 TEST_F(LayerTreeHostContextTestLostContextFails,
637 LoseOnRecreate100_SingleThread) { 677 FailRecreate100_MultiThread_DirectRenderer) {
678 times_to_fail_reinitialize_ = 0;
679 times_to_fail_recreate_ = 100;
680 times_to_lose_on_recreate_ = 0;
681 RunTest(true, false);
682 }
683
684 TEST_F(LayerTreeHostContextTestLostContextFails,
685 FailRecreate100_MultiThread_DelegatingRenderer) {
686 times_to_fail_reinitialize_ = 0;
687 times_to_fail_recreate_ = 100;
688 times_to_lose_on_recreate_ = 0;
689 RunTest(true, true);
690 }
691
692 TEST_F(LayerTreeHostContextTestLostContextFails,
693 LoseOnRecreate100_SingleThread_DirectRenderer) {
638 times_to_fail_reinitialize_ = 0; 694 times_to_fail_reinitialize_ = 0;
639 times_to_fail_recreate_ = 0; 695 times_to_fail_recreate_ = 0;
640 times_to_lose_on_recreate_ = 100; 696 times_to_lose_on_recreate_ = 100;
641 RunTest(false); 697 RunTest(false, false);
642 } 698 }
643 699
644 TEST_F(LayerTreeHostContextTestLostContextFails, 700 TEST_F(LayerTreeHostContextTestLostContextFails,
645 LoseOnRecreate100_MultiThread) { 701 LoseOnRecreate100_SingleThread_DelegatingRenderer) {
646 times_to_fail_reinitialize_ = 0; 702 times_to_fail_reinitialize_ = 0;
647 times_to_fail_recreate_ = 0; 703 times_to_fail_recreate_ = 0;
648 times_to_lose_on_recreate_ = 100; 704 times_to_lose_on_recreate_ = 100;
649 RunTest(true); 705 RunTest(false, true);
706 }
707
708 TEST_F(LayerTreeHostContextTestLostContextFails,
709 LoseOnRecreate100_MultiThread_DirectRenderer) {
710 times_to_fail_reinitialize_ = 0;
711 times_to_fail_recreate_ = 0;
712 times_to_lose_on_recreate_ = 100;
713 RunTest(true, false);
714 }
715
716 TEST_F(LayerTreeHostContextTestLostContextFails,
717 LoseOnRecreate100_MultiThread_DelegatingRenderer) {
718 times_to_fail_reinitialize_ = 0;
719 times_to_fail_recreate_ = 0;
720 times_to_lose_on_recreate_ = 100;
721 RunTest(true, true);
650 } 722 }
651 723
652 class LayerTreeHostContextTestFinishAllRenderingAfterLoss 724 class LayerTreeHostContextTestFinishAllRenderingAfterLoss
653 : public LayerTreeHostContextTest { 725 : public LayerTreeHostContextTest {
654 public: 726 public:
655 virtual void BeginTest() OVERRIDE { 727 virtual void BeginTest() OVERRIDE {
656 // Lose the context until the compositor gives up on it. 728 // Lose the context until the compositor gives up on it.
657 first_initialized_ = false; 729 first_initialized_ = false;
658 times_to_lose_during_commit_ = 1; 730 times_to_lose_during_commit_ = 1;
659 times_to_fail_reinitialize_ = 10; 731 times_to_fail_reinitialize_ = 10;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 815
744 protected: 816 protected:
745 bool lose_after_evict_; 817 bool lose_after_evict_;
746 FakeContentLayerClient client_; 818 FakeContentLayerClient client_;
747 scoped_refptr<FakeContentLayer> layer_; 819 scoped_refptr<FakeContentLayer> layer_;
748 LayerTreeHostImpl* impl_host_; 820 LayerTreeHostImpl* impl_host_;
749 int num_commits_; 821 int num_commits_;
750 }; 822 };
751 823
752 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, 824 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
753 LoseAfterEvict_SingleThread) { 825 LoseAfterEvict_SingleThread_DirectRenderer) {
754 lose_after_evict_ = true; 826 lose_after_evict_ = true;
755 RunTest(false); 827 RunTest(false, false);
756 } 828 }
757 829
758 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, 830 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
759 LoseAfterEvict_MultiThread) { 831 LoseAfterEvict_SingleThread_DelegatingRenderer) {
760 lose_after_evict_ = true; 832 lose_after_evict_ = true;
761 RunTest(true); 833 RunTest(false, true);
762 } 834 }
763 835
764 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, 836 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
765 LoseBeforeEvict_SingleThread) { 837 LoseAfterEvict_MultiThread_DirectRenderer) {
766 lose_after_evict_ = false; 838 lose_after_evict_ = true;
767 RunTest(false); 839 RunTest(true, false);
768 } 840 }
769 841
770 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures, 842 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
771 LoseBeforeEvict_MultiThread) { 843 LoseAfterEvict_MultiThread_DelegatingRenderer) {
844 lose_after_evict_ = true;
845 RunTest(true, true);
846 }
847
848 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
849 LoseBeforeEvict_SingleThread_DirectRenderer) {
772 lose_after_evict_ = false; 850 lose_after_evict_ = false;
773 RunTest(true); 851 RunTest(false, false);
852 }
853
854 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
855 LoseBeforeEvict_SingleThread_DelegatingRenderer) {
856 lose_after_evict_ = false;
857 RunTest(false, true);
858 }
859
860 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
861 LoseBeforeEvict_MultiThread_DirectRenderer) {
862 lose_after_evict_ = false;
863 RunTest(true, false);
864 }
865
866 TEST_F(LayerTreeHostContextTestLostContextAndEvictTextures,
867 LoseBeforeEvict_MultiThread_DelegatingRenderer) {
868 lose_after_evict_ = false;
869 RunTest(true, true);
774 } 870 }
775 871
776 class LayerTreeHostContextTestLostContextWhileUpdatingResources 872 class LayerTreeHostContextTestLostContextWhileUpdatingResources
777 : public LayerTreeHostContextTest { 873 : public LayerTreeHostContextTest {
778 public: 874 public:
779 LayerTreeHostContextTestLostContextWhileUpdatingResources() 875 LayerTreeHostContextTestLostContextWhileUpdatingResources()
780 : parent_(FakeContentLayer::Create(&client_)), 876 : parent_(FakeContentLayer::Create(&client_)),
781 num_children_(50), 877 num_children_(50),
782 times_to_lose_on_end_query_(3) {} 878 times_to_lose_on_end_query_(3) {}
783 879
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestFailsToCreateSurface); 1462 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestFailsToCreateSurface);
1367 1463
1368 // Not reusing LayerTreeTest because it expects creating LTH to always succeed. 1464 // Not reusing LayerTreeTest because it expects creating LTH to always succeed.
1369 class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface 1465 class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface
1370 : public testing::Test, 1466 : public testing::Test,
1371 public FakeLayerTreeHostClient { 1467 public FakeLayerTreeHostClient {
1372 public: 1468 public:
1373 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface() 1469 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface()
1374 : FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {} 1470 : FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {}
1375 1471
1376 // FakeLayerTreeHostClient 1472 // FakeLayerTreeHostClient implementation.
1377 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE { 1473 virtual scoped_ptr<OutputSurface> CreateOutputSurface() OVERRIDE {
1378 return scoped_ptr<OutputSurface>(); 1474 return scoped_ptr<OutputSurface>();
1379 } 1475 }
1380 1476
1381 void RunTest(bool threaded) { 1477 void RunTest(bool threaded, bool delegating_renderer) {
1382 scoped_ptr<base::Thread> impl_thread; 1478 scoped_ptr<base::Thread> impl_thread;
1383 scoped_ptr<cc::Thread> impl_ccthread(NULL); 1479 scoped_ptr<cc::Thread> impl_ccthread(NULL);
1384 if (threaded) { 1480 if (threaded) {
1385 impl_thread.reset(new base::Thread("LayerTreeTest")); 1481 impl_thread.reset(new base::Thread("LayerTreeTest"));
1386 impl_ccthread = cc::ThreadImpl::CreateForDifferentThread( 1482 impl_ccthread = cc::ThreadImpl::CreateForDifferentThread(
1387 impl_thread->message_loop_proxy()); 1483 impl_thread->message_loop_proxy());
1388 ASSERT_TRUE(impl_ccthread); 1484 ASSERT_TRUE(impl_ccthread);
1389 } 1485 }
1390 1486
1391 LayerTreeSettings settings; 1487 LayerTreeSettings settings;
1392 scoped_ptr<LayerTreeHost> layer_tree_host = 1488 scoped_ptr<LayerTreeHost> layer_tree_host =
1393 LayerTreeHost::Create(this, settings, impl_ccthread.Pass()); 1489 LayerTreeHost::Create(this, settings, impl_ccthread.Pass());
1394 EXPECT_FALSE(layer_tree_host); 1490 EXPECT_FALSE(layer_tree_host);
1395 } 1491 }
1396 }; 1492 };
1397 1493
1398 SINGLE_AND_MULTI_THREAD_TEST_F( 1494 SINGLE_AND_MULTI_THREAD_TEST_F(
1399 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); 1495 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface);
1400 1496
1401 } // namespace 1497 } // namespace
1402 } // namespace cc 1498 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698