| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/animation/Animation.h" | 6 #include "core/animation/Animation.h" |
| 7 | 7 |
| 8 #include "bindings/v8/Dictionary.h" | 8 #include "bindings/v8/Dictionary.h" |
| 9 #include "core/animation/AnimatableLength.h" | 9 #include "core/animation/AnimatableLength.h" |
| 10 #include "core/animation/AnimationClock.h" | 10 #include "core/animation/AnimationClock.h" |
| 11 #include "core/animation/AnimationHelpers.h" | 11 #include "core/animation/AnimationHelpers.h" |
| 12 #include "core/animation/AnimationTestHelper.h" | 12 #include "core/animation/AnimationTestHelper.h" |
| 13 #include "core/animation/DocumentTimeline.h" | 13 #include "core/animation/DocumentTimeline.h" |
| 14 #include "core/animation/KeyframeEffectModel.h" | 14 #include "core/animation/KeyframeEffectModel.h" |
| 15 #include "core/animation/Timing.h" |
| 15 #include "platform/animation/TimingFunctionTestHelper.h" | 16 #include "platform/animation/TimingFunctionTestHelper.h" |
| 16 | 17 |
| 17 #include <gtest/gtest.h> | 18 #include <gtest/gtest.h> |
| 18 | 19 |
| 19 namespace WebCore { | 20 namespace WebCore { |
| 20 | 21 |
| 21 class AnimationAnimationTest : public ::testing::Test { | 22 class AnimationAnimationTest : public ::testing::Test { |
| 22 protected: | 23 protected: |
| 23 AnimationAnimationTest() | 24 AnimationAnimationTest() |
| 24 : document(Document::create()) | 25 : document(Document::create()) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 class AnimationAnimationV8Test : public AnimationAnimationTest { | 37 class AnimationAnimationV8Test : public AnimationAnimationTest { |
| 37 protected: | 38 protected: |
| 38 AnimationAnimationV8Test() | 39 AnimationAnimationV8Test() |
| 39 : isolate(v8::Isolate::GetCurrent()) | 40 : isolate(v8::Isolate::GetCurrent()) |
| 40 , scope(isolate) | 41 , scope(isolate) |
| 41 , context(v8::Context::New(isolate)) | 42 , context(v8::Context::New(isolate)) |
| 42 , contextScope(context) | 43 , contextScope(context) |
| 43 { | 44 { |
| 44 } | 45 } |
| 45 | 46 |
| 47 template<typename T> |
| 48 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio
nary> keyframeDictionaryVector, T timingInput) |
| 49 { |
| 50 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, true), timingInput); |
| 51 } |
| 52 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio
nary> keyframeDictionaryVector) |
| 53 { |
| 54 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, true)); |
| 55 } |
| 56 |
| 46 v8::Isolate* isolate; | 57 v8::Isolate* isolate; |
| 47 v8::HandleScope scope; | 58 v8::HandleScope scope; |
| 48 v8::Local<v8::Context> context; | 59 v8::Local<v8::Context> context; |
| 49 v8::Context::Scope contextScope; | 60 v8::Context::Scope contextScope; |
| 50 | |
| 51 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k
eyframeDictionaryVector, Dictionary timingInput) | |
| 52 { | |
| 53 return Animation::createUnsafe(element, keyframeDictionaryVector, timing
Input); | |
| 54 } | |
| 55 | |
| 56 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k
eyframeDictionaryVector, double timingInput) | |
| 57 { | |
| 58 return Animation::createUnsafe(element, keyframeDictionaryVector, timing
Input); | |
| 59 } | |
| 60 | |
| 61 PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictionary> k
eyframeDictionaryVector) | |
| 62 { | |
| 63 return Animation::createUnsafe(element, keyframeDictionaryVector); | |
| 64 } | |
| 65 }; | 61 }; |
| 66 | 62 |
| 67 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation) | 63 TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation) |
| 68 { | 64 { |
| 69 Vector<Dictionary> jsKeyframes; | 65 Vector<Dictionary> jsKeyframes; |
| 70 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate); | 66 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate); |
| 71 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate); | 67 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate); |
| 72 | 68 |
| 73 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 69 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
| 74 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 70 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 EXPECT_EQ(duration, animation->specifiedTiming().iterationDuration); | 120 EXPECT_EQ(duration, animation->specifiedTiming().iterationDuration); |
| 125 } | 121 } |
| 126 | 122 |
| 127 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) | 123 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) |
| 128 { | 124 { |
| 129 Vector<Dictionary, 0> jsKeyframes; | 125 Vector<Dictionary, 0> jsKeyframes; |
| 130 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes); | 126 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes); |
| 131 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 127 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
| 132 } | 128 } |
| 133 | 129 |
| 134 TEST_F(AnimationAnimationV8Test, ClipNegativeDurationToZero) | 130 TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto) |
| 135 { | 131 { |
| 136 Vector<Dictionary, 0> jsKeyframes; | 132 Vector<Dictionary, 0> jsKeyframes; |
| 137 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2
); | 133 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2
); |
| 138 EXPECT_EQ(0, animation->specifiedTiming().iterationDuration); | 134 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
| 139 } | 135 } |
| 140 | 136 |
| 141 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) | 137 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) |
| 142 { | 138 { |
| 143 Vector<Dictionary, 0> jsKeyframes; | 139 Vector<Dictionary, 0> jsKeyframes; |
| 144 | 140 |
| 145 v8::Handle<v8::Object> timingInput = v8::Object::New(isolate); | 141 v8::Handle<v8::Object> timingInput = v8::Object::New(isolate); |
| 146 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); | 142 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); |
| 147 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); | 143 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); |
| 148 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); | 144 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 player->setCurrentTime(150); | 365 player->setCurrentTime(150); |
| 370 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 366 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
| 371 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 367 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
| 372 | 368 |
| 373 player->setCurrentTime(200); | 369 player->setCurrentTime(200); |
| 374 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 370 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
| 375 EXPECT_EQ(50, animation->timeToReverseEffectChange()); | 371 EXPECT_EQ(50, animation->timeToReverseEffectChange()); |
| 376 } | 372 } |
| 377 | 373 |
| 378 } // namespace WebCore | 374 } // namespace WebCore |
| OLD | NEW |