| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 RefPtrWillBePersistent<Document> document; | 79 RefPtrWillBePersistent<Document> document; |
| 80 RefPtrWillBePersistent<AnimationTimeline> timeline; | 80 RefPtrWillBePersistent<AnimationTimeline> timeline; |
| 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 InterpolationPipelineMap result = AnimationStack::activeInterpolations(&elem
ent->activeAnimations()->defaultStack(), 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(3).get())); | 91 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize).first().get()
)->equals(AnimatableDouble::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 InterpolationPipelineMap result = AnimationStack::activeInterpolations(&elem
ent->activeAnimations()->defaultStack(), &newAnimations, 0, Animation::DefaultPr
iority, 10); |
| 104 EXPECT_EQ(2u, result.size()); | 104 EXPECT_EQ(2u, result.size()); |
| 105 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize))->equals(Anim
atableDouble::create(3).get())); | 105 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyFontSize).first().get()
)->equals(AnimatableDouble::create(3).get())); |
| 106 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyZIndex))->equals(Animat
ableDouble::create(4).get())); | 106 EXPECT_TRUE(interpolationValue(result.get(CSSPropertyZIndex).first().get())-
>equals(AnimatableDouble::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 InterpolationPipelineMap result = AnimationStack::activeInterpolations(&elem
ent->activeAnimations()->defaultStack(), 0, &cancelledAnimationPlayers, Animatio
n::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).first().get())-
>equals(AnimatableDouble::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().update(); | 125 document->compositorPendingAnimations().update(); |
| 126 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > interpo
lations; | 126 InterpolationPipelineMap interpolations; |
| 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(3).get())); | 131 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize).first
().get())->equals(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 | 134 |
| 135 updateTimeline(13); | 135 updateTimeline(13); |
| 136 Heap::collectAllGarbage(); | 136 Heap::collectAllGarbage(); |
| 137 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); |
| 138 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); | 138 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize).first
().get())->equals(AnimatableDouble::create(3).get())); |
| 139 EXPECT_EQ(3u, effects().size()); | 139 EXPECT_EQ(3u, effects().size()); |
| 140 | 140 |
| 141 updateTimeline(15); | 141 updateTimeline(15); |
| 142 Heap::collectAllGarbage(); | 142 Heap::collectAllGarbage(); |
| 143 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); |
| 144 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); | 144 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize).first
().get())->equals(AnimatableDouble::create(3).get())); |
| 145 EXPECT_EQ(2u, effects().size()); | 145 EXPECT_EQ(2u, effects().size()); |
| 146 | 146 |
| 147 updateTimeline(17); | 147 updateTimeline(17); |
| 148 Heap::collectAllGarbage(); | 148 Heap::collectAllGarbage(); |
| 149 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); |
| 150 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(3).get())); | 150 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize).first
().get())->equals(AnimatableDouble::create(3).get())); |
| 151 EXPECT_EQ(1u, effects().size()); | 151 EXPECT_EQ(1u, effects().size()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } | 154 } |
| OLD | NEW |