| 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" |
| 11 #include "core/animation/KeyframeEffectModel.h" | 11 #include "core/animation/KeyframeEffectModel.h" |
| 12 #include "core/animation/animatable/AnimatableDouble.h" | 12 #include "core/animation/animatable/AnimatableDouble.h" |
| 13 #include "core/animation/interpolation/LegacyStyleInterpolation.h" | 13 #include "core/animation/interpolation/LegacyStyleInterpolation.h" |
| 14 #include <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
| 15 | 15 |
| 16 namespace WebCore { | 16 namespace WebCore { |
| 17 | 17 |
| 18 class AnimationAnimationStackTest : public ::testing::Test { | 18 class AnimationAnimationStackTest : public ::testing::Test { |
| 19 protected: | 19 protected: |
| 20 virtual void SetUp() | 20 virtual void SetUp() |
| 21 { | 21 { |
| 22 document = Document::create(); | 22 document = Document::create(); |
| 23 document->animationClock().resetTimeForTesting(); | 23 document->animationClock().clearTimeForTesting(); |
| 24 document->animationClock().updateTime(AnimationClock::createTimeForTesti
ng(0, 0)); |
| 24 timeline = AnimationTimeline::create(document.get()); | 25 timeline = AnimationTimeline::create(document.get()); |
| 25 element = document->createElement("foo", ASSERT_NO_EXCEPTION); | 26 element = document->createElement("foo", ASSERT_NO_EXCEPTION); |
| 26 } | 27 } |
| 27 | 28 |
| 28 AnimationPlayer* play(Animation* animation, double startTime) | 29 AnimationPlayer* play(Animation* animation, double startTime) |
| 29 { | 30 { |
| 30 AnimationPlayer* player = timeline->createAnimationPlayer(animation); | 31 AnimationPlayer* player = timeline->createAnimationPlayer(animation); |
| 31 player->setStartTimeInternal(startTime); | 32 player->setStartTimeInternal(startTime); |
| 32 player->update(TimingUpdateOnDemand); | 33 player->update(TimingUpdateOnDemand); |
| 33 return player; | 34 return player; |
| 34 } | 35 } |
| 35 | 36 |
| 36 void updateTimeline(double time) | 37 void updateTimeline(double time) |
| 37 { | 38 { |
| 38 document->animationClock().updateTime(time); | 39 document->animationClock().updateTime(AnimationClock::createTimeForTesti
ng(time, time + 1)); |
| 39 timeline->serviceAnimations(TimingUpdateForAnimationFrame); | 40 timeline->serviceAnimations(TimingUpdateForAnimationFrame); |
| 40 } | 41 } |
| 41 | 42 |
| 42 const WillBeHeapVector<OwnPtrWillBeMember<SampledEffect> >& effects() | 43 const WillBeHeapVector<OwnPtrWillBeMember<SampledEffect> >& effects() |
| 43 { | 44 { |
| 44 return element->ensureActiveAnimations().defaultStack().m_effects; | 45 return element->ensureActiveAnimations().defaultStack().m_effects; |
| 45 } | 46 } |
| 46 | 47 |
| 47 PassRefPtrWillBeRawPtr<AnimationEffect> makeAnimationEffect(CSSPropertyID id
, PassRefPtrWillBeRawPtr<AnimatableValue> value) | 48 PassRefPtrWillBeRawPtr<AnimationEffect> makeAnimationEffect(CSSPropertyID id
, PassRefPtrWillBeRawPtr<AnimatableValue> value) |
| 48 { | 49 { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 155 |
| 155 updateTimeline(17); | 156 updateTimeline(17); |
| 156 Heap::collectAllGarbage(); | 157 Heap::collectAllGarbage(); |
| 157 interpolations = AnimationStack::activeInterpolations(&element->activeAnimat
ions()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); | 158 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())); | 159 EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equ
als(AnimatableDouble::create(2).get())); |
| 159 EXPECT_EQ(1u, effects().size()); | 160 EXPECT_EQ(1u, effects().size()); |
| 160 EXPECT_EQ(6, effects()[0]->sortInfo().startTime()); | 161 EXPECT_EQ(6, effects()[0]->sortInfo().startTime()); |
| 161 } | 162 } |
| 162 | 163 |
| 163 } | 164 } |
| OLD | NEW |