| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 double actualValue; | 69 double actualValue; |
| 70 if (value->isLength()) | 70 if (value->isLength()) |
| 71 actualValue = toCSSPrimitiveValue(toAnimatableLength(value.get())->toCSS
Value().get())->getDoubleValue(); | 71 actualValue = toCSSPrimitiveValue(toAnimatableLength(value.get())->toCSS
Value().get())->getDoubleValue(); |
| 72 else | 72 else |
| 73 actualValue = toCSSPrimitiveValue(toAnimatableUnknown(value.get())->toCS
SValue().get())->getDoubleValue(); | 73 actualValue = toCSSPrimitiveValue(toAnimatableUnknown(value.get())->toCS
SValue().get())->getDoubleValue(); |
| 74 | 74 |
| 75 EXPECT_FLOAT_EQ(static_cast<float>(expectedValue), actualValue); | 75 EXPECT_FLOAT_EQ(static_cast<float>(expectedValue), actualValue); |
| 76 } | 76 } |
| 77 | 77 |
| 78 const AnimationEffect::CompositableValue* findValue(const AnimationEffect::Compo
sitableValueList& values, CSSPropertyID id) |
| 79 { |
| 80 for (size_t i = 0; i < values.size(); ++i) { |
| 81 const std::pair<CSSPropertyID, RefPtr<AnimationEffect::CompositableValue
> >& value = values.at(i); |
| 82 if (value.first == id) |
| 83 return value.second.get(); |
| 84 } |
| 85 return 0; |
| 86 } |
| 87 |
| 78 | 88 |
| 79 TEST(AnimationKeyframeEffectModel, BasicOperation) | 89 TEST(AnimationKeyframeEffectModel, BasicOperation) |
| 80 { | 90 { |
| 81 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); | 91 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(unknow
nAnimatableValue(3.0), unknownAnimatableValue(5.0)); |
| 82 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); | 92 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 83 OwnPtr<AnimationEffect::CompositableValueList> values = effect->sample(0, 0.
6); | 93 OwnPtr<AnimationEffect::CompositableValueList> values = effect->sample(0, 0.
6); |
| 84 ASSERT_EQ(1UL, values->size()); | 94 ASSERT_EQ(1UL, values->size()); |
| 85 EXPECT_EQ(CSSPropertyLeft, values->at(0).first); | 95 EXPECT_EQ(CSSPropertyLeft, values->at(0).first); |
| 86 expectDoubleValue(5.0, values->at(0).second->compositeOnto(unknownAnimatable
Value(7.0))); | 96 expectDoubleValue(5.0, values->at(0).second->compositeOnto(unknownAnimatable
Value(7.0))); |
| 87 } | 97 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 keyframes[0]->setOffset(0.0); | 317 keyframes[0]->setOffset(0.0); |
| 308 keyframes[0]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(3.0))
; | 318 keyframes[0]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(3.0))
; |
| 309 keyframes[0]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(4.0)
); | 319 keyframes[0]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(4.0)
); |
| 310 keyframes[1] = Keyframe::create(); | 320 keyframes[1] = Keyframe::create(); |
| 311 keyframes[1]->setOffset(1.0); | 321 keyframes[1]->setOffset(1.0); |
| 312 keyframes[1]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0))
; | 322 keyframes[1]->setPropertyValue(CSSPropertyLeft, unknownAnimatableValue(5.0))
; |
| 313 keyframes[1]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(6.0)
); | 323 keyframes[1]->setPropertyValue(CSSPropertyRight, unknownAnimatableValue(6.0)
); |
| 314 | 324 |
| 315 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); | 325 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 316 OwnPtr<AnimationEffect::CompositableValueList> values = effect->sample(0, 0.
6); | 326 OwnPtr<AnimationEffect::CompositableValueList> values = effect->sample(0, 0.
6); |
| 317 ASSERT_EQ(2UL, values->size()); | 327 EXPECT_EQ(2UL, values->size()); |
| 318 EXPECT_TRUE(values->at(0).first == CSSPropertyLeft); | 328 const AnimationEffect::CompositableValue* leftValue = findValue(*values.get(
), CSSPropertyLeft); |
| 319 expectDoubleValue(5.0, values->at(0).second->compositeOnto(unknownAnimatable
Value(7.0))); | 329 ASSERT_TRUE(leftValue); |
| 320 EXPECT_TRUE(values->at(1).first == CSSPropertyRight); | 330 expectDoubleValue(5.0, leftValue->compositeOnto(unknownAnimatableValue(7.0))
); |
| 321 expectDoubleValue(6.0, values->at(1).second->compositeOnto(unknownAnimatable
Value(7.0))); | 331 const AnimationEffect::CompositableValue* rightValue = findValue(*values.get
(), CSSPropertyRight); |
| 332 ASSERT_TRUE(rightValue); |
| 333 expectDoubleValue(6.0, rightValue->compositeOnto(unknownAnimatableValue(7.0)
)); |
| 322 } | 334 } |
| 323 | 335 |
| 324 TEST(AnimationKeyframeEffectModel, RecompositeCompositableValue) | 336 TEST(AnimationKeyframeEffectModel, RecompositeCompositableValue) |
| 325 { | 337 { |
| 326 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); | 338 KeyframeEffectModel::KeyframeVector keyframes = keyframesAtZeroAndOne(pixelA
nimatableValue(3.0), pixelAnimatableValue(5.0)); |
| 327 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); | 339 keyframes[0]->setComposite(AnimationEffect::CompositeAdd); |
| 328 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); | 340 keyframes[1]->setComposite(AnimationEffect::CompositeAdd); |
| 329 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); | 341 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 330 OwnPtr<AnimationEffect::CompositableValueList> values = effect->sample(0, 0.
6); | 342 OwnPtr<AnimationEffect::CompositableValueList> values = effect->sample(0, 0.
6); |
| 331 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values->at(0).secon
d->compositeOnto(pixelAnimatableValue(7.0))); | 343 expectDoubleValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values->at(0).secon
d->compositeOnto(pixelAnimatableValue(7.0))); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 TEST(AnimationKeyframeEffectModel, ToKeyframeEffectModel) | 382 TEST(AnimationKeyframeEffectModel, ToKeyframeEffectModel) |
| 371 { | 383 { |
| 372 KeyframeEffectModel::KeyframeVector keyframes(0); | 384 KeyframeEffectModel::KeyframeVector keyframes(0); |
| 373 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); | 385 RefPtr<KeyframeEffectModel> effect = KeyframeEffectModel::create(keyframes); |
| 374 | 386 |
| 375 AnimationEffect* baseEffect = effect.get(); | 387 AnimationEffect* baseEffect = effect.get(); |
| 376 EXPECT_TRUE(toKeyframeEffectModel(baseEffect)); | 388 EXPECT_TRUE(toKeyframeEffectModel(baseEffect)); |
| 377 } | 389 } |
| 378 | 390 |
| 379 } // namespace | 391 } // namespace |
| OLD | NEW |