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

Unified 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, 12 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 503eead6f6853e79ada14751076bb4c698695a82..ca2256a8d0e2a1f9d8c99f707f23b582d4d2bd3a 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -3592,6 +3592,10 @@ class ViewLayerTest : public ViewsTestBase {
Widget* widget() { return widget_; }
+ protected:
+ // Accessors to View internals.
+ void SchedulePaintOnParent(View* view) { view->SchedulePaintOnParent(); }
+
private:
Widget* widget_;
};
@@ -3984,6 +3988,49 @@ TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
EXPECT_TRUE(content_view->painted());
}
+TEST_F(ViewLayerTest, NoCrashWhenParentlessViewSchedulesPaintOnParent) {
+ TestView* v = new TestView;
+ SchedulePaintOnParent(v);
+}
+
+TEST_F(ViewLayerTest, ScheduledRectsInParentAfterSchedulingPaint) {
+ TestView* v1 = new TestView;
+ v1->SetBounds(10, 10, 100, 100);
+
+ TestView* v2 = new TestView;
+ v2->SetBounds(5, 6, 10, 20);
+ v1->AddChildView(v2);
+
+ v1->scheduled_paint_rects_.clear();
+ SchedulePaintOnParent(v2);
+ ASSERT_EQ(1U, v1->scheduled_paint_rects_.size());
+ EXPECT_EQ(gfx::Rect(5, 6, 10, 20), v1->scheduled_paint_rects_.front());
+}
+
+TEST_F(ViewLayerTest, ParentPaintWhenSwitchingPaintToLayerFromFalseToTrue) {
+ TestView* v1 = new TestView;
+ v1->SetBounds(10, 11, 12, 13);
+
+ TestView* v2 = new TestView;
+ v1->AddChildView(v2);
+
+ v1->scheduled_paint_rects_.clear();
+ v2->SetPaintToLayer(true);
+ EXPECT_EQ(1U, v1->scheduled_paint_rects_.size());
+}
+
+TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) {
+ TestView* v1 = new TestView;
+ v1->SetBounds(10, 11, 12, 13);
+
+ TestView* v2 = new TestView;
+ v2->SetPaintToLayer(true);
+ v1->AddChildView(v2);
+
+ v1->scheduled_paint_rects_.clear();
+ EXPECT_EQ(0U, v1->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