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

Side by Side Diff: Source/platform/animation/TimingFunctionTestHelperTest.cpp

Issue 149363002: Web Animations API: Implement step-middle and steps(x, middle) timing functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix TimingFunctionTestHelperTest 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 ::testing::MatchesRegex("cubic-bezier\\(0.17, 0.67, 1, -1.73\\)")); 111 ::testing::MatchesRegex("cubic-bezier\\(0.17, 0.67, 1, -1.73\\)"));
112 } 112 }
113 113
114 TEST_F(TimingFunctionTestHelperTest, StepPrintTo) 114 TEST_F(TimingFunctionTestHelperTest, StepPrintTo)
115 { 115 {
116 RefPtr<TimingFunction> stepTimingStart = StepsTimingFunction::preset(StepsTi mingFunction::Start); 116 RefPtr<TimingFunction> stepTimingStart = StepsTimingFunction::preset(StepsTi mingFunction::Start);
117 EXPECT_THAT( 117 EXPECT_THAT(
118 PrintToString(stepTimingStart), 118 PrintToString(stepTimingStart),
119 ::testing::MatchesRegex("step-start")); 119 ::testing::MatchesRegex("step-start"));
120 120
121 RefPtr<TimingFunction> stepTimingCustom = StepsTimingFunction::create(5, fal se); 121 RefPtr<TimingFunction> stepTimingMiddle = StepsTimingFunction::preset(StepsT imingFunction::Middle);
122 EXPECT_THAT(
123 PrintToString(stepTimingMiddle),
124 ::testing::MatchesRegex("step-middle"));
125
126 RefPtr<TimingFunction> stepTimingCustom = StepsTimingFunction::create(5, Ste psTimingFunction::StepAtEnd);
122 EXPECT_THAT( 127 EXPECT_THAT(
123 PrintToString(stepTimingCustom), 128 PrintToString(stepTimingCustom),
124 ::testing::MatchesRegex("steps\\(5, end\\)")); 129 ::testing::MatchesRegex("steps\\(5, end\\)"));
125 } 130 }
126 131
127 TEST_F(TimingFunctionTestHelperTest, ChainedPrintTo) 132 TEST_F(TimingFunctionTestHelperTest, ChainedPrintTo)
128 { 133 {
129 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create(); 134 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create();
130 RefPtr<ChainedTimingFunction> chainedLinearSingle = ChainedTimingFunction::c reate(); 135 RefPtr<ChainedTimingFunction> chainedLinearSingle = ChainedTimingFunction::c reate();
131 chainedLinearSingle->appendSegment(1.0, linearTiming.get()); 136 chainedLinearSingle->appendSegment(1.0, linearTiming.get());
(...skipping 19 matching lines...) Expand all
151 "cubic-bezier\\(1, 0, 1, -1\\)\\[0.75 -> 1\\]" 156 "cubic-bezier\\(1, 0, 1, -1\\)\\[0.75 -> 1\\]"
152 "\\)")); 157 "\\)"));
153 } 158 }
154 159
155 TEST_F(TimingFunctionTestHelperTest, BaseOperatorEq) 160 TEST_F(TimingFunctionTestHelperTest, BaseOperatorEq)
156 { 161 {
157 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create(); 162 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create();
158 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseIn); 163 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseIn);
159 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.17 , 0.67, 1, -1.73); 164 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.17 , 0.67, 1, -1.73);
160 RefPtr<TimingFunction> stepsTiming1 = StepsTimingFunction::preset(StepsTimin gFunction::End); 165 RefPtr<TimingFunction> stepsTiming1 = StepsTimingFunction::preset(StepsTimin gFunction::End);
161 RefPtr<TimingFunction> stepsTiming2 = StepsTimingFunction::create(5, true); 166 RefPtr<TimingFunction> stepsTiming2 = StepsTimingFunction::create(5, StepsTi mingFunction::StepAtStart);
162 167
163 RefPtr<ChainedTimingFunction> chainedTiming1 = ChainedTimingFunction::create (); 168 RefPtr<ChainedTimingFunction> chainedTiming1 = ChainedTimingFunction::create ();
164 chainedTiming1->appendSegment(1.0, linearTiming.get()); 169 chainedTiming1->appendSegment(1.0, linearTiming.get());
165 170
166 RefPtr<ChainedTimingFunction> chainedTiming2 = ChainedTimingFunction::create (); 171 RefPtr<ChainedTimingFunction> chainedTiming2 = ChainedTimingFunction::create ();
167 chainedTiming2->appendSegment(0.5, cubicTiming1.get()); 172 chainedTiming2->appendSegment(0.5, cubicTiming1.get());
168 chainedTiming2->appendSegment(1.0, cubicTiming2.get()); 173 chainedTiming2->appendSegment(1.0, cubicTiming2.get());
169 174
170 NE_HELPER(v); 175 NE_HELPER(v);
171 NE_HELPER_APPEND(v, linearTiming); 176 NE_HELPER_APPEND(v, linearTiming);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 { 230 {
226 RefPtr<TimingFunction> stepsTimingStart1 = StepsTimingFunction::preset(Steps TimingFunction::Start); 231 RefPtr<TimingFunction> stepsTimingStart1 = StepsTimingFunction::preset(Steps TimingFunction::Start);
227 RefPtr<TimingFunction> stepsTimingStart2 = StepsTimingFunction::preset(Steps TimingFunction::Start); 232 RefPtr<TimingFunction> stepsTimingStart2 = StepsTimingFunction::preset(Steps TimingFunction::Start);
228 EXPECT_REFV_EQ(stepsTimingStart1, stepsTimingStart1); 233 EXPECT_REFV_EQ(stepsTimingStart1, stepsTimingStart1);
229 EXPECT_REFV_EQ(stepsTimingStart1, stepsTimingStart2); 234 EXPECT_REFV_EQ(stepsTimingStart1, stepsTimingStart2);
230 235
231 RefPtr<TimingFunction> stepsTimingEnd1 = StepsTimingFunction::preset(StepsTi mingFunction::End); 236 RefPtr<TimingFunction> stepsTimingEnd1 = StepsTimingFunction::preset(StepsTi mingFunction::End);
232 RefPtr<TimingFunction> stepsTimingEnd2 = StepsTimingFunction::preset(StepsTi mingFunction::End); 237 RefPtr<TimingFunction> stepsTimingEnd2 = StepsTimingFunction::preset(StepsTi mingFunction::End);
233 EXPECT_REFV_EQ(stepsTimingEnd1, stepsTimingEnd2); 238 EXPECT_REFV_EQ(stepsTimingEnd1, stepsTimingEnd2);
234 239
235 RefPtr<TimingFunction> stepsTimingCustom1 = StepsTimingFunction::create(5, t rue); 240 RefPtr<TimingFunction> stepsTimingCustom1 = StepsTimingFunction::create(5, S tepsTimingFunction::StepAtStart);
236 RefPtr<TimingFunction> stepsTimingCustom2 = StepsTimingFunction::create(5, f alse); 241 RefPtr<TimingFunction> stepsTimingCustom2 = StepsTimingFunction::create(5, S tepsTimingFunction::StepAtEnd);
237 RefPtr<TimingFunction> stepsTimingCustom3 = StepsTimingFunction::create(7, t rue); 242 RefPtr<TimingFunction> stepsTimingCustom3 = StepsTimingFunction::create(7, S tepsTimingFunction::StepAtStart);
238 RefPtr<TimingFunction> stepsTimingCustom4 = StepsTimingFunction::create(7, f alse); 243 RefPtr<TimingFunction> stepsTimingCustom4 = StepsTimingFunction::create(7, S tepsTimingFunction::StepAtEnd);
239 244
240 EXPECT_REFV_EQ(stepsTimingCustom1, StepsTimingFunction::create(5, true)); 245 EXPECT_REFV_EQ(stepsTimingCustom1, StepsTimingFunction::create(5, StepsTimin gFunction::StepAtStart));
241 EXPECT_REFV_EQ(stepsTimingCustom2, StepsTimingFunction::create(5, false)); 246 EXPECT_REFV_EQ(stepsTimingCustom2, StepsTimingFunction::create(5, StepsTimin gFunction::StepAtEnd));
242 EXPECT_REFV_EQ(stepsTimingCustom3, StepsTimingFunction::create(7, true)); 247 EXPECT_REFV_EQ(stepsTimingCustom3, StepsTimingFunction::create(7, StepsTimin gFunction::StepAtStart));
243 EXPECT_REFV_EQ(stepsTimingCustom4, StepsTimingFunction::create(7, false)); 248 EXPECT_REFV_EQ(stepsTimingCustom4, StepsTimingFunction::create(7, StepsTimin gFunction::StepAtEnd));
244 249
245 NE_HELPER(v); 250 NE_HELPER(v);
246 NE_HELPER_APPEND(v, stepsTimingStart1); 251 NE_HELPER_APPEND(v, stepsTimingStart1);
247 NE_HELPER_APPEND(v, stepsTimingEnd1); 252 NE_HELPER_APPEND(v, stepsTimingEnd1);
248 NE_HELPER_APPEND(v, stepsTimingCustom1); 253 NE_HELPER_APPEND(v, stepsTimingCustom1);
249 NE_HELPER_APPEND(v, stepsTimingCustom2); 254 NE_HELPER_APPEND(v, stepsTimingCustom2);
250 NE_HELPER_APPEND(v, stepsTimingCustom3); 255 NE_HELPER_APPEND(v, stepsTimingCustom3);
251 NE_HELPER_APPEND(v, stepsTimingCustom4); 256 NE_HELPER_APPEND(v, stepsTimingCustom4);
252 NE_HELPER_LOOP(v); 257 NE_HELPER_LOOP(v);
253 } 258 }
254 259
255 TEST_F(TimingFunctionTestHelperTest, StepsOperatorEqReflectivity) 260 TEST_F(TimingFunctionTestHelperTest, StepsOperatorEqReflectivity)
256 { 261 {
257 RefPtr<TimingFunction> stepsA = StepsTimingFunction::preset(StepsTimingFunct ion::Start); 262 RefPtr<TimingFunction> stepsA = StepsTimingFunction::preset(StepsTimingFunct ion::Start);
258 RefPtr<TimingFunction> stepsB = StepsTimingFunction::create(1, true); 263 RefPtr<TimingFunction> stepsB = StepsTimingFunction::create(1, StepsTimingFu nction::StepAtStart);
259 EXPECT_REFV_NE(stepsA, stepsB); 264 EXPECT_REFV_NE(stepsA, stepsB);
260 EXPECT_REFV_NE(stepsB, stepsA); 265 EXPECT_REFV_NE(stepsB, stepsA);
261 } 266 }
262 267
263 TEST_F(TimingFunctionTestHelperTest, ChainedEq) 268 TEST_F(TimingFunctionTestHelperTest, ChainedEq)
264 { 269 {
265 // Single item in chain 270 // Single item in chain
266 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::create(0.25 , 0.1, 0.25, 1.0); 271 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::create(0.25 , 0.1, 0.25, 1.0);
267 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.25 , 0.1, 0.25, 1.0); 272 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.25 , 0.1, 0.25, 1.0);
268 RefPtr<TimingFunction> cubicTiming3 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseOut); 273 RefPtr<TimingFunction> cubicTiming3 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseOut);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_REFV_NE(chainedMixed1, chainedSingleCubic1); 322 EXPECT_REFV_NE(chainedMixed1, chainedSingleCubic1);
318 EXPECT_REFV_NE(chainedMixed1, chainedSingleLinear1); 323 EXPECT_REFV_NE(chainedMixed1, chainedSingleLinear1);
319 324
320 RefPtr<ChainedTimingFunction> chainedMixed4 = ChainedTimingFunction::create( ); 325 RefPtr<ChainedTimingFunction> chainedMixed4 = ChainedTimingFunction::create( );
321 chainedMixed4->appendSegment(0.20, chainedSingleLinear1.get()); // Different offset 326 chainedMixed4->appendSegment(0.20, chainedSingleLinear1.get()); // Different offset
322 chainedMixed4->appendSegment(1.0, cubicTiming1.get()); 327 chainedMixed4->appendSegment(1.0, cubicTiming1.get());
323 EXPECT_REFV_NE(chainedMixed1, chainedMixed4); 328 EXPECT_REFV_NE(chainedMixed1, chainedMixed4);
324 } 329 }
325 330
326 } // namespace 331 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698