| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 KeyframeEffectModel::KeyframeVector keyframes(2); | 59 KeyframeEffectModel::KeyframeVector keyframes(2); |
| 60 keyframes[0] = Keyframe::create(); | 60 keyframes[0] = Keyframe::create(); |
| 61 keyframes[0]->setOffset(0.0); | 61 keyframes[0]->setOffset(0.0); |
| 62 keyframes[0]->setPropertyValue(CSSPropertyLeft, zeroValue.get()); | 62 keyframes[0]->setPropertyValue(CSSPropertyLeft, zeroValue.get()); |
| 63 keyframes[1] = Keyframe::create(); | 63 keyframes[1] = Keyframe::create(); |
| 64 keyframes[1]->setOffset(1.0); | 64 keyframes[1]->setOffset(1.0); |
| 65 keyframes[1]->setPropertyValue(CSSPropertyLeft, oneValue.get()); | 65 keyframes[1]->setPropertyValue(CSSPropertyLeft, oneValue.get()); |
| 66 return keyframes; | 66 return keyframes; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void expectProperty(CSSPropertyID property, PassRefPtr<Interpolation> interpolat
ionValue) | 69 void expectProperty(CSSPropertyID property, PassRefPtrWillBeRawPtr<Interpolation
> interpolationValue) |
| 70 { | 70 { |
| 71 LegacyStyleInterpolation* interpolation = toLegacyStyleInterpolation(interpo
lationValue.get()); | 71 LegacyStyleInterpolation* interpolation = toLegacyStyleInterpolation(interpo
lationValue.get()); |
| 72 ASSERT_EQ(property, interpolation->id()); | 72 ASSERT_EQ(property, interpolation->id()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void expectDoubleValue(double expectedValue, PassRefPtr<Interpolation> interpola
tionValue) | 75 void expectDoubleValue(double expectedValue, PassRefPtrWillBeRawPtr<Interpolatio
n> interpolationValue) |
| 76 { | 76 { |
| 77 LegacyStyleInterpolation* interpolation = toLegacyStyleInterpolation(interpo
lationValue.get()); | 77 LegacyStyleInterpolation* interpolation = toLegacyStyleInterpolation(interpo
lationValue.get()); |
| 78 RefPtrWillBeRawPtr<AnimatableValue> value = interpolation->currentValue(); | 78 RefPtrWillBeRawPtr<AnimatableValue> value = interpolation->currentValue(); |
| 79 | 79 |
| 80 ASSERT_TRUE(value->isLength() || value->isUnknown()); | 80 ASSERT_TRUE(value->isLength() || value->isUnknown()); |
| 81 | 81 |
| 82 double actualValue; | 82 double actualValue; |
| 83 if (value->isLength()) | 83 if (value->isLength()) |
| 84 actualValue = toCSSPrimitiveValue(toAnimatableLength(value.get())->toCSS
Value().get())->getDoubleValue(); | 84 actualValue = toCSSPrimitiveValue(toAnimatableLength(value.get())->toCSS
Value().get())->getDoubleValue(); |
| 85 else | 85 else |
| 86 actualValue = toCSSPrimitiveValue(toAnimatableUnknown(value.get())->toCS
SValue().get())->getDoubleValue(); | 86 actualValue = toCSSPrimitiveValue(toAnimatableUnknown(value.get())->toCS
SValue().get())->getDoubleValue(); |
| 87 | 87 |
| 88 EXPECT_FLOAT_EQ(static_cast<float>(expectedValue), actualValue); | 88 EXPECT_FLOAT_EQ(static_cast<float>(expectedValue), actualValue); |
| 89 } | 89 } |
| 90 | 90 |
| 91 Interpolation* findValue(Vector<RefPtr<Interpolation> >& values, CSSPropertyID i
d) | 91 Interpolation* findValue(WillBeHeapVector<RefPtrWillBeMember<Interpolation> >& v
alues, CSSPropertyID id) |
| 92 { | 92 { |
| 93 for (size_t i = 0; i < values.size(); ++i) { | 93 for (size_t i = 0; i < values.size(); ++i) { |
| 94 LegacyStyleInterpolation* value = toLegacyStyleInterpolation(values.at(i
).get()); | 94 LegacyStyleInterpolation* value = toLegacyStyleInterpolation(values.at(i
).get()); |
| 95 if (value->id() == id) | 95 if (value->id() == id) |
| 96 return value; | 96 return value; |
| 97 } | 97 } |
| 98 return 0; | 98 return 0; |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 TEST(AnimationKeyframeEffectModel, BasicOperation) | 102 TEST(AnimationKeyframeEffectModel, BasicOperation) |
| 103 { | 103 { |
| 104 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); | 104 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); |
| 105 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); | 105 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); |
| 106 OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6, dura
tion); | 106 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > va
lues = effect->sample(0, 0.6, duration); |
| 107 ASSERT_EQ(1UL, values->size()); | 107 ASSERT_EQ(1UL, values->size()); |
| 108 expectProperty(CSSPropertyLeft, values->at(0)); | 108 expectProperty(CSSPropertyLeft, values->at(0)); |
| 109 expectDoubleValue(5.0, values->at(0)); | 109 expectDoubleValue(5.0, values->at(0)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 TEST(AnimationKeyframeEffectModel, CompositeReplaceNonInterpolable) | 112 TEST(AnimationKeyframeEffectModel, CompositeReplaceNonInterpolable) |
| 113 { | 113 { |
| 114 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); | 114 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); |
| 115 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); | 115 keyframes[0]->setComposite(AnimationEffect::CompositeReplace); |
| 116 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); | 116 keyframes[1]->setComposite(AnimationEffect::CompositeReplace); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 keyframes[0] = Keyframe::create(); | 336 keyframes[0] = Keyframe::create(); |
| 337 keyframes[0]->setOffset(0.0); | 337 keyframes[0]->setOffset(0.0); |
| 338 keyframes[0]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(3.0).
get()); | 338 keyframes[0]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(3.0).
get()); |
| 339 keyframes[0]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(4.0)
.get()); | 339 keyframes[0]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(4.0)
.get()); |
| 340 keyframes[1] = Keyframe::create(); | 340 keyframes[1] = Keyframe::create(); |
| 341 keyframes[1]->setOffset(1.0); | 341 keyframes[1]->setOffset(1.0); |
| 342 keyframes[1]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0).
get()); | 342 keyframes[1]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0).
get()); |
| 343 keyframes[1]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(6.0)
.get()); | 343 keyframes[1]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(6.0)
.get()); |
| 344 | 344 |
| 345 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); | 345 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); |
| 346 OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6, dura
tion); | 346 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > va
lues = effect->sample(0, 0.6, duration); |
| 347 EXPECT_EQ(2UL, values->size()); | 347 EXPECT_EQ(2UL, values->size()); |
| 348 Interpolation* leftValue = findValue(*values.get(), CSSPropertyLeft); | 348 Interpolation* leftValue = findValue(*values.get(), CSSPropertyLeft); |
| 349 ASSERT_TRUE(leftValue); | 349 ASSERT_TRUE(leftValue); |
| 350 expectDoubleValue(5.0, leftValue); | 350 expectDoubleValue(5.0, leftValue); |
| 351 Interpolation* rightValue = findValue(*values.get(), CSSPropertyRight); | 351 Interpolation* rightValue = findValue(*values.get(), CSSPropertyRight); |
| 352 ASSERT_TRUE(rightValue); | 352 ASSERT_TRUE(rightValue); |
| 353 expectDoubleValue(6.0, rightValue); | 353 expectDoubleValue(6.0, rightValue); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // FIXME: Re-enable this test once compositing of CompositeAdd is supported. | 356 // FIXME: Re-enable this test once compositing of CompositeAdd is supported. |
| 357 TEST(AnimationKeyframeEffectModel, DISABLED_RecompositeCompositableValue) | 357 TEST(AnimationKeyframeEffectModel, DISABLED_RecompositeCompositableValue) |
| 358 { | 358 { |
| 359 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); | 359 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); |
| 360 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); | 360 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); |
| 361 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); | 361 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); |
| 362 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); | 362 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); |
| 363 OwnPtr<Vector<RefPtr<Interpolation> > > values = effect->sample(0, 0.6, dura
tion); | 363 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > va
lues = effect->sample(0, 0.6, duration); |
| 364 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values->at(0)); | 364 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values->at(0)); |
| 365 expectDoubleValue((9.0 + 3.0) * 0.4 + (9.0 + 5.0) * 0.6, values->at(0)); | 365 expectDoubleValue((9.0 + 3.0) * 0.4 + (9.0 + 5.0) * 0.6, values->at(0)); |
| 366 } | 366 } |
| 367 | 367 |
| 368 TEST(AnimationKeyframeEffectModel, MultipleIterations) | 368 TEST(AnimationKeyframeEffectModel, MultipleIterations) |
| 369 { | 369 { |
| 370 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(1.0), pixelAnimatableValue(3.0)); | 370 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(1.0), pixelAnimatableValue(3.0)); |
| 371 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); | 371 RefPtrWillBeRawPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create
(keyframes); |
| 372 expectDoubleValue(2.0, effect->sample(0, 0.5, duration)->at(0)); | 372 expectDoubleValue(2.0, effect->sample(0, 0.5, duration)->at(0)); |
| 373 expectDoubleValue(2.0, effect->sample(1, 0.5, duration)->at(0)); | 373 expectDoubleValue(2.0, effect->sample(1, 0.5, duration)->at(0)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 EXPECT_DOUBLE_EQ(0.6, result[5]->offset()); | 556 EXPECT_DOUBLE_EQ(0.6, result[5]->offset()); |
| 557 EXPECT_DOUBLE_EQ(0.7, result[6]->offset()); | 557 EXPECT_DOUBLE_EQ(0.7, result[6]->offset()); |
| 558 EXPECT_DOUBLE_EQ(0.8, result[7]->offset()); | 558 EXPECT_DOUBLE_EQ(0.8, result[7]->offset()); |
| 559 EXPECT_DOUBLE_EQ(0.85, result[8]->offset()); | 559 EXPECT_DOUBLE_EQ(0.85, result[8]->offset()); |
| 560 EXPECT_DOUBLE_EQ(0.9, result[9]->offset()); | 560 EXPECT_DOUBLE_EQ(0.9, result[9]->offset()); |
| 561 EXPECT_DOUBLE_EQ(0.95, result[10]->offset()); | 561 EXPECT_DOUBLE_EQ(0.95, result[10]->offset()); |
| 562 EXPECT_DOUBLE_EQ(1.0, result[11]->offset()); | 562 EXPECT_DOUBLE_EQ(1.0, result[11]->offset()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 } // namespace WebCore | 565 } // namespace WebCore |
| OLD | NEW |