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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 4ea748e3fca37edc3fbe3e8def69c99d7a6eb8ff..68675c0aa8d0748f74102ea9f7b7e3295d9d9334 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -3596,6 +3596,10 @@ class ViewLayerTest : public ViewsTestBase {
Widget* widget() { return widget_; }
+ protected:
+ // Accessors to View internals.
+ void SchedulePaintOnParent(View* view) { view->SchedulePaintOnParent(); }
+
private:
Widget* widget_;
};
@@ -3988,6 +3992,50 @@ TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
EXPECT_TRUE(content_view->painted());
}
+TEST_F(ViewLayerTest, NoCrashWhenParentlessViewSchedulesPaintOnParent) {
+ TestView v;
+ SchedulePaintOnParent(&v);
+}
+
+TEST_F(ViewLayerTest, ScheduledRectsInParentAfterSchedulingPaint) {
+ TestView parent_view;
+ parent_view.SetBounds(10, 10, 100, 100);
+
+ TestView* child_view = new TestView;
+ child_view->SetBounds(5, 6, 10, 20);
+ parent_view.AddChildView(child_view);
+
+ parent_view.scheduled_paint_rects_.clear();
+ SchedulePaintOnParent(child_view);
+ ASSERT_EQ(1U, parent_view.scheduled_paint_rects_.size());
+ EXPECT_EQ(gfx::Rect(5, 6, 10, 20),
+ parent_view.scheduled_paint_rects_.front());
+}
+
+TEST_F(ViewLayerTest, ParentPaintWhenSwitchingPaintToLayerFromFalseToTrue) {
+ TestView parent_view;
+ parent_view.SetBounds(10, 11, 12, 13);
+
+ TestView* child_view = new TestView;
+ parent_view.AddChildView(child_view);
+
+ parent_view.scheduled_paint_rects_.clear();
+ child_view->SetPaintToLayer(true);
+ EXPECT_EQ(1U, parent_view.scheduled_paint_rects_.size());
+}
+
+TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) {
+ TestView parent_view;
+ parent_view.SetBounds(10, 11, 12, 13);
+
+ TestView* child_view = new TestView;
+ child_view->SetPaintToLayer(true);
+ parent_view.AddChildView(child_view);
+
+ parent_view.scheduled_paint_rects_.clear();
+ EXPECT_EQ(0U, parent_view.scheduled_paint_rects_.size());
+}
+
// Tests that the visibility of child layers are updated correctly when a View's
// visibility changes.
TEST_F(ViewLayerTest, VisibilityChildLayers) {
« 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