| 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 "core/animation/AnimationStack.h" | 5 #include "core/animation/AnimationStack.h" |
| 6 | 6 |
| 7 #include "core/animation/AnimationClock.h" | 7 #include "core/animation/AnimationClock.h" |
| 8 #include "core/animation/AnimationTimeline.h" | 8 #include "core/animation/AnimationTimeline.h" |
| 9 #include "core/animation/CompositorPendingAnimations.h" | 9 #include "core/animation/CompositorPendingAnimations.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" | 14 #include "core/testing/DummyPageHolder.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include <memory> | |
| 17 | 16 |
| 18 namespace blink { | 17 namespace blink { |
| 19 | 18 |
| 20 class AnimationAnimationStackTest : public ::testing::Test { | 19 class AnimationAnimationStackTest : public ::testing::Test { |
| 21 protected: | 20 protected: |
| 22 virtual void SetUp() | 21 virtual void SetUp() |
| 23 { | 22 { |
| 24 pageHolder = DummyPageHolder::create(); | 23 pageHolder = DummyPageHolder::create(); |
| 25 document = &pageHolder->document(); | 24 document = &pageHolder->document(); |
| 26 document->animationClock().resetTimeForTesting(); | 25 document->animationClock().resetTimeForTesting(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 timing.iterationDuration = duration; | 72 timing.iterationDuration = duration; |
| 74 return KeyframeEffect::create(element.get(), effect, timing); | 73 return KeyframeEffect::create(element.get(), effect, timing); |
| 75 } | 74 } |
| 76 | 75 |
| 77 AnimatableValue* interpolationValue(const ActiveInterpolationsMap& activeInt
erpolations, CSSPropertyID id) | 76 AnimatableValue* interpolationValue(const ActiveInterpolationsMap& activeInt
erpolations, CSSPropertyID id) |
| 78 { | 77 { |
| 79 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle(
id)).at(0); | 78 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle(
id)).at(0); |
| 80 return toLegacyStyleInterpolation(interpolation).currentValue().get(); | 79 return toLegacyStyleInterpolation(interpolation).currentValue().get(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 std::unique_ptr<DummyPageHolder> pageHolder; | 82 OwnPtr<DummyPageHolder> pageHolder; |
| 84 Persistent<Document> document; | 83 Persistent<Document> document; |
| 85 Persistent<AnimationTimeline> timeline; | 84 Persistent<AnimationTimeline> timeline; |
| 86 Persistent<Element> element; | 85 Persistent<Element> element; |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted) | 88 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted) |
| 90 { | 89 { |
| 91 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl
e::create(1))), 10); | 90 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl
e::create(1))), 10); |
| 92 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl
e::create(2))), 15); | 91 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl
e::create(2))), 15); |
| 93 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl
e::create(3))), 5); | 92 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl
e::create(3))), 5); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 164 |
| 166 updateTimeline(17); | 165 updateTimeline(17); |
| 167 ThreadHeap::collectAllGarbage(); | 166 ThreadHeap::collectAllGarbage(); |
| 168 interpolations = AnimationStack::activeInterpolations(&element->elementAnima
tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority); | 167 interpolations = AnimationStack::activeInterpolations(&element->elementAnima
tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority); |
| 169 EXPECT_EQ(1u, interpolations.size()); | 168 EXPECT_EQ(1u, interpolations.size()); |
| 170 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals(
AnimatableDouble::create(3).get())); | 169 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals(
AnimatableDouble::create(3).get())); |
| 171 EXPECT_EQ(1u, sampledEffectCount()); | 170 EXPECT_EQ(1u, sampledEffectCount()); |
| 172 } | 171 } |
| 173 | 172 |
| 174 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |