| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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/AnimatableLength.h" | 34 #include "core/animation/AnimatableLength.h" |
| 35 #include "core/animation/AnimatableUnknown.h" | 35 #include "core/animation/AnimatableUnknown.h" |
| 36 #include "core/css/CSSPrimitiveValue.h" | 36 #include "core/css/CSSPrimitiveValue.h" |
| 37 #include "core/css/parser/BisonCSSParser.h" |
| 38 #include "core/css/resolver/CSSToStyleMap.h" |
| 37 #include <gtest/gtest.h> | 39 #include <gtest/gtest.h> |
| 38 | 40 |
| 39 using namespace WebCore; | 41 using namespace WebCore; |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 AnimatableValue* unknownAnimatableValue(double n) | 45 AnimatableValue* unknownAnimatableValue(double n) |
| 44 { | 46 { |
| 45 return AnimatableUnknown::create(CSSPrimitiveValue::create(n, CSSPrimitiveVa
lue::CSS_UNKNOWN).get()).leakRef(); | 47 return AnimatableUnknown::create(CSSPrimitiveValue::create(n, CSSPrimitiveVa
lue::CSS_UNKNOWN).get()).leakRef(); |
| 46 } | 48 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 118 |
| 117 TEST(AnimationKeyframeEffectModel, CompositeAdd) | 119 TEST(AnimationKeyframeEffectModel, CompositeAdd) |
| 118 { | 120 { |
| 119 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); | 121 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); |
| 120 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); | 122 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); |
| 121 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); | 123 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); |
| 122 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); | 124 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 123 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0
.6)->at(0).second->compositeOnto(pixelAnimatableValue(7.0))); | 125 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, effect->sample(0, 0
.6)->at(0).second->compositeOnto(pixelAnimatableValue(7.0))); |
| 124 } | 126 } |
| 125 | 127 |
| 128 TEST(AnimationKeyframeEffectModel, CompositeEaseIn) |
| 129 { |
| 130 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); |
| 131 RefPtr<CSSValue> timingFunction = BisonCSSParser::parseAnimationTimingFuncti
onValue("ease-in"); |
| 132 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); |
| 133 keyframes[0]->setEasing(CSSToStyleMap::animationTimingFunction(timingFunctio
n.get(), false)); |
| 134 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); |
| 135 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 136 expectDoubleValue(3.8582394, effect->sample(0, 0.6)->at(0).second->composite
Onto(unknownAnimatableValue(7.0))); |
| 137 } |
| 138 |
| 139 TEST(AnimationKeyframeEffectModel, CompositeCubicBezier) |
| 140 { |
| 141 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); |
| 142 RefPtr<CSSValue> timingFunction = BisonCSSParser::parseAnimationTimingFuncti
onValue("cubic-bezier(0.42, 0, 0.58, 1)"); |
| 143 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); |
| 144 keyframes[0]->setEasing(CSSToStyleMap::animationTimingFunction(timingFunctio
n.get(), false)); |
| 145 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); |
| 146 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 147 expectDoubleValue(4.3362322, effect->sample(0, 0.6)->at(0).second->composite
Onto(unknownAnimatableValue(7.0))); |
| 148 } |
| 149 |
| 126 TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable) | 150 TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable) |
| 127 { | 151 { |
| 128 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); | 152 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); |
| 129 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); | 153 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 130 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); | 154 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); |
| 131 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); | 155 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); |
| 132 expectDoubleValue(5.0, effect->sample(0, 1.6)->at(0).second->compositeOnto(u
nknownAnimatableValue(7.0))); | 156 expectDoubleValue(5.0, effect->sample(0, 1.6)->at(0).second->compositeOnto(u
nknownAnimatableValue(7.0))); |
| 133 } | 157 } |
| 134 | 158 |
| 135 TEST(AnimationKeyframeEffectModel, ExtrapolateReplace) | 159 TEST(AnimationKeyframeEffectModel, ExtrapolateReplace) |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 EXPECT_DOUBLE_EQ(0.6, result[5]->offset()); | 543 EXPECT_DOUBLE_EQ(0.6, result[5]->offset()); |
| 520 EXPECT_DOUBLE_EQ(0.7, result[6]->offset()); | 544 EXPECT_DOUBLE_EQ(0.7, result[6]->offset()); |
| 521 EXPECT_DOUBLE_EQ(0.8, result[7]->offset()); | 545 EXPECT_DOUBLE_EQ(0.8, result[7]->offset()); |
| 522 EXPECT_DOUBLE_EQ(0.85, result[8]->offset()); | 546 EXPECT_DOUBLE_EQ(0.85, result[8]->offset()); |
| 523 EXPECT_DOUBLE_EQ(0.9, result[9]->offset()); | 547 EXPECT_DOUBLE_EQ(0.9, result[9]->offset()); |
| 524 EXPECT_DOUBLE_EQ(0.95, result[10]->offset()); | 548 EXPECT_DOUBLE_EQ(0.95, result[10]->offset()); |
| 525 EXPECT_DOUBLE_EQ(1.0, result[11]->offset()); | 549 EXPECT_DOUBLE_EQ(1.0, result[11]->offset()); |
| 526 } | 550 } |
| 527 | 551 |
| 528 } // namespace WebCore | 552 } // namespace WebCore |
| OLD | NEW |