OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/layer_owner.h" | 5 #include "ui/compositor/layer_owner.h" |
6 | 6 |
7 #include "base/test/null_task_runner.h" | 7 #include "base/test/null_task_runner.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/compositor/compositor.h" | 9 #include "ui/compositor/compositor.h" |
10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 EXPECT_TRUE(layer->visible()); | 94 EXPECT_TRUE(layer->visible()); |
95 EXPECT_EQ(1.0f, layer->opacity()); | 95 EXPECT_EQ(1.0f, layer->opacity()); |
96 EXPECT_EQ(SK_ColorRED, layer->background_color()); | 96 EXPECT_EQ(SK_ColorRED, layer->background_color()); |
97 | 97 |
98 scoped_ptr<Layer> old_layer(owner.RecreateLayer()); | 98 scoped_ptr<Layer> old_layer(owner.RecreateLayer()); |
99 EXPECT_FALSE(owner.layer()->visible()); | 99 EXPECT_FALSE(owner.layer()->visible()); |
100 EXPECT_EQ(0.0f, owner.layer()->opacity()); | 100 EXPECT_EQ(0.0f, owner.layer()->opacity()); |
101 EXPECT_EQ(SK_ColorGREEN, owner.layer()->background_color()); | 101 EXPECT_EQ(SK_ColorGREEN, owner.layer()->background_color()); |
102 } | 102 } |
103 | 103 |
| 104 // Tests that when a LAYER_SOLID_COLOR which is not backed by a SolidColorLayer |
| 105 // that opaqueness and color targets are maintained when the |
| 106 // LayerOwner::RecreateLayers is called. |
| 107 TEST(LayerOwnerTest, RecreateLayerSolidColorWithChangedCCLayerHonorsTargets) { |
| 108 SkColor transparent = SK_ColorTRANSPARENT; |
| 109 LayerOwner owner; |
| 110 Layer* layer = new Layer(LAYER_SOLID_COLOR); |
| 111 owner.SetLayer(layer); |
| 112 layer->SetFillsBoundsOpaquely(false); |
| 113 layer->SetColor(transparent); |
| 114 // Changing the backing layer takes LAYER_SOLID_COLOR off of the normal layer |
| 115 // flow, need to ensure that set values are maintained. |
| 116 layer->SwitchCCLayerForTest(); |
| 117 |
| 118 EXPECT_FALSE(layer->fills_bounds_opaquely()); |
| 119 EXPECT_EQ(transparent, layer->background_color()); |
| 120 EXPECT_EQ(transparent, layer->GetTargetColor()); |
| 121 |
| 122 scoped_ptr<Layer> old_layer(owner.RecreateLayer()); |
| 123 EXPECT_FALSE(owner.layer()->fills_bounds_opaquely()); |
| 124 EXPECT_EQ(transparent, owner.layer()->background_color()); |
| 125 EXPECT_EQ(transparent, owner.layer()->GetTargetColor()); |
| 126 } |
| 127 |
104 TEST(LayerOwnerTest, RecreateRootLayerWithNullCompositor) { | 128 TEST(LayerOwnerTest, RecreateRootLayerWithNullCompositor) { |
105 LayerOwner owner; | 129 LayerOwner owner; |
106 Layer* layer = new Layer; | 130 Layer* layer = new Layer; |
107 owner.SetLayer(layer); | 131 owner.SetLayer(layer); |
108 | 132 |
109 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); | 133 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); |
110 | 134 |
111 EXPECT_EQ(nullptr, owner.layer()->GetCompositor()); | 135 EXPECT_EQ(nullptr, owner.layer()->GetCompositor()); |
112 EXPECT_EQ(nullptr, layer_copy->GetCompositor()); | 136 EXPECT_EQ(nullptr, layer_copy->GetCompositor()); |
113 } | 137 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 animation.AddObserver(observer.get()); | 211 animation.AddObserver(observer.get()); |
188 gfx::Transform transform; | 212 gfx::Transform transform; |
189 transform.Scale(0.5f, 0.5f); | 213 transform.Scale(0.5f, 0.5f); |
190 child->SetTransform(transform); | 214 child->SetTransform(transform); |
191 } | 215 } |
192 | 216 |
193 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); | 217 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); |
194 } | 218 } |
195 | 219 |
196 } // namespace ui | 220 } // namespace ui |
OLD | NEW |