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

Side by Side Diff: Source/core/animation/KeyframeEffectModelTest.cpp

Issue 552123003: Create timing functions directly instead of using parser in KeyframeEffectModelTest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/KeyframeEffectModel.h" 32 #include "core/animation/KeyframeEffectModel.h"
33 33
34 #include "core/animation/LegacyStyleInterpolation.h" 34 #include "core/animation/LegacyStyleInterpolation.h"
35 #include "core/animation/animatable/AnimatableLength.h" 35 #include "core/animation/animatable/AnimatableLength.h"
36 #include "core/animation/animatable/AnimatableUnknown.h" 36 #include "core/animation/animatable/AnimatableUnknown.h"
37 #include "core/css/CSSPrimitiveValue.h" 37 #include "core/css/CSSPrimitiveValue.h"
38 #include "core/css/parser/BisonCSSParser.h"
39 #include "core/css/resolver/CSSToStyleMap.h"
40 #include <gtest/gtest.h> 38 #include <gtest/gtest.h>
41 39
42 using namespace blink; 40 using namespace blink;
43 41
44 namespace { 42 namespace {
45 43
46 const double duration = 1.0; 44 const double duration = 1.0;
47 45
48 PassRefPtrWillBeRawPtr<AnimatableValue> unknownAnimatableValue(double n) 46 PassRefPtrWillBeRawPtr<AnimatableValue> unknownAnimatableValue(double n)
49 { 47 {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimata bleValue(3.0), pixelAnimatableValue(5.0)); 132 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimata bleValue(3.0), pixelAnimatableValue(5.0));
135 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); 133 keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
136 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); 134 keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
137 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes); 135 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes);
138 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0 .6, duration)->at(0)); 136 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0 .6, duration)->at(0));
139 } 137 }
140 138
141 TEST(AnimationKeyframeEffectModel, CompositeEaseIn) 139 TEST(AnimationKeyframeEffectModel, CompositeEaseIn)
142 { 140 {
143 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimata bleValue(3.0), pixelAnimatableValue(5.0)); 141 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimata bleValue(3.0), pixelAnimatableValue(5.0));
144 RefPtrWillBeRawPtr<CSSValue> timingFunction = BisonCSSParser::parseAnimation TimingFunctionValue("ease-in");
145 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); 142 keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
146 keyframes[0]->setEasing(CSSToStyleMap::mapAnimationTimingFunction(timingFunc tion.get(), true)); 143 keyframes[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingF unction::EaseIn));
147 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); 144 keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
148 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes); 145 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes);
149 expectDoubleValue(3.8579516, effect->sample(0, 0.6, duration)->at(0)); 146 expectDoubleValue(3.8579516, effect->sample(0, 0.6, duration)->at(0));
150 expectDoubleValue(3.8582394, effect->sample(0, 0.6, duration * 100)->at(0)); 147 expectDoubleValue(3.8582394, effect->sample(0, 0.6, duration * 100)->at(0));
151 } 148 }
152 149
153 TEST(AnimationKeyframeEffectModel, CompositeCubicBezier) 150 TEST(AnimationKeyframeEffectModel, CompositeCubicBezier)
154 { 151 {
155 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimata bleValue(3.0), pixelAnimatableValue(5.0)); 152 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimata bleValue(3.0), pixelAnimatableValue(5.0));
156 RefPtrWillBeRawPtr<CSSValue> timingFunction = BisonCSSParser::parseAnimation TimingFunctionValue("cubic-bezier(0.42, 0, 0.58, 1)");
157 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); 153 keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
158 keyframes[0]->setEasing(CSSToStyleMap::mapAnimationTimingFunction(timingFunc tion.get(), true)); 154 keyframes[0]->setEasing(CubicBezierTimingFunction::create(0.42, 0, 0.58, 1)) ;
159 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); 155 keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
160 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes); 156 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa lueKeyframeEffectModel::create(keyframes);
161 expectDoubleValue(4.3363357, effect->sample(0, 0.6, duration)->at(0)); 157 expectDoubleValue(4.3363357, effect->sample(0, 0.6, duration)->at(0));
162 expectDoubleValue(4.3362322, effect->sample(0, 0.6, duration * 1000)->at(0)) ; 158 expectDoubleValue(4.3362322, effect->sample(0, 0.6, duration * 1000)->at(0)) ;
163 } 159 }
164 160
165 TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable) 161 TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable)
166 { 162 {
167 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(unknownAnima tableValue(3.0), unknownAnimatableValue(5.0)); 163 AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(unknownAnima tableValue(3.0), unknownAnimatableValue(5.0));
168 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); 164 keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 EXPECT_DOUBLE_EQ(0.6, result[5]->offset()); 504 EXPECT_DOUBLE_EQ(0.6, result[5]->offset());
509 EXPECT_DOUBLE_EQ(0.7, result[6]->offset()); 505 EXPECT_DOUBLE_EQ(0.7, result[6]->offset());
510 EXPECT_DOUBLE_EQ(0.8, result[7]->offset()); 506 EXPECT_DOUBLE_EQ(0.8, result[7]->offset());
511 EXPECT_DOUBLE_EQ(0.85, result[8]->offset()); 507 EXPECT_DOUBLE_EQ(0.85, result[8]->offset());
512 EXPECT_DOUBLE_EQ(0.9, result[9]->offset()); 508 EXPECT_DOUBLE_EQ(0.9, result[9]->offset());
513 EXPECT_DOUBLE_EQ(0.95, result[10]->offset()); 509 EXPECT_DOUBLE_EQ(0.95, result[10]->offset());
514 EXPECT_DOUBLE_EQ(1.0, result[11]->offset()); 510 EXPECT_DOUBLE_EQ(1.0, result[11]->offset());
515 } 511 }
516 512
517 } // namespace blink 513 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698