Index: ui/views/view_unittest.cc |
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc |
index bb71337326da40184c6090bd7ed46186cad96138..1df4e8b2a02400775f6abeb867f06175e806789a 100644 |
--- a/ui/views/view_unittest.cc |
+++ b/ui/views/view_unittest.cc |
@@ -157,7 +157,7 @@ void ConstructTree(views::View* view, int depth) { |
views::View* v = new views::View; |
view->AddChildView(v); |
if (base::RandDouble() > 0.5) |
- v->SetPaintToLayer(true); |
+ v->SetPaintToLayer(); |
if (base::RandDouble() < 0.2) |
v->SetVisible(false); |
@@ -184,7 +184,7 @@ void ScrambleTree(views::View* view) { |
} |
if (!view->layer() && base::RandDouble() < 0.1) |
- view->SetPaintToLayer(true); |
+ view->SetPaintToLayer(); |
if (base::RandDouble() < 0.1) |
view->SetVisible(!view->visible()); |
@@ -783,15 +783,15 @@ TEST_F(ViewTest, PaintContainsChildrenInRTL) { |
v1->AddChildView(v2); |
// Verify where the layers actually appear. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
// x: 25 - 10(x) - 12(width) = 3 |
EXPECT_EQ(gfx::Rect(3, 11, 12, 13), v1->layer()->bounds()); |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
// x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
- v2->SetPaintToLayer(false); |
+ v2->DestroyLayer(); |
// Paint everything once, since it has to build its cache. Then we can test |
// invalidation. |
@@ -859,15 +859,15 @@ TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { |
v1->AddChildView(v2); |
// Verify where the layers actually appear. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
// x: 25 - 10(x) - 12(width) = 3 |
EXPECT_EQ(gfx::Rect(3, 11, 12, 13), v1->layer()->bounds()); |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
// x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
- v2->SetPaintToLayer(false); |
+ v2->DestroyLayer(); |
// Paint everything once, since it has to build its cache. Then we can test |
// invalidation. |
@@ -935,15 +935,15 @@ TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { |
v1->AddChildView(v2); |
// Verify where the layers actually appear. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
// x: 25 - 10(x) - 12(width) = 3 |
EXPECT_EQ(gfx::Rect(3, 11, 12, 13), v1->layer()->bounds()); |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
// x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
- v2->SetPaintToLayer(false); |
+ v2->DestroyLayer(); |
// Paint everything once, since it has to build its cache. Then we can test |
// invalidation. |
@@ -1011,15 +1011,15 @@ TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { |
v1->AddChildView(v2); |
// Verify where the layers actually appear. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
// x: 25 - 10(x) - 12(width) = 3 |
EXPECT_EQ(gfx::Rect(3, 11, 12, 13), v1->layer()->bounds()); |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
// x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
- v2->SetPaintToLayer(false); |
+ v2->DestroyLayer(); |
// Paint everything once, since it has to build its cache. Then we can test |
// invalidation. |
@@ -1099,15 +1099,15 @@ TEST_F(ViewTest, PaintIntersectsOneChildInRTL) { |
root_view->AddChildView(v2); |
// Verify where the layers actually appear. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
// x: 25 - 10(x) - 12(width) = 3 |
EXPECT_EQ(gfx::Rect(3, 11, 12, 13), v1->layer()->bounds()); |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
// x: 25 - 3(x) - 6(width) = 16 |
EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds()); |
- v2->SetPaintToLayer(false); |
+ v2->DestroyLayer(); |
// Paint everything once, since it has to build its cache. Then we can test |
// invalidation. |
@@ -1146,7 +1146,7 @@ TEST_F(ViewTest, PaintInPromotedToLayer) { |
View* root_view = widget->GetRootView(); |
TestView* v1 = new TestView; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
v1->SetBounds(10, 11, 12, 13); |
root_view->AddChildView(v1); |
@@ -1230,7 +1230,7 @@ TEST_F(ViewTest, PaintLocalBounds) { |
root_view->SetBounds(0, 0, 200, 200); |
TestPaintView* v1 = new TestPaintView; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
// Set bounds for |v1| such that it has an offset to its parent and only part |
// of it is visible. The visible bounds does not intersect with |root_view|'s |
@@ -3733,7 +3733,7 @@ TEST_F(ViewLayerTest, LayerToggling) { |
// Create v1, give it a bounds and verify everything is set up correctly. |
View* v1 = new View; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
EXPECT_TRUE(v1->layer() != NULL); |
v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150)); |
content_view->AddChildView(v1); |
@@ -3746,14 +3746,14 @@ TEST_F(ViewLayerTest, LayerToggling) { |
v1->AddChildView(v2); |
EXPECT_TRUE(v2->layer() == NULL); |
v2->SetBoundsRect(gfx::Rect(10, 20, 30, 40)); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
ASSERT_TRUE(v2->layer() != NULL); |
EXPECT_EQ(v1->layer(), v2->layer()->parent()); |
EXPECT_EQ(gfx::Rect(10, 20, 30, 40), v2->layer()->bounds()); |
// Turn off v1s layer. v2 should still have a layer but its parent should have |
// changed. |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
EXPECT_TRUE(v1->layer() == NULL); |
EXPECT_TRUE(v2->layer() != NULL); |
EXPECT_EQ(root_layer, v2->layer()->parent()); |
@@ -3792,13 +3792,13 @@ TEST_F(ViewLayerTest, NestedLayerToggling) { |
v1->AddChildView(v2); |
View* v3 = new View; |
- v3->SetPaintToLayer(true); |
+ v3->SetPaintToLayer(); |
v2->AddChildView(v3); |
ASSERT_TRUE(v3->layer() != NULL); |
// At this point we have v1-v2-v3. v3 has a layer, v1 and v2 don't. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
EXPECT_EQ(v1->layer(), v3->layer()->parent()); |
} |
@@ -3808,7 +3808,7 @@ TEST_F(ViewLayerTest, LayerAnimator) { |
View* v1 = new View; |
content_view->AddChildView(v1); |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
EXPECT_TRUE(v1->layer() != NULL); |
TestLayerAnimator* animator = new TestLayerAnimator(); |
@@ -3834,7 +3834,7 @@ TEST_F(ViewLayerTest, BoundsChangeWithLayer) { |
View* v2 = new View; |
v2->SetBoundsRect(gfx::Rect(10, 11, 40, 50)); |
v1->AddChildView(v2); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
ASSERT_TRUE(v2->layer() != NULL); |
EXPECT_EQ(gfx::Rect(30, 41, 40, 50), v2->layer()->bounds()); |
@@ -3866,7 +3866,7 @@ TEST_F(ViewLayerTest, BoundInRTL) { |
// |v1| is initially not attached to anything. So its layer will have the same |
// bounds as the view. |
View* v1 = new View; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
v1->SetBounds(10, 10, 20, 10); |
EXPECT_EQ(gfx::Rect(10, 10, 20, 10), |
v1->layer()->bounds()); |
@@ -3884,12 +3884,12 @@ TEST_F(ViewLayerTest, BoundInRTL) { |
v2->SetBounds(50, 10, 30, 10); |
EXPECT_FALSE(v2->layer()); |
view->AddChildView(v2); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
EXPECT_EQ(gfx::Rect(content_width - 80, 10, 30, 10), |
v2->layer()->bounds()); |
gfx::Rect l2bounds = v2->layer()->bounds(); |
- view->SetPaintToLayer(true); |
+ view->SetPaintToLayer(); |
EXPECT_EQ(l1bounds, v1->layer()->bounds()); |
EXPECT_EQ(l2bounds, v2->layer()->bounds()); |
@@ -3899,7 +3899,7 @@ TEST_F(ViewLayerTest, BoundInRTL) { |
l1bounds.set_x(l1bounds.x() + 5); |
EXPECT_EQ(l1bounds, v1->layer()->bounds()); |
- view->SetPaintToLayer(false); |
+ view->DestroyLayer(); |
EXPECT_EQ(l1bounds, v1->layer()->bounds()); |
EXPECT_EQ(l2bounds, v2->layer()->bounds()); |
@@ -3920,7 +3920,7 @@ TEST_F(ViewLayerTest, ResizeParentInRTL) { |
// Create a paints-to-layer view |v1|. |
View* v1 = new View; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
v1->SetBounds(10, 10, 20, 10); |
view->AddChildView(v1); |
EXPECT_EQ(gfx::Rect(content_width - 30, 10, 20, 10), |
@@ -3928,7 +3928,7 @@ TEST_F(ViewLayerTest, ResizeParentInRTL) { |
// Attach a paints-to-layer child view to |v1|. |
View* v2 = new View; |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
v2->SetBounds(3, 5, 6, 4); |
EXPECT_EQ(gfx::Rect(3, 5, 6, 4), |
v2->layer()->bounds()); |
@@ -3941,7 +3941,7 @@ TEST_F(ViewLayerTest, ResizeParentInRTL) { |
View* v3 = new View; |
v3->SetBounds(1, 1, 18, 8); |
View* v4 = new View; |
- v4->SetPaintToLayer(true); |
+ v4->SetPaintToLayer(); |
v4->SetBounds(2, 4, 6, 4); |
EXPECT_EQ(gfx::Rect(2, 4, 6, 4), |
v4->layer()->bounds()); |
@@ -4013,7 +4013,7 @@ TEST_F(ViewLayerTest, ToggleVisibilityWithLayer) { |
// still have a layer, but the layer should not be attached to the root |
// layer. |
View* v1 = new View; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
EXPECT_TRUE(v1->layer()); |
EXPECT_FALSE(LayerIsAncestor(widget()->GetCompositor()->root_layer(), |
v1->layer())); |
@@ -4049,7 +4049,7 @@ TEST_F(ViewLayerTest, OrphanLayerAfterViewRemove) { |
View* v2 = new View; |
v1->AddChildView(v2); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
EXPECT_TRUE(LayerIsAncestor(widget()->GetCompositor()->root_layer(), |
v2->layer())); |
EXPECT_TRUE(v2->layer()->IsDrawn()); |
@@ -4092,7 +4092,7 @@ TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { |
return; |
PaintTrackingView* content_view = new PaintTrackingView; |
widget()->SetContentsView(content_view); |
- content_view->SetPaintToLayer(true); |
+ content_view->SetPaintToLayer(); |
GetRootLayer()->GetCompositor()->ScheduleDraw(); |
ui::DrawWaiterForTest::WaitForCompositingEnded( |
GetRootLayer()->GetCompositor()); |
@@ -4142,7 +4142,7 @@ TEST_F(ViewLayerTest, ParentPaintWhenSwitchingPaintToLayerFromFalseToTrue) { |
parent_view.AddChildView(child_view); |
parent_view.scheduled_paint_rects_.clear(); |
- child_view->SetPaintToLayer(true); |
+ child_view->SetPaintToLayer(); |
EXPECT_EQ(1U, parent_view.scheduled_paint_rects_.size()); |
} |
@@ -4151,7 +4151,7 @@ TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) { |
parent_view.SetBounds(10, 11, 12, 13); |
TestView* child_view = new TestView; |
- child_view->SetPaintToLayer(true); |
+ child_view->SetPaintToLayer(); |
parent_view.AddChildView(child_view); |
parent_view.scheduled_paint_rects_.clear(); |
@@ -4162,7 +4162,7 @@ TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) { |
// visibility changes. |
TEST_F(ViewLayerTest, VisibilityChildLayers) { |
View* v1 = new View; |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
widget()->SetContentsView(v1); |
View* v2 = new View; |
@@ -4173,7 +4173,7 @@ TEST_F(ViewLayerTest, VisibilityChildLayers) { |
v3->SetVisible(false); |
View* v4 = new View; |
- v4->SetPaintToLayer(true); |
+ v4->SetPaintToLayer(); |
v3->AddChildView(v4); |
EXPECT_TRUE(v1->layer()->IsDrawn()); |
@@ -4209,7 +4209,7 @@ TEST_F(ViewLayerTest, VisibilityChildLayers) { |
// marking this as FLAKY. |
TEST_F(ViewLayerTest, DISABLED_ViewLayerTreesInSync) { |
View* content = new View; |
- content->SetPaintToLayer(true); |
+ content->SetPaintToLayer(); |
widget()->SetContentsView(content); |
widget()->Show(); |
@@ -4232,10 +4232,10 @@ TEST_F(ViewLayerTest, ReorderUnderWidget) { |
View* content = new View; |
widget()->SetContentsView(content); |
View* c1 = new View; |
- c1->SetPaintToLayer(true); |
+ c1->SetPaintToLayer(); |
content->AddChildView(c1); |
View* c2 = new View; |
- c2->SetPaintToLayer(true); |
+ c2->SetPaintToLayer(); |
content->AddChildView(c2); |
ui::Layer* parent_layer = c1->layer()->parent(); |
@@ -4255,7 +4255,7 @@ TEST_F(ViewLayerTest, AcquireLayer) { |
View* content = new View; |
widget()->SetContentsView(content); |
std::unique_ptr<View> c1(new View); |
- c1->SetPaintToLayer(true); |
+ c1->SetPaintToLayer(); |
EXPECT_TRUE(c1->layer()); |
content->AddChildView(c1.get()); |
@@ -4272,13 +4272,13 @@ TEST_F(ViewLayerTest, AcquireLayer) { |
// Verify the z-order of the layers as a result of calling RecreateLayer(). |
TEST_F(ViewLayerTest, RecreateLayerZOrder) { |
std::unique_ptr<View> v(new View()); |
- v->SetPaintToLayer(true); |
+ v->SetPaintToLayer(); |
View* v1 = new View(); |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
v->AddChildView(v1); |
View* v2 = new View(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
v->AddChildView(v2); |
// Test the initial z-order. |
@@ -4305,10 +4305,10 @@ TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) { |
widget()->SetContentsView(v); |
View* v1 = new View(); |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
v->AddChildView(v1); |
View* v2 = new View(); |
- v2->SetPaintToLayer(true); |
+ v2->SetPaintToLayer(); |
v->AddChildView(v2); |
ui::Layer* root_layer = GetRootLayer(); |
@@ -4333,9 +4333,9 @@ TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) { |
// a View. |
TEST_F(ViewLayerTest, RecreateLayerMovesNonViewChildren) { |
View v; |
- v.SetPaintToLayer(true); |
+ v.SetPaintToLayer(); |
View child; |
- child.SetPaintToLayer(true); |
+ child.SetPaintToLayer(); |
v.AddChildView(&child); |
ASSERT_TRUE(v.layer() != NULL); |
ASSERT_EQ(1u, v.layer()->children().size()); |
@@ -4379,12 +4379,12 @@ TEST_F(ViewLayerTest, SnapLayerToPixel) { |
v11->SetBoundsRect(gfx::Rect(1, 1, 10, 10)); |
v1->SetBoundsRect(gfx::Rect(1, 1, 10, 10)); |
- v11->SetPaintToLayer(true); |
+ v11->SetPaintToLayer(); |
EXPECT_EQ("0.40 0.40", ToString(v11->layer()->subpixel_position_offset())); |
// Creating a layer in parent should update the child view's layer offset. |
- v1->SetPaintToLayer(true); |
+ v1->SetPaintToLayer(); |
EXPECT_EQ("-0.20 -0.20", ToString(v1->layer()->subpixel_position_offset())); |
EXPECT_EQ("-0.20 -0.20", ToString(v11->layer()->subpixel_position_offset())); |
@@ -4394,7 +4394,7 @@ TEST_F(ViewLayerTest, SnapLayerToPixel) { |
EXPECT_EQ("0.33 0.33", ToString(v11->layer()->subpixel_position_offset())); |
// Deleting parent's layer should update the child view's layer's offset. |
- v1->SetPaintToLayer(false); |
+ v1->DestroyLayer(); |
EXPECT_EQ("0.00 0.00", ToString(v11->layer()->subpixel_position_offset())); |
// Setting parent view should update the child view's layer's offset. |
@@ -4545,7 +4545,7 @@ class WidgetWithCustomTheme : public Widget { |
// See comment above test for details. |
class ViewThatAddsViewInOnNativeThemeChanged : public View { |
public: |
- ViewThatAddsViewInOnNativeThemeChanged() { SetPaintToLayer(true); } |
+ ViewThatAddsViewInOnNativeThemeChanged() { SetPaintToLayer(); } |
~ViewThatAddsViewInOnNativeThemeChanged() override {} |
bool on_native_theme_changed_called() const { |
@@ -4592,7 +4592,7 @@ class TestNativeTheme : public ui::NativeTheme { |
// Creates and adds a new child view to |parent| that has a layer. |
void AddViewWithChildLayer(View* parent) { |
View* child = new View; |
- child->SetPaintToLayer(true); |
+ child->SetPaintToLayer(); |
parent->AddChildView(child); |
} |
@@ -4623,7 +4623,7 @@ TEST_F(ViewTest, CrashOnAddFromFromOnNativeThemeChanged) { |
class NoLayerWhenHiddenView : public View { |
public: |
NoLayerWhenHiddenView() { |
- SetPaintToLayer(true); |
+ SetPaintToLayer(); |
set_owned_by_client(); |
SetBounds(0, 0, 100, 100); |
} |
@@ -4634,7 +4634,7 @@ class NoLayerWhenHiddenView : public View { |
void VisibilityChanged(View* starting_from, bool is_visible) override { |
if (!is_visible) { |
was_hidden_ = true; |
- SetPaintToLayer(false); |
+ DestroyLayer(); |
} |
} |
@@ -4701,7 +4701,7 @@ class OrderableView : public View { |
TEST_F(ViewTest, ChildViewZOrderChanged) { |
const int kChildrenCount = 4; |
std::unique_ptr<View> view(new OrderableView()); |
- view->SetPaintToLayer(true); |
+ view->SetPaintToLayer(); |
for (int i = 0; i < kChildrenCount; ++i) |
AddViewWithChildLayer(view.get()); |
View::Views children = view->GetChildrenInZOrder(); |