| 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/AnimationClock.h" | 9 #include "core/animation/AnimationClock.h" |
| 10 #include "core/animation/AnimationHelpers.h" | 10 #include "core/animation/AnimationHelpers.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 class AnimationAnimationV8Test : public AnimationAnimationTest { | 37 class AnimationAnimationV8Test : public AnimationAnimationTest { |
| 38 protected: | 38 protected: |
| 39 AnimationAnimationV8Test() | 39 AnimationAnimationV8Test() |
| 40 : m_isolate(v8::Isolate::GetCurrent()) | 40 : m_isolate(v8::Isolate::GetCurrent()) |
| 41 , m_scope(V8ExecutionScope::create(m_isolate)) | 41 , m_scope(V8ExecutionScope::create(m_isolate)) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 template<typename T> | 45 template<typename T> |
| 46 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio
nary> keyframeDictionaryVector, T timingInput, ExceptionState& exceptionState) | 46 static PassRefPtrWillBeRawPtr<Animation> createAnimation(Element* element, V
ector<Dictionary> keyframeDictionaryVector, T timingInput, ExceptionState& excep
tionState) |
| 47 { | 47 { |
| 48 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true), timingInput); | 48 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true), timingInput); |
| 49 } | 49 } |
| 50 static PassRefPtr<Animation> createAnimation(Element* element, Vector<Dictio
nary> keyframeDictionaryVector, ExceptionState& exceptionState) | 50 static PassRefPtrWillBeRawPtr<Animation> createAnimation(Element* element, V
ector<Dictionary> keyframeDictionaryVector, ExceptionState& exceptionState) |
| 51 { | 51 { |
| 52 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true)); | 52 return Animation::create(element, EffectInput::convert(element, keyframe
DictionaryVector, exceptionState, true)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 v8::Isolate* m_isolate; | 55 v8::Isolate* m_isolate; |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 OwnPtr<V8ExecutionScope> m_scope; | 58 OwnPtr<V8ExecutionScope> m_scope; |
| 59 }; | 59 }; |
| 60 | 60 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 75 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 75 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
| 76 | 76 |
| 77 String value1; | 77 String value1; |
| 78 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); | 78 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); |
| 79 ASSERT_EQ("100px", value1); | 79 ASSERT_EQ("100px", value1); |
| 80 | 80 |
| 81 String value2; | 81 String value2; |
| 82 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); | 82 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); |
| 83 ASSERT_EQ("0px", value2); | 83 ASSERT_EQ("0px", value2); |
| 84 | 84 |
| 85 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 85 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
| 86 | 86 |
| 87 Element* target = animation->target(); | 87 Element* target = animation->target(); |
| 88 EXPECT_EQ(*element.get(), *target); | 88 EXPECT_EQ(*element.get(), *target); |
| 89 | 89 |
| 90 const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->effect
())->getFrames(); | 90 const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->effect
())->getFrames(); |
| 91 | 91 |
| 92 EXPECT_EQ(0, keyframes[0]->offset()); | 92 EXPECT_EQ(0, keyframes[0]->offset()); |
| 93 EXPECT_EQ(1, keyframes[1]->offset()); | 93 EXPECT_EQ(1, keyframes[1]->offset()); |
| 94 | 94 |
| 95 const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->prope
rtyValue(CSSPropertyWidth); | 95 const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->prope
rtyValue(CSSPropertyWidth); |
| 96 const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->prope
rtyValue(CSSPropertyWidth); | 96 const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->prope
rtyValue(CSSPropertyWidth); |
| 97 ASSERT(keyframe1Width); | 97 ASSERT(keyframe1Width); |
| 98 ASSERT(keyframe2Width); | 98 ASSERT(keyframe2Width); |
| 99 | 99 |
| 100 EXPECT_EQ("100px", keyframe1Width->cssText()); | 100 EXPECT_EQ("100px", keyframe1Width->cssText()); |
| 101 EXPECT_EQ("0px", keyframe2Width->cssText()); | 101 EXPECT_EQ("0px", keyframe2Width->cssText()); |
| 102 | 102 |
| 103 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas
eInOut)), *keyframes[0]->easing()); | 103 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas
eInOut)), *keyframes[0]->easing()); |
| 104 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), *keyfr
ames[1]->easing()); | 104 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), *keyfr
ames[1]->easing()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 TEST_F(AnimationAnimationV8Test, CanSetDuration) | 107 TEST_F(AnimationAnimationV8Test, CanSetDuration) |
| 108 { | 108 { |
| 109 Vector<Dictionary, 0> jsKeyframes; | 109 Vector<Dictionary, 0> jsKeyframes; |
| 110 double duration = 2000; | 110 double duration = 2000; |
| 111 | 111 |
| 112 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, du
ration, exceptionState); | 112 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, duration, exceptionState); |
| 113 | 113 |
| 114 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); | 114 EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration); |
| 115 } | 115 } |
| 116 | 116 |
| 117 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) | 117 TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration) |
| 118 { | 118 { |
| 119 Vector<Dictionary, 0> jsKeyframes; | 119 Vector<Dictionary, 0> jsKeyframes; |
| 120 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ex
ceptionState); | 120 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, exceptionState); |
| 121 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 121 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto) | 124 TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto) |
| 125 { | 125 { |
| 126 Vector<Dictionary, 0> jsKeyframes; | 126 Vector<Dictionary, 0> jsKeyframes; |
| 127 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2
, exceptionState); | 127 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, -2, exceptionState); |
| 128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); | 128 EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException) | 131 TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException) |
| 132 { | 132 { |
| 133 Vector<Dictionary> jsKeyframes; | 133 Vector<Dictionary> jsKeyframes; |
| 134 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 134 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
| 135 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 135 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
| 136 | 136 |
| 137 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 137 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
| 138 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 138 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
| 139 | 139 |
| 140 // Height property appears only in keyframe2 | 140 // Height property appears only in keyframe2 |
| 141 setV8ObjectPropertyAsString(keyframe2, "height", "100px"); | 141 setV8ObjectPropertyAsString(keyframe2, "height", "100px"); |
| 142 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 142 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
| 143 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); | 143 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); |
| 144 | 144 |
| 145 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 145 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
| 146 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 146 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
| 147 | 147 |
| 148 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 148 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
| 149 | 149 |
| 150 EXPECT_TRUE(exceptionState.hadException()); | 150 EXPECT_TRUE(exceptionState.hadException()); |
| 151 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 151 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
| 152 } | 152 } |
| 153 | 153 |
| 154 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException) | 154 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException) |
| 155 { | 155 { |
| 156 Vector<Dictionary> jsKeyframes; | 156 Vector<Dictionary> jsKeyframes; |
| 157 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 157 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
| 158 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 158 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
| 159 | 159 |
| 160 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 160 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
| 161 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); | 161 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); |
| 162 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 162 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
| 163 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); | 163 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); |
| 164 | 164 |
| 165 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 165 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
| 166 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 166 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
| 167 | 167 |
| 168 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 168 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
| 169 | 169 |
| 170 EXPECT_TRUE(exceptionState.hadException()); | 170 EXPECT_TRUE(exceptionState.hadException()); |
| 171 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 171 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException) | 174 TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException) |
| 175 { | 175 { |
| 176 Vector<Dictionary> jsKeyframes; | 176 Vector<Dictionary> jsKeyframes; |
| 177 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 177 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
| 178 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 178 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
| 179 | 179 |
| 180 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 180 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
| 181 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); | 181 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); |
| 182 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 182 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
| 183 setV8ObjectPropertyAsString(keyframe2, "offset", "0.1"); | 183 setV8ObjectPropertyAsString(keyframe2, "offset", "0.1"); |
| 184 | 184 |
| 185 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 185 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
| 186 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 186 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
| 187 | 187 |
| 188 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 188 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
| 189 | 189 |
| 190 EXPECT_TRUE(exceptionState.hadException()); | 190 EXPECT_TRUE(exceptionState.hadException()); |
| 191 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 191 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException) | 194 TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException) |
| 195 { | 195 { |
| 196 Vector<Dictionary> jsKeyframes; | 196 Vector<Dictionary> jsKeyframes; |
| 197 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 197 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
| 198 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 198 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
| 199 | 199 |
| 200 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); | 200 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); |
| 201 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); | 201 setV8ObjectPropertyAsString(keyframe1, "offset", "0.1"); |
| 202 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); | 202 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); |
| 203 setV8ObjectPropertyAsString(keyframe2, "offset", "0.2"); | 203 setV8ObjectPropertyAsString(keyframe2, "offset", "0.2"); |
| 204 | 204 |
| 205 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 205 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
| 206 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 206 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
| 207 | 207 |
| 208 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0,
exceptionState); | 208 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, 0, exceptionState); |
| 209 | 209 |
| 210 EXPECT_TRUE(exceptionState.hadException()); | 210 EXPECT_TRUE(exceptionState.hadException()); |
| 211 EXPECT_EQ(NotSupportedError, exceptionState.code()); | 211 EXPECT_EQ(NotSupportedError, exceptionState.code()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) | 214 TEST_F(AnimationAnimationV8Test, SpecifiedGetters) |
| 215 { | 215 { |
| 216 Vector<Dictionary, 0> jsKeyframes; | 216 Vector<Dictionary, 0> jsKeyframes; |
| 217 | 217 |
| 218 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 218 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
| 219 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); | 219 setV8ObjectPropertyAsNumber(timingInput, "delay", 2); |
| 220 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); | 220 setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5); |
| 221 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); | 221 setV8ObjectPropertyAsString(timingInput, "fill", "backwards"); |
| 222 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2); | 222 setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2); |
| 223 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10); | 223 setV8ObjectPropertyAsNumber(timingInput, "iterations", 10); |
| 224 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2); | 224 setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2); |
| 225 setV8ObjectPropertyAsString(timingInput, "direction", "reverse"); | 225 setV8ObjectPropertyAsString(timingInput, "direction", "reverse"); |
| 226 setV8ObjectPropertyAsString(timingInput, "easing", "step-start"); | 226 setV8ObjectPropertyAsString(timingInput, "easing", "step-start"); |
| 227 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); | 227 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); |
| 228 | 228 |
| 229 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti
mingInputDictionary, exceptionState); | 229 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, timingInputDictionary, exceptionState); |
| 230 | 230 |
| 231 RefPtr<TimedItemTiming> specified = animation->timing(); | 231 RefPtrWillBeRawPtr<TimedItemTiming> specified = animation->timing(); |
| 232 EXPECT_EQ(2, specified->delay()); | 232 EXPECT_EQ(2, specified->delay()); |
| 233 EXPECT_EQ(0.5, specified->endDelay()); | 233 EXPECT_EQ(0.5, specified->endDelay()); |
| 234 EXPECT_EQ("backwards", specified->fill()); | 234 EXPECT_EQ("backwards", specified->fill()); |
| 235 EXPECT_EQ(2, specified->iterationStart()); | 235 EXPECT_EQ(2, specified->iterationStart()); |
| 236 EXPECT_EQ(10, specified->iterations()); | 236 EXPECT_EQ(10, specified->iterations()); |
| 237 EXPECT_EQ(2, specified->playbackRate()); | 237 EXPECT_EQ(2, specified->playbackRate()); |
| 238 EXPECT_EQ("reverse", specified->direction()); | 238 EXPECT_EQ("reverse", specified->direction()); |
| 239 EXPECT_EQ("step-start", specified->easing()); | 239 EXPECT_EQ("step-start", specified->easing()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter) | 242 TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter) |
| 243 { | 243 { |
| 244 Vector<Dictionary, 0> jsKeyframes; | 244 Vector<Dictionary, 0> jsKeyframes; |
| 245 | 245 |
| 246 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); | 246 v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate); |
| 247 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5); | 247 setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5); |
| 248 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val
ue>::Cast(timingInputWithDuration), m_isolate); | 248 Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Val
ue>::Cast(timingInputWithDuration), m_isolate); |
| 249 | 249 |
| 250 RefPtr<Animation> animationWithDuration = createAnimation(element.get(), jsK
eyframes, timingInputDictionaryWithDuration, exceptionState); | 250 RefPtrWillBeRawPtr<Animation> animationWithDuration = createAnimation(elemen
t.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState); |
| 251 | 251 |
| 252 RefPtr<TimedItemTiming> specifiedWithDuration = animationWithDuration->timin
g(); | 252 RefPtrWillBeRawPtr<TimedItemTiming> specifiedWithDuration = animationWithDur
ation->timing(); |
| 253 bool isNumber = false; | 253 bool isNumber = false; |
| 254 double numberDuration = std::numeric_limits<double>::quiet_NaN(); | 254 double numberDuration = std::numeric_limits<double>::quiet_NaN(); |
| 255 bool isString = false; | 255 bool isString = false; |
| 256 String stringDuration = ""; | 256 String stringDuration = ""; |
| 257 specifiedWithDuration->getDuration("duration", isNumber, numberDuration, isS
tring, stringDuration); | 257 specifiedWithDuration->getDuration("duration", isNumber, numberDuration, isS
tring, stringDuration); |
| 258 EXPECT_TRUE(isNumber); | 258 EXPECT_TRUE(isNumber); |
| 259 EXPECT_EQ(2.5, numberDuration); | 259 EXPECT_EQ(2.5, numberDuration); |
| 260 EXPECT_FALSE(isString); | 260 EXPECT_FALSE(isString); |
| 261 EXPECT_EQ("", stringDuration); | 261 EXPECT_EQ("", stringDuration); |
| 262 | 262 |
| 263 | 263 |
| 264 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); | 264 v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate); |
| 265 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value
>::Cast(timingInputNoDuration), m_isolate); | 265 Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value
>::Cast(timingInputNoDuration), m_isolate); |
| 266 | 266 |
| 267 RefPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKey
frames, timingInputDictionaryNoDuration, exceptionState); | 267 RefPtrWillBeRawPtr<Animation> animationNoDuration = createAnimation(element.
get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState); |
| 268 | 268 |
| 269 RefPtr<TimedItemTiming> specifiedNoDuration = animationNoDuration->timing(); | 269 RefPtrWillBeRawPtr<TimedItemTiming> specifiedNoDuration = animationNoDuratio
n->timing(); |
| 270 isNumber = false; | 270 isNumber = false; |
| 271 numberDuration = std::numeric_limits<double>::quiet_NaN(); | 271 numberDuration = std::numeric_limits<double>::quiet_NaN(); |
| 272 isString = false; | 272 isString = false; |
| 273 stringDuration = ""; | 273 stringDuration = ""; |
| 274 specifiedNoDuration->getDuration("duration", isNumber, numberDuration, isStr
ing, stringDuration); | 274 specifiedNoDuration->getDuration("duration", isNumber, numberDuration, isStr
ing, stringDuration); |
| 275 EXPECT_FALSE(isNumber); | 275 EXPECT_FALSE(isNumber); |
| 276 EXPECT_TRUE(std::isnan(numberDuration)); | 276 EXPECT_TRUE(std::isnan(numberDuration)); |
| 277 EXPECT_TRUE(isString); | 277 EXPECT_TRUE(isString); |
| 278 EXPECT_EQ("auto", stringDuration); | 278 EXPECT_EQ("auto", stringDuration); |
| 279 } | 279 } |
| 280 | 280 |
| 281 TEST_F(AnimationAnimationV8Test, SpecifiedSetters) | 281 TEST_F(AnimationAnimationV8Test, SpecifiedSetters) |
| 282 { | 282 { |
| 283 Vector<Dictionary, 0> jsKeyframes; | 283 Vector<Dictionary, 0> jsKeyframes; |
| 284 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 284 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
| 285 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); | 285 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); |
| 286 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti
mingInputDictionary, exceptionState); | 286 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, timingInputDictionary, exceptionState); |
| 287 | 287 |
| 288 RefPtr<TimedItemTiming> specified = animation->timing(); | 288 RefPtrWillBeRawPtr<TimedItemTiming> specified = animation->timing(); |
| 289 | 289 |
| 290 EXPECT_EQ(0, specified->delay()); | 290 EXPECT_EQ(0, specified->delay()); |
| 291 specified->setDelay(2); | 291 specified->setDelay(2); |
| 292 EXPECT_EQ(2, specified->delay()); | 292 EXPECT_EQ(2, specified->delay()); |
| 293 | 293 |
| 294 EXPECT_EQ(0, specified->endDelay()); | 294 EXPECT_EQ(0, specified->endDelay()); |
| 295 specified->setEndDelay(0.5); | 295 specified->setEndDelay(0.5); |
| 296 EXPECT_EQ(0.5, specified->endDelay()); | 296 EXPECT_EQ(0.5, specified->endDelay()); |
| 297 | 297 |
| 298 EXPECT_EQ("auto", specified->fill()); | 298 EXPECT_EQ("auto", specified->fill()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 318 EXPECT_EQ("linear", specified->easing()); | 318 EXPECT_EQ("linear", specified->easing()); |
| 319 specified->setEasing("step-start"); | 319 specified->setEasing("step-start"); |
| 320 EXPECT_EQ("step-start", specified->easing()); | 320 EXPECT_EQ("step-start", specified->easing()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration) | 323 TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration) |
| 324 { | 324 { |
| 325 Vector<Dictionary, 0> jsKeyframes; | 325 Vector<Dictionary, 0> jsKeyframes; |
| 326 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); | 326 v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate); |
| 327 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); | 327 Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(ti
mingInput), m_isolate); |
| 328 RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, ti
mingInputDictionary, exceptionState); | 328 RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsK
eyframes, timingInputDictionary, exceptionState); |
| 329 | 329 |
| 330 RefPtr<TimedItemTiming> specified = animation->timing(); | 330 RefPtrWillBeRawPtr<TimedItemTiming> specified = animation->timing(); |
| 331 | 331 |
| 332 bool isNumber = false; | 332 bool isNumber = false; |
| 333 double numberDuration = std::numeric_limits<double>::quiet_NaN(); | 333 double numberDuration = std::numeric_limits<double>::quiet_NaN(); |
| 334 bool isString = false; | 334 bool isString = false; |
| 335 String stringDuration = ""; | 335 String stringDuration = ""; |
| 336 specified->getDuration("duration", isNumber, numberDuration, isString, strin
gDuration); | 336 specified->getDuration("duration", isNumber, numberDuration, isString, strin
gDuration); |
| 337 EXPECT_FALSE(isNumber); | 337 EXPECT_FALSE(isNumber); |
| 338 EXPECT_TRUE(std::isnan(numberDuration)); | 338 EXPECT_TRUE(std::isnan(numberDuration)); |
| 339 EXPECT_TRUE(isString); | 339 EXPECT_TRUE(isString); |
| 340 EXPECT_EQ("auto", stringDuration); | 340 EXPECT_EQ("auto", stringDuration); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 351 EXPECT_EQ("", stringDuration); | 351 EXPECT_EQ("", stringDuration); |
| 352 } | 352 } |
| 353 | 353 |
| 354 TEST_F(AnimationAnimationTest, TimeToEffectChange) | 354 TEST_F(AnimationAnimationTest, TimeToEffectChange) |
| 355 { | 355 { |
| 356 Timing timing; | 356 Timing timing; |
| 357 timing.iterationDuration = 100; | 357 timing.iterationDuration = 100; |
| 358 timing.startDelay = 100; | 358 timing.startDelay = 100; |
| 359 timing.endDelay = 100; | 359 timing.endDelay = 100; |
| 360 timing.fillMode = Timing::FillModeNone; | 360 timing.fillMode = Timing::FillModeNone; |
| 361 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 361 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
| 362 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 362 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
| 363 double inf = std::numeric_limits<double>::infinity(); | 363 double inf = std::numeric_limits<double>::infinity(); |
| 364 | 364 |
| 365 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 365 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
| 366 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 366 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
| 367 | 367 |
| 368 player->setCurrentTimeInternal(100); | 368 player->setCurrentTimeInternal(100); |
| 369 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 369 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
| 370 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 370 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
| 371 | 371 |
| 372 player->setCurrentTimeInternal(199); | 372 player->setCurrentTimeInternal(199); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 384 } | 384 } |
| 385 | 385 |
| 386 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithPlaybackRate) | 386 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithPlaybackRate) |
| 387 { | 387 { |
| 388 Timing timing; | 388 Timing timing; |
| 389 timing.iterationDuration = 100; | 389 timing.iterationDuration = 100; |
| 390 timing.startDelay = 100; | 390 timing.startDelay = 100; |
| 391 timing.endDelay = 100; | 391 timing.endDelay = 100; |
| 392 timing.playbackRate = 2; | 392 timing.playbackRate = 2; |
| 393 timing.fillMode = Timing::FillModeNone; | 393 timing.fillMode = Timing::FillModeNone; |
| 394 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 394 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
| 395 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 395 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
| 396 double inf = std::numeric_limits<double>::infinity(); | 396 double inf = std::numeric_limits<double>::infinity(); |
| 397 | 397 |
| 398 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 398 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
| 399 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 399 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
| 400 | 400 |
| 401 player->setCurrentTimeInternal(100); | 401 player->setCurrentTimeInternal(100); |
| 402 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 402 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
| 403 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 403 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
| 404 | 404 |
| 405 player->setCurrentTimeInternal(149); | 405 player->setCurrentTimeInternal(149); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 417 } | 417 } |
| 418 | 418 |
| 419 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithNegativePlaybackRate) | 419 TEST_F(AnimationAnimationTest, TimeToEffectChangeWithNegativePlaybackRate) |
| 420 { | 420 { |
| 421 Timing timing; | 421 Timing timing; |
| 422 timing.iterationDuration = 100; | 422 timing.iterationDuration = 100; |
| 423 timing.startDelay = 100; | 423 timing.startDelay = 100; |
| 424 timing.endDelay = 100; | 424 timing.endDelay = 100; |
| 425 timing.playbackRate = -2; | 425 timing.playbackRate = -2; |
| 426 timing.fillMode = Timing::FillModeNone; | 426 timing.fillMode = Timing::FillModeNone; |
| 427 RefPtr<Animation> animation = Animation::create(0, nullptr, timing); | 427 RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timi
ng); |
| 428 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 428 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
| 429 double inf = std::numeric_limits<double>::infinity(); | 429 double inf = std::numeric_limits<double>::infinity(); |
| 430 | 430 |
| 431 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); | 431 EXPECT_EQ(100, animation->timeToForwardsEffectChange()); |
| 432 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); | 432 EXPECT_EQ(inf, animation->timeToReverseEffectChange()); |
| 433 | 433 |
| 434 player->setCurrentTimeInternal(100); | 434 player->setCurrentTimeInternal(100); |
| 435 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 435 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
| 436 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 436 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
| 437 | 437 |
| 438 player->setCurrentTimeInternal(149); | 438 player->setCurrentTimeInternal(149); |
| 439 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); | 439 EXPECT_EQ(0, animation->timeToForwardsEffectChange()); |
| 440 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 440 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
| 441 | 441 |
| 442 player->setCurrentTimeInternal(150); | 442 player->setCurrentTimeInternal(150); |
| 443 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 443 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
| 444 EXPECT_EQ(0, animation->timeToReverseEffectChange()); | 444 EXPECT_EQ(0, animation->timeToReverseEffectChange()); |
| 445 | 445 |
| 446 player->setCurrentTimeInternal(200); | 446 player->setCurrentTimeInternal(200); |
| 447 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); | 447 EXPECT_EQ(inf, animation->timeToForwardsEffectChange()); |
| 448 EXPECT_EQ(50, animation->timeToReverseEffectChange()); | 448 EXPECT_EQ(50, animation->timeToReverseEffectChange()); |
| 449 } | 449 } |
| 450 | 450 |
| 451 TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget) | 451 TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget) |
| 452 { | 452 { |
| 453 // This test expects incorrect behaviour should be removed once Element | 453 // This test expects incorrect behaviour should be removed once Element |
| 454 // and Animation are moved to Oilpan. See crbug.com/362404 for context. | 454 // and Animation are moved to Oilpan. See crbug.com/362404 for context. |
| 455 Timing timing; | 455 Timing timing; |
| 456 timing.iterationDuration = 5; | 456 timing.iterationDuration = 5; |
| 457 RefPtr<Animation> animation = Animation::create(element.get(), nullptr, timi
ng); | 457 RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), n
ullptr, timing); |
| 458 EXPECT_EQ(element.get(), animation->target()); | 458 EXPECT_EQ(element.get(), animation->target()); |
| 459 RefPtr<AnimationPlayer> player = document->timeline().play(animation.get()); | 459 RefPtrWillBeRawPtr<AnimationPlayer> player = document->timeline().play(anima
tion.get()); |
| 460 document.clear(); | 460 document.clear(); |
| 461 element.clear(); | 461 element.clear(); |
| 462 Heap::collectAllGarbage(); | 462 Heap::collectAllGarbage(); |
| 463 EXPECT_EQ(0, animation->target()); | 463 EXPECT_EQ(0, animation->target()); |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace WebCore | 466 } // namespace WebCore |
| OLD | NEW |