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

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

Issue 1461673002: Moved parent_->SchedulePaint() to Views::SetFillsBoundsOpaquely() and Views::SchedulePaint(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed doc comment in View::CreateLayer(). 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 <map> 5 #include <map>
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 3574 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 widget_->GetRootView()->SetBounds(0, 0, 200, 200); 3585 widget_->GetRootView()->SetBounds(0, 0, 200, 200);
3586 } 3586 }
3587 3587
3588 void TearDown() override { 3588 void TearDown() override {
3589 widget_->CloseNow(); 3589 widget_->CloseNow();
3590 ViewsTestBase::TearDown(); 3590 ViewsTestBase::TearDown();
3591 } 3591 }
3592 3592
3593 Widget* widget() { return widget_; } 3593 Widget* widget() { return widget_; }
3594 3594
3595 protected:
3596 // Accessors to View internals.
3597 void SchedulePaintOnParent(View* view) { view->SchedulePaintOnParent(); }
3598
3595 private: 3599 private:
3596 Widget* widget_; 3600 Widget* widget_;
3597 }; 3601 };
3598 3602
3599 3603
3600 TEST_F(ViewLayerTest, LayerToggling) { 3604 TEST_F(ViewLayerTest, LayerToggling) {
3601 // Because we lazily create textures the calls to DrawTree are necessary to 3605 // Because we lazily create textures the calls to DrawTree are necessary to
3602 // ensure we trigger creation of textures. 3606 // ensure we trigger creation of textures.
3603 ui::Layer* root_layer = widget()->GetLayer(); 3607 ui::Layer* root_layer = widget()->GetLayer();
3604 View* content_view = new View; 3608 View* content_view = new View;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
3977 3981
3978 // Make content_view have a dirty rect, paint the layers and make sure 3982 // Make content_view have a dirty rect, paint the layers and make sure
3979 // PaintTrackingView is painted. 3983 // PaintTrackingView is painted.
3980 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); 3984 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10));
3981 GetRootLayer()->GetCompositor()->ScheduleDraw(); 3985 GetRootLayer()->GetCompositor()->ScheduleDraw();
3982 ui::DrawWaiterForTest::WaitForCompositingEnded( 3986 ui::DrawWaiterForTest::WaitForCompositingEnded(
3983 GetRootLayer()->GetCompositor()); 3987 GetRootLayer()->GetCompositor());
3984 EXPECT_TRUE(content_view->painted()); 3988 EXPECT_TRUE(content_view->painted());
3985 } 3989 }
3986 3990
3991 TEST_F(ViewLayerTest, NoCrashWhenParentlessViewSchedulesPaintOnParent) {
3992 TestView* v = new TestView;
3993 SchedulePaintOnParent(v);
3994 }
3995
3996 TEST_F(ViewLayerTest, ScheduledRectsInParentAfterSchedulingPaint) {
3997 TestView* v1 = new TestView;
3998 v1->SetBounds(10, 10, 100, 100);
3999
4000 TestView* v2 = new TestView;
4001 v2->SetBounds(5, 6, 10, 20);
4002 v1->AddChildView(v2);
4003
4004 v1->scheduled_paint_rects_.clear();
4005 SchedulePaintOnParent(v2);
4006 ASSERT_EQ(1U, v1->scheduled_paint_rects_.size());
4007 EXPECT_EQ(gfx::Rect(5, 6, 10, 20), v1->scheduled_paint_rects_.front());
4008 }
4009
4010 TEST_F(ViewLayerTest, ParentPaintWhenSwitchingPaintToLayerFromFalseToTrue) {
4011 TestView* v1 = new TestView;
4012 v1->SetBounds(10, 11, 12, 13);
4013
4014 TestView* v2 = new TestView;
4015 v1->AddChildView(v2);
4016
4017 v1->scheduled_paint_rects_.clear();
4018 v2->SetPaintToLayer(true);
4019 EXPECT_EQ(1U, v1->scheduled_paint_rects_.size());
4020 }
4021
4022 TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) {
4023 TestView* v1 = new TestView;
4024 v1->SetBounds(10, 11, 12, 13);
4025
4026 TestView* v2 = new TestView;
4027 v2->SetPaintToLayer(true);
4028 v1->AddChildView(v2);
4029
4030 v1->scheduled_paint_rects_.clear();
4031 EXPECT_EQ(0U, v1->scheduled_paint_rects_.size());
4032 }
4033
3987 // Tests that the visibility of child layers are updated correctly when a View's 4034 // Tests that the visibility of child layers are updated correctly when a View's
3988 // visibility changes. 4035 // visibility changes.
3989 TEST_F(ViewLayerTest, VisibilityChildLayers) { 4036 TEST_F(ViewLayerTest, VisibilityChildLayers) {
3990 View* v1 = new View; 4037 View* v1 = new View;
3991 v1->SetPaintToLayer(true); 4038 v1->SetPaintToLayer(true);
3992 widget()->SetContentsView(v1); 4039 widget()->SetContentsView(v1);
3993 4040
3994 View* v2 = new View; 4041 View* v2 = new View;
3995 v1->AddChildView(v2); 4042 v1->AddChildView(v2);
3996 4043
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
4345 4392
4346 // The View should continue receiving events after the |handler| is deleted. 4393 // The View should continue receiving events after the |handler| is deleted.
4347 v->Reset(); 4394 v->Reset();
4348 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 4395 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(),
4349 ui::EventTimeForNow(), 0, 0); 4396 ui::EventTimeForNow(), 0, 0);
4350 root->OnMouseReleased(released); 4397 root->OnMouseReleased(released);
4351 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_); 4398 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_);
4352 } 4399 }
4353 4400
4354 } // namespace views 4401 } // 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