Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: cc/layer_unittest.cc

Issue 12517003: cc: Chromify the Animation and LayerAnimationController classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_unittest_context.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/layer.h" 5 #include "cc/layer.h"
6 6
7 #include "cc/keyframed_animation_curve.h" 7 #include "cc/keyframed_animation_curve.h"
8 #include "cc/layer_impl.h" 8 #include "cc/layer_impl.h"
9 #include "cc/layer_painter.h" 9 #include "cc/layer_painter.h"
10 #include "cc/layer_tree_host.h" 10 #include "cc/layer_tree_host.h"
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 { 875 {
876 scoped_refptr<Layer> root = Layer::create(); 876 scoped_refptr<Layer> root = Layer::create();
877 scoped_refptr<Layer> child = Layer::create(); 877 scoped_refptr<Layer> child = Layer::create();
878 root->addChild(child); 878 root->addChild(child);
879 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e()); 879 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e());
880 layerTreeHost->setRootLayer(root); 880 layerTreeHost->setRootLayer(root);
881 } 881 }
882 882
883 static bool addTestAnimation(Layer* layer) 883 static bool addTestAnimation(Layer* layer)
884 { 884 {
885 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create()); 885 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :Create());
886 curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction> ())); 886 curve->AddKeyframe(FloatKeyframe::Create(0.0, 0.3f, scoped_ptr<TimingFunctio n>()));
887 curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction> ())); 887 curve->AddKeyframe(FloatKeyframe::Create(1.0, 0.7f, scoped_ptr<TimingFunctio n>()));
888 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv e>(), 0, 0, Animation::Opacity)); 888 scoped_ptr<Animation> animation(Animation::Create(curve.PassAs<AnimationCurv e>(), 0, 0, Animation::Opacity));
889 889
890 return layer->addAnimation(animation.Pass()); 890 return layer->AddAnimation(animation.Pass());
891 } 891 }
892 892
893 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutAnimationRegistrar) 893 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutAnimationRegistrar)
894 { 894 {
895 scoped_refptr<Layer> layer = Layer::create(); 895 scoped_refptr<Layer> layer = Layer::create();
896 896
897 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the 897 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the
898 // animation should not be accepted. 898 // animation should not be accepted.
899 EXPECT_FALSE(addTestAnimation(layer.get())); 899 EXPECT_FALSE(addTestAnimation(layer.get()));
900 900
901 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create(); 901 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::create();
902 layer->layerAnimationController()->setAnimationRegistrar(registrar.get()); 902 layer->layerAnimationController()->SetAnimationRegistrar(registrar.get());
903 903
904 // Case 2: with an AnimationRegistrar, the animation should be accepted. 904 // Case 2: with an AnimationRegistrar, the animation should be accepted.
905 EXPECT_TRUE(addTestAnimation(layer.get())); 905 EXPECT_TRUE(addTestAnimation(layer.get()));
906 906
907 LayerTreeSettings settings; 907 LayerTreeSettings settings;
908 settings.acceleratedAnimationEnabled = false; 908 settings.acceleratedAnimationEnabled = false;
909 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e(settings)); 909 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e(settings));
910 layerTreeHost->setRootLayer(layer.get()); 910 layerTreeHost->setRootLayer(layer.get());
911 layer->setLayerTreeHost(layerTreeHost.get()); 911 layer->setLayerTreeHost(layerTreeHost.get());
912 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); 912 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get());
913 913
914 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the 914 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the
915 // animation should be rejected. 915 // animation should be rejected.
916 EXPECT_FALSE(addTestAnimation(layer.get())); 916 EXPECT_FALSE(addTestAnimation(layer.get()));
917 } 917 }
918 918
919 } // namespace 919 } // namespace
920 } // namespace cc 920 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_unittest_context.cc ('k') | cc/test/animation_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698