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

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

Issue 1566693002: Moved parent_->SchedulePaint() to Views::SetFillsBoundsOpaquely() and Views::SchedulePaint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 3578 matching lines...) Expand 10 before | Expand all | Expand 10 after
3589 widget_->GetRootView()->SetBounds(0, 0, 200, 200); 3589 widget_->GetRootView()->SetBounds(0, 0, 200, 200);
3590 } 3590 }
3591 3591
3592 void TearDown() override { 3592 void TearDown() override {
3593 widget_->CloseNow(); 3593 widget_->CloseNow();
3594 ViewsTestBase::TearDown(); 3594 ViewsTestBase::TearDown();
3595 } 3595 }
3596 3596
3597 Widget* widget() { return widget_; } 3597 Widget* widget() { return widget_; }
3598 3598
3599 protected:
3600 // Accessors to View internals.
3601 void SchedulePaintOnParent(View* view) { view->SchedulePaintOnParent(); }
3602
3599 private: 3603 private:
3600 Widget* widget_; 3604 Widget* widget_;
3601 }; 3605 };
3602 3606
3603 3607
3604 TEST_F(ViewLayerTest, LayerToggling) { 3608 TEST_F(ViewLayerTest, LayerToggling) {
3605 // Because we lazily create textures the calls to DrawTree are necessary to 3609 // Because we lazily create textures the calls to DrawTree are necessary to
3606 // ensure we trigger creation of textures. 3610 // ensure we trigger creation of textures.
3607 ui::Layer* root_layer = widget()->GetLayer(); 3611 ui::Layer* root_layer = widget()->GetLayer();
3608 View* content_view = new View; 3612 View* content_view = new View;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 3985
3982 // Make content_view have a dirty rect, paint the layers and make sure 3986 // Make content_view have a dirty rect, paint the layers and make sure
3983 // PaintTrackingView is painted. 3987 // PaintTrackingView is painted.
3984 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); 3988 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
3985 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3989 GetRootLayer()->GetCompositor()->ScheduleDraw();
3986 ui::DrawWaiterForTest::WaitForCompositingEnded( 3990 ui::DrawWaiterForTest::WaitForCompositingEnded(
3987 GetRootLayer()->GetCompositor()); 3991 GetRootLayer()->GetCompositor());
3988 EXPECT_TRUE(content_view->painted()); 3992 EXPECT_TRUE(content_view->painted());
3989 } 3993 }
3990 3994
3995 TEST_F(ViewLayerTest, NoCrashWhenParentlessViewSchedulesPaintOnParent) {
3996 TestView v;
3997 SchedulePaintOnParent(&v);
3998 }
3999
4000 TEST_F(ViewLayerTest, ScheduledRectsInParentAfterSchedulingPaint) {
4001 TestView parent_view;
4002 parent_view.SetBounds(10, 10, 100, 100);
4003
4004 TestView* child_view = new TestView;
4005 child_view->SetBounds(5, 6, 10, 20);
4006 parent_view.AddChildView(child_view);
4007
4008 parent_view.scheduled_paint_rects_.clear();
4009 SchedulePaintOnParent(child_view);
4010 ASSERT_EQ(1U, parent_view.scheduled_paint_rects_.size());
4011 EXPECT_EQ(gfx::Rect(5, 6, 10, 20),
4012 parent_view.scheduled_paint_rects_.front());
4013 }
4014
4015 TEST_F(ViewLayerTest, ParentPaintWhenSwitchingPaintToLayerFromFalseToTrue) {
4016 TestView parent_view;
4017 parent_view.SetBounds(10, 11, 12, 13);
4018
4019 TestView* child_view = new TestView;
4020 parent_view.AddChildView(child_view);
4021
4022 parent_view.scheduled_paint_rects_.clear();
4023 child_view->SetPaintToLayer(true);
4024 EXPECT_EQ(1U, parent_view.scheduled_paint_rects_.size());
4025 }
4026
4027 TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) {
4028 TestView parent_view;
4029 parent_view.SetBounds(10, 11, 12, 13);
4030
4031 TestView* child_view = new TestView;
4032 child_view->SetPaintToLayer(true);
4033 parent_view.AddChildView(child_view);
4034
4035 parent_view.scheduled_paint_rects_.clear();
4036 EXPECT_EQ(0U, parent_view.scheduled_paint_rects_.size());
4037 }
4038
3991 // Tests that the visibility of child layers are updated correctly when a View's 4039 // Tests that the visibility of child layers are updated correctly when a View's
3992 // visibility changes. 4040 // visibility changes.
3993 TEST_F(ViewLayerTest, VisibilityChildLayers) { 4041 TEST_F(ViewLayerTest, VisibilityChildLayers) {
3994 View* v1 = new View; 4042 View* v1 = new View;
3995 v1->SetPaintToLayer(true); 4043 v1->SetPaintToLayer(true);
3996 widget()->SetContentsView(v1); 4044 widget()->SetContentsView(v1);
3997 4045
3998 View* v2 = new View; 4046 View* v2 = new View;
3999 v1->AddChildView(v2); 4047 v1->AddChildView(v2);
4000 4048
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
4349 4397
4350 // The View should continue receiving events after the |handler| is deleted. 4398 // The View should continue receiving events after the |handler| is deleted.
4351 v->Reset(); 4399 v->Reset();
4352 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 4400 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(),
4353 ui::EventTimeForNow(), 0, 0); 4401 ui::EventTimeForNow(), 0, 0);
4354 root->OnMouseReleased(released); 4402 root->OnMouseReleased(released);
4355 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_); 4403 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_);
4356 } 4404 }
4357 4405
4358 } // namespace views 4406 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698