Index: ui/compositor/layer_unittest.cc |
diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc |
index 00efb17664aa36bf8115cd6466d5487ab0ba6e78..eac9e825152689da93efc4d8bb8ab8881774be57 100644 |
--- a/ui/compositor/layer_unittest.cc |
+++ b/ui/compositor/layer_unittest.cc |
@@ -735,6 +735,7 @@ TEST_F(LayerWithDelegateTest, Cloning) { |
layer->SetLayerInverted(true); |
const float temperature = 0.8f; |
layer->SetLayerTemperature(temperature); |
+ layer->SetCacheRenderSurface(true); |
auto clone = layer->Clone(); |
@@ -744,6 +745,9 @@ TEST_F(LayerWithDelegateTest, Cloning) { |
EXPECT_EQ(SK_ColorRED, clone->GetTargetColor()); |
EXPECT_TRUE(clone->layer_inverted()); |
EXPECT_FLOAT_EQ(temperature, clone->GetTargetTemperature()); |
+ // Cloning should not preserve cache_render_surface flag. |
+ EXPECT_NE(layer->cc_layer_for_testing()->cache_render_surface(), |
+ clone->cc_layer_for_testing()->cache_render_surface()); |
layer->SetTransform(gfx::Transform()); |
layer->SetColor(SK_ColorGREEN); |
@@ -1997,6 +2001,23 @@ TEST_F(LayerWithRealCompositorTest, SwitchCCLayerSolidColorWhileAnimating) { |
EXPECT_EQ(transparent, root->GetTargetColor()); |
} |
+// Tests that when a layer with cache_render_surface flag has its CC layer |
+// switched, that the cache_render_surface flag is maintained. |
+TEST_F(LayerWithRealCompositorTest, SwitchCCLayerCacheRenderSurface) { |
+ std::unique_ptr<Layer> root(CreateLayer(LAYER_TEXTURED)); |
+ std::unique_ptr<Layer> l1(CreateLayer(LAYER_TEXTURED)); |
+ GetCompositor()->SetRootLayer(root.get()); |
+ root->Add(l1.get()); |
+ |
+ l1->SetCacheRenderSurface(true); |
+ |
+ // Change l1's cc::Layer. |
+ l1->SwitchCCLayerForTest(); |
+ |
+ // Ensure that the cache_render_surface flag is maintained. |
+ EXPECT_TRUE(l1->cc_layer_for_testing()->cache_render_surface()); |
+} |
+ |
// Tests that the animators in the layer tree is added to the |
// animator-collection when the root-layer is set to the compositor. |
TEST_F(LayerWithDelegateTest, RootLayerAnimatorsInCompositor) { |