OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 3383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3394 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); | 3394 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); |
3395 }; | 3395 }; |
3396 | 3396 |
3397 // Makes sure child views with layers aren't painted when paint starts at an | 3397 // Makes sure child views with layers aren't painted when paint starts at an |
3398 // ancestor. | 3398 // ancestor. |
3399 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { | 3399 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { |
3400 PaintTrackingView* content_view = new PaintTrackingView; | 3400 PaintTrackingView* content_view = new PaintTrackingView; |
3401 widget()->SetContentsView(content_view); | 3401 widget()->SetContentsView(content_view); |
3402 content_view->SetPaintToLayer(true); | 3402 content_view->SetPaintToLayer(true); |
3403 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3403 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3404 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3404 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3405 GetRootLayer()->GetCompositor()); | |
3406 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 3405 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
3407 content_view->set_painted(false); | 3406 content_view->set_painted(false); |
3408 // content_view no longer has a dirty rect. Paint from the root and make sure | 3407 // content_view no longer has a dirty rect. Paint from the root and make sure |
3409 // PaintTrackingView isn't painted. | 3408 // PaintTrackingView isn't painted. |
3410 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3409 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3411 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3410 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3412 GetRootLayer()->GetCompositor()); | |
3413 EXPECT_FALSE(content_view->painted()); | 3411 EXPECT_FALSE(content_view->painted()); |
3414 | 3412 |
3415 // Make content_view have a dirty rect, paint the layers and make sure | 3413 // Make content_view have a dirty rect, paint the layers and make sure |
3416 // PaintTrackingView is painted. | 3414 // PaintTrackingView is painted. |
3417 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 3415 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
3418 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3416 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3419 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3417 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3420 GetRootLayer()->GetCompositor()); | |
3421 EXPECT_TRUE(content_view->painted()); | 3418 EXPECT_TRUE(content_view->painted()); |
3422 } | 3419 } |
3423 | 3420 |
3424 // Tests that the visibility of child layers are updated correctly when a View's | 3421 // Tests that the visibility of child layers are updated correctly when a View's |
3425 // visibility changes. | 3422 // visibility changes. |
3426 TEST_F(ViewLayerTest, VisibilityChildLayers) { | 3423 TEST_F(ViewLayerTest, VisibilityChildLayers) { |
3427 View* v1 = new View; | 3424 View* v1 = new View; |
3428 v1->SetPaintToLayer(true); | 3425 v1->SetPaintToLayer(true); |
3429 widget()->SetContentsView(v1); | 3426 widget()->SetContentsView(v1); |
3430 | 3427 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 v1->SetBoundsRect(gfx::Rect(10, 15, 150, 151)); | 3647 v1->SetBoundsRect(gfx::Rect(10, 15, 150, 151)); |
3651 test_view->AddChildView(v1); | 3648 test_view->AddChildView(v1); |
3652 | 3649 |
3653 View* v2 = new View(); | 3650 View* v2 = new View(); |
3654 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50)); | 3651 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50)); |
3655 v1->AddChildView(v2); | 3652 v1->AddChildView(v2); |
3656 | 3653 |
3657 // Schedule a full-view paint to get everyone's rectangles updated. | 3654 // Schedule a full-view paint to get everyone's rectangles updated. |
3658 test_view->SchedulePaintInRect(test_view->bounds()); | 3655 test_view->SchedulePaintInRect(test_view->bounds()); |
3659 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3656 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3660 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3657 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3661 GetRootLayer()->GetCompositor()); | |
3662 | 3658 |
3663 // Now we have test_view - v1 - v2. Damage to only test_view should only | 3659 // Now we have test_view - v1 - v2. Damage to only test_view should only |
3664 // return root_view and test_view. | 3660 // return root_view and test_view. |
3665 test_view->SchedulePaintInRect(gfx::Rect(0, 0, 1, 1)); | 3661 test_view->SchedulePaintInRect(gfx::Rect(0, 0, 1, 1)); |
3666 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3662 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3667 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3663 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3668 GetRootLayer()->GetCompositor()); | |
3669 EXPECT_EQ(2U, test_view->last_cull_set_.size()); | 3664 EXPECT_EQ(2U, test_view->last_cull_set_.size()); |
3670 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3665 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3671 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3666 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3672 | 3667 |
3673 // Damage to v1 only should only return root_view, test_view, and v1. | 3668 // Damage to v1 only should only return root_view, test_view, and v1. |
3674 test_view->SchedulePaintInRect(gfx::Rect(11, 16, 1, 1)); | 3669 test_view->SchedulePaintInRect(gfx::Rect(11, 16, 1, 1)); |
3675 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3670 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3676 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3671 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3677 GetRootLayer()->GetCompositor()); | |
3678 EXPECT_EQ(3U, test_view->last_cull_set_.size()); | 3672 EXPECT_EQ(3U, test_view->last_cull_set_.size()); |
3679 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3673 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3680 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3674 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3681 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); | 3675 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); |
3682 | 3676 |
3683 // A Damage rect inside v2 should get all 3 views back in the |last_cull_set_| | 3677 // A Damage rect inside v2 should get all 3 views back in the |last_cull_set_| |
3684 // on call to TestView::Paint(), along with the widget root view. | 3678 // on call to TestView::Paint(), along with the widget root view. |
3685 test_view->SchedulePaintInRect(gfx::Rect(31, 49, 1, 1)); | 3679 test_view->SchedulePaintInRect(gfx::Rect(31, 49, 1, 1)); |
3686 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3680 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3687 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3681 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3688 GetRootLayer()->GetCompositor()); | |
3689 EXPECT_EQ(4U, test_view->last_cull_set_.size()); | 3682 EXPECT_EQ(4U, test_view->last_cull_set_.size()); |
3690 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3683 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3691 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3684 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3692 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); | 3685 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); |
3693 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); | 3686 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); |
3694 } | 3687 } |
3695 | 3688 |
3696 TEST_F(ViewLayerTest, BoundsTreeWithRTL) { | 3689 TEST_F(ViewLayerTest, BoundsTreeWithRTL) { |
3697 std::string locale = l10n_util::GetApplicationLocale(std::string()); | 3690 std::string locale = l10n_util::GetApplicationLocale(std::string()); |
3698 base::i18n::SetICUDefaultLocale("ar"); | 3691 base::i18n::SetICUDefaultLocale("ar"); |
3699 | 3692 |
3700 BoundsTreeTestView* test_view = new BoundsTreeTestView; | 3693 BoundsTreeTestView* test_view = new BoundsTreeTestView; |
3701 widget()->SetContentsView(test_view); | 3694 widget()->SetContentsView(test_view); |
3702 | 3695 |
3703 // Add child views, which should be in RTL coordinate space of parent view. | 3696 // Add child views, which should be in RTL coordinate space of parent view. |
3704 View* v1 = new View; | 3697 View* v1 = new View; |
3705 v1->SetBoundsRect(gfx::Rect(10, 12, 25, 26)); | 3698 v1->SetBoundsRect(gfx::Rect(10, 12, 25, 26)); |
3706 test_view->AddChildView(v1); | 3699 test_view->AddChildView(v1); |
3707 | 3700 |
3708 View* v2 = new View; | 3701 View* v2 = new View; |
3709 v2->SetBoundsRect(gfx::Rect(5, 6, 7, 8)); | 3702 v2->SetBoundsRect(gfx::Rect(5, 6, 7, 8)); |
3710 v1->AddChildView(v2); | 3703 v1->AddChildView(v2); |
3711 | 3704 |
3712 // Schedule a full-view paint to get everyone's rectangles updated. | 3705 // Schedule a full-view paint to get everyone's rectangles updated. |
3713 test_view->SchedulePaintInRect(test_view->bounds()); | 3706 test_view->SchedulePaintInRect(test_view->bounds()); |
3714 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3707 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3715 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3708 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3716 GetRootLayer()->GetCompositor()); | |
3717 | 3709 |
3718 // Damage to the right side of the parent view should touch both child views. | 3710 // Damage to the right side of the parent view should touch both child views. |
3719 gfx::Rect rtl_damage(test_view->bounds().width() - 16, 18, 1, 1); | 3711 gfx::Rect rtl_damage(test_view->bounds().width() - 16, 18, 1, 1); |
3720 test_view->SchedulePaintInRect(rtl_damage); | 3712 test_view->SchedulePaintInRect(rtl_damage); |
3721 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3713 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3722 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3714 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3723 GetRootLayer()->GetCompositor()); | |
3724 EXPECT_EQ(4U, test_view->last_cull_set_.size()); | 3715 EXPECT_EQ(4U, test_view->last_cull_set_.size()); |
3725 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3716 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3726 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3717 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3727 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); | 3718 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); |
3728 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); | 3719 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); |
3729 | 3720 |
3730 // Damage to the left side of the parent view should only touch the | 3721 // Damage to the left side of the parent view should only touch the |
3731 // container views. | 3722 // container views. |
3732 gfx::Rect ltr_damage(16, 18, 1, 1); | 3723 gfx::Rect ltr_damage(16, 18, 1, 1); |
3733 test_view->SchedulePaintInRect(ltr_damage); | 3724 test_view->SchedulePaintInRect(ltr_damage); |
3734 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3725 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3735 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3726 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3736 GetRootLayer()->GetCompositor()); | |
3737 EXPECT_EQ(2U, test_view->last_cull_set_.size()); | 3727 EXPECT_EQ(2U, test_view->last_cull_set_.size()); |
3738 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3728 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3739 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3729 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3740 | 3730 |
3741 // Reset locale. | 3731 // Reset locale. |
3742 base::i18n::SetICUDefaultLocale(locale); | 3732 base::i18n::SetICUDefaultLocale(locale); |
3743 } | 3733 } |
3744 | 3734 |
3745 TEST_F(ViewLayerTest, BoundsTreeSetBoundsChangesCullSet) { | 3735 TEST_F(ViewLayerTest, BoundsTreeSetBoundsChangesCullSet) { |
3746 BoundsTreeTestView* test_view = new BoundsTreeTestView; | 3736 BoundsTreeTestView* test_view = new BoundsTreeTestView; |
3747 widget()->SetContentsView(test_view); | 3737 widget()->SetContentsView(test_view); |
3748 | 3738 |
3749 View* v1 = new View; | 3739 View* v1 = new View; |
3750 v1->SetBoundsRect(gfx::Rect(5, 6, 100, 101)); | 3740 v1->SetBoundsRect(gfx::Rect(5, 6, 100, 101)); |
3751 test_view->AddChildView(v1); | 3741 test_view->AddChildView(v1); |
3752 | 3742 |
3753 View* v2 = new View; | 3743 View* v2 = new View; |
3754 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50)); | 3744 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50)); |
3755 v1->AddChildView(v2); | 3745 v1->AddChildView(v2); |
3756 | 3746 |
3757 // Schedule a full-view paint to get everyone's rectangles updated. | 3747 // Schedule a full-view paint to get everyone's rectangles updated. |
3758 test_view->SchedulePaintInRect(test_view->bounds()); | 3748 test_view->SchedulePaintInRect(test_view->bounds()); |
3759 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3749 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3760 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3750 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3761 GetRootLayer()->GetCompositor()); | |
3762 | 3751 |
3763 // Move v1 to a new origin out of the way of our next query. | 3752 // Move v1 to a new origin out of the way of our next query. |
3764 v1->SetBoundsRect(gfx::Rect(50, 60, 100, 101)); | 3753 v1->SetBoundsRect(gfx::Rect(50, 60, 100, 101)); |
3765 // The move will force a repaint. | 3754 // The move will force a repaint. |
3766 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3755 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3767 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3756 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3768 GetRootLayer()->GetCompositor()); | |
3769 | 3757 |
3770 // Schedule a paint with damage rect where v1 used to be. | 3758 // Schedule a paint with damage rect where v1 used to be. |
3771 test_view->SchedulePaintInRect(gfx::Rect(5, 6, 10, 11)); | 3759 test_view->SchedulePaintInRect(gfx::Rect(5, 6, 10, 11)); |
3772 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3760 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3773 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3761 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3774 GetRootLayer()->GetCompositor()); | |
3775 | 3762 |
3776 // Should only have picked up root_view and test_view. | 3763 // Should only have picked up root_view and test_view. |
3777 EXPECT_EQ(2U, test_view->last_cull_set_.size()); | 3764 EXPECT_EQ(2U, test_view->last_cull_set_.size()); |
3778 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3765 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3779 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3766 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3780 } | 3767 } |
3781 | 3768 |
3782 TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) { | 3769 TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) { |
3783 BoundsTreeTestView* test_view = new BoundsTreeTestView; | 3770 BoundsTreeTestView* test_view = new BoundsTreeTestView; |
3784 widget()->SetContentsView(test_view); | 3771 widget()->SetContentsView(test_view); |
3785 | 3772 |
3786 View* v1 = new View; | 3773 View* v1 = new View; |
3787 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20)); | 3774 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20)); |
3788 test_view->AddChildView(v1); | 3775 test_view->AddChildView(v1); |
3789 | 3776 |
3790 View* v2 = new View; | 3777 View* v2 = new View; |
3791 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); | 3778 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); |
3792 v1->AddChildView(v2); | 3779 v1->AddChildView(v2); |
3793 | 3780 |
3794 // Schedule a full-view paint to get everyone's rectangles updated. | 3781 // Schedule a full-view paint to get everyone's rectangles updated. |
3795 test_view->SchedulePaintInRect(test_view->bounds()); | 3782 test_view->SchedulePaintInRect(test_view->bounds()); |
3796 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3783 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3797 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3784 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3798 GetRootLayer()->GetCompositor()); | |
3799 | 3785 |
3800 // Set v1 to paint to its own layer, it should remove itself from the | 3786 // Set v1 to paint to its own layer, it should remove itself from the |
3801 // test_view heiarchy and no longer intersect with damage rects in that cull | 3787 // test_view heiarchy and no longer intersect with damage rects in that cull |
3802 // set. | 3788 // set. |
3803 v1->SetPaintToLayer(true); | 3789 v1->SetPaintToLayer(true); |
3804 | 3790 |
3805 // Schedule another full-view paint. | 3791 // Schedule another full-view paint. |
3806 test_view->SchedulePaintInRect(test_view->bounds()); | 3792 test_view->SchedulePaintInRect(test_view->bounds()); |
3807 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3793 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3808 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3794 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3809 GetRootLayer()->GetCompositor()); | |
3810 // v1 and v2 should no longer be present in the test_view cull_set. | 3795 // v1 and v2 should no longer be present in the test_view cull_set. |
3811 EXPECT_EQ(2U, test_view->last_cull_set_.size()); | 3796 EXPECT_EQ(2U, test_view->last_cull_set_.size()); |
3812 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1)); | 3797 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1)); |
3813 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2)); | 3798 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2)); |
3814 | 3799 |
3815 // Now set v1 back to not painting to a layer. | 3800 // Now set v1 back to not painting to a layer. |
3816 v1->SetPaintToLayer(false); | 3801 v1->SetPaintToLayer(false); |
3817 // Schedule another full-view paint. | 3802 // Schedule another full-view paint. |
3818 test_view->SchedulePaintInRect(test_view->bounds()); | 3803 test_view->SchedulePaintInRect(test_view->bounds()); |
3819 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3804 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3820 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3805 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3821 GetRootLayer()->GetCompositor()); | |
3822 // We should be back to the full cull set including v1 and v2. | 3806 // We should be back to the full cull set including v1 and v2. |
3823 EXPECT_EQ(4U, test_view->last_cull_set_.size()); | 3807 EXPECT_EQ(4U, test_view->last_cull_set_.size()); |
3824 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3808 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3825 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3809 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3826 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); | 3810 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); |
3827 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); | 3811 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); |
3828 } | 3812 } |
3829 | 3813 |
3830 TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) { | 3814 TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) { |
3831 BoundsTreeTestView* test_view = new BoundsTreeTestView; | 3815 BoundsTreeTestView* test_view = new BoundsTreeTestView; |
3832 widget()->SetContentsView(test_view); | 3816 widget()->SetContentsView(test_view); |
3833 | 3817 |
3834 View* v1 = new View; | 3818 View* v1 = new View; |
3835 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20)); | 3819 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20)); |
3836 test_view->AddChildView(v1); | 3820 test_view->AddChildView(v1); |
3837 | 3821 |
3838 View* v2 = new View; | 3822 View* v2 = new View; |
3839 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); | 3823 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); |
3840 v1->AddChildView(v2); | 3824 v1->AddChildView(v2); |
3841 | 3825 |
3842 // Schedule a full-view paint to get everyone's rectangles updated. | 3826 // Schedule a full-view paint to get everyone's rectangles updated. |
3843 test_view->SchedulePaintInRect(test_view->bounds()); | 3827 test_view->SchedulePaintInRect(test_view->bounds()); |
3844 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3828 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3845 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3829 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3846 GetRootLayer()->GetCompositor()); | |
3847 | 3830 |
3848 // Now remove v1 from the root view. | 3831 // Now remove v1 from the root view. |
3849 test_view->RemoveChildView(v1); | 3832 test_view->RemoveChildView(v1); |
3850 | 3833 |
3851 // Schedule another full-view paint. | 3834 // Schedule another full-view paint. |
3852 test_view->SchedulePaintInRect(test_view->bounds()); | 3835 test_view->SchedulePaintInRect(test_view->bounds()); |
3853 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3836 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3854 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3837 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3855 GetRootLayer()->GetCompositor()); | |
3856 // v1 and v2 should no longer be present in the test_view cull_set. | 3838 // v1 and v2 should no longer be present in the test_view cull_set. |
3857 EXPECT_EQ(2U, test_view->last_cull_set_.size()); | 3839 EXPECT_EQ(2U, test_view->last_cull_set_.size()); |
3858 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1)); | 3840 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1)); |
3859 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2)); | 3841 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2)); |
3860 | 3842 |
3861 // View v1 and v2 are no longer part of view hierarchy and therefore won't be | 3843 // View v1 and v2 are no longer part of view hierarchy and therefore won't be |
3862 // deleted with that hierarchy. | 3844 // deleted with that hierarchy. |
3863 delete v1; | 3845 delete v1; |
3864 } | 3846 } |
3865 | 3847 |
(...skipping 10 matching lines...) Expand all Loading... |
3876 v2->SetBoundsRect(gfx::Rect(5, 10, 40, 50)); | 3858 v2->SetBoundsRect(gfx::Rect(5, 10, 40, 50)); |
3877 v1->AddChildView(v2); | 3859 v1->AddChildView(v2); |
3878 | 3860 |
3879 View* v3 = new View; | 3861 View* v3 = new View; |
3880 v3->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); | 3862 v3->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); |
3881 v2->AddChildView(v3); | 3863 v2->AddChildView(v3); |
3882 | 3864 |
3883 // Schedule a full-view paint and ensure all views are present in the cull. | 3865 // Schedule a full-view paint and ensure all views are present in the cull. |
3884 test_view->SchedulePaintInRect(test_view->bounds()); | 3866 test_view->SchedulePaintInRect(test_view->bounds()); |
3885 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3867 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3886 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3868 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3887 GetRootLayer()->GetCompositor()); | |
3888 EXPECT_EQ(5U, test_view->last_cull_set_.size()); | 3869 EXPECT_EQ(5U, test_view->last_cull_set_.size()); |
3889 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3870 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3890 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3871 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3891 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); | 3872 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); |
3892 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); | 3873 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); |
3893 EXPECT_EQ(1U, test_view->last_cull_set_.count(v3)); | 3874 EXPECT_EQ(1U, test_view->last_cull_set_.count(v3)); |
3894 | 3875 |
3895 // Build an unrelated view hierarchy and move v2 in to it. | 3876 // Build an unrelated view hierarchy and move v2 in to it. |
3896 scoped_ptr<Widget> test_widget(new Widget); | 3877 scoped_ptr<Widget> test_widget(new Widget); |
3897 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 3878 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
3898 params.bounds = gfx::Rect(10, 10, 500, 500); | 3879 params.bounds = gfx::Rect(10, 10, 500, 500); |
3899 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 3880 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
3900 test_widget->Init(params); | 3881 test_widget->Init(params); |
3901 test_widget->Show(); | 3882 test_widget->Show(); |
3902 BoundsTreeTestView* widget_view = new BoundsTreeTestView; | 3883 BoundsTreeTestView* widget_view = new BoundsTreeTestView; |
3903 test_widget->SetContentsView(widget_view); | 3884 test_widget->SetContentsView(widget_view); |
3904 widget_view->AddChildView(v2); | 3885 widget_view->AddChildView(v2); |
3905 | 3886 |
3906 // Now schedule full-view paints in both widgets. | 3887 // Now schedule full-view paints in both widgets. |
3907 test_view->SchedulePaintInRect(test_view->bounds()); | 3888 test_view->SchedulePaintInRect(test_view->bounds()); |
3908 widget_view->SchedulePaintInRect(widget_view->bounds()); | 3889 widget_view->SchedulePaintInRect(widget_view->bounds()); |
3909 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 3890 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3910 ui::DrawWaiterForTest::WaitForCompositingEnded( | 3891 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); |
3911 GetRootLayer()->GetCompositor()); | |
3912 | 3892 |
3913 // Only v1 should be present in the first cull set. | 3893 // Only v1 should be present in the first cull set. |
3914 EXPECT_EQ(3U, test_view->last_cull_set_.size()); | 3894 EXPECT_EQ(3U, test_view->last_cull_set_.size()); |
3915 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); | 3895 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); |
3916 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); | 3896 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); |
3917 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); | 3897 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); |
3918 | 3898 |
3919 // We should find v2 and v3 in the widget_view cull_set. | 3899 // We should find v2 and v3 in the widget_view cull_set. |
3920 EXPECT_EQ(4U, widget_view->last_cull_set_.size()); | 3900 EXPECT_EQ(4U, widget_view->last_cull_set_.size()); |
3921 EXPECT_EQ(1U, widget_view->last_cull_set_.count(test_widget->GetRootView())); | 3901 EXPECT_EQ(1U, widget_view->last_cull_set_.count(test_widget->GetRootView())); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3984 // notification. | 3964 // notification. |
3985 TestView* test_view_child_2 = new TestView(); | 3965 TestView* test_view_child_2 = new TestView(); |
3986 test_view->AddChildView(test_view_child_2); | 3966 test_view->AddChildView(test_view_child_2); |
3987 EXPECT_TRUE(test_view_child_2->native_theme_); | 3967 EXPECT_TRUE(test_view_child_2->native_theme_); |
3988 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); | 3968 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); |
3989 | 3969 |
3990 widget->CloseNow(); | 3970 widget->CloseNow(); |
3991 } | 3971 } |
3992 | 3972 |
3993 } // namespace views | 3973 } // namespace views |
OLD | NEW |