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

Side by Side Diff: ui/views/view_unittest.cc

Issue 134623005: Make SingleThreadProxy a SchedulerClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Asynchronous BeginMainFrame Created 6 years, 4 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 (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/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 3196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); 3207 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView);
3208 }; 3208 };
3209 3209
3210 // Makes sure child views with layers aren't painted when paint starts at an 3210 // Makes sure child views with layers aren't painted when paint starts at an
3211 // ancestor. 3211 // ancestor.
3212 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { 3212 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
3213 PaintTrackingView* content_view = new PaintTrackingView; 3213 PaintTrackingView* content_view = new PaintTrackingView;
3214 widget()->SetContentsView(content_view); 3214 widget()->SetContentsView(content_view);
3215 content_view->SetPaintToLayer(true); 3215 content_view->SetPaintToLayer(true);
3216 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3216 GetRootLayer()->GetCompositor()->ScheduleDraw();
3217 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3217 ui::DrawWaiterForTest::WaitForCompositingEnded(
3218 GetRootLayer()->GetCompositor());
3218 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); 3219 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
3219 content_view->set_painted(false); 3220 content_view->set_painted(false);
3220 // content_view no longer has a dirty rect. Paint from the root and make sure 3221 // content_view no longer has a dirty rect. Paint from the root and make sure
3221 // PaintTrackingView isn't painted. 3222 // PaintTrackingView isn't painted.
3222 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3223 GetRootLayer()->GetCompositor()->ScheduleDraw();
3223 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3224 ui::DrawWaiterForTest::WaitForCompositingEnded(
3225 GetRootLayer()->GetCompositor());
3224 EXPECT_FALSE(content_view->painted()); 3226 EXPECT_FALSE(content_view->painted());
3225 3227
3226 // Make content_view have a dirty rect, paint the layers and make sure 3228 // Make content_view have a dirty rect, paint the layers and make sure
3227 // PaintTrackingView is painted. 3229 // PaintTrackingView is painted.
3228 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); 3230 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
3229 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3231 GetRootLayer()->GetCompositor()->ScheduleDraw();
3230 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3232 ui::DrawWaiterForTest::WaitForCompositingEnded(
3233 GetRootLayer()->GetCompositor());
3231 EXPECT_TRUE(content_view->painted()); 3234 EXPECT_TRUE(content_view->painted());
3232 } 3235 }
3233 3236
3234 // Tests that the visibility of child layers are updated correctly when a View's 3237 // Tests that the visibility of child layers are updated correctly when a View's
3235 // visibility changes. 3238 // visibility changes.
3236 TEST_F(ViewLayerTest, VisibilityChildLayers) { 3239 TEST_F(ViewLayerTest, VisibilityChildLayers) {
3237 View* v1 = new View; 3240 View* v1 = new View;
3238 v1->SetPaintToLayer(true); 3241 v1->SetPaintToLayer(true);
3239 widget()->SetContentsView(v1); 3242 widget()->SetContentsView(v1);
3240 3243
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 v1->SetBoundsRect(gfx::Rect(10, 15, 150, 151)); 3463 v1->SetBoundsRect(gfx::Rect(10, 15, 150, 151));
3461 test_view->AddChildView(v1); 3464 test_view->AddChildView(v1);
3462 3465
3463 View* v2 = new View(); 3466 View* v2 = new View();
3464 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50)); 3467 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50));
3465 v1->AddChildView(v2); 3468 v1->AddChildView(v2);
3466 3469
3467 // Schedule a full-view paint to get everyone's rectangles updated. 3470 // Schedule a full-view paint to get everyone's rectangles updated.
3468 test_view->SchedulePaintInRect(test_view->bounds()); 3471 test_view->SchedulePaintInRect(test_view->bounds());
3469 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3472 GetRootLayer()->GetCompositor()->ScheduleDraw();
3470 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3473 ui::DrawWaiterForTest::WaitForCompositingEnded(
3474 GetRootLayer()->GetCompositor());
3471 3475
3472 // Now we have test_view - v1 - v2. Damage to only test_view should only 3476 // Now we have test_view - v1 - v2. Damage to only test_view should only
3473 // return root_view and test_view. 3477 // return root_view and test_view.
3474 test_view->SchedulePaintInRect(gfx::Rect(0, 0, 1, 1)); 3478 test_view->SchedulePaintInRect(gfx::Rect(0, 0, 1, 1));
3475 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3479 GetRootLayer()->GetCompositor()->ScheduleDraw();
3476 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3480 ui::DrawWaiterForTest::WaitForCompositingEnded(
3481 GetRootLayer()->GetCompositor());
3477 EXPECT_EQ(2U, test_view->last_cull_set_.size()); 3482 EXPECT_EQ(2U, test_view->last_cull_set_.size());
3478 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3483 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3479 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3484 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3480 3485
3481 // Damage to v1 only should only return root_view, test_view, and v1. 3486 // Damage to v1 only should only return root_view, test_view, and v1.
3482 test_view->SchedulePaintInRect(gfx::Rect(11, 16, 1, 1)); 3487 test_view->SchedulePaintInRect(gfx::Rect(11, 16, 1, 1));
3483 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3488 GetRootLayer()->GetCompositor()->ScheduleDraw();
3484 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3489 ui::DrawWaiterForTest::WaitForCompositingEnded(
3490 GetRootLayer()->GetCompositor());
3485 EXPECT_EQ(3U, test_view->last_cull_set_.size()); 3491 EXPECT_EQ(3U, test_view->last_cull_set_.size());
3486 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3492 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3487 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3493 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3488 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); 3494 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
3489 3495
3490 // A Damage rect inside v2 should get all 3 views back in the |last_cull_set_| 3496 // A Damage rect inside v2 should get all 3 views back in the |last_cull_set_|
3491 // on call to TestView::Paint(), along with the widget root view. 3497 // on call to TestView::Paint(), along with the widget root view.
3492 test_view->SchedulePaintInRect(gfx::Rect(31, 49, 1, 1)); 3498 test_view->SchedulePaintInRect(gfx::Rect(31, 49, 1, 1));
3493 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3499 GetRootLayer()->GetCompositor()->ScheduleDraw();
3494 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3500 ui::DrawWaiterForTest::WaitForCompositingEnded(
3501 GetRootLayer()->GetCompositor());
3495 EXPECT_EQ(4U, test_view->last_cull_set_.size()); 3502 EXPECT_EQ(4U, test_view->last_cull_set_.size());
3496 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3503 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3497 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3504 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3498 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); 3505 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
3499 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); 3506 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
3500 } 3507 }
3501 3508
3502 TEST_F(ViewLayerTest, BoundsTreeWithRTL) { 3509 TEST_F(ViewLayerTest, BoundsTreeWithRTL) {
3503 std::string locale = l10n_util::GetApplicationLocale(std::string()); 3510 std::string locale = l10n_util::GetApplicationLocale(std::string());
3504 base::i18n::SetICUDefaultLocale("ar"); 3511 base::i18n::SetICUDefaultLocale("ar");
3505 3512
3506 BoundsTreeTestView* test_view = new BoundsTreeTestView; 3513 BoundsTreeTestView* test_view = new BoundsTreeTestView;
3507 widget()->SetContentsView(test_view); 3514 widget()->SetContentsView(test_view);
3508 3515
3509 // Add child views, which should be in RTL coordinate space of parent view. 3516 // Add child views, which should be in RTL coordinate space of parent view.
3510 View* v1 = new View; 3517 View* v1 = new View;
3511 v1->SetBoundsRect(gfx::Rect(10, 12, 25, 26)); 3518 v1->SetBoundsRect(gfx::Rect(10, 12, 25, 26));
3512 test_view->AddChildView(v1); 3519 test_view->AddChildView(v1);
3513 3520
3514 View* v2 = new View; 3521 View* v2 = new View;
3515 v2->SetBoundsRect(gfx::Rect(5, 6, 7, 8)); 3522 v2->SetBoundsRect(gfx::Rect(5, 6, 7, 8));
3516 v1->AddChildView(v2); 3523 v1->AddChildView(v2);
3517 3524
3518 // Schedule a full-view paint to get everyone's rectangles updated. 3525 // Schedule a full-view paint to get everyone's rectangles updated.
3519 test_view->SchedulePaintInRect(test_view->bounds()); 3526 test_view->SchedulePaintInRect(test_view->bounds());
3520 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3527 GetRootLayer()->GetCompositor()->ScheduleDraw();
3521 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3528 ui::DrawWaiterForTest::WaitForCompositingEnded(
3529 GetRootLayer()->GetCompositor());
3522 3530
3523 // Damage to the right side of the parent view should touch both child views. 3531 // Damage to the right side of the parent view should touch both child views.
3524 gfx::Rect rtl_damage(test_view->bounds().width() - 16, 18, 1, 1); 3532 gfx::Rect rtl_damage(test_view->bounds().width() - 16, 18, 1, 1);
3525 test_view->SchedulePaintInRect(rtl_damage); 3533 test_view->SchedulePaintInRect(rtl_damage);
3526 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3534 GetRootLayer()->GetCompositor()->ScheduleDraw();
3527 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3535 ui::DrawWaiterForTest::WaitForCompositingEnded(
3536 GetRootLayer()->GetCompositor());
3528 EXPECT_EQ(4U, test_view->last_cull_set_.size()); 3537 EXPECT_EQ(4U, test_view->last_cull_set_.size());
3529 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3538 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3530 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3539 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3531 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); 3540 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
3532 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); 3541 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
3533 3542
3534 // Damage to the left side of the parent view should only touch the 3543 // Damage to the left side of the parent view should only touch the
3535 // container views. 3544 // container views.
3536 gfx::Rect ltr_damage(16, 18, 1, 1); 3545 gfx::Rect ltr_damage(16, 18, 1, 1);
3537 test_view->SchedulePaintInRect(ltr_damage); 3546 test_view->SchedulePaintInRect(ltr_damage);
3538 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3547 GetRootLayer()->GetCompositor()->ScheduleDraw();
3539 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3548 ui::DrawWaiterForTest::WaitForCompositingEnded(
3549 GetRootLayer()->GetCompositor());
3540 EXPECT_EQ(2U, test_view->last_cull_set_.size()); 3550 EXPECT_EQ(2U, test_view->last_cull_set_.size());
3541 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3551 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3542 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3552 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3543 3553
3544 // Reset locale. 3554 // Reset locale.
3545 base::i18n::SetICUDefaultLocale(locale); 3555 base::i18n::SetICUDefaultLocale(locale);
3546 } 3556 }
3547 3557
3548 TEST_F(ViewLayerTest, BoundsTreeSetBoundsChangesCullSet) { 3558 TEST_F(ViewLayerTest, BoundsTreeSetBoundsChangesCullSet) {
3549 BoundsTreeTestView* test_view = new BoundsTreeTestView; 3559 BoundsTreeTestView* test_view = new BoundsTreeTestView;
3550 widget()->SetContentsView(test_view); 3560 widget()->SetContentsView(test_view);
3551 3561
3552 View* v1 = new View; 3562 View* v1 = new View;
3553 v1->SetBoundsRect(gfx::Rect(5, 6, 100, 101)); 3563 v1->SetBoundsRect(gfx::Rect(5, 6, 100, 101));
3554 test_view->AddChildView(v1); 3564 test_view->AddChildView(v1);
3555 3565
3556 View* v2 = new View; 3566 View* v2 = new View;
3557 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50)); 3567 v2->SetBoundsRect(gfx::Rect(20, 33, 40, 50));
3558 v1->AddChildView(v2); 3568 v1->AddChildView(v2);
3559 3569
3560 // Schedule a full-view paint to get everyone's rectangles updated. 3570 // Schedule a full-view paint to get everyone's rectangles updated.
3561 test_view->SchedulePaintInRect(test_view->bounds()); 3571 test_view->SchedulePaintInRect(test_view->bounds());
3562 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3572 GetRootLayer()->GetCompositor()->ScheduleDraw();
3563 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3573 ui::DrawWaiterForTest::WaitForCompositingEnded(
3574 GetRootLayer()->GetCompositor());
3564 3575
3565 // Move v1 to a new origin out of the way of our next query. 3576 // Move v1 to a new origin out of the way of our next query.
3566 v1->SetBoundsRect(gfx::Rect(50, 60, 100, 101)); 3577 v1->SetBoundsRect(gfx::Rect(50, 60, 100, 101));
3567 // The move will force a repaint. 3578 // The move will force a repaint.
3568 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3579 GetRootLayer()->GetCompositor()->ScheduleDraw();
3569 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3580 ui::DrawWaiterForTest::WaitForCompositingEnded(
3581 GetRootLayer()->GetCompositor());
3570 3582
3571 // Schedule a paint with damage rect where v1 used to be. 3583 // Schedule a paint with damage rect where v1 used to be.
3572 test_view->SchedulePaintInRect(gfx::Rect(5, 6, 10, 11)); 3584 test_view->SchedulePaintInRect(gfx::Rect(5, 6, 10, 11));
3573 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3585 GetRootLayer()->GetCompositor()->ScheduleDraw();
3574 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3586 ui::DrawWaiterForTest::WaitForCompositingEnded(
3587 GetRootLayer()->GetCompositor());
3575 3588
3576 // Should only have picked up root_view and test_view. 3589 // Should only have picked up root_view and test_view.
3577 EXPECT_EQ(2U, test_view->last_cull_set_.size()); 3590 EXPECT_EQ(2U, test_view->last_cull_set_.size());
3578 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3591 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3579 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3592 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3580 } 3593 }
3581 3594
3582 TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) { 3595 TEST_F(ViewLayerTest, BoundsTreeLayerChangeMakesNewTree) {
3583 BoundsTreeTestView* test_view = new BoundsTreeTestView; 3596 BoundsTreeTestView* test_view = new BoundsTreeTestView;
3584 widget()->SetContentsView(test_view); 3597 widget()->SetContentsView(test_view);
3585 3598
3586 View* v1 = new View; 3599 View* v1 = new View;
3587 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20)); 3600 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20));
3588 test_view->AddChildView(v1); 3601 test_view->AddChildView(v1);
3589 3602
3590 View* v2 = new View; 3603 View* v2 = new View;
3591 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); 3604 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4));
3592 v1->AddChildView(v2); 3605 v1->AddChildView(v2);
3593 3606
3594 // Schedule a full-view paint to get everyone's rectangles updated. 3607 // Schedule a full-view paint to get everyone's rectangles updated.
3595 test_view->SchedulePaintInRect(test_view->bounds()); 3608 test_view->SchedulePaintInRect(test_view->bounds());
3596 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3609 GetRootLayer()->GetCompositor()->ScheduleDraw();
3597 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3610 ui::DrawWaiterForTest::WaitForCompositingEnded(
3611 GetRootLayer()->GetCompositor());
3598 3612
3599 // Set v1 to paint to its own layer, it should remove itself from the 3613 // Set v1 to paint to its own layer, it should remove itself from the
3600 // test_view heiarchy and no longer intersect with damage rects in that cull 3614 // test_view heiarchy and no longer intersect with damage rects in that cull
3601 // set. 3615 // set.
3602 v1->SetPaintToLayer(true); 3616 v1->SetPaintToLayer(true);
3603 3617
3604 // Schedule another full-view paint. 3618 // Schedule another full-view paint.
3605 test_view->SchedulePaintInRect(test_view->bounds()); 3619 test_view->SchedulePaintInRect(test_view->bounds());
3606 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3620 GetRootLayer()->GetCompositor()->ScheduleDraw();
3607 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3621 ui::DrawWaiterForTest::WaitForCompositingEnded(
3622 GetRootLayer()->GetCompositor());
3608 // v1 and v2 should no longer be present in the test_view cull_set. 3623 // v1 and v2 should no longer be present in the test_view cull_set.
3609 EXPECT_EQ(2U, test_view->last_cull_set_.size()); 3624 EXPECT_EQ(2U, test_view->last_cull_set_.size());
3610 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1)); 3625 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1));
3611 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2)); 3626 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2));
3612 3627
3613 // Now set v1 back to not painting to a layer. 3628 // Now set v1 back to not painting to a layer.
3614 v1->SetPaintToLayer(false); 3629 v1->SetPaintToLayer(false);
3615 // Schedule another full-view paint. 3630 // Schedule another full-view paint.
3616 test_view->SchedulePaintInRect(test_view->bounds()); 3631 test_view->SchedulePaintInRect(test_view->bounds());
3617 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3632 GetRootLayer()->GetCompositor()->ScheduleDraw();
3618 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3633 ui::DrawWaiterForTest::WaitForCompositingEnded(
3634 GetRootLayer()->GetCompositor());
3619 // We should be back to the full cull set including v1 and v2. 3635 // We should be back to the full cull set including v1 and v2.
3620 EXPECT_EQ(4U, test_view->last_cull_set_.size()); 3636 EXPECT_EQ(4U, test_view->last_cull_set_.size());
3621 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3637 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3622 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3638 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3623 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); 3639 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
3624 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); 3640 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
3625 } 3641 }
3626 3642
3627 TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) { 3643 TEST_F(ViewLayerTest, BoundsTreeRemoveChildRemovesBounds) {
3628 BoundsTreeTestView* test_view = new BoundsTreeTestView; 3644 BoundsTreeTestView* test_view = new BoundsTreeTestView;
3629 widget()->SetContentsView(test_view); 3645 widget()->SetContentsView(test_view);
3630 3646
3631 View* v1 = new View; 3647 View* v1 = new View;
3632 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20)); 3648 v1->SetBoundsRect(gfx::Rect(5, 10, 15, 20));
3633 test_view->AddChildView(v1); 3649 test_view->AddChildView(v1);
3634 3650
3635 View* v2 = new View; 3651 View* v2 = new View;
3636 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); 3652 v2->SetBoundsRect(gfx::Rect(1, 2, 3, 4));
3637 v1->AddChildView(v2); 3653 v1->AddChildView(v2);
3638 3654
3639 // Schedule a full-view paint to get everyone's rectangles updated. 3655 // Schedule a full-view paint to get everyone's rectangles updated.
3640 test_view->SchedulePaintInRect(test_view->bounds()); 3656 test_view->SchedulePaintInRect(test_view->bounds());
3641 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3657 GetRootLayer()->GetCompositor()->ScheduleDraw();
3642 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3658 ui::DrawWaiterForTest::WaitForCompositingEnded(
3659 GetRootLayer()->GetCompositor());
3643 3660
3644 // Now remove v1 from the root view. 3661 // Now remove v1 from the root view.
3645 test_view->RemoveChildView(v1); 3662 test_view->RemoveChildView(v1);
3646 3663
3647 // Schedule another full-view paint. 3664 // Schedule another full-view paint.
3648 test_view->SchedulePaintInRect(test_view->bounds()); 3665 test_view->SchedulePaintInRect(test_view->bounds());
3649 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3666 GetRootLayer()->GetCompositor()->ScheduleDraw();
3650 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3667 ui::DrawWaiterForTest::WaitForCompositingEnded(
3668 GetRootLayer()->GetCompositor());
3651 // v1 and v2 should no longer be present in the test_view cull_set. 3669 // v1 and v2 should no longer be present in the test_view cull_set.
3652 EXPECT_EQ(2U, test_view->last_cull_set_.size()); 3670 EXPECT_EQ(2U, test_view->last_cull_set_.size());
3653 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1)); 3671 EXPECT_EQ(0U, test_view->last_cull_set_.count(v1));
3654 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2)); 3672 EXPECT_EQ(0U, test_view->last_cull_set_.count(v2));
3655 3673
3656 // View v1 and v2 are no longer part of view hierarchy and therefore won't be 3674 // View v1 and v2 are no longer part of view hierarchy and therefore won't be
3657 // deleted with that hierarchy. 3675 // deleted with that hierarchy.
3658 delete v1; 3676 delete v1;
3659 } 3677 }
3660 3678
(...skipping 10 matching lines...) Expand all
3671 v2->SetBoundsRect(gfx::Rect(5, 10, 40, 50)); 3689 v2->SetBoundsRect(gfx::Rect(5, 10, 40, 50));
3672 v1->AddChildView(v2); 3690 v1->AddChildView(v2);
3673 3691
3674 View* v3 = new View; 3692 View* v3 = new View;
3675 v3->SetBoundsRect(gfx::Rect(1, 2, 3, 4)); 3693 v3->SetBoundsRect(gfx::Rect(1, 2, 3, 4));
3676 v2->AddChildView(v3); 3694 v2->AddChildView(v3);
3677 3695
3678 // Schedule a full-view paint and ensure all views are present in the cull. 3696 // Schedule a full-view paint and ensure all views are present in the cull.
3679 test_view->SchedulePaintInRect(test_view->bounds()); 3697 test_view->SchedulePaintInRect(test_view->bounds());
3680 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3698 GetRootLayer()->GetCompositor()->ScheduleDraw();
3681 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3699 ui::DrawWaiterForTest::WaitForCompositingEnded(
3700 GetRootLayer()->GetCompositor());
3682 EXPECT_EQ(5U, test_view->last_cull_set_.size()); 3701 EXPECT_EQ(5U, test_view->last_cull_set_.size());
3683 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3702 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3684 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3703 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3685 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); 3704 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
3686 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2)); 3705 EXPECT_EQ(1U, test_view->last_cull_set_.count(v2));
3687 EXPECT_EQ(1U, test_view->last_cull_set_.count(v3)); 3706 EXPECT_EQ(1U, test_view->last_cull_set_.count(v3));
3688 3707
3689 // Build an unrelated view hierarchy and move v2 in to it. 3708 // Build an unrelated view hierarchy and move v2 in to it.
3690 scoped_ptr<Widget> test_widget(new Widget); 3709 scoped_ptr<Widget> test_widget(new Widget);
3691 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 3710 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
3692 params.bounds = gfx::Rect(10, 10, 500, 500); 3711 params.bounds = gfx::Rect(10, 10, 500, 500);
3693 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 3712 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
3694 test_widget->Init(params); 3713 test_widget->Init(params);
3695 test_widget->Show(); 3714 test_widget->Show();
3696 BoundsTreeTestView* widget_view = new BoundsTreeTestView; 3715 BoundsTreeTestView* widget_view = new BoundsTreeTestView;
3697 test_widget->SetContentsView(widget_view); 3716 test_widget->SetContentsView(widget_view);
3698 widget_view->AddChildView(v2); 3717 widget_view->AddChildView(v2);
3699 3718
3700 // Now schedule full-view paints in both widgets. 3719 // Now schedule full-view paints in both widgets.
3701 test_view->SchedulePaintInRect(test_view->bounds()); 3720 test_view->SchedulePaintInRect(test_view->bounds());
3702 widget_view->SchedulePaintInRect(widget_view->bounds()); 3721 widget_view->SchedulePaintInRect(widget_view->bounds());
3703 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3722 GetRootLayer()->GetCompositor()->ScheduleDraw();
3704 ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor()); 3723 ui::DrawWaiterForTest::WaitForCompositingEnded(
3724 GetRootLayer()->GetCompositor());
3705 3725
3706 // Only v1 should be present in the first cull set. 3726 // Only v1 should be present in the first cull set.
3707 EXPECT_EQ(3U, test_view->last_cull_set_.size()); 3727 EXPECT_EQ(3U, test_view->last_cull_set_.size());
3708 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView())); 3728 EXPECT_EQ(1U, test_view->last_cull_set_.count(widget()->GetRootView()));
3709 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view)); 3729 EXPECT_EQ(1U, test_view->last_cull_set_.count(test_view));
3710 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1)); 3730 EXPECT_EQ(1U, test_view->last_cull_set_.count(v1));
3711 3731
3712 // We should find v2 and v3 in the widget_view cull_set. 3732 // We should find v2 and v3 in the widget_view cull_set.
3713 EXPECT_EQ(4U, widget_view->last_cull_set_.size()); 3733 EXPECT_EQ(4U, widget_view->last_cull_set_.size());
3714 EXPECT_EQ(1U, widget_view->last_cull_set_.count(test_widget->GetRootView())); 3734 EXPECT_EQ(1U, widget_view->last_cull_set_.count(test_widget->GetRootView()));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3825 // notification. 3845 // notification.
3826 TestView* test_view_child_2 = new TestView(); 3846 TestView* test_view_child_2 = new TestView();
3827 test_view->AddChildView(test_view_child_2); 3847 test_view->AddChildView(test_view_child_2);
3828 EXPECT_TRUE(test_view_child_2->native_theme_); 3848 EXPECT_TRUE(test_view_child_2->native_theme_);
3829 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); 3849 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_);
3830 3850
3831 widget->CloseNow(); 3851 widget->CloseNow();
3832 } 3852 }
3833 3853
3834 } // namespace views 3854 } // namespace views
OLDNEW
« cc/trees/single_thread_proxy.cc ('K') | « ui/snapshot/snapshot_aura_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698