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

Side by Side Diff: cc/layers/layer_unittest.cc

Issue 1101823002: CC Animations: Make LayerAnimationController creation optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use per-process global variable to create LAC Created 5 years, 7 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
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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "cc/animation/keyframed_animation_curve.h" 8 #include "cc/animation/keyframed_animation_curve.h"
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr)); 1148 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr));
1149 scoped_ptr<Animation> animation = 1149 scoped_ptr<Animation> animation =
1150 Animation::Create(curve.Pass(), 0, 0, Animation::OPACITY); 1150 Animation::Create(curve.Pass(), 0, 0, Animation::OPACITY);
1151 1151
1152 return layer->AddAnimation(animation.Pass()); 1152 return layer->AddAnimation(animation.Pass());
1153 } 1153 }
1154 1154
1155 TEST(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { 1155 TEST(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) {
1156 scoped_refptr<Layer> layer = Layer::Create(); 1156 scoped_refptr<Layer> layer = Layer::Create();
1157 1157
1158 LayerTreeSettings settings;
1159 settings.accelerated_animation_enabled = false;
1160
1158 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the 1161 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the
1159 // animation should not be accepted. 1162 // animation should not be accepted.
1160 EXPECT_FALSE(AddTestAnimation(layer.get())); 1163 EXPECT_FALSE(AddTestAnimation(layer.get()));
1161 1164
1162 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); 1165 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create();
1163 layer->layer_animation_controller()->SetAnimationRegistrar(registrar.get()); 1166 layer->RegisterForAnimations(registrar.get(), settings);
1164 1167
1165 // Case 2: with an AnimationRegistrar, the animation should be accepted. 1168 // Case 2: with an AnimationRegistrar, the animation should be accepted.
1166 EXPECT_TRUE(AddTestAnimation(layer.get())); 1169 EXPECT_TRUE(AddTestAnimation(layer.get()));
1167 1170
1168 LayerTreeSettings settings;
1169 settings.accelerated_animation_enabled = false;
1170 LayerTreeHostFactory factory; 1171 LayerTreeHostFactory factory;
1171 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); 1172 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings);
1172 layer_tree_host->SetRootLayer(layer); 1173 layer_tree_host->SetRootLayer(layer);
1173 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); 1174 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get());
1174 1175
1175 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the 1176 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the
1176 // animation should be rejected. 1177 // animation should be rejected.
1177 EXPECT_FALSE(AddTestAnimation(layer.get())); 1178 EXPECT_FALSE(AddTestAnimation(layer.get()));
1178 } 1179 }
1179 1180
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 // When the layer is destroyed, the other three requests should be aborted. 1317 // When the layer is destroyed, the other three requests should be aborted.
1317 layer = nullptr; 1318 layer = nullptr;
1318 EXPECT_EQ(1, did_receive_first_result_from_this_source); 1319 EXPECT_EQ(1, did_receive_first_result_from_this_source);
1319 EXPECT_EQ(1, did_receive_result_from_different_source); 1320 EXPECT_EQ(1, did_receive_result_from_different_source);
1320 EXPECT_EQ(1, did_receive_result_from_anonymous_source); 1321 EXPECT_EQ(1, did_receive_result_from_anonymous_source);
1321 EXPECT_EQ(1, did_receive_second_result_from_this_source); 1322 EXPECT_EQ(1, did_receive_second_result_from_this_source);
1322 } 1323 }
1323 1324
1324 } // namespace 1325 } // namespace
1325 } // namespace cc 1326 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698