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

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

Issue 142523005: Web Animations: Define easing for each keyframe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Rename s_accuracy to accuracyForKeyframeEasing Created 6 years, 10 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/Animation.cpp ('k') | Source/core/animation/KeyframeEffectModel.h » ('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/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"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 v8::HandleScope scope(isolate); 98 v8::HandleScope scope(isolate);
99 v8::Local<v8::Context> context = v8::Context::New(isolate); 99 v8::Local<v8::Context> context = v8::Context::New(isolate);
100 v8::Context::Scope contextScope(context); 100 v8::Context::Scope contextScope(context);
101 101
102 Vector<Dictionary> jsKeyframes; 102 Vector<Dictionary> jsKeyframes;
103 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate); 103 v8::Handle<v8::Object> keyframe1 = v8::Object::New(isolate);
104 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate); 104 v8::Handle<v8::Object> keyframe2 = v8::Object::New(isolate);
105 105
106 setV8ObjectPropertyAsString(keyframe1, "width", "100px"); 106 setV8ObjectPropertyAsString(keyframe1, "width", "100px");
107 setV8ObjectPropertyAsString(keyframe1, "offset", "0"); 107 setV8ObjectPropertyAsString(keyframe1, "offset", "0");
108 setV8ObjectPropertyAsString(keyframe1, "easing", "ease-in-out");
108 setV8ObjectPropertyAsString(keyframe2, "width", "0px"); 109 setV8ObjectPropertyAsString(keyframe2, "width", "0px");
109 setV8ObjectPropertyAsString(keyframe2, "offset", "1"); 110 setV8ObjectPropertyAsString(keyframe2, "offset", "1");
111 setV8ObjectPropertyAsString(keyframe2, "easing", "cubic-bezier(1, 1, 0.3, 0. 3)");
110 112
111 jsKeyframes.append(Dictionary(keyframe1, isolate)); 113 jsKeyframes.append(Dictionary(keyframe1, isolate));
112 jsKeyframes.append(Dictionary(keyframe2, isolate)); 114 jsKeyframes.append(Dictionary(keyframe2, isolate));
113 115
114 String value1; 116 String value1;
115 ASSERT_TRUE(jsKeyframes[0].get("width", value1)); 117 ASSERT_TRUE(jsKeyframes[0].get("width", value1));
116 ASSERT_EQ("100px", value1); 118 ASSERT_EQ("100px", value1);
117 119
118 String value2; 120 String value2;
119 ASSERT_TRUE(jsKeyframes[1].get("width", value2)); 121 ASSERT_TRUE(jsKeyframes[1].get("width", value2));
(...skipping 13 matching lines...) Expand all
133 const AnimatableValue* keyframe1Width = keyframes[0]->propertyValue(CSSPrope rtyWidth); 135 const AnimatableValue* keyframe1Width = keyframes[0]->propertyValue(CSSPrope rtyWidth);
134 const AnimatableValue* keyframe2Width = keyframes[1]->propertyValue(CSSPrope rtyWidth); 136 const AnimatableValue* keyframe2Width = keyframes[1]->propertyValue(CSSPrope rtyWidth);
135 ASSERT(keyframe1Width); 137 ASSERT(keyframe1Width);
136 ASSERT(keyframe2Width); 138 ASSERT(keyframe2Width);
137 139
138 EXPECT_TRUE(keyframe1Width->isLength()); 140 EXPECT_TRUE(keyframe1Width->isLength());
139 EXPECT_TRUE(keyframe2Width->isLength()); 141 EXPECT_TRUE(keyframe2Width->isLength());
140 142
141 EXPECT_EQ("100px", toAnimatableLength(keyframe1Width)->toCSSValue()->cssText ()); 143 EXPECT_EQ("100px", toAnimatableLength(keyframe1Width)->toCSSValue()->cssText ());
142 EXPECT_EQ("0px", toAnimatableLength(keyframe2Width)->toCSSValue()->cssText() ); 144 EXPECT_EQ("0px", toAnimatableLength(keyframe2Width)->toCSSValue()->cssText() );
145
146 EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::Eas eInOut)), *keyframes[0]->easing());
147 EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), *keyfr ames[1]->easing());
143 } 148 }
144 149
145 TEST_F(AnimationAnimationTest, CanSetDuration) 150 TEST_F(AnimationAnimationTest, CanSetDuration)
146 { 151 {
147 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 152 v8::Isolate* isolate = v8::Isolate::GetCurrent();
148 v8::HandleScope scope(isolate); 153 v8::HandleScope scope(isolate);
149 v8::Local<v8::Context> context = v8::Context::New(isolate); 154 v8::Local<v8::Context> context = v8::Context::New(isolate);
150 v8::Context::Scope contextScope(context); 155 v8::Context::Scope contextScope(context);
151 156
152 Vector<Dictionary, 0> jsKeyframes; 157 Vector<Dictionary, 0> jsKeyframes;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 EXPECT_EQ(controlTiming.fillMode, updatedTiming.fillMode); 552 EXPECT_EQ(controlTiming.fillMode, updatedTiming.fillMode);
548 EXPECT_EQ(controlTiming.iterationStart, updatedTiming.iterationStart); 553 EXPECT_EQ(controlTiming.iterationStart, updatedTiming.iterationStart);
549 EXPECT_EQ(controlTiming.iterationCount, updatedTiming.iterationCount); 554 EXPECT_EQ(controlTiming.iterationCount, updatedTiming.iterationCount);
550 EXPECT_TRUE(std::isnan(updatedTiming.iterationDuration)); 555 EXPECT_TRUE(std::isnan(updatedTiming.iterationDuration));
551 EXPECT_EQ(controlTiming.playbackRate, updatedTiming.playbackRate); 556 EXPECT_EQ(controlTiming.playbackRate, updatedTiming.playbackRate);
552 EXPECT_EQ(controlTiming.direction, updatedTiming.direction); 557 EXPECT_EQ(controlTiming.direction, updatedTiming.direction);
553 EXPECT_EQ(*controlTiming.timingFunction.get(), *updatedTiming.timingFunction .get()); 558 EXPECT_EQ(*controlTiming.timingFunction.get(), *updatedTiming.timingFunction .get());
554 } 559 }
555 560
556 } // namespace WebCore 561 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/Animation.cpp ('k') | Source/core/animation/KeyframeEffectModel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698