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

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationStackTest.cpp

Issue 1417613005: Revert of Web Animations: Use a single animation clock (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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 "config.h" 5 #include "config.h"
6 #include "core/animation/AnimationStack.h" 6 #include "core/animation/AnimationStack.h"
7 7
8 #include "core/animation/AnimationClock.h" 8 #include "core/animation/AnimationClock.h"
9 #include "core/animation/AnimationTimeline.h" 9 #include "core/animation/AnimationTimeline.h"
10 #include "core/animation/ElementAnimations.h" 10 #include "core/animation/ElementAnimations.h"
11 #include "core/animation/KeyframeEffectModel.h" 11 #include "core/animation/KeyframeEffectModel.h"
12 #include "core/animation/LegacyStyleInterpolation.h" 12 #include "core/animation/LegacyStyleInterpolation.h"
13 #include "core/animation/animatable/AnimatableDouble.h" 13 #include "core/animation/animatable/AnimatableDouble.h"
14 #include "core/testing/DummyPageHolder.h"
15 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
16 15
17 namespace blink { 16 namespace blink {
18 17
19 class AnimationAnimationStackTest : public ::testing::Test { 18 class AnimationAnimationStackTest : public ::testing::Test {
20 protected: 19 protected:
21 virtual void SetUp() 20 virtual void SetUp()
22 { 21 {
23 pageHolder = DummyPageHolder::create(); 22 document = Document::create();
24 document = &pageHolder->document();
25 document->animationClock().resetTimeForTesting(); 23 document->animationClock().resetTimeForTesting();
26 timeline = AnimationTimeline::create(document.get()); 24 timeline = AnimationTimeline::create(document.get());
27 element = document->createElement("foo", ASSERT_NO_EXCEPTION); 25 element = document->createElement("foo", ASSERT_NO_EXCEPTION);
28 } 26 }
29 27
30 Animation* play(KeyframeEffect* effect, double startTime) 28 Animation* play(KeyframeEffect* effect, double startTime)
31 { 29 {
32 Animation* animation = timeline->play(effect); 30 Animation* animation = timeline->play(effect);
33 animation->setStartTime(startTime * 1000); 31 animation->setStartTime(startTime * 1000);
34 animation->update(TimingUpdateOnDemand); 32 animation->update(TimingUpdateOnDemand);
35 return animation; 33 return animation;
36 } 34 }
37 35
38 void updateTimeline(double time) 36 void updateTimeline(double time)
39 { 37 {
40 document->animationClock().updateTime(document->timeline().zeroTime() + time); 38 document->animationClock().updateTime(time);
41 timeline->serviceAnimations(TimingUpdateForAnimationFrame); 39 timeline->serviceAnimations(TimingUpdateForAnimationFrame);
42 } 40 }
43 41
44 const HeapVector<Member<SampledEffect>>& effects() 42 const HeapVector<Member<SampledEffect>>& effects()
45 { 43 {
46 return element->ensureElementAnimations().animationStack().m_effects; 44 return element->ensureElementAnimations().animationStack().m_effects;
47 } 45 }
48 46
49 EffectModel* makeEffectModel(CSSPropertyID id, PassRefPtr<AnimatableValue> v alue) 47 EffectModel* makeEffectModel(CSSPropertyID id, PassRefPtr<AnimatableValue> v alue)
50 { 48 {
(...skipping 21 matching lines...) Expand all
72 timing.iterationDuration = duration; 70 timing.iterationDuration = duration;
73 return KeyframeEffect::create(element.get(), effect, timing); 71 return KeyframeEffect::create(element.get(), effect, timing);
74 } 72 }
75 73
76 AnimatableValue* interpolationValue(const ActiveInterpolationsMap& activeInt erpolations, CSSPropertyID id) 74 AnimatableValue* interpolationValue(const ActiveInterpolationsMap& activeInt erpolations, CSSPropertyID id)
77 { 75 {
78 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle( id)).at(0); 76 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle( id)).at(0);
79 return toLegacyStyleInterpolation(interpolation).currentValue().get(); 77 return toLegacyStyleInterpolation(interpolation).currentValue().get();
80 } 78 }
81 79
82 OwnPtr<DummyPageHolder> pageHolder;
83 RefPtrWillBePersistent<Document> document; 80 RefPtrWillBePersistent<Document> document;
84 Persistent<AnimationTimeline> timeline; 81 Persistent<AnimationTimeline> timeline;
85 RefPtrWillBePersistent<Element> element; 82 RefPtrWillBePersistent<Element> element;
86 }; 83 };
87 84
88 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted) 85 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted)
89 { 86 {
90 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(1))), 10); 87 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(1))), 10);
91 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(2))), 15); 88 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(2))), 15);
92 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(3))), 5); 89 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(3))), 5);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ActiveInterpolationsMap result = AnimationStack::activeInterpolations(&eleme nt->elementAnimations()->animationStack(), 0, 0, KeyframeEffect::DefaultPriority ); 124 ActiveInterpolationsMap result = AnimationStack::activeInterpolations(&eleme nt->elementAnimations()->animationStack(), 0, 0, KeyframeEffect::DefaultPriority );
128 EXPECT_EQ(1u, result.size()); 125 EXPECT_EQ(1u, result.size());
129 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab leDouble::create(1).get())); 126 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab leDouble::create(1).get()));
130 127
131 animation->setEffect(0); 128 animation->setEffect(0);
132 result = AnimationStack::activeInterpolations(&element->elementAnimations()- >animationStack(), 0, 0, KeyframeEffect::DefaultPriority); 129 result = AnimationStack::activeInterpolations(&element->elementAnimations()- >animationStack(), 0, 0, KeyframeEffect::DefaultPriority);
133 EXPECT_EQ(0u, result.size()); 130 EXPECT_EQ(0u, result.size());
134 } 131 }
135 132
136 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698