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 "config.h" | 5 #include "config.h" |
6 #include "core/animation/AnimationStack.h" | 6 #include "core/animation/AnimationStack.h" |
7 | 7 |
8 #include "core/animation/ActiveAnimations.h" | 8 #include "core/animation/ActiveAnimations.h" |
9 #include "core/animation/AnimationClock.h" | 9 #include "core/animation/AnimationClock.h" |
10 #include "core/animation/AnimationTimeline.h" | 10 #include "core/animation/AnimationTimeline.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 RefPtrWillBePersistent<Element> element; | 81 RefPtrWillBePersistent<Element> element; |
82 }; | 82 }; |
83 | 83 |
84 TEST_F(AnimationAnimationStackTest, ActiveAnimationsSorted) | 84 TEST_F(AnimationAnimationStackTest, ActiveAnimationsSorted) |
85 { | 85 { |
86 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 10); | 86 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 10); |
87 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(2))).get(), 15); | 87 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(2))).get(), 15); |
88 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(3))).get(), 5); | 88 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(3))).get(), 5); |
89 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result
= AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStac
k(), 0, 0, Animation::DefaultPriority, 0); | 89 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result
= AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStac
k(), 0, 0, Animation::DefaultPriority, 0); |
90 EXPECT_EQ(1u, result.size()); | 90 EXPECT_EQ(1u, result.size()); |
91 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize))->equals(Anim
atableDouble::create(2).get())); | 91 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize))->equals(Anim
atableDouble::create(3).get())); |
92 } | 92 } |
93 | 93 |
94 TEST_F(AnimationAnimationStackTest, NewAnimations) | 94 TEST_F(AnimationAnimationStackTest, NewAnimations) |
95 { | 95 { |
96 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 15); | 96 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 15); |
97 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))).get(), 10); | 97 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))).get(), 10); |
98 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newAnimations; | 98 WillBeHeapVector<RawPtrWillBeMember<InertAnimation> > newAnimations; |
99 RefPtrWillBeRawPtr<InertAnimation> inert1 = makeInertAnimation(makeAnimation
Effect(CSSPropertyFontSize, AnimatableDouble::create(3))); | 99 RefPtrWillBeRawPtr<InertAnimation> inert1 = makeInertAnimation(makeAnimation
Effect(CSSPropertyFontSize, AnimatableDouble::create(3))); |
100 RefPtrWillBeRawPtr<InertAnimation> inert2 = makeInertAnimation(makeAnimation
Effect(CSSPropertyZIndex, AnimatableDouble::create(4))); | 100 RefPtrWillBeRawPtr<InertAnimation> inert2 = makeInertAnimation(makeAnimation
Effect(CSSPropertyZIndex, AnimatableDouble::create(4))); |
101 newAnimations.append(inert1.get()); | 101 newAnimations.append(inert1.get()); |
102 newAnimations.append(inert2.get()); | 102 newAnimations.append(inert2.get()); |
103 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result
= AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStac
k(), &newAnimations, 0, Animation::DefaultPriority, 10); | 103 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result
= AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStac
k(), &newAnimations, 0, Animation::DefaultPriority, 10); |
104 EXPECT_EQ(2u, result.size()); | 104 EXPECT_EQ(2u, result.size()); |
105 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize))->equals(Anim
atableDouble::create(1).get())); | 105 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize))->equals(Anim
atableDouble::create(3).get())); |
106 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyZIndex))->equals(Animat
ableDouble::create(4).get())); | 106 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyZIndex))->equals(Animat
ableDouble::create(4).get())); |
107 } | 107 } |
108 | 108 |
109 TEST_F(AnimationAnimationStackTest, CancelledAnimationPlayers) | 109 TEST_F(AnimationAnimationStackTest, CancelledAnimationPlayers) |
110 { | 110 { |
111 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> > cancelledAnima
tionPlayers; | 111 WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> > cancelledAnima
tionPlayers; |
112 RefPtrWillBeRawPtr<AnimationPlayer> player = play(makeAnimation(makeAnimatio
nEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 0); | 112 RefPtrWillBeRawPtr<AnimationPlayer> player = play(makeAnimation(makeAnimatio
nEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 0); |
113 cancelledAnimationPlayers.add(player.get()); | 113 cancelledAnimationPlayers.add(player.get()); |
114 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))).get(), 0); | 114 play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::
create(2))).get(), 0); |
115 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result
= AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStac
k(), 0, &cancelledAnimationPlayers, Animation::DefaultPriority, 0); | 115 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result
= AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStac
k(), 0, &cancelledAnimationPlayers, Animation::DefaultPriority, 0); |
116 EXPECT_EQ(1u, result.size()); | 116 EXPECT_EQ(1u, result.size()); |
117 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyZIndex))->equals(Animat
ableDouble::create(2).get())); | 117 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyZIndex))->equals(Animat
ableDouble::create(2).get())); |
118 } | 118 } |
119 | 119 |
120 TEST_F(AnimationAnimationStackTest, ForwardsFillDiscarding) | 120 TEST_F(AnimationAnimationStackTest, ForwardsFillDiscarding) |
121 { | 121 { |
122 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 2); | 122 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(1))).get(), 2); |
123 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(2))).get(), 6); | 123 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(2))).get(), 6); |
124 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(3))).get(), 4); | 124 play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble
::create(3))).get(), 4); |
125 document->compositorPendingAnimations().startPendingAnimations(); | 125 document->compositorPendingAnimations().startPendingAnimations(); |
126 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > interpo
lations; | 126 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > interpo
lations; |
127 | 127 |
128 updateTimeline(11); | 128 updateTimeline(11); |
129 Heap::collectAllGarbage(); | 129 Heap::collectAllGarbage(); |
130 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); | 130 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); |
131 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(2).get())); | 131 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); |
132 EXPECT_EQ(3u, effects().size()); | 132 EXPECT_EQ(3u, effects().size()); |
133 EXPECT_EQ(1u, interpolations.size()); | 133 EXPECT_EQ(1u, interpolations.size()); |
134 EXPECT_EQ(2, effects()[0]->sortInfo().startTime()); | |
135 EXPECT_EQ(4, effects()[1]->sortInfo().startTime()); | |
136 EXPECT_EQ(6, effects()[2]->sortInfo().startTime()); | |
137 | 134 |
138 updateTimeline(13); | 135 updateTimeline(13); |
139 Heap::collectAllGarbage(); | 136 Heap::collectAllGarbage(); |
140 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); | 137 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); |
141 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(2).get())); | 138 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); |
142 EXPECT_EQ(3u, effects().size()); | 139 EXPECT_EQ(3u, effects().size()); |
143 EXPECT_EQ(2, effects()[0]->sortInfo().startTime()); | |
144 EXPECT_EQ(4, effects()[1]->sortInfo().startTime()); | |
145 EXPECT_EQ(6, effects()[2]->sortInfo().startTime()); | |
146 | 140 |
147 updateTimeline(15); | 141 updateTimeline(15); |
148 Heap::collectAllGarbage(); | 142 Heap::collectAllGarbage(); |
149 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); | 143 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); |
150 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(2).get())); | 144 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); |
151 EXPECT_EQ(2u, effects().size()); | 145 EXPECT_EQ(2u, effects().size()); |
152 EXPECT_EQ(4, effects()[0]->sortInfo().startTime()); | |
153 EXPECT_EQ(6, effects()[1]->sortInfo().startTime()); | |
154 | 146 |
155 updateTimeline(17); | 147 updateTimeline(17); |
156 Heap::collectAllGarbage(); | 148 Heap::collectAllGarbage(); |
157 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); | 149 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); |
158 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(2).get())); | 150 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); |
159 EXPECT_EQ(1u, effects().size()); | 151 EXPECT_EQ(1u, effects().size()); |
160 EXPECT_EQ(6, effects()[0]->sortInfo().startTime()); | |
161 } | 152 } |
162 | 153 |
163 } | 154 } |
OLD | NEW |