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

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

Issue 2222313002: Implement DocumentTimeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update global-interface-listing-expected.txt Created 4 years, 4 months 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 "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"
9 #include "core/animation/CompositorPendingAnimations.h" 8 #include "core/animation/CompositorPendingAnimations.h"
9 #include "core/animation/DocumentTimeline.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> 16 #include <memory>
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class AnimationAnimationStackTest : public ::testing::Test { 20 class AnimationAnimationStackTest : public ::testing::Test {
21 protected: 21 protected:
22 virtual void SetUp() 22 virtual void SetUp()
23 { 23 {
24 pageHolder = DummyPageHolder::create(); 24 pageHolder = DummyPageHolder::create();
25 document = &pageHolder->document(); 25 document = &pageHolder->document();
26 document->animationClock().resetTimeForTesting(); 26 document->animationClock().resetTimeForTesting();
27 timeline = AnimationTimeline::create(document.get()); 27 timeline = DocumentTimeline::create(document.get());
28 element = document->createElement("foo", ASSERT_NO_EXCEPTION); 28 element = document->createElement("foo", ASSERT_NO_EXCEPTION);
29 } 29 }
30 30
31 Animation* play(KeyframeEffect* effect, double startTime) 31 Animation* play(KeyframeEffect* effect, double startTime)
32 { 32 {
33 Animation* animation = timeline->play(effect); 33 Animation* animation = timeline->play(effect);
34 animation->setStartTime(startTime * 1000); 34 animation->setStartTime(startTime * 1000);
35 animation->update(TimingUpdateOnDemand); 35 animation->update(TimingUpdateOnDemand);
36 return animation; 36 return animation;
37 } 37 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 AnimatableValue* interpolationValue(const ActiveInterpolationsMap& activeInt erpolations, CSSPropertyID id) 77 AnimatableValue* interpolationValue(const ActiveInterpolationsMap& activeInt erpolations, CSSPropertyID id)
78 { 78 {
79 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle( id)).at(0); 79 Interpolation& interpolation = *activeInterpolations.get(PropertyHandle( id)).at(0);
80 return toLegacyStyleInterpolation(interpolation).currentValue().get(); 80 return toLegacyStyleInterpolation(interpolation).currentValue().get();
81 } 81 }
82 82
83 std::unique_ptr<DummyPageHolder> pageHolder; 83 std::unique_ptr<DummyPageHolder> pageHolder;
84 Persistent<Document> document; 84 Persistent<Document> document;
85 Persistent<AnimationTimeline> timeline; 85 Persistent<DocumentTimeline> timeline;
86 Persistent<Element> element; 86 Persistent<Element> element;
87 }; 87 };
88 88
89 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted) 89 TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted)
90 { 90 {
91 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(1))), 10); 91 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(1))), 10);
92 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(2))), 15); 92 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(2))), 15);
93 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(3))), 5); 93 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(3))), 5);
94 ActiveInterpolationsMap result = AnimationStack::activeInterpolations(&eleme nt->elementAnimations()->animationStack(), 0, 0, KeyframeEffect::DefaultPriority ); 94 ActiveInterpolationsMap result = AnimationStack::activeInterpolations(&eleme nt->elementAnimations()->animationStack(), 0, 0, KeyframeEffect::DefaultPriority );
95 EXPECT_EQ(1u, result.size()); 95 EXPECT_EQ(1u, result.size());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 updateTimeline(17); 166 updateTimeline(17);
167 ThreadHeap::collectAllGarbage(); 167 ThreadHeap::collectAllGarbage();
168 interpolations = AnimationStack::activeInterpolations(&element->elementAnima tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority); 168 interpolations = AnimationStack::activeInterpolations(&element->elementAnima tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority);
169 EXPECT_EQ(1u, interpolations.size()); 169 EXPECT_EQ(1u, interpolations.size());
170 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals( AnimatableDouble::create(3).get())); 170 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals( AnimatableDouble::create(3).get()));
171 EXPECT_EQ(1u, sampledEffectCount()); 171 EXPECT_EQ(1u, sampledEffectCount());
172 } 172 }
173 173
174 } // namespace blink 174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698