| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/test/null_task_runner.h" | 8 #include "base/test/null_task_runner.h" |
| 9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
| 10 #include "cc/layers/layer_settings.h" | 10 #include "cc/layers/layer_settings.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 transform.Scale(0.5f, 0.5f); | 221 transform.Scale(0.5f, 0.5f); |
| 222 child->SetTransform(transform); | 222 child->SetTransform(transform); |
| 223 } | 223 } |
| 224 | 224 |
| 225 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); | 225 scoped_ptr<Layer> layer_copy = owner.RecreateLayer(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Tests that if LayerOwner-derived class destroys layer, then | 228 // Tests that if LayerOwner-derived class destroys layer, then |
| 229 // LayerAnimator's player becomes detached from compositor timeline. | 229 // LayerAnimator's player becomes detached from compositor timeline. |
| 230 TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) { | 230 TEST_F(LayerOwnerTestWithCompositor, DetachTimelineOnAnimatorDeletion) { |
| 231 // This test is meaningless if CC timelines disabled. | |
| 232 if (!Layer::UILayerSettings().use_compositor_animation_timelines) | |
| 233 return; | |
| 234 | |
| 235 scoped_ptr<Layer> root_layer(new Layer); | 231 scoped_ptr<Layer> root_layer(new Layer); |
| 236 compositor()->SetRootLayer(root_layer.get()); | 232 compositor()->SetRootLayer(root_layer.get()); |
| 237 | 233 |
| 238 LayerOwnerForTesting owner; | 234 LayerOwnerForTesting owner; |
| 239 Layer* layer = new Layer; | 235 Layer* layer = new Layer; |
| 240 owner.SetLayer(layer); | 236 owner.SetLayer(layer); |
| 241 layer->SetOpacity(0.5f); | 237 layer->SetOpacity(0.5f); |
| 242 root_layer->Add(layer); | 238 root_layer->Add(layer); |
| 243 | 239 |
| 244 scoped_refptr<cc::AnimationPlayer> player = | 240 scoped_refptr<cc::AnimationPlayer> player = |
| 245 layer->GetAnimator()->GetAnimationPlayerForTesting(); | 241 layer->GetAnimator()->GetAnimationPlayerForTesting(); |
| 246 EXPECT_TRUE(player); | 242 EXPECT_TRUE(player); |
| 247 EXPECT_TRUE(player->animation_timeline()); | 243 EXPECT_TRUE(player->animation_timeline()); |
| 248 | 244 |
| 249 // Destroying layer/animator must detach animator's player from timeline. | 245 // Destroying layer/animator must detach animator's player from timeline. |
| 250 owner.DestroyLayerForTesting(); | 246 owner.DestroyLayerForTesting(); |
| 251 EXPECT_FALSE(player->animation_timeline()); | 247 EXPECT_FALSE(player->animation_timeline()); |
| 252 } | 248 } |
| 253 | 249 |
| 254 // Tests that if we run threaded opacity animation on already added layer | 250 // Tests that if we run threaded opacity animation on already added layer |
| 255 // then LayerAnimator's player becomes attached to timeline. | 251 // then LayerAnimator's player becomes attached to timeline. |
| 256 TEST_F(LayerOwnerTestWithCompositor, | 252 TEST_F(LayerOwnerTestWithCompositor, |
| 257 AttachTimelineIfAnimatorCreatedAfterSetCompositor) { | 253 AttachTimelineIfAnimatorCreatedAfterSetCompositor) { |
| 258 // This test is meaningless if CC timelines disabled. | |
| 259 if (!Layer::UILayerSettings().use_compositor_animation_timelines) | |
| 260 return; | |
| 261 | |
| 262 scoped_ptr<Layer> root_layer(new Layer); | 254 scoped_ptr<Layer> root_layer(new Layer); |
| 263 compositor()->SetRootLayer(root_layer.get()); | 255 compositor()->SetRootLayer(root_layer.get()); |
| 264 | 256 |
| 265 LayerOwner owner; | 257 LayerOwner owner; |
| 266 Layer* layer = new Layer; | 258 Layer* layer = new Layer; |
| 267 owner.SetLayer(layer); | 259 owner.SetLayer(layer); |
| 268 root_layer->Add(layer); | 260 root_layer->Add(layer); |
| 269 | 261 |
| 270 layer->SetOpacity(0.5f); | 262 layer->SetOpacity(0.5f); |
| 271 | 263 |
| 272 scoped_refptr<cc::AnimationPlayer> player = | 264 scoped_refptr<cc::AnimationPlayer> player = |
| 273 layer->GetAnimator()->GetAnimationPlayerForTesting(); | 265 layer->GetAnimator()->GetAnimationPlayerForTesting(); |
| 274 EXPECT_TRUE(player); | 266 EXPECT_TRUE(player); |
| 275 EXPECT_TRUE(player->animation_timeline()); | 267 EXPECT_TRUE(player->animation_timeline()); |
| 276 } | 268 } |
| 277 | 269 |
| 278 } // namespace ui | 270 } // namespace ui |
| OLD | NEW |