OLD | NEW |
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 "ui/views/view.h" | 5 #include "ui/views/view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 4193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4204 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); | 4204 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); |
4205 }; | 4205 }; |
4206 | 4206 |
4207 // Makes sure child views with layers aren't painted when paint starts at an | 4207 // Makes sure child views with layers aren't painted when paint starts at an |
4208 // ancestor. | 4208 // ancestor. |
4209 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { | 4209 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { |
4210 PaintTrackingView* content_view = new PaintTrackingView; | 4210 PaintTrackingView* content_view = new PaintTrackingView; |
4211 widget()->SetContentsView(content_view); | 4211 widget()->SetContentsView(content_view); |
4212 content_view->SetPaintToLayer(); | 4212 content_view->SetPaintToLayer(); |
4213 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 4213 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
4214 ui::DrawWaiterForTest::WaitForCompositingStarted( | 4214 ui::DrawWaiterForTest::WaitForCompositingEnded( |
4215 GetRootLayer()->GetCompositor()); | 4215 GetRootLayer()->GetCompositor()); |
4216 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 4216 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
4217 content_view->set_painted(false); | 4217 content_view->set_painted(false); |
4218 // content_view no longer has a dirty rect. Paint from the root and make sure | 4218 // content_view no longer has a dirty rect. Paint from the root and make sure |
4219 // PaintTrackingView isn't painted. | 4219 // PaintTrackingView isn't painted. |
4220 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 4220 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
4221 ui::DrawWaiterForTest::WaitForCompositingStarted( | 4221 ui::DrawWaiterForTest::WaitForCompositingEnded( |
4222 GetRootLayer()->GetCompositor()); | 4222 GetRootLayer()->GetCompositor()); |
4223 EXPECT_FALSE(content_view->painted()); | 4223 EXPECT_FALSE(content_view->painted()); |
4224 | 4224 |
4225 // Make content_view have a dirty rect, paint the layers and make sure | 4225 // Make content_view have a dirty rect, paint the layers and make sure |
4226 // PaintTrackingView is painted. | 4226 // PaintTrackingView is painted. |
4227 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 4227 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
4228 GetRootLayer()->GetCompositor()->ScheduleDraw(); | 4228 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
4229 ui::DrawWaiterForTest::WaitForCompositingStarted( | 4229 ui::DrawWaiterForTest::WaitForCompositingEnded( |
4230 GetRootLayer()->GetCompositor()); | 4230 GetRootLayer()->GetCompositor()); |
4231 EXPECT_TRUE(content_view->painted()); | 4231 EXPECT_TRUE(content_view->painted()); |
4232 } | 4232 } |
4233 | 4233 |
4234 TEST_F(ViewLayerTest, NoCrashWhenParentlessViewSchedulesPaintOnParent) { | 4234 TEST_F(ViewLayerTest, NoCrashWhenParentlessViewSchedulesPaintOnParent) { |
4235 TestView v; | 4235 TestView v; |
4236 SchedulePaintOnParent(&v); | 4236 SchedulePaintOnParent(&v); |
4237 } | 4237 } |
4238 | 4238 |
4239 TEST_F(ViewLayerTest, ScheduledRectsInParentAfterSchedulingPaint) { | 4239 TEST_F(ViewLayerTest, ScheduledRectsInParentAfterSchedulingPaint) { |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5017 std::unique_ptr<View> view = NewView(); | 5017 std::unique_ptr<View> view = NewView(); |
5018 std::unique_ptr<View> child_view = NewView(); | 5018 std::unique_ptr<View> child_view = NewView(); |
5019 std::unique_ptr<View> child_view2 = NewView(); | 5019 std::unique_ptr<View> child_view2 = NewView(); |
5020 view->AddChildView(child_view.get()); | 5020 view->AddChildView(child_view.get()); |
5021 view->AddChildView(child_view2.get()); | 5021 view->AddChildView(child_view2.get()); |
5022 view->ReorderChildView(child_view2.get(), 0); | 5022 view->ReorderChildView(child_view2.get(), 0); |
5023 EXPECT_EQ(child_view2.get(), view_reordered()); | 5023 EXPECT_EQ(child_view2.get(), view_reordered()); |
5024 } | 5024 } |
5025 | 5025 |
5026 } // namespace views | 5026 } // namespace views |
OLD | NEW |