Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: Source/core/animation/EffectInputTest.cpp

Issue 1079973002: [Source/core/animation] Use Local<> in lieu of Handle<> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed build breaks Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/TimingInputTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "core/animation/AnimationTestHelper.h" 10 #include "core/animation/AnimationTestHelper.h"
(...skipping 23 matching lines...) Expand all
34 TrackExceptionState exceptionState; 34 TrackExceptionState exceptionState;
35 v8::Isolate* m_isolate; 35 v8::Isolate* m_isolate;
36 36
37 private: 37 private:
38 V8TestingScope m_scope; 38 V8TestingScope m_scope;
39 }; 39 };
40 40
41 TEST_F(AnimationEffectInputTest, SortedOffsets) 41 TEST_F(AnimationEffectInputTest, SortedOffsets)
42 { 42 {
43 Vector<Dictionary> jsKeyframes; 43 Vector<Dictionary> jsKeyframes;
44 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); 44 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
45 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); 45 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
46 46
47 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); 47 setV8ObjectPropertyAsString(keyframe1, "width", "100px");
48 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); 48 setV8ObjectPropertyAsString(keyframe1, "offset", "0");
49 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); 49 setV8ObjectPropertyAsString(keyframe2, "width", "0px");
50 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); 50 setV8ObjectPropertyAsString(keyframe2, "offset", "1");
51 51
52 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState)); 52 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
53 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); 53 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
54 54
55 RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(e lement.get(), jsKeyframes, exceptionState); 55 RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(e lement.get(), jsKeyframes, exceptionState);
56 EXPECT_FALSE(exceptionState.hadException()); 56 EXPECT_FALSE(exceptionState.hadException());
57 const KeyframeEffectModelBase& keyframeEffect = *toKeyframeEffectModelBase(a nimationEffect.get()); 57 const KeyframeEffectModelBase& keyframeEffect = *toKeyframeEffectModelBase(a nimationEffect.get());
58 EXPECT_EQ(1.0, keyframeEffect.getFrames()[1]->offset()); 58 EXPECT_EQ(1.0, keyframeEffect.getFrames()[1]->offset());
59 } 59 }
60 60
61 TEST_F(AnimationEffectInputTest, UnsortedOffsets) 61 TEST_F(AnimationEffectInputTest, UnsortedOffsets)
62 { 62 {
63 Vector<Dictionary> jsKeyframes; 63 Vector<Dictionary> jsKeyframes;
64 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); 64 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
65 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); 65 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
66 66
67 setV8ObjectPropertyAsString(keyframe1, "width", "0px"); 67 setV8ObjectPropertyAsString(keyframe1, "width", "0px");
68 setV8ObjectPropertyAsString(keyframe1, "offset", "1"); 68 setV8ObjectPropertyAsString(keyframe1, "offset", "1");
69 setV8ObjectPropertyAsString(keyframe2, "width", "100px"); 69 setV8ObjectPropertyAsString(keyframe2, "width", "100px");
70 setV8ObjectPropertyAsString(keyframe2, "offset", "0"); 70 setV8ObjectPropertyAsString(keyframe2, "offset", "0");
71 71
72 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState)); 72 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
73 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); 73 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
74 74
75 EffectInput::convert(element.get(), jsKeyframes, exceptionState); 75 EffectInput::convert(element.get(), jsKeyframes, exceptionState);
76 EXPECT_TRUE(exceptionState.hadException()); 76 EXPECT_TRUE(exceptionState.hadException());
77 EXPECT_EQ(InvalidModificationError, exceptionState.code()); 77 EXPECT_EQ(InvalidModificationError, exceptionState.code());
78 } 78 }
79 79
80 TEST_F(AnimationEffectInputTest, LooslySorted) 80 TEST_F(AnimationEffectInputTest, LooslySorted)
81 { 81 {
82 Vector<Dictionary> jsKeyframes; 82 Vector<Dictionary> jsKeyframes;
83 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); 83 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
84 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); 84 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
85 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); 85 v8::Local<v8::Object> keyframe3 = v8::Object::New(m_isolate);
86 86
87 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); 87 setV8ObjectPropertyAsString(keyframe1, "width", "100px");
88 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); 88 setV8ObjectPropertyAsString(keyframe1, "offset", "0");
89 setV8ObjectPropertyAsString(keyframe2, "width", "200px"); 89 setV8ObjectPropertyAsString(keyframe2, "width", "200px");
90 setV8ObjectPropertyAsString(keyframe3, "width", "0px"); 90 setV8ObjectPropertyAsString(keyframe3, "width", "0px");
91 setV8ObjectPropertyAsString(keyframe3, "offset", "1"); 91 setV8ObjectPropertyAsString(keyframe3, "offset", "1");
92 92
93 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState)); 93 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
94 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); 94 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
95 jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState)); 95 jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState));
96 96
97 RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(e lement.get(), jsKeyframes, exceptionState); 97 RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(e lement.get(), jsKeyframes, exceptionState);
98 EXPECT_FALSE(exceptionState.hadException()); 98 EXPECT_FALSE(exceptionState.hadException());
99 const KeyframeEffectModelBase& keyframeEffect = *toKeyframeEffectModelBase(a nimationEffect.get()); 99 const KeyframeEffectModelBase& keyframeEffect = *toKeyframeEffectModelBase(a nimationEffect.get());
100 EXPECT_EQ(1, keyframeEffect.getFrames()[2]->offset()); 100 EXPECT_EQ(1, keyframeEffect.getFrames()[2]->offset());
101 } 101 }
102 102
103 TEST_F(AnimationEffectInputTest, OutOfOrderWithNullOffsets) 103 TEST_F(AnimationEffectInputTest, OutOfOrderWithNullOffsets)
104 { 104 {
105 Vector<Dictionary> jsKeyframes; 105 Vector<Dictionary> jsKeyframes;
106 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); 106 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
107 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); 107 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
108 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); 108 v8::Local<v8::Object> keyframe3 = v8::Object::New(m_isolate);
109 v8::Handle<v8::Object> keyframe4 = v8::Object::New(m_isolate); 109 v8::Local<v8::Object> keyframe4 = v8::Object::New(m_isolate);
110 110
111 setV8ObjectPropertyAsString(keyframe1, "height", "100px"); 111 setV8ObjectPropertyAsString(keyframe1, "height", "100px");
112 setV8ObjectPropertyAsString(keyframe1, "offset", "0.5"); 112 setV8ObjectPropertyAsString(keyframe1, "offset", "0.5");
113 setV8ObjectPropertyAsString(keyframe2, "height", "150px"); 113 setV8ObjectPropertyAsString(keyframe2, "height", "150px");
114 setV8ObjectPropertyAsString(keyframe3, "height", "200px"); 114 setV8ObjectPropertyAsString(keyframe3, "height", "200px");
115 setV8ObjectPropertyAsString(keyframe3, "offset", "0"); 115 setV8ObjectPropertyAsString(keyframe3, "offset", "0");
116 setV8ObjectPropertyAsString(keyframe4, "height", "300px"); 116 setV8ObjectPropertyAsString(keyframe4, "height", "300px");
117 setV8ObjectPropertyAsString(keyframe4, "offset", "1"); 117 setV8ObjectPropertyAsString(keyframe4, "offset", "1");
118 118
119 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState)); 119 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
120 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); 120 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
121 jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState)); 121 jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState));
122 jsKeyframes.append(Dictionary(keyframe4, m_isolate, exceptionState)); 122 jsKeyframes.append(Dictionary(keyframe4, m_isolate, exceptionState));
123 123
124 EffectInput::convert(element.get(), jsKeyframes, exceptionState); 124 EffectInput::convert(element.get(), jsKeyframes, exceptionState);
125 EXPECT_TRUE(exceptionState.hadException()); 125 EXPECT_TRUE(exceptionState.hadException());
126 } 126 }
127 127
128 TEST_F(AnimationEffectInputTest, Invalid) 128 TEST_F(AnimationEffectInputTest, Invalid)
129 { 129 {
130 // Not loosely sorted by offset, and there exists a keyframe with null offse t. 130 // Not loosely sorted by offset, and there exists a keyframe with null offse t.
131 Vector<Dictionary> jsKeyframes; 131 Vector<Dictionary> jsKeyframes;
132 v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate); 132 v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
133 v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate); 133 v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
134 v8::Handle<v8::Object> keyframe3 = v8::Object::New(m_isolate); 134 v8::Local<v8::Object> keyframe3 = v8::Object::New(m_isolate);
135 135
136 setV8ObjectPropertyAsString(keyframe1, "width", "0px"); 136 setV8ObjectPropertyAsString(keyframe1, "width", "0px");
137 setV8ObjectPropertyAsString(keyframe1, "offset", "1"); 137 setV8ObjectPropertyAsString(keyframe1, "offset", "1");
138 setV8ObjectPropertyAsString(keyframe2, "width", "200px"); 138 setV8ObjectPropertyAsString(keyframe2, "width", "200px");
139 setV8ObjectPropertyAsString(keyframe3, "width", "100px"); 139 setV8ObjectPropertyAsString(keyframe3, "width", "100px");
140 setV8ObjectPropertyAsString(keyframe3, "offset", "0"); 140 setV8ObjectPropertyAsString(keyframe3, "offset", "0");
141 141
142 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState)); 142 jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
143 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState)); 143 jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
144 jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState)); 144 jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState));
145 145
146 EffectInput::convert(element.get(), jsKeyframes, exceptionState); 146 EffectInput::convert(element.get(), jsKeyframes, exceptionState);
147 EXPECT_TRUE(exceptionState.hadException()); 147 EXPECT_TRUE(exceptionState.hadException());
148 EXPECT_EQ(InvalidModificationError, exceptionState.code()); 148 EXPECT_EQ(InvalidModificationError, exceptionState.code());
149 } 149 }
150 150
151 } 151 }
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationTest.cpp ('k') | Source/core/animation/TimingInputTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698