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/EffectInput.h" | 6 #include "core/animation/EffectInput.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "core/animation/AnimationTestHelper.h" | 9 #include "core/animation/AnimationTestHelper.h" |
10 #include "core/animation/KeyframeEffectModel.h" | 10 #include "core/animation/KeyframeEffectModel.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 63 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
64 | 64 |
65 setV8ObjectPropertyAsString(keyframe1, "width", "0px"); | 65 setV8ObjectPropertyAsString(keyframe1, "width", "0px"); |
66 setV8ObjectPropertyAsString(keyframe1, "offset", "1"); | 66 setV8ObjectPropertyAsString(keyframe1, "offset", "1"); |
67 setV8ObjectPropertyAsString(keyframe2, "width", "100px"); | 67 setV8ObjectPropertyAsString(keyframe2, "width", "100px"); |
68 setV8ObjectPropertyAsString(keyframe2, "offset", "0"); | 68 setV8ObjectPropertyAsString(keyframe2, "offset", "0"); |
69 | 69 |
70 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 70 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
71 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 71 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
72 | 72 |
73 RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(e
lement.get(), jsKeyframes, exceptionState); | 73 EffectInput::convert(element.get(), jsKeyframes, exceptionState); |
74 EXPECT_TRUE(exceptionState.hadException()); | 74 EXPECT_TRUE(exceptionState.hadException()); |
75 EXPECT_EQ(InvalidModificationError, exceptionState.code()); | 75 EXPECT_EQ(InvalidModificationError, exceptionState.code()); |
76 } | 76 } |
77 | 77 |
78 TEST_F(AnimationEffectInputTest, LooslySorted) | 78 TEST_F(AnimationEffectInputTest, LooslySorted) |
79 { | 79 { |
80 Vector<Dictionary> jsKeyframes; | 80 Vector<Dictionary> jsKeyframes; |
81 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 81 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
82 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 82 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
83 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); | 83 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); |
(...skipping 28 matching lines...) Expand all Loading... |
112 setV8ObjectPropertyAsString(keyframe3, "height", "200px"); | 112 setV8ObjectPropertyAsString(keyframe3, "height", "200px"); |
113 setV8ObjectPropertyAsString(keyframe3, "offset", "0"); | 113 setV8ObjectPropertyAsString(keyframe3, "offset", "0"); |
114 setV8ObjectPropertyAsString(keyframe4, "height", "300px"); | 114 setV8ObjectPropertyAsString(keyframe4, "height", "300px"); |
115 setV8ObjectPropertyAsString(keyframe4, "offset", "1"); | 115 setV8ObjectPropertyAsString(keyframe4, "offset", "1"); |
116 | 116 |
117 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 117 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
118 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 118 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
119 jsKeyframes.append(Dictionary(keyframe3, m_isolate)); | 119 jsKeyframes.append(Dictionary(keyframe3, m_isolate)); |
120 jsKeyframes.append(Dictionary(keyframe4, m_isolate)); | 120 jsKeyframes.append(Dictionary(keyframe4, m_isolate)); |
121 | 121 |
122 RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(e
lement.get(), jsKeyframes, exceptionState); | 122 EffectInput::convert(element.get(), jsKeyframes, exceptionState); |
123 EXPECT_TRUE(exceptionState.hadException()); | 123 EXPECT_TRUE(exceptionState.hadException()); |
124 } | 124 } |
125 | 125 |
126 TEST_F(AnimationEffectInputTest, Invalid) | 126 TEST_F(AnimationEffectInputTest, Invalid) |
127 { | 127 { |
128 // Not loosely sorted by offset, and there exists a keyframe with null offse
t. | 128 // Not loosely sorted by offset, and there exists a keyframe with null offse
t. |
129 Vector<Dictionary> jsKeyframes; | 129 Vector<Dictionary> jsKeyframes; |
130 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); | 130 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); |
131 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); | 131 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); |
132 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); | 132 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); |
133 | 133 |
134 setV8ObjectPropertyAsString(keyframe1, "width", "0px"); | 134 setV8ObjectPropertyAsString(keyframe1, "width", "0px"); |
135 setV8ObjectPropertyAsString(keyframe1, "offset", "1"); | 135 setV8ObjectPropertyAsString(keyframe1, "offset", "1"); |
136 setV8ObjectPropertyAsString(keyframe2, "width", "200px"); | 136 setV8ObjectPropertyAsString(keyframe2, "width", "200px"); |
137 setV8ObjectPropertyAsString(keyframe3, "width", "100px"); | 137 setV8ObjectPropertyAsString(keyframe3, "width", "100px"); |
138 setV8ObjectPropertyAsString(keyframe3, "offset", "0"); | 138 setV8ObjectPropertyAsString(keyframe3, "offset", "0"); |
139 | 139 |
140 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); | 140 jsKeyframes.append(Dictionary(keyframe1, m_isolate)); |
141 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); | 141 jsKeyframes.append(Dictionary(keyframe2, m_isolate)); |
142 jsKeyframes.append(Dictionary(keyframe3, m_isolate)); | 142 jsKeyframes.append(Dictionary(keyframe3, m_isolate)); |
143 | 143 |
144 RefPtrWillBeRawPtr<AnimationEffect> animationEffect ALLOW_UNUSED = EffectInp
ut::convert(element.get(), jsKeyframes, exceptionState); | 144 EffectInput::convert(element.get(), jsKeyframes, exceptionState); |
145 EXPECT_TRUE(exceptionState.hadException()); | 145 EXPECT_TRUE(exceptionState.hadException()); |
146 EXPECT_EQ(InvalidModificationError, exceptionState.code()); | 146 EXPECT_EQ(InvalidModificationError, exceptionState.code()); |
147 } | 147 } |
148 | 148 |
149 } | 149 } |
OLD | NEW |