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

Side by Side Diff: Source/core/platform/animation/TimingFunctionTest.cpp

Issue 57563002: Adding operator== for ChainedTimingFunction (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove EQ reflectivity fix. Created 7 years, 1 month 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/platform/animation/TimingFunction.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 EXPECT_REFV_NE(v[i].second, v[j].second) \ 57 EXPECT_REFV_NE(v[i].second, v[j].second) \
58 << v[i].first \ 58 << v[i].first \
59 << " (" << ::testing::PrintToString(*v[i].second.get()) << ")" \ 59 << " (" << ::testing::PrintToString(*v[i].second.get()) << ")" \
60 << " == " \ 60 << " == " \
61 << v[j].first \ 61 << v[j].first \
62 << " (" << ::testing::PrintToString(*v[j].second.get()) << ")" \ 62 << " (" << ::testing::PrintToString(*v[j].second.get()) << ")" \
63 << "\n"; \ 63 << "\n"; \
64 } \ 64 } \
65 } 65 }
66 66
67
67 using namespace WebCore; 68 using namespace WebCore;
68 69
69 namespace { 70 namespace {
70 71
71 class TimingFunctionTest : public ::testing::Test { 72 class TimingFunctionTest : public ::testing::Test {
72 protected: 73 protected:
73 virtual void SetUp() 74 virtual void SetUp()
74 { 75 {
75 // Needed for ChainedTimingFunction support 76 // Needed for ChainedTimingFunction support
76 RuntimeEnabledFeatures::setWebAnimationsEnabled(true); 77 RuntimeEnabledFeatures::setWebAnimationsEnabled(true);
77 } 78 }
78 79
79 }; 80 };
80 81
81 TEST_F(TimingFunctionTest, BaseOperatorEq) 82 TEST_F(TimingFunctionTest, BaseOperatorEq)
82 { 83 {
83 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create(); 84 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create();
84 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseIn); 85 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseIn);
85 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.17 , 0.67, 1, -1.73); 86 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.17 , 0.67, 1, -1.73);
86 RefPtr<TimingFunction> stepsTiming1 = StepsTimingFunction::preset(StepsTimin gFunction::End); 87 RefPtr<TimingFunction> stepsTiming1 = StepsTimingFunction::preset(StepsTimin gFunction::End);
87 RefPtr<TimingFunction> stepsTiming2 = StepsTimingFunction::create(5, true); 88 RefPtr<TimingFunction> stepsTiming2 = StepsTimingFunction::create(5, true);
88 89
90 RefPtr<ChainedTimingFunction> chainedTiming1 = ChainedTimingFunction::create ();
91 chainedTiming1->appendSegment(1.0, linearTiming.get());
92
93 RefPtr<ChainedTimingFunction> chainedTiming2 = ChainedTimingFunction::create ();
94 chainedTiming2->appendSegment(0.5, cubicTiming1.get());
95 chainedTiming2->appendSegment(1.0, cubicTiming2.get());
96
89 NE_HELPER(v); 97 NE_HELPER(v);
90 NE_HELPER_APPEND(v, linearTiming); 98 NE_HELPER_APPEND(v, linearTiming);
91 NE_HELPER_APPEND(v, cubicTiming1); 99 NE_HELPER_APPEND(v, cubicTiming1);
92 NE_HELPER_APPEND(v, cubicTiming2); 100 NE_HELPER_APPEND(v, cubicTiming2);
93 NE_HELPER_APPEND(v, stepsTiming1); 101 NE_HELPER_APPEND(v, stepsTiming1);
94 NE_HELPER_APPEND(v, stepsTiming2); 102 NE_HELPER_APPEND(v, stepsTiming2);
103 NE_HELPER_APPEND(v, chainedTiming1);
104 NE_HELPER_APPEND(v, chainedTiming2);
95 NE_HELPER_LOOP(v); 105 NE_HELPER_LOOP(v);
96 } 106 }
97 107
98 TEST_F(TimingFunctionTest, LinearOperatorEq) 108 TEST_F(TimingFunctionTest, LinearOperatorEq)
99 { 109 {
100 RefPtr<TimingFunction> linearTiming1 = LinearTimingFunction::create(); 110 RefPtr<TimingFunction> linearTiming1 = LinearTimingFunction::create();
101 RefPtr<TimingFunction> linearTiming2 = LinearTimingFunction::create(); 111 RefPtr<TimingFunction> linearTiming2 = LinearTimingFunction::create();
102 EXPECT_REFV_EQ(linearTiming1, linearTiming1); 112 EXPECT_REFV_EQ(linearTiming1, linearTiming1);
103 EXPECT_REFV_EQ(linearTiming1, linearTiming2); 113 EXPECT_REFV_EQ(linearTiming1, linearTiming2);
104 } 114 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 180 }
171 181
172 TEST_F(TimingFunctionTest, StepsOperatorEqReflectivityBug) 182 TEST_F(TimingFunctionTest, StepsOperatorEqReflectivityBug)
173 { 183 {
174 RefPtr<TimingFunction> stepsA = StepsTimingFunction::preset(StepsTimingFunct ion::Start); 184 RefPtr<TimingFunction> stepsA = StepsTimingFunction::preset(StepsTimingFunct ion::Start);
175 RefPtr<TimingFunction> stepsB = StepsTimingFunction::create(1, true); 185 RefPtr<TimingFunction> stepsB = StepsTimingFunction::create(1, true);
176 EXPECT_REFV_NE(stepsA, stepsB); 186 EXPECT_REFV_NE(stepsA, stepsB);
177 EXPECT_REFV_NE(stepsB, stepsA); 187 EXPECT_REFV_NE(stepsB, stepsA);
178 } 188 }
179 189
190 TEST_F(TimingFunctionTest, ChainedEq)
191 {
192 // Single item in chain
193 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::create(0.25 , 0.1, 0.25, 1.0);
194 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.25 , 0.1, 0.25, 1.0);
195 RefPtr<TimingFunction> cubicTiming3 = CubicBezierTimingFunction::preset(Cubi cBezierTimingFunction::EaseOut);
196
197 RefPtr<ChainedTimingFunction> chainedSingleCubic1 = ChainedTimingFunction::c reate();
198 chainedSingleCubic1->appendSegment(1.0, cubicTiming1.get());
199 EXPECT_REFV_EQ(chainedSingleCubic1, chainedSingleCubic1);
200
201 RefPtr<ChainedTimingFunction> chainedSingleCubic2 = ChainedTimingFunction::c reate();
202 chainedSingleCubic2->appendSegment(1.0, cubicTiming1.get()); // Same inner t iming function
203 EXPECT_REFV_EQ(chainedSingleCubic1, chainedSingleCubic2);
204
205 RefPtr<ChainedTimingFunction> chainedSingleCubic3 = ChainedTimingFunction::c reate();
206 chainedSingleCubic3->appendSegment(1.0, cubicTiming2.get()); // == inner tim ing function
207 EXPECT_REFV_EQ(chainedSingleCubic1, chainedSingleCubic3);
208
209 RefPtr<ChainedTimingFunction> chainedSingleCubic4 = ChainedTimingFunction::c reate();
210 chainedSingleCubic4->appendSegment(0.5, cubicTiming1.get()); // Different of fset
211 EXPECT_REFV_NE(chainedSingleCubic1, chainedSingleCubic4);
212 EXPECT_REFV_NE(chainedSingleCubic3, chainedSingleCubic4);
213
214 RefPtr<ChainedTimingFunction> chainedSingleCubic5 = ChainedTimingFunction::c reate();
215 chainedSingleCubic5->appendSegment(1.0, cubicTiming3.get()); // != inner tim ing function (same type)
216 EXPECT_REFV_NE(chainedSingleCubic1, chainedSingleCubic5);
217 EXPECT_REFV_NE(chainedSingleCubic2, chainedSingleCubic5);
218 EXPECT_REFV_NE(chainedSingleCubic3, chainedSingleCubic5);
219 EXPECT_REFV_NE(chainedSingleCubic4, chainedSingleCubic5);
220
221 RefPtr<TimingFunction> linearTiming1 = LinearTimingFunction::create();
222 RefPtr<ChainedTimingFunction> chainedSingleLinear1 = ChainedTimingFunction:: create();
223 chainedSingleLinear1->appendSegment(1.0, linearTiming1.get()); // != inner t iming function (different type)
224 EXPECT_REFV_NE(chainedSingleLinear1, chainedSingleCubic1);
225 EXPECT_REFV_NE(chainedSingleLinear1, chainedSingleCubic2);
226 EXPECT_REFV_NE(chainedSingleLinear1, chainedSingleCubic3);
227 EXPECT_REFV_NE(chainedSingleLinear1, chainedSingleCubic4);
228
229 // Multiple items in chain
230 RefPtr<ChainedTimingFunction> chainedMixed1 = ChainedTimingFunction::create( );
231 chainedMixed1->appendSegment(0.25, chainedSingleLinear1.get());
232 chainedMixed1->appendSegment(1.0, cubicTiming1.get());
233
234 RefPtr<ChainedTimingFunction> chainedMixed2 = ChainedTimingFunction::create( );
235 chainedMixed2->appendSegment(0.25, chainedSingleLinear1.get());
236 chainedMixed2->appendSegment(1.0, cubicTiming1.get());
237
238 RefPtr<ChainedTimingFunction> chainedMixed3 = ChainedTimingFunction::create( );
239 chainedMixed3->appendSegment(0.25, chainedSingleLinear1.get());
240 chainedMixed3->appendSegment(1.0, cubicTiming2.get());
241
242 EXPECT_REFV_EQ(chainedMixed1, chainedMixed2);
243 EXPECT_REFV_EQ(chainedMixed1, chainedMixed3);
244 EXPECT_REFV_NE(chainedMixed1, chainedSingleCubic1);
245 EXPECT_REFV_NE(chainedMixed1, chainedSingleLinear1);
246
247 RefPtr<ChainedTimingFunction> chainedMixed4 = ChainedTimingFunction::create( );
248 chainedMixed4->appendSegment(0.20, chainedSingleLinear1.get()); // Different offset
249 chainedMixed4->appendSegment(1.0, cubicTiming1.get());
250 EXPECT_REFV_NE(chainedMixed1, chainedMixed4);
251 }
180 252
181 } // namespace 253 } // namespace
OLDNEW
« no previous file with comments | « Source/core/platform/animation/TimingFunction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698