| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTe
stBase { | 70 class AnimationCompositorAnimationsTest : public AnimationCompositorAnimationsTe
stBase { |
| 71 protected: | 71 protected: |
| 72 RefPtr<TimingFunction> m_linearTimingFunction; | 72 RefPtr<TimingFunction> m_linearTimingFunction; |
| 73 RefPtr<TimingFunction> m_cubicEaseTimingFunction; | 73 RefPtr<TimingFunction> m_cubicEaseTimingFunction; |
| 74 RefPtr<TimingFunction> m_cubicCustomTimingFunction; | 74 RefPtr<TimingFunction> m_cubicCustomTimingFunction; |
| 75 RefPtr<TimingFunction> m_stepTimingFunction; | 75 RefPtr<TimingFunction> m_stepTimingFunction; |
| 76 | 76 |
| 77 Timing m_timing; | 77 Timing m_timing; |
| 78 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; | 78 CompositorAnimationsImpl::CompositorTiming m_compositorTiming; |
| 79 OwnPtrWillBePersistent<AnimatableValueKeyframeVector> m_keyframeVector2; | 79 Persistent<AnimatableValueKeyframeVector> m_keyframeVector2; |
| 80 RefPtrWillBePersistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimati
onEffect2; | 80 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect2; |
| 81 OwnPtrWillBePersistent<AnimatableValueKeyframeVector> m_keyframeVector5; | 81 Persistent<AnimatableValueKeyframeVector> m_keyframeVector5; |
| 82 RefPtrWillBePersistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimati
onEffect5; | 82 Persistent<AnimatableValueKeyframeEffectModel> m_keyframeAnimationEffect5; |
| 83 | 83 |
| 84 RefPtrWillBePersistent<Document> m_document; | 84 RefPtrWillBePersistent<Document> m_document; |
| 85 RefPtrWillBePersistent<Element> m_element; | 85 RefPtrWillBePersistent<Element> m_element; |
| 86 RefPtrWillBePersistent<AnimationTimeline> m_timeline; | 86 Persistent<AnimationTimeline> m_timeline; |
| 87 | 87 |
| 88 virtual void SetUp() | 88 virtual void SetUp() |
| 89 { | 89 { |
| 90 AnimationCompositorAnimationsTestBase::SetUp(); | 90 AnimationCompositorAnimationsTestBase::SetUp(); |
| 91 | 91 |
| 92 m_linearTimingFunction = LinearTimingFunction::shared(); | 92 m_linearTimingFunction = LinearTimingFunction::shared(); |
| 93 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::Ease); | 93 m_cubicEaseTimingFunction = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::Ease); |
| 94 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3,
4); | 94 m_cubicCustomTimingFunction = CubicBezierTimingFunction::create(1, 2, 3,
4); |
| 95 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio
n::End); | 95 m_stepTimingFunction = StepsTimingFunction::create(1, StepsTimingFunctio
n::End); |
| 96 | 96 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 bool getAnimationBounds(FloatBox& boundingBox, const AnimationEffect& effect
, double minValue, double maxValue) | 133 bool getAnimationBounds(FloatBox& boundingBox, const AnimationEffect& effect
, double minValue, double maxValue) |
| 134 { | 134 { |
| 135 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); | 135 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) | 138 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) |
| 139 { | 139 { |
| 140 EXPECT_EQ(frame->offset(), 0); | 140 EXPECT_EQ(frame->offset(), 0); |
| 141 AnimatableValueKeyframeVector frames; | 141 AnimatableValueKeyframeVector frames; |
| 142 RefPtrWillBeRawPtr<Keyframe> second = frame->cloneWithOffset(1); | 142 Keyframe* second = frame->cloneWithOffset(1); |
| 143 | 143 |
| 144 frames.append(frame); | 144 frames.append(frame); |
| 145 frames.append(toAnimatableValueKeyframe(second.get())); | 145 frames.append(toAnimatableValueKeyframe(second)); |
| 146 return isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKey
frameEffectModel::create(frames).get()); | 146 return isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKey
frameEffectModel::create(frames)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // ------------------------------------------------------------------- | 149 // ------------------------------------------------------------------- |
| 150 | 150 |
| 151 Timing createCompositableTiming() | 151 Timing createCompositableTiming() |
| 152 { | 152 { |
| 153 Timing timing; | 153 Timing timing; |
| 154 timing.startDelay = 0; | 154 timing.startDelay = 0; |
| 155 timing.fillMode = Timing::FillModeNone; | 155 timing.fillMode = Timing::FillModeNone; |
| 156 timing.iterationStart = 0; | 156 timing.iterationStart = 0; |
| 157 timing.iterationCount = 1; | 157 timing.iterationCount = 1; |
| 158 timing.iterationDuration = 1.0; | 158 timing.iterationDuration = 1.0; |
| 159 timing.playbackRate = 1.0; | 159 timing.playbackRate = 1.0; |
| 160 timing.direction = Timing::PlaybackDirectionNormal; | 160 timing.direction = Timing::PlaybackDirectionNormal; |
| 161 ASSERT(m_linearTimingFunction); | 161 ASSERT(m_linearTimingFunction); |
| 162 timing.timingFunction = m_linearTimingFunction; | 162 timing.timingFunction = m_linearTimingFunction; |
| 163 return timing; | 163 return timing; |
| 164 } | 164 } |
| 165 | 165 |
| 166 PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createReplaceOpKeyframe(CSSP
ropertyID id, AnimatableValue* value, double offset = 0) | 166 AnimatableValueKeyframe* createReplaceOpKeyframe(CSSPropertyID id, Animatabl
eValue* value, double offset = 0) |
| 167 { | 167 { |
| 168 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe
yframe::create(); | 168 AnimatableValueKeyframe* keyframe = AnimatableValueKeyframe::create(); |
| 169 keyframe->setPropertyValue(id, value); | 169 keyframe->setPropertyValue(id, value); |
| 170 keyframe->setComposite(AnimationEffect::CompositeReplace); | 170 keyframe->setComposite(AnimationEffect::CompositeReplace); |
| 171 keyframe->setOffset(offset); | 171 keyframe->setOffset(offset); |
| 172 keyframe->setEasing(LinearTimingFunction::shared()); | 172 keyframe->setEasing(LinearTimingFunction::shared()); |
| 173 return keyframe; | 173 return keyframe; |
| 174 } | 174 } |
| 175 | 175 |
| 176 PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createDefaultKeyframe(CSSPro
pertyID id, AnimationEffect::CompositeOperation op, double offset = 0) | 176 AnimatableValueKeyframe* createDefaultKeyframe(CSSPropertyID id, AnimationEf
fect::CompositeOperation op, double offset = 0) |
| 177 { | 177 { |
| 178 RefPtrWillBeRawPtr<AnimatableValue> value = nullptr; | 178 AnimatableValue* value = nullptr; |
| 179 if (id == CSSPropertyTransform) | 179 if (id == CSSPropertyTransform) |
| 180 value = AnimatableTransform::create(TransformOperations()); | 180 value = AnimatableTransform::create(TransformOperations()); |
| 181 else | 181 else |
| 182 value = AnimatableDouble::create(10.0); | 182 value = AnimatableDouble::create(10.0); |
| 183 | 183 |
| 184 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = createReplaceOpKe
yframe(id, value.get(), offset); | 184 AnimatableValueKeyframe* keyframe = createReplaceOpKeyframe(id, value, o
ffset); |
| 185 keyframe->setComposite(op); | 185 keyframe->setComposite(op); |
| 186 return keyframe; | 186 return keyframe; |
| 187 } | 187 } |
| 188 | 188 |
| 189 PassOwnPtrWillBeRawPtr<AnimatableValueKeyframeVector> createCompositableFloa
tKeyframeVector(size_t n) | 189 AnimatableValueKeyframeVector* createCompositableFloatKeyframeVector(size_t
n) |
| 190 { | 190 { |
| 191 Vector<double> values; | 191 Vector<double> values; |
| 192 for (size_t i = 0; i < n; i++) { | 192 for (size_t i = 0; i < n; i++) { |
| 193 values.append(static_cast<double>(i)); | 193 values.append(static_cast<double>(i)); |
| 194 } | 194 } |
| 195 return createCompositableFloatKeyframeVector(values); | 195 return createCompositableFloatKeyframeVector(values); |
| 196 } | 196 } |
| 197 | 197 |
| 198 PassOwnPtrWillBeRawPtr<AnimatableValueKeyframeVector> createCompositableFloa
tKeyframeVector(Vector<double>& values) | 198 AnimatableValueKeyframeVector* createCompositableFloatKeyframeVector(Vector<
double>& values) |
| 199 { | 199 { |
| 200 OwnPtrWillBeRawPtr<AnimatableValueKeyframeVector> frames = adoptPtrWillB
eNoop(new AnimatableValueKeyframeVector); | 200 AnimatableValueKeyframeVector* frames = new AnimatableValueKeyframeVecto
r; |
| 201 for (size_t i = 0; i < values.size(); i++) { | 201 for (size_t i = 0; i < values.size(); i++) { |
| 202 double offset = 1.0 / (values.size() - 1) * i; | 202 double offset = 1.0 / (values.size() - 1) * i; |
| 203 RefPtrWillBeRawPtr<AnimatableDouble> value = AnimatableDouble::creat
e(values[i]); | 203 AnimatableDouble* value = AnimatableDouble::create(values[i]); |
| 204 frames->append(createReplaceOpKeyframe(CSSPropertyOpacity, value.get
(), offset).get()); | 204 frames->append(createReplaceOpKeyframe(CSSPropertyOpacity, value, of
fset)); |
| 205 } | 205 } |
| 206 return frames.release(); | 206 return frames; |
| 207 } | 207 } |
| 208 | 208 |
| 209 PassOwnPtrWillBeRawPtr<AnimatableValueKeyframeVector> createCompositableTran
sformKeyframeVector(const Vector<TransformOperations>& values) | 209 AnimatableValueKeyframeVector* createCompositableTransformKeyframeVector(con
st Vector<TransformOperations>& values) |
| 210 { | 210 { |
| 211 OwnPtrWillBeRawPtr<AnimatableValueKeyframeVector> frames = adoptPtrWillB
eNoop(new AnimatableValueKeyframeVector); | 211 AnimatableValueKeyframeVector* frames = new AnimatableValueKeyframeVecto
r; |
| 212 for (size_t i = 0; i < values.size(); ++i) { | 212 for (size_t i = 0; i < values.size(); ++i) { |
| 213 double offset = 1.0f / (values.size() - 1) * i; | 213 double offset = 1.0f / (values.size() - 1) * i; |
| 214 RefPtrWillBeRawPtr<AnimatableTransform> value = AnimatableTransform:
:create(values[i]); | 214 AnimatableTransform* value = AnimatableTransform::create(values[i]); |
| 215 frames->append(createReplaceOpKeyframe(CSSPropertyTransform, value.g
et(), offset).get()); | 215 frames->append(createReplaceOpKeyframe(CSSPropertyTransform, value,
offset)); |
| 216 } | 216 } |
| 217 return frames.release(); | 217 return frames; |
| 218 } | 218 } |
| 219 | 219 |
| 220 PassRefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> createKeyframeEff
ectModel(PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> prpFrom, PassRefPtrWill
BeRawPtr<AnimatableValueKeyframe> prpTo, PassRefPtrWillBeRawPtr<AnimatableValueK
eyframe> prpC = nullptr, PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> prpD =
nullptr) | 220 AnimatableValueKeyframeEffectModel* createKeyframeEffectModel(AnimatableValu
eKeyframe* prpFrom, AnimatableValueKeyframe* prpTo, AnimatableValueKeyframe* prp
C = nullptr, AnimatableValueKeyframe* prpD = nullptr) |
| 221 { | 221 { |
| 222 RefPtrWillBeRawPtr<AnimatableValueKeyframe> from = prpFrom; | 222 AnimatableValueKeyframe* from = prpFrom; |
| 223 RefPtrWillBeRawPtr<AnimatableValueKeyframe> to = prpTo; | 223 AnimatableValueKeyframe* to = prpTo; |
| 224 RefPtrWillBeRawPtr<AnimatableValueKeyframe> c = prpC; | 224 AnimatableValueKeyframe* c = prpC; |
| 225 RefPtrWillBeRawPtr<AnimatableValueKeyframe> d = prpD; | 225 AnimatableValueKeyframe* d = prpD; |
| 226 | 226 |
| 227 EXPECT_EQ(from->offset(), 0); | 227 EXPECT_EQ(from->offset(), 0); |
| 228 AnimatableValueKeyframeVector frames; | 228 AnimatableValueKeyframeVector frames; |
| 229 frames.append(from); | 229 frames.append(from); |
| 230 EXPECT_LE(from->offset(), to->offset()); | 230 EXPECT_LE(from->offset(), to->offset()); |
| 231 frames.append(to); | 231 frames.append(to); |
| 232 if (c) { | 232 if (c) { |
| 233 EXPECT_LE(to->offset(), c->offset()); | 233 EXPECT_LE(to->offset(), c->offset()); |
| 234 frames.append(c); | 234 frames.append(c); |
| 235 } | 235 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 : LayoutObject(node) | 274 : LayoutObject(node) |
| 275 { | 275 { |
| 276 } | 276 } |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 // ----------------------------------------------------------------------- | 279 // ----------------------------------------------------------------------- |
| 280 // ----------------------------------------------------------------------- | 280 // ----------------------------------------------------------------------- |
| 281 | 281 |
| 282 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) | 282 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) |
| 283 { | 283 { |
| 284 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDef
aultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace); | 284 AnimatableValueKeyframe* keyframeGoodMultiple = createDefaultKeyframe(CSSPro
pertyOpacity, AnimationEffect::CompositeReplace); |
| 285 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations()).get()); | 285 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations())); |
| 286 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); | 286 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple)); |
| 287 | 287 |
| 288 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDe
faultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace); | 288 AnimatableValueKeyframe* keyframeBadMultipleID = createDefaultKeyframe(CSSPr
opertyColor, AnimationEffect::CompositeReplace); |
| 289 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); | 289 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0)); |
| 290 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMu
ltipleID.get())); | 290 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMu
ltipleID)); |
| 291 } | 291 } |
| 292 | 292 |
| 293 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) | 293 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) |
| 294 { | 294 { |
| 295 TransformOperations ops; | 295 TransformOperations ops; |
| 296 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(2, Fixed), TransformOperation::TranslateX)); | 296 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(2, Fixed), TransformOperation::TranslateX)); |
| 297 RefPtrWillBeRawPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops).get()); | 297 AnimatableValueKeyframe* goodKeyframe = createReplaceOpKeyframe(CSSPropertyT
ransform, AnimatableTransform::create(ops)); |
| 298 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.g
et())); | 298 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe))
; |
| 299 | 299 |
| 300 ops.operations().append(TranslateTransformOperation::create(Length(50, Perce
nt), Length(2, Fixed), TransformOperation::TranslateX)); | 300 ops.operations().append(TranslateTransformOperation::create(Length(50, Perce
nt), Length(2, Fixed), TransformOperation::TranslateX)); |
| 301 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKey
frame(CSSPropertyTransform, AnimatableTransform::create(ops).get()); | 301 AnimatableValueKeyframe* badKeyframe = createReplaceOpKeyframe(CSSPropertyTr
ansform, AnimatableTransform::create(ops)); |
| 302 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.g
et())); | 302 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe))
; |
| 303 | 303 |
| 304 TransformOperations ops2; | 304 TransformOperations ops2; |
| 305 Length calcLength = Length(100, Percent).blend(Length(100, Fixed), 0.5, Valu
eRangeAll); | 305 Length calcLength = Length(100, Percent).blend(Length(100, Fixed), 0.5, Valu
eRangeAll); |
| 306 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, Fixed), TransformOperation::TranslateX)); | 306 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, Fixed), TransformOperation::TranslateX)); |
| 307 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops2).get()); | 307 AnimatableValueKeyframe* badKeyframe2 = createReplaceOpKeyframe(CSSPropertyT
ransform, AnimatableTransform::create(ops2)); |
| 308 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.
get())); | 308 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2)
); |
| 309 } | 309 } |
| 310 | 310 |
| 311 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) | 311 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) |
| 312 { | 312 { |
| 313 AnimatableValueKeyframeVector framesSame; | 313 AnimatableValueKeyframeVector framesSame; |
| 314 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0).get()); | 314 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0)); |
| 315 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0).get()); | 315 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0)); |
| 316 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKe
yframeEffectModel::create(framesSame).get())); | 316 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKe
yframeEffectModel::create(framesSame))); |
| 317 | 317 |
| 318 AnimatableValueKeyframeVector framesMixed; | 318 AnimatableValueKeyframeVector framesMixed; |
| 319 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect
::CompositeReplace, 0.0).get()); | 319 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect
::CompositeReplace, 0.0)); |
| 320 framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, AnimationEffe
ct::CompositeReplace, 1.0).get()); | 320 framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, AnimationEffe
ct::CompositeReplace, 1.0)); |
| 321 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixed).get())); | 321 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixed))); |
| 322 } | 322 } |
| 323 | 323 |
| 324 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModel) | 324 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModel) |
| 325 { | 325 { |
| 326 AnimatableValueKeyframeVector framesSame; | 326 AnimatableValueKeyframeVector framesSame; |
| 327 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 0.0).get()); | 327 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 0.0)); |
| 328 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 1.0).get()); | 328 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 1.0)); |
| 329 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesSame).get())); | 329 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesSame))); |
| 330 | 330 |
| 331 AnimatableValueKeyframeVector framesMixedProperties; | 331 AnimatableValueKeyframeVector framesMixedProperties; |
| 332 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, Anima
tionEffect::CompositeReplace, 0.0).get()); | 332 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, Anima
tionEffect::CompositeReplace, 0.0)); |
| 333 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, Animati
onEffect::CompositeReplace, 1.0).get()); | 333 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, Animati
onEffect::CompositeReplace, 1.0)); |
| 334 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixedProperties).get())); | 334 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixedProperties))); |
| 335 } | 335 } |
| 336 | 336 |
| 337 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) | 337 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) |
| 338 { | 338 { |
| 339 Vector<TransformOperations> transformVector; | 339 Vector<TransformOperations> transformVector; |
| 340 transformVector.append(TransformOperations()); | 340 transformVector.append(TransformOperations()); |
| 341 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(0, Fixed), Length(0, Fixed), 0.0, TransformOperation::Translate3D)); | 341 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(0, Fixed), Length(0, Fixed), 0.0, TransformOperation::Translate3D)); |
| 342 transformVector.append(TransformOperations()); | 342 transformVector.append(TransformOperations()); |
| 343 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(200, Fixed), Length(200, Fixed), 0.0, TransformOperation::Translate3D)
); | 343 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(200, Fixed), Length(200, Fixed), 0.0, TransformOperation::Translate3D)
); |
| 344 OwnPtrWillBePersistent<AnimatableValueKeyframeVector> frames = createComposi
tableTransformKeyframeVector(transformVector); | 344 Persistent<AnimatableValueKeyframeVector> frames = createCompositableTransfo
rmKeyframeVector(transformVector); |
| 345 FloatBox bounds; | 345 FloatBox bounds; |
| 346 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), 0, 1)); | 346 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames), 0, 1)); |
| 347 EXPECT_EQ(FloatBox(0.0f, 0.f, 0.0f, 200.0f, 200.0f, 0.0f), bounds); | 347 EXPECT_EQ(FloatBox(0.0f, 0.f, 0.0f, 200.0f, 200.0f, 0.0f), bounds); |
| 348 bounds = FloatBox(); | 348 bounds = FloatBox(); |
| 349 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), -1, 1)); | 349 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames), -1, 1)); |
| 350 EXPECT_EQ(FloatBox(-200.0f, -200.0, 0.0, 400.0f, 400.0f, 0.0f), bounds); | 350 EXPECT_EQ(FloatBox(-200.0f, -200.0, 0.0, 400.0f, 400.0f, 0.0f), bounds); |
| 351 transformVector.append(TransformOperations()); | 351 transformVector.append(TransformOperations()); |
| 352 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(-300, Fixed), Length(-400, Fixed), 1.0f, TransformOperation::Translate
3D)); | 352 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(-300, Fixed), Length(-400, Fixed), 1.0f, TransformOperation::Translate
3D)); |
| 353 bounds = FloatBox(); | 353 bounds = FloatBox(); |
| 354 frames = createCompositableTransformKeyframeVector(transformVector); | 354 frames = createCompositableTransformKeyframeVector(transformVector); |
| 355 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), 0, 1)); | 355 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames), 0, 1)); |
| 356 EXPECT_EQ(FloatBox(-300.0f, -400.f, 0.0f, 500.0f, 600.0f, 1.0f), bounds); | 356 EXPECT_EQ(FloatBox(-300.0f, -400.f, 0.0f, 500.0f, 600.0f, 1.0f), bounds); |
| 357 bounds = FloatBox(); | 357 bounds = FloatBox(); |
| 358 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), -1, 2)); | 358 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames), -1, 2)); |
| 359 EXPECT_EQ(FloatBox(-1300.0f, -1600.f, 0.0f, 1500.0f, 1800.0f, 3.0f), bounds)
; | 359 EXPECT_EQ(FloatBox(-1300.0f, -1600.f, 0.0f, 1500.0f, 1800.0f, 3.0f), bounds)
; |
| 360 } | 360 } |
| 361 | 361 |
| 362 TEST_F(AnimationCompositorAnimationsTest, ConvertTimingForCompositorStartDelay) | 362 TEST_F(AnimationCompositorAnimationsTest, ConvertTimingForCompositorStartDelay) |
| 363 { | 363 { |
| 364 m_timing.iterationDuration = 20.0; | 364 m_timing.iterationDuration = 20.0; |
| 365 | 365 |
| 366 m_timing.startDelay = 2.0; | 366 m_timing.startDelay = 2.0; |
| 367 EXPECT_TRUE(convertTimingForCompositor(m_timing, m_compositorTiming)); | 367 EXPECT_TRUE(convertTimingForCompositor(m_timing, m_compositorTiming)); |
| 368 EXPECT_DOUBLE_EQ(-2.0, m_compositorTiming.scaledTimeOffset); | 368 EXPECT_DOUBLE_EQ(-2.0, m_compositorTiming.scaledTimeOffset); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); | 600 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); |
| 601 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector5); | 601 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector5); |
| 602 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); | 602 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
| 603 } | 603 } |
| 604 | 604 |
| 605 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) | 605 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) |
| 606 { | 606 { |
| 607 Timing linearTiming(createCompositableTiming()); | 607 Timing linearTiming(createCompositableTiming()); |
| 608 | 608 |
| 609 AnimatableValueKeyframeVector basicFramesVector; | 609 AnimatableValueKeyframeVector basicFramesVector; |
| 610 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation
Effect::CompositeReplace, 0.0).get()); | 610 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation
Effect::CompositeReplace, 0.0)); |
| 611 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation
Effect::CompositeReplace, 1.0).get()); | 611 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation
Effect::CompositeReplace, 1.0)); |
| 612 | 612 |
| 613 AnimatableValueKeyframeVector nonBasicFramesVector; | 613 AnimatableValueKeyframeVector nonBasicFramesVector; |
| 614 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 0.0).get()); | 614 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 0.0)); |
| 615 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 0.5).get()); | 615 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 0.5)); |
| 616 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 1.0).get()); | 616 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 1.0)); |
| 617 | 617 |
| 618 basicFramesVector[0]->setEasing(m_linearTimingFunction.get()); | 618 basicFramesVector[0]->setEasing(m_linearTimingFunction.get()); |
| 619 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> basicFrames = Animata
bleValueKeyframeEffectModel::create(basicFramesVector).get(); | 619 AnimatableValueKeyframeEffectModel* basicFrames = AnimatableValueKeyframeEff
ectModel::create(basicFramesVector); |
| 620 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames.g
et())); | 620 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames))
; |
| 621 | 621 |
| 622 basicFramesVector[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::EaseIn)); | 622 basicFramesVector[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::EaseIn)); |
| 623 basicFrames = AnimatableValueKeyframeEffectModel::create(basicFramesVector).
get(); | 623 basicFrames = AnimatableValueKeyframeEffectModel::create(basicFramesVector); |
| 624 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames.g
et())); | 624 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames))
; |
| 625 | 625 |
| 626 nonBasicFramesVector[0]->setEasing(m_linearTimingFunction.get()); | 626 nonBasicFramesVector[0]->setEasing(m_linearTimingFunction.get()); |
| 627 nonBasicFramesVector[1]->setEasing(CubicBezierTimingFunction::preset(CubicBe
zierTimingFunction::EaseIn)); | 627 nonBasicFramesVector[1]->setEasing(CubicBezierTimingFunction::preset(CubicBe
zierTimingFunction::EaseIn)); |
| 628 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> nonBasicFrames = Anim
atableValueKeyframeEffectModel::create(nonBasicFramesVector).get(); | 628 AnimatableValueKeyframeEffectModel* nonBasicFrames = AnimatableValueKeyframe
EffectModel::create(nonBasicFramesVector); |
| 629 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *nonBasicFrame
s.get())); | 629 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *nonBasicFrame
s)); |
| 630 } | 630 } |
| 631 | 631 |
| 632 // ----------------------------------------------------------------------- | 632 // ----------------------------------------------------------------------- |
| 633 // ----------------------------------------------------------------------- | 633 // ----------------------------------------------------------------------- |
| 634 | 634 |
| 635 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) | 635 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) |
| 636 { | 636 { |
| 637 // Animation to convert | 637 // Animation to convert |
| 638 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 638 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 639 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 639 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 640 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 640 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 641 // -- | 641 // -- |
| 642 | 642 |
| 643 WebCompositorSupportMock mockCompositor; | 643 WebCompositorSupportMock mockCompositor; |
| 644 | 644 |
| 645 // Curve is created | 645 // Curve is created |
| 646 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 646 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 647 ExpectationSet usesMockCurve; | 647 ExpectationSet usesMockCurve; |
| 648 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 648 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| 649 .WillOnce(Return(mockCurvePtr)); | 649 .WillOnce(Return(mockCurvePtr)); |
| 650 | 650 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 666 EXPECT_CALL(*mockAnimationPtr, delete_()) | 666 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 667 .Times(1) | 667 .Times(1) |
| 668 .After(usesMockAnimation); | 668 .After(usesMockAnimation); |
| 669 EXPECT_CALL(*mockCurvePtr, delete_()) | 669 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 670 .Times(1) | 670 .Times(1) |
| 671 .After(usesMockCurve); | 671 .After(usesMockCurve); |
| 672 | 672 |
| 673 // Go! | 673 // Go! |
| 674 setCompositorForTesting(mockCompositor); | 674 setCompositorForTesting(mockCompositor); |
| 675 Vector<OwnPtr<WebCompositorAnimation>> result; | 675 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 676 getAnimationOnCompositor(m_timing, *effect.get(), result); | 676 getAnimationOnCompositor(m_timing, *effect, result); |
| 677 EXPECT_EQ(1U, result.size()); | 677 EXPECT_EQ(1U, result.size()); |
| 678 result[0].clear(); | 678 result[0].clear(); |
| 679 } | 679 } |
| 680 | 680 |
| 681 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) | 681 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
| 682 { | 682 { |
| 683 // Animation to convert | 683 // Animation to convert |
| 684 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 684 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 685 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 685 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 686 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 686 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 687 | 687 |
| 688 m_timing.iterationDuration = 10.0; | 688 m_timing.iterationDuration = 10.0; |
| 689 // -- | 689 // -- |
| 690 | 690 |
| 691 WebCompositorSupportMock mockCompositor; | 691 WebCompositorSupportMock mockCompositor; |
| 692 | 692 |
| 693 // Curve is created | 693 // Curve is created |
| 694 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 694 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 695 ExpectationSet usesMockCurve; | 695 ExpectationSet usesMockCurve; |
| 696 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 696 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 714 EXPECT_CALL(*mockAnimationPtr, delete_()) | 714 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 715 .Times(1) | 715 .Times(1) |
| 716 .After(usesMockAnimation); | 716 .After(usesMockAnimation); |
| 717 EXPECT_CALL(*mockCurvePtr, delete_()) | 717 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 718 .Times(1) | 718 .Times(1) |
| 719 .After(usesMockCurve); | 719 .After(usesMockCurve); |
| 720 | 720 |
| 721 // Go! | 721 // Go! |
| 722 setCompositorForTesting(mockCompositor); | 722 setCompositorForTesting(mockCompositor); |
| 723 Vector<OwnPtr<WebCompositorAnimation>> result; | 723 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 724 getAnimationOnCompositor(m_timing, *effect.get(), result); | 724 getAnimationOnCompositor(m_timing, *effect, result); |
| 725 EXPECT_EQ(1U, result.size()); | 725 EXPECT_EQ(1U, result.size()); |
| 726 result[0].clear(); | 726 result[0].clear(); |
| 727 } | 727 } |
| 728 | 728 |
| 729 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) | 729 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) |
| 730 { | 730 { |
| 731 // Animation to convert | 731 // Animation to convert |
| 732 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 732 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 733 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 733 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 734 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), | 734 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0), 0.25), |
| 735 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), | 735 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0), 0.5), |
| 736 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 736 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 737 | 737 |
| 738 m_timing.iterationCount = 5; | 738 m_timing.iterationCount = 5; |
| 739 m_timing.direction = Timing::PlaybackDirectionAlternate; | 739 m_timing.direction = Timing::PlaybackDirectionAlternate; |
| 740 m_timing.playbackRate = 2.0; | 740 m_timing.playbackRate = 2.0; |
| 741 // -- | 741 // -- |
| 742 | 742 |
| 743 WebCompositorSupportMock mockCompositor; | 743 WebCompositorSupportMock mockCompositor; |
| 744 | 744 |
| 745 // Curve is created | 745 // Curve is created |
| 746 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 746 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 769 EXPECT_CALL(*mockAnimationPtr, delete_()) | 769 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 770 .Times(1) | 770 .Times(1) |
| 771 .After(usesMockAnimation); | 771 .After(usesMockAnimation); |
| 772 EXPECT_CALL(*mockCurvePtr, delete_()) | 772 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 773 .Times(1) | 773 .Times(1) |
| 774 .After(usesMockCurve); | 774 .After(usesMockCurve); |
| 775 | 775 |
| 776 // Go! | 776 // Go! |
| 777 setCompositorForTesting(mockCompositor); | 777 setCompositorForTesting(mockCompositor); |
| 778 Vector<OwnPtr<WebCompositorAnimation>> result; | 778 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 779 getAnimationOnCompositor(m_timing, *effect.get(), result); | 779 getAnimationOnCompositor(m_timing, *effect, result); |
| 780 EXPECT_EQ(1U, result.size()); | 780 EXPECT_EQ(1U, result.size()); |
| 781 result[0].clear(); | 781 result[0].clear(); |
| 782 } | 782 } |
| 783 | 783 |
| 784 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) | 784 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) |
| 785 { | 785 { |
| 786 // Animation to convert | 786 // Animation to convert |
| 787 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 787 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 788 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 788 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 789 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 789 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 790 | 790 |
| 791 m_timing.iterationCount = 5.0; | 791 m_timing.iterationCount = 5.0; |
| 792 m_timing.iterationDuration = 1.75; | 792 m_timing.iterationDuration = 1.75; |
| 793 m_timing.startDelay = 3.25; | 793 m_timing.startDelay = 3.25; |
| 794 // -- | 794 // -- |
| 795 | 795 |
| 796 WebCompositorSupportMock mockCompositor; | 796 WebCompositorSupportMock mockCompositor; |
| 797 | 797 |
| 798 // Curve is created | 798 // Curve is created |
| 799 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 799 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 819 EXPECT_CALL(*mockAnimationPtr, delete_()) | 819 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 820 .Times(1) | 820 .Times(1) |
| 821 .After(usesMockAnimation); | 821 .After(usesMockAnimation); |
| 822 EXPECT_CALL(*mockCurvePtr, delete_()) | 822 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 823 .Times(1) | 823 .Times(1) |
| 824 .After(usesMockCurve); | 824 .After(usesMockCurve); |
| 825 | 825 |
| 826 // Go! | 826 // Go! |
| 827 setCompositorForTesting(mockCompositor); | 827 setCompositorForTesting(mockCompositor); |
| 828 Vector<OwnPtr<WebCompositorAnimation>> result; | 828 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 829 getAnimationOnCompositor(m_timing, *effect.get(), result); | 829 getAnimationOnCompositor(m_timing, *effect, result); |
| 830 EXPECT_EQ(1U, result.size()); | 830 EXPECT_EQ(1U, result.size()); |
| 831 result[0].clear(); | 831 result[0].clear(); |
| 832 } | 832 } |
| 833 | 833 |
| 834 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) | 834 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) |
| 835 { | 835 { |
| 836 // Animation to convert | 836 // Animation to convert |
| 837 AnimatableValueKeyframeVector frames; | 837 AnimatableValueKeyframeVector frames; |
| 838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0), 0)); |
| 839 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 839 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0), 0.25)); |
| 840 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 840 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0), 0.5)); |
| 841 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 841 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0), 1.0)); |
| 842 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); | 842 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); |
| 843 frames[1]->setEasing(m_linearTimingFunction.get()); | 843 frames[1]->setEasing(m_linearTimingFunction.get()); |
| 844 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); | 844 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); |
| 845 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); | 845 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo
del::create(frames); |
| 846 | 846 |
| 847 m_timing.timingFunction = m_linearTimingFunction.get(); | 847 m_timing.timingFunction = m_linearTimingFunction.get(); |
| 848 m_timing.iterationDuration = 2.0; | 848 m_timing.iterationDuration = 2.0; |
| 849 m_timing.iterationCount = 10; | 849 m_timing.iterationCount = 10; |
| 850 m_timing.direction = Timing::PlaybackDirectionAlternate; | 850 m_timing.direction = Timing::PlaybackDirectionAlternate; |
| 851 // -- | 851 // -- |
| 852 | 852 |
| 853 WebCompositorSupportMock mockCompositor; | 853 WebCompositorSupportMock mockCompositor; |
| 854 | 854 |
| 855 // Curve is created | 855 // Curve is created |
| (...skipping 23 matching lines...) Expand all Loading... |
| 879 EXPECT_CALL(*mockAnimationPtr, delete_()) | 879 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 880 .Times(1) | 880 .Times(1) |
| 881 .After(usesMockAnimation); | 881 .After(usesMockAnimation); |
| 882 EXPECT_CALL(*mockCurvePtr, delete_()) | 882 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 883 .Times(1) | 883 .Times(1) |
| 884 .After(usesMockCurve); | 884 .After(usesMockCurve); |
| 885 | 885 |
| 886 // Go! | 886 // Go! |
| 887 setCompositorForTesting(mockCompositor); | 887 setCompositorForTesting(mockCompositor); |
| 888 Vector<OwnPtr<WebCompositorAnimation>> result; | 888 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 889 getAnimationOnCompositor(m_timing, *effect.get(), result); | 889 getAnimationOnCompositor(m_timing, *effect, result); |
| 890 EXPECT_EQ(1U, result.size()); | 890 EXPECT_EQ(1U, result.size()); |
| 891 result[0].clear(); | 891 result[0].clear(); |
| 892 } | 892 } |
| 893 | 893 |
| 894 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) | 894 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
| 895 { | 895 { |
| 896 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); | 896 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); |
| 897 | 897 |
| 898 // Animation to convert | 898 // Animation to convert |
| 899 AnimatableValueKeyframeVector frames; | 899 AnimatableValueKeyframeVector frames; |
| 900 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 900 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0), 0)); |
| 901 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 901 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0), 0.25)); |
| 902 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 902 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0), 0.5)); |
| 903 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 903 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0), 1.0)); |
| 904 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); | 904 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); |
| 905 frames[1]->setEasing(m_linearTimingFunction.get()); | 905 frames[1]->setEasing(m_linearTimingFunction.get()); |
| 906 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); | 906 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); |
| 907 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); | 907 AnimatableValueKeyframeEffectModel* effect = AnimatableValueKeyframeEffectMo
del::create(frames); |
| 908 | 908 |
| 909 m_timing.timingFunction = m_linearTimingFunction.get(); | 909 m_timing.timingFunction = m_linearTimingFunction.get(); |
| 910 m_timing.iterationCount = 10; | 910 m_timing.iterationCount = 10; |
| 911 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 911 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| 912 // -- | 912 // -- |
| 913 | 913 |
| 914 WebCompositorSupportMock mockCompositor; | 914 WebCompositorSupportMock mockCompositor; |
| 915 | 915 |
| 916 // Curve is created | 916 // Curve is created |
| 917 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 917 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 940 EXPECT_CALL(*mockAnimationPtr, delete_()) | 940 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 941 .Times(1) | 941 .Times(1) |
| 942 .After(usesMockAnimation); | 942 .After(usesMockAnimation); |
| 943 EXPECT_CALL(*mockCurvePtr, delete_()) | 943 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 944 .Times(1) | 944 .Times(1) |
| 945 .After(usesMockCurve); | 945 .After(usesMockCurve); |
| 946 | 946 |
| 947 // Go! | 947 // Go! |
| 948 setCompositorForTesting(mockCompositor); | 948 setCompositorForTesting(mockCompositor); |
| 949 Vector<OwnPtr<WebCompositorAnimation>> result; | 949 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 950 getAnimationOnCompositor(m_timing, *effect.get(), result); | 950 getAnimationOnCompositor(m_timing, *effect, result); |
| 951 EXPECT_EQ(1U, result.size()); | 951 EXPECT_EQ(1U, result.size()); |
| 952 result[0].clear(); | 952 result[0].clear(); |
| 953 } | 953 } |
| 954 | 954 |
| 955 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) | 955 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) |
| 956 { | 956 { |
| 957 // Animation to convert | 957 // Animation to convert |
| 958 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 958 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 959 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 959 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 961 | 961 |
| 962 m_timing.iterationCount = 5.0; | 962 m_timing.iterationCount = 5.0; |
| 963 m_timing.iterationDuration = 1.5; | 963 m_timing.iterationDuration = 1.5; |
| 964 m_timing.startDelay = -3; | 964 m_timing.startDelay = -3; |
| 965 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 965 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
| 966 // -- | 966 // -- |
| 967 | 967 |
| 968 WebCompositorSupportMock mockCompositor; | 968 WebCompositorSupportMock mockCompositor; |
| 969 | 969 |
| 970 // Curve is created | 970 // Curve is created |
| (...skipping 20 matching lines...) Expand all Loading... |
| 991 EXPECT_CALL(*mockAnimationPtr, delete_()) | 991 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 992 .Times(1) | 992 .Times(1) |
| 993 .After(usesMockAnimation); | 993 .After(usesMockAnimation); |
| 994 EXPECT_CALL(*mockCurvePtr, delete_()) | 994 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 995 .Times(1) | 995 .Times(1) |
| 996 .After(usesMockCurve); | 996 .After(usesMockCurve); |
| 997 | 997 |
| 998 // Go! | 998 // Go! |
| 999 setCompositorForTesting(mockCompositor); | 999 setCompositorForTesting(mockCompositor); |
| 1000 Vector<OwnPtr<WebCompositorAnimation>> result; | 1000 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 1001 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1001 getAnimationOnCompositor(m_timing, *effect, result); |
| 1002 EXPECT_EQ(1U, result.size()); | 1002 EXPECT_EQ(1U, result.size()); |
| 1003 result[0].clear(); | 1003 result[0].clear(); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
tes) | 1006 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
tes) |
| 1007 { | 1007 { |
| 1008 // Animation to convert | 1008 // Animation to convert |
| 1009 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1009 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1010 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1010 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 1011 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1011 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 1012 | 1012 |
| 1013 m_timing.playbackRate = 2; | 1013 m_timing.playbackRate = 2; |
| 1014 // -- | 1014 // -- |
| 1015 | 1015 |
| 1016 WebCompositorSupportMock mockCompositor; | 1016 WebCompositorSupportMock mockCompositor; |
| 1017 | 1017 |
| 1018 // Curve is created | 1018 // Curve is created |
| 1019 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1019 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1020 ExpectationSet usesMockCurve; | 1020 ExpectationSet usesMockCurve; |
| 1021 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 1021 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1040 .Times(1) | 1040 .Times(1) |
| 1041 .After(usesMockAnimation); | 1041 .After(usesMockAnimation); |
| 1042 EXPECT_CALL(*mockCurvePtr, delete_()) | 1042 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1043 .Times(1) | 1043 .Times(1) |
| 1044 .After(usesMockCurve); | 1044 .After(usesMockCurve); |
| 1045 | 1045 |
| 1046 // Go! | 1046 // Go! |
| 1047 setCompositorForTesting(mockCompositor); | 1047 setCompositorForTesting(mockCompositor); |
| 1048 Vector<OwnPtr<WebCompositorAnimation>> result; | 1048 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 1049 // Set player plaback rate also | 1049 // Set player plaback rate also |
| 1050 getAnimationOnCompositor(m_timing, *effect.get(), result, -1.5); | 1050 getAnimationOnCompositor(m_timing, *effect, result, -1.5); |
| 1051 EXPECT_EQ(1U, result.size()); | 1051 EXPECT_EQ(1U, result.size()); |
| 1052 result[0].clear(); | 1052 result[0].clear(); |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
ne) | 1055 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
ne) |
| 1056 { | 1056 { |
| 1057 // Animation to convert | 1057 // Animation to convert |
| 1058 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1058 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1059 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1059 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 1060 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1060 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 1061 | 1061 |
| 1062 m_timing.fillMode = Timing::FillModeNone; | 1062 m_timing.fillMode = Timing::FillModeNone; |
| 1063 | 1063 |
| 1064 WebCompositorSupportMock mockCompositor; | 1064 WebCompositorSupportMock mockCompositor; |
| 1065 | 1065 |
| 1066 // Curve is created | 1066 // Curve is created |
| 1067 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1067 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1068 ExpectationSet usesMockCurve; | 1068 ExpectationSet usesMockCurve; |
| 1069 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 1069 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| 1070 .WillOnce(Return(mockCurvePtr)); | 1070 .WillOnce(Return(mockCurvePtr)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1088 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1088 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1089 .Times(1) | 1089 .Times(1) |
| 1090 .After(usesMockAnimation); | 1090 .After(usesMockAnimation); |
| 1091 EXPECT_CALL(*mockCurvePtr, delete_()) | 1091 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1092 .Times(1) | 1092 .Times(1) |
| 1093 .After(usesMockCurve); | 1093 .After(usesMockCurve); |
| 1094 | 1094 |
| 1095 // Go! | 1095 // Go! |
| 1096 setCompositorForTesting(mockCompositor); | 1096 setCompositorForTesting(mockCompositor); |
| 1097 Vector<OwnPtr<WebCompositorAnimation>> result; | 1097 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 1098 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1098 getAnimationOnCompositor(m_timing, *effect, result); |
| 1099 EXPECT_EQ(1U, result.size()); | 1099 EXPECT_EQ(1U, result.size()); |
| 1100 result[0].clear(); | 1100 result[0].clear(); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
to) | 1103 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
to) |
| 1104 { | 1104 { |
| 1105 // Animation to convert | 1105 // Animation to convert |
| 1106 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1106 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1107 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1107 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 1108 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1108 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 1109 | 1109 |
| 1110 m_timing.fillMode = Timing::FillModeAuto; | 1110 m_timing.fillMode = Timing::FillModeAuto; |
| 1111 | 1111 |
| 1112 WebCompositorSupportMock mockCompositor; | 1112 WebCompositorSupportMock mockCompositor; |
| 1113 | 1113 |
| 1114 // Curve is created | 1114 // Curve is created |
| 1115 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1115 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1116 ExpectationSet usesMockCurve; | 1116 ExpectationSet usesMockCurve; |
| 1117 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 1117 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| 1118 .WillOnce(Return(mockCurvePtr)); | 1118 .WillOnce(Return(mockCurvePtr)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1136 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1136 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1137 .Times(1) | 1137 .Times(1) |
| 1138 .After(usesMockAnimation); | 1138 .After(usesMockAnimation); |
| 1139 EXPECT_CALL(*mockCurvePtr, delete_()) | 1139 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1140 .Times(1) | 1140 .Times(1) |
| 1141 .After(usesMockCurve); | 1141 .After(usesMockCurve); |
| 1142 | 1142 |
| 1143 // Go! | 1143 // Go! |
| 1144 setCompositorForTesting(mockCompositor); | 1144 setCompositorForTesting(mockCompositor); |
| 1145 Vector<OwnPtr<WebCompositorAnimation>> result; | 1145 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 1146 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1146 getAnimationOnCompositor(m_timing, *effect, result); |
| 1147 EXPECT_EQ(1U, result.size()); | 1147 EXPECT_EQ(1U, result.size()); |
| 1148 result[0].clear(); | 1148 result[0].clear(); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) | 1151 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) |
| 1152 { | 1152 { |
| 1153 // Animation to convert | 1153 // Animation to convert |
| 1154 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1154 AnimatableValueKeyframeEffectModel* effect = createKeyframeEffectModel( |
| 1155 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1155 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
), 0), |
| 1156 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1156 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
), 1.0)); |
| 1157 | 1157 |
| 1158 m_timing.timingFunction = m_cubicCustomTimingFunction; | 1158 m_timing.timingFunction = m_cubicCustomTimingFunction; |
| 1159 | 1159 |
| 1160 WebCompositorSupportMock mockCompositor; | 1160 WebCompositorSupportMock mockCompositor; |
| 1161 | 1161 |
| 1162 // Curve is created | 1162 // Curve is created |
| 1163 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1163 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1164 ExpectationSet usesMockCurve; | 1164 ExpectationSet usesMockCurve; |
| 1165 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 1165 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| 1166 .WillOnce(Return(mockCurvePtr)); | 1166 .WillOnce(Return(mockCurvePtr)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1184 EXPECT_CALL(*mockAnimationPtr, delete_()) | 1184 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1185 .Times(1) | 1185 .Times(1) |
| 1186 .After(usesMockAnimation); | 1186 .After(usesMockAnimation); |
| 1187 EXPECT_CALL(*mockCurvePtr, delete_()) | 1187 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1188 .Times(1) | 1188 .Times(1) |
| 1189 .After(usesMockCurve); | 1189 .After(usesMockCurve); |
| 1190 | 1190 |
| 1191 // Go! | 1191 // Go! |
| 1192 setCompositorForTesting(mockCompositor); | 1192 setCompositorForTesting(mockCompositor); |
| 1193 Vector<OwnPtr<WebCompositorAnimation>> result; | 1193 Vector<OwnPtr<WebCompositorAnimation>> result; |
| 1194 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1194 getAnimationOnCompositor(m_timing, *effect, result); |
| 1195 EXPECT_EQ(1U, result.size()); | 1195 EXPECT_EQ(1U, result.size()); |
| 1196 result[0].clear(); | 1196 result[0].clear(); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
) | 1199 TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
) |
| 1200 { | 1200 { |
| 1201 WebCompositorSupportMock mockCompositor; | 1201 WebCompositorSupportMock mockCompositor; |
| 1202 setCompositorForTesting(mockCompositor); | 1202 setCompositorForTesting(mockCompositor); |
| 1203 | 1203 |
| 1204 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); | 1204 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); |
| 1205 | 1205 |
| 1206 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); | 1206 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); |
| 1207 element->setLayoutObject(layoutObject); | 1207 element->setLayoutObject(layoutObject); |
| 1208 | 1208 |
| 1209 AnimatableValueKeyframeVector keyFrames; | 1209 AnimatableValueKeyframeVector keyFrames; |
| 1210 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 0.0).get()); | 1210 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 0.0)); |
| 1211 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 1.0).get()); | 1211 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 1.0)); |
| 1212 RefPtrWillBeRawPtr<AnimationEffect> animationEffect1 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); | 1212 AnimationEffect* animationEffect1 = AnimatableValueKeyframeEffectModel::crea
te(keyFrames); |
| 1213 RefPtrWillBeRawPtr<AnimationEffect> animationEffect2 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); | 1213 AnimationEffect* animationEffect2 = AnimatableValueKeyframeEffectModel::crea
te(keyFrames); |
| 1214 | 1214 |
| 1215 Timing timing; | 1215 Timing timing; |
| 1216 timing.iterationDuration = 1.f; | 1216 timing.iterationDuration = 1.f; |
| 1217 | 1217 |
| 1218 // The first player for opacity is ok to run on compositor. | 1218 // The first player for opacity is ok to run on compositor. |
| 1219 RefPtrWillBeRawPtr<Animation> animation1 = Animation::create(element.get(),
animationEffect1, timing); | 1219 Animation* animation1 = Animation::create(element.get(), animationEffect1, t
iming); |
| 1220 RefPtrWillBePersistent<AnimationPlayer> player1 = m_timeline->play(animation
1.get()); | 1220 RefPtrWillBePersistent<AnimationPlayer> player1 = m_timeline->play(animation
1); |
| 1221 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo
sitor(timing, *element.get(), player1.get(), *animationEffect1.get(), 1)); | 1221 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo
sitor(timing, *element.get(), player1.get(), *animationEffect1, 1)); |
| 1222 | 1222 |
| 1223 // simulate Animation::maybeStartAnimationOnCompositor | 1223 // simulate Animation::maybeStartAnimationOnCompositor |
| 1224 Vector<int> compositorAnimationIds; | 1224 Vector<int> compositorAnimationIds; |
| 1225 compositorAnimationIds.append(1); | 1225 compositorAnimationIds.append(1); |
| 1226 animation1->setCompositorAnimationIdsForTesting(compositorAnimationIds); | 1226 animation1->setCompositorAnimationIdsForTesting(compositorAnimationIds); |
| 1227 EXPECT_TRUE(player1->hasActiveAnimationsOnCompositor()); | 1227 EXPECT_TRUE(player1->hasActiveAnimationsOnCompositor()); |
| 1228 | 1228 |
| 1229 // The second player for opacity is not ok to run on compositor. | 1229 // The second player for opacity is not ok to run on compositor. |
| 1230 RefPtrWillBeRawPtr<Animation> animation2 = Animation::create(element.get(),
animationEffect2, timing); | 1230 Animation* animation2 = Animation::create(element.get(), animationEffect2, t
iming); |
| 1231 RefPtrWillBePersistent<AnimationPlayer> player2 = m_timeline->play(animation
2.get()); | 1231 RefPtrWillBePersistent<AnimationPlayer> player2 = m_timeline->play(animation
2); |
| 1232 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp
ositor(timing, *element.get(), player2.get(), *animationEffect2.get(), 1)); | 1232 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp
ositor(timing, *element.get(), player2.get(), *animationEffect2, 1)); |
| 1233 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); | 1233 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); |
| 1234 | 1234 |
| 1235 // A fallback to blink implementation needed, so cancel all compositor-side
opacity animations for this element. | 1235 // A fallback to blink implementation needed, so cancel all compositor-side
opacity animations for this element. |
| 1236 player2->cancelIncompatibleAnimationsOnCompositor(); | 1236 player2->cancelIncompatibleAnimationsOnCompositor(); |
| 1237 | 1237 |
| 1238 EXPECT_FALSE(player1->hasActiveAnimationsOnCompositor()); | 1238 EXPECT_FALSE(player1->hasActiveAnimationsOnCompositor()); |
| 1239 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); | 1239 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); |
| 1240 | 1240 |
| 1241 simulateFrame(0); | 1241 simulateFrame(0); |
| 1242 EXPECT_EQ(2U, element->elementAnimations()->players().size()); | 1242 EXPECT_EQ(2U, element->elementAnimations()->players().size()); |
| 1243 simulateFrame(1.); | 1243 simulateFrame(1.); |
| 1244 | 1244 |
| 1245 element->setLayoutObject(nullptr); | 1245 element->setLayoutObject(nullptr); |
| 1246 LayoutObjectProxy::dispose(layoutObject); | 1246 LayoutObjectProxy::dispose(layoutObject); |
| 1247 | 1247 |
| 1248 player1.release(); | 1248 player1.release(); |
| 1249 player2.release(); | 1249 player2.release(); |
| 1250 Heap::collectAllGarbage(); | 1250 Heap::collectAllGarbage(); |
| 1251 EXPECT_TRUE(element->elementAnimations()->players().isEmpty()); | 1251 EXPECT_TRUE(element->elementAnimations()->players().isEmpty()); |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 } // namespace blink | 1254 } // namespace blink |
| OLD | NEW |