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

Side by Side Diff: cc/animation/element_animations_unittest.cc

Issue 2032643003: CC Animation: Erase EaseTimingFunction helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmock
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | cc/animation/keyframed_animation_curve_unittest.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/animation/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include "cc/animation/animation_delegate.h" 7 #include "cc/animation/animation_delegate.h"
8 #include "cc/animation/animation_host.h" 8 #include "cc/animation/animation_host.h"
9 #include "cc/animation/animation_id_provider.h" 9 #include "cc/animation/animation_id_provider.h"
10 #include "cc/animation/animation_player.h" 10 #include "cc/animation/animation_player.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing()); 261 EXPECT_FALSE(animations_impl->needs_to_start_animations_for_testing());
262 262
263 gfx::ScrollOffset initial_value(100.f, 300.f); 263 gfx::ScrollOffset initial_value(100.f, 300.f);
264 gfx::ScrollOffset provider_initial_value(150.f, 300.f); 264 gfx::ScrollOffset provider_initial_value(150.f, 300.f);
265 gfx::ScrollOffset target_value(300.f, 200.f); 265 gfx::ScrollOffset target_value(300.f, 200.f);
266 266
267 client_impl_.SetScrollOffsetForAnimation(provider_initial_value); 267 client_impl_.SetScrollOffsetForAnimation(provider_initial_value);
268 268
269 // Animation with initial value set. 269 // Animation with initial value set.
270 std::unique_ptr<ScrollOffsetAnimationCurve> curve_fixed( 270 std::unique_ptr<ScrollOffsetAnimationCurve> curve_fixed(
271 ScrollOffsetAnimationCurve::Create(target_value, 271 ScrollOffsetAnimationCurve::Create(
272 EaseInOutTimingFunction::Create())); 272 target_value, CubicBezierTimingFunction::CreatePreset(
273 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
273 curve_fixed->SetInitialValue(initial_value); 274 curve_fixed->SetInitialValue(initial_value);
274 const int animation1_id = 1; 275 const int animation1_id = 1;
275 std::unique_ptr<Animation> animation_fixed(Animation::Create( 276 std::unique_ptr<Animation> animation_fixed(Animation::Create(
276 std::move(curve_fixed), animation1_id, 0, TargetProperty::SCROLL_OFFSET)); 277 std::move(curve_fixed), animation1_id, 0, TargetProperty::SCROLL_OFFSET));
277 animations->AddAnimation(std::move(animation_fixed)); 278 animations->AddAnimation(std::move(animation_fixed));
278 animations->PushPropertiesTo(animations_impl.get()); 279 animations->PushPropertiesTo(animations_impl.get());
279 EXPECT_VECTOR2DF_EQ(initial_value, 280 EXPECT_VECTOR2DF_EQ(initial_value,
280 animations_impl->GetAnimationById(animation1_id) 281 animations_impl->GetAnimationById(animation1_id)
281 ->curve() 282 ->curve()
282 ->ToScrollOffsetAnimationCurve() 283 ->ToScrollOffsetAnimationCurve()
283 ->GetValue(base::TimeDelta())); 284 ->GetValue(base::TimeDelta()));
284 285
285 // Animation without initial value set. 286 // Animation without initial value set.
286 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 287 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
287 ScrollOffsetAnimationCurve::Create(target_value, 288 ScrollOffsetAnimationCurve::Create(
288 EaseInOutTimingFunction::Create())); 289 target_value, CubicBezierTimingFunction::CreatePreset(
290 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
289 const int animation2_id = 2; 291 const int animation2_id = 2;
290 std::unique_ptr<Animation> animation(Animation::Create( 292 std::unique_ptr<Animation> animation(Animation::Create(
291 std::move(curve), animation2_id, 0, TargetProperty::SCROLL_OFFSET)); 293 std::move(curve), animation2_id, 0, TargetProperty::SCROLL_OFFSET));
292 animations->AddAnimation(std::move(animation)); 294 animations->AddAnimation(std::move(animation));
293 animations->PushPropertiesTo(animations_impl.get()); 295 animations->PushPropertiesTo(animations_impl.get());
294 EXPECT_VECTOR2DF_EQ(provider_initial_value, 296 EXPECT_VECTOR2DF_EQ(provider_initial_value,
295 animations_impl->GetAnimationById(animation2_id) 297 animations_impl->GetAnimationById(animation2_id)
296 ->curve() 298 ->curve()
297 ->ToScrollOffsetAnimationCurve() 299 ->ToScrollOffsetAnimationCurve()
298 ->GetValue(base::TimeDelta())); 300 ->GetValue(base::TimeDelta()));
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 CreateImplTimelineAndPlayer(); 757 CreateImplTimelineAndPlayer();
756 758
757 scoped_refptr<ElementAnimations> animations = element_animations(); 759 scoped_refptr<ElementAnimations> animations = element_animations();
758 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 760 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
759 761
760 auto events = host_impl_->CreateEvents(); 762 auto events = host_impl_->CreateEvents();
761 763
762 gfx::ScrollOffset initial_value(100.f, 300.f); 764 gfx::ScrollOffset initial_value(100.f, 300.f);
763 gfx::ScrollOffset target_value(300.f, 200.f); 765 gfx::ScrollOffset target_value(300.f, 200.f);
764 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 766 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
765 ScrollOffsetAnimationCurve::Create(target_value, 767 ScrollOffsetAnimationCurve::Create(
766 EaseInOutTimingFunction::Create())); 768 target_value, CubicBezierTimingFunction::CreatePreset(
769 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
767 770
768 std::unique_ptr<Animation> animation( 771 std::unique_ptr<Animation> animation(
769 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 772 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
770 animation->set_needs_synchronized_start_time(true); 773 animation->set_needs_synchronized_start_time(true);
771 animations->AddAnimation(std::move(animation)); 774 animations->AddAnimation(std::move(animation));
772 775
773 client_impl_.SetScrollOffsetForAnimation(initial_value); 776 client_impl_.SetScrollOffsetForAnimation(initial_value);
774 animations->PushPropertiesTo(animations_impl.get()); 777 animations->PushPropertiesTo(animations_impl.get());
775 animations_impl->ActivateAnimations(); 778 animations_impl->ActivateAnimations();
776 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); 779 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 AttachTimelinePlayerLayer(); 836 AttachTimelinePlayerLayer();
834 CreateImplTimelineAndPlayer(); 837 CreateImplTimelineAndPlayer();
835 838
836 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 839 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
837 840
838 auto events = host_impl_->CreateEvents(); 841 auto events = host_impl_->CreateEvents();
839 842
840 gfx::ScrollOffset initial_value(100.f, 300.f); 843 gfx::ScrollOffset initial_value(100.f, 300.f);
841 gfx::ScrollOffset target_value(300.f, 200.f); 844 gfx::ScrollOffset target_value(300.f, 200.f);
842 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 845 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
843 ScrollOffsetAnimationCurve::Create(target_value, 846 ScrollOffsetAnimationCurve::Create(
844 EaseInOutTimingFunction::Create())); 847 target_value, CubicBezierTimingFunction::CreatePreset(
848 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
845 curve->SetInitialValue(initial_value); 849 curve->SetInitialValue(initial_value);
846 double duration_in_seconds = curve->Duration().InSecondsF(); 850 double duration_in_seconds = curve->Duration().InSecondsF();
847 851
848 std::unique_ptr<Animation> animation( 852 std::unique_ptr<Animation> animation(
849 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 853 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
850 animation->set_is_impl_only(true); 854 animation->set_is_impl_only(true);
851 animations_impl->AddAnimation(std::move(animation)); 855 animations_impl->AddAnimation(std::move(animation));
852 856
853 animations_impl->Animate(kInitialTickTime); 857 animations_impl->Animate(kInitialTickTime);
854 animations_impl->UpdateState(true, events.get()); 858 animations_impl->UpdateState(true, events.get());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 896 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
893 897
894 EXPECT_TRUE(animations_impl->has_element_in_pending_list()); 898 EXPECT_TRUE(animations_impl->has_element_in_pending_list());
895 EXPECT_FALSE(animations_impl->has_element_in_active_list()); 899 EXPECT_FALSE(animations_impl->has_element_in_active_list());
896 900
897 auto events = host_impl_->CreateEvents(); 901 auto events = host_impl_->CreateEvents();
898 902
899 gfx::ScrollOffset initial_value(500.f, 100.f); 903 gfx::ScrollOffset initial_value(500.f, 100.f);
900 gfx::ScrollOffset target_value(300.f, 200.f); 904 gfx::ScrollOffset target_value(300.f, 200.f);
901 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 905 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
902 ScrollOffsetAnimationCurve::Create(target_value, 906 ScrollOffsetAnimationCurve::Create(
903 EaseInOutTimingFunction::Create())); 907 target_value, CubicBezierTimingFunction::CreatePreset(
908 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
904 909
905 std::unique_ptr<Animation> animation( 910 std::unique_ptr<Animation> animation(
906 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 911 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
907 animation->set_needs_synchronized_start_time(true); 912 animation->set_needs_synchronized_start_time(true);
908 animations->AddAnimation(std::move(animation)); 913 animations->AddAnimation(std::move(animation));
909 914
910 client_.SetScrollOffsetForAnimation(initial_value); 915 client_.SetScrollOffsetForAnimation(initial_value);
911 animations->PushPropertiesTo(animations_impl.get()); 916 animations->PushPropertiesTo(animations_impl.get());
912 animations_impl->ActivateAnimations(); 917 animations_impl->ActivateAnimations();
913 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET)); 918 EXPECT_TRUE(animations_impl->GetAnimation(TargetProperty::SCROLL_OFFSET));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 CreateImplTimelineAndPlayer(); 985 CreateImplTimelineAndPlayer();
981 986
982 scoped_refptr<ElementAnimations> animations = element_animations(); 987 scoped_refptr<ElementAnimations> animations = element_animations();
983 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 988 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
984 989
985 auto events = host_impl_->CreateEvents(); 990 auto events = host_impl_->CreateEvents();
986 991
987 // First test the 1-argument version of RemoveAnimation. 992 // First test the 1-argument version of RemoveAnimation.
988 gfx::ScrollOffset target_value(300.f, 200.f); 993 gfx::ScrollOffset target_value(300.f, 200.f);
989 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 994 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
990 ScrollOffsetAnimationCurve::Create(target_value, 995 ScrollOffsetAnimationCurve::Create(
991 EaseInOutTimingFunction::Create())); 996 target_value, CubicBezierTimingFunction::CreatePreset(
997 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
992 998
993 int animation_id = 1; 999 int animation_id = 1;
994 std::unique_ptr<Animation> animation(Animation::Create( 1000 std::unique_ptr<Animation> animation(Animation::Create(
995 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); 1001 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET));
996 animation->set_needs_synchronized_start_time(true); 1002 animation->set_needs_synchronized_start_time(true);
997 animations->AddAnimation(std::move(animation)); 1003 animations->AddAnimation(std::move(animation));
998 animations->PushPropertiesTo(animations_impl.get()); 1004 animations->PushPropertiesTo(animations_impl.get());
999 animations_impl->ActivateAnimations(); 1005 animations_impl->ActivateAnimations();
1000 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); 1006 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted());
1001 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); 1007 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted());
1002 1008
1003 animations->RemoveAnimation(animation_id); 1009 animations->RemoveAnimation(animation_id);
1004 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted()); 1010 EXPECT_TRUE(animations->scroll_offset_animation_was_interrupted());
1005 1011
1006 animations->PushPropertiesTo(animations_impl.get()); 1012 animations->PushPropertiesTo(animations_impl.get());
1007 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted()); 1013 EXPECT_TRUE(animations_impl->scroll_offset_animation_was_interrupted());
1008 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); 1014 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted());
1009 1015
1010 animations_impl->ActivateAnimations(); 1016 animations_impl->ActivateAnimations();
1011 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); 1017 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted());
1012 1018
1013 // Now, test the 2-argument version of RemoveAnimation. 1019 // Now, test the 2-argument version of RemoveAnimation.
1014 curve = ScrollOffsetAnimationCurve::Create(target_value, 1020 curve = ScrollOffsetAnimationCurve::Create(
1015 EaseInOutTimingFunction::Create()); 1021 target_value, CubicBezierTimingFunction::CreatePreset(
1022 CubicBezierTimingFunction::EaseType::EASE_IN_OUT));
1016 animation = Animation::Create(std::move(curve), animation_id, 0, 1023 animation = Animation::Create(std::move(curve), animation_id, 0,
1017 TargetProperty::SCROLL_OFFSET); 1024 TargetProperty::SCROLL_OFFSET);
1018 animation->set_needs_synchronized_start_time(true); 1025 animation->set_needs_synchronized_start_time(true);
1019 animations->AddAnimation(std::move(animation)); 1026 animations->AddAnimation(std::move(animation));
1020 animations->PushPropertiesTo(animations_impl.get()); 1027 animations->PushPropertiesTo(animations_impl.get());
1021 animations_impl->ActivateAnimations(); 1028 animations_impl->ActivateAnimations();
1022 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted()); 1029 EXPECT_FALSE(animations->scroll_offset_animation_was_interrupted());
1023 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted()); 1030 EXPECT_FALSE(animations_impl->scroll_offset_animation_was_interrupted());
1024 1031
1025 animations->RemoveAnimation(animation_id); 1032 animations->RemoveAnimation(animation_id);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl(); 1088 scoped_refptr<ElementAnimations> animations_impl = element_animations_impl();
1082 1089
1083 auto events = host_impl_->CreateEvents(); 1090 auto events = host_impl_->CreateEvents();
1084 1091
1085 TestAnimationDelegate delegate; 1092 TestAnimationDelegate delegate;
1086 player_impl_->set_animation_delegate(&delegate); 1093 player_impl_->set_animation_delegate(&delegate);
1087 1094
1088 gfx::ScrollOffset initial_value(100.f, 300.f); 1095 gfx::ScrollOffset initial_value(100.f, 300.f);
1089 gfx::ScrollOffset target_value(300.f, 200.f); 1096 gfx::ScrollOffset target_value(300.f, 200.f);
1090 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 1097 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
1091 ScrollOffsetAnimationCurve::Create(target_value, 1098 ScrollOffsetAnimationCurve::Create(
1092 EaseInOutTimingFunction::Create())); 1099 target_value, CubicBezierTimingFunction::CreatePreset(
1100 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
1093 curve->SetInitialValue(initial_value); 1101 curve->SetInitialValue(initial_value);
1094 TimeDelta duration = curve->Duration(); 1102 TimeDelta duration = curve->Duration();
1095 std::unique_ptr<Animation> to_add( 1103 std::unique_ptr<Animation> to_add(
1096 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET)); 1104 Animation::Create(std::move(curve), 1, 0, TargetProperty::SCROLL_OFFSET));
1097 to_add->set_is_impl_only(true); 1105 to_add->set_is_impl_only(true);
1098 animations_impl->AddAnimation(std::move(to_add)); 1106 animations_impl->AddAnimation(std::move(to_add));
1099 1107
1100 EXPECT_FALSE(delegate.started()); 1108 EXPECT_FALSE(delegate.started());
1101 EXPECT_FALSE(delegate.finished()); 1109 EXPECT_FALSE(delegate.finished());
1102 1110
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 TestAnimationDelegate delegate_impl; 1910 TestAnimationDelegate delegate_impl;
1903 player_impl_->set_animation_delegate(&delegate_impl); 1911 player_impl_->set_animation_delegate(&delegate_impl);
1904 TestAnimationDelegate delegate; 1912 TestAnimationDelegate delegate;
1905 player_->set_animation_delegate(&delegate); 1913 player_->set_animation_delegate(&delegate);
1906 1914
1907 // Add impl-only scroll offset animation. 1915 // Add impl-only scroll offset animation.
1908 const int animation_id = 1; 1916 const int animation_id = 1;
1909 gfx::ScrollOffset initial_value(100.f, 300.f); 1917 gfx::ScrollOffset initial_value(100.f, 300.f);
1910 gfx::ScrollOffset target_value(300.f, 200.f); 1918 gfx::ScrollOffset target_value(300.f, 200.f);
1911 std::unique_ptr<ScrollOffsetAnimationCurve> curve( 1919 std::unique_ptr<ScrollOffsetAnimationCurve> curve(
1912 ScrollOffsetAnimationCurve::Create(target_value, 1920 ScrollOffsetAnimationCurve::Create(
1913 EaseInOutTimingFunction::Create())); 1921 target_value, CubicBezierTimingFunction::CreatePreset(
1922 CubicBezierTimingFunction::EaseType::EASE_IN_OUT)));
1914 curve->SetInitialValue(initial_value); 1923 curve->SetInitialValue(initial_value);
1915 std::unique_ptr<Animation> animation(Animation::Create( 1924 std::unique_ptr<Animation> animation(Animation::Create(
1916 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET)); 1925 std::move(curve), animation_id, 0, TargetProperty::SCROLL_OFFSET));
1917 animation->set_start_time(TicksFromSecondsF(123)); 1926 animation->set_start_time(TicksFromSecondsF(123));
1918 animation->set_is_impl_only(true); 1927 animation->set_is_impl_only(true);
1919 animations_impl->AddAnimation(std::move(animation)); 1928 animations_impl->AddAnimation(std::move(animation));
1920 1929
1921 animations->PushPropertiesTo(animations_impl.get()); 1930 animations->PushPropertiesTo(animations_impl.get());
1922 animations_impl->ActivateAnimations(); 1931 animations_impl->ActivateAnimations();
1923 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id)); 1932 EXPECT_TRUE(animations_impl->GetAnimationById(animation_id));
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after
3389 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty( 3398 EXPECT_FALSE(animations->IsPotentiallyAnimatingProperty(
3390 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3399 TargetProperty::OPACITY, ElementListType::ACTIVE));
3391 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3400 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3392 TargetProperty::OPACITY, ElementListType::PENDING)); 3401 TargetProperty::OPACITY, ElementListType::PENDING));
3393 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty( 3402 EXPECT_FALSE(animations->IsCurrentlyAnimatingProperty(
3394 TargetProperty::OPACITY, ElementListType::ACTIVE)); 3403 TargetProperty::OPACITY, ElementListType::ACTIVE));
3395 } 3404 }
3396 3405
3397 } // namespace 3406 } // namespace
3398 } // namespace cc 3407 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/animation/keyframed_animation_curve_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698