OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 << b.first \ | 47 << b.first \ |
48 << " (" << b.second->toString().latin1().data() << ")" \ | 48 << " (" << b.second->toString().latin1().data() << ")" \ |
49 << "\n"; | 49 << "\n"; |
50 | 50 |
51 namespace blink { | 51 namespace blink { |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 class TimingFunctionTest : public ::testing::Test { | 55 class TimingFunctionTest : public ::testing::Test { |
56 public: | 56 public: |
57 void notEqualHelperLoop(Vector<std::pair<std::string, RefPtr<TimingFunction>
> >& v) | 57 void notEqualHelperLoop(Vector<std::pair<std::string, RefPtr<TimingFunction>
>>& v) |
58 { | 58 { |
59 for (size_t i = 0; i < v.size(); ++i) { | 59 for (size_t i = 0; i < v.size(); ++i) { |
60 for (size_t j = 0; j < v.size(); ++j) { | 60 for (size_t j = 0; j < v.size(); ++j) { |
61 if (i == j) | 61 if (i == j) |
62 continue; | 62 continue; |
63 EXPECT_NE_WITH_MESSAGE(v[i], v[j]); | 63 EXPECT_NE_WITH_MESSAGE(v[i], v[j]); |
64 } | 64 } |
65 } | 65 } |
66 } | 66 } |
67 }; | 67 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 TEST_F(TimingFunctionTest, BaseOperatorEq) | 111 TEST_F(TimingFunctionTest, BaseOperatorEq) |
112 { | 112 { |
113 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::shared(); | 113 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::shared(); |
114 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::preset(Cubi
cBezierTimingFunction::EaseIn); | 114 RefPtr<TimingFunction> cubicTiming1 = CubicBezierTimingFunction::preset(Cubi
cBezierTimingFunction::EaseIn); |
115 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.17
, 0.67, 1, -1.73); | 115 RefPtr<TimingFunction> cubicTiming2 = CubicBezierTimingFunction::create(0.17
, 0.67, 1, -1.73); |
116 RefPtr<TimingFunction> stepsTiming1 = StepsTimingFunction::preset(StepsTimin
gFunction::End); | 116 RefPtr<TimingFunction> stepsTiming1 = StepsTimingFunction::preset(StepsTimin
gFunction::End); |
117 RefPtr<TimingFunction> stepsTiming2 = StepsTimingFunction::create(5, StepsTi
mingFunction::Start); | 117 RefPtr<TimingFunction> stepsTiming2 = StepsTimingFunction::create(5, StepsTi
mingFunction::Start); |
118 | 118 |
119 Vector<std::pair<std::string, RefPtr<TimingFunction>> > v; | 119 Vector<std::pair<std::string, RefPtr<TimingFunction>>> v; |
120 v.append(std::make_pair("linearTiming", linearTiming)); | 120 v.append(std::make_pair("linearTiming", linearTiming)); |
121 v.append(std::make_pair("cubicTiming1", cubicTiming1)); | 121 v.append(std::make_pair("cubicTiming1", cubicTiming1)); |
122 v.append(std::make_pair("cubicTiming2", cubicTiming2)); | 122 v.append(std::make_pair("cubicTiming2", cubicTiming2)); |
123 v.append(std::make_pair("stepsTiming1", stepsTiming1)); | 123 v.append(std::make_pair("stepsTiming1", stepsTiming1)); |
124 v.append(std::make_pair("stepsTiming2", stepsTiming2)); | 124 v.append(std::make_pair("stepsTiming2", stepsTiming2)); |
125 notEqualHelperLoop(v); | 125 notEqualHelperLoop(v); |
126 } | 126 } |
127 | 127 |
128 TEST_F(TimingFunctionTest, LinearOperatorEq) | 128 TEST_F(TimingFunctionTest, LinearOperatorEq) |
129 { | 129 { |
(...skipping 18 matching lines...) Expand all Loading... |
148 RefPtr<TimingFunction> cubicEaseInOutTiming1 = CubicBezierTimingFunction::pr
eset(CubicBezierTimingFunction::EaseInOut); | 148 RefPtr<TimingFunction> cubicEaseInOutTiming1 = CubicBezierTimingFunction::pr
eset(CubicBezierTimingFunction::EaseInOut); |
149 RefPtr<TimingFunction> cubicEaseInOutTiming2 = CubicBezierTimingFunction::pr
eset(CubicBezierTimingFunction::EaseInOut); | 149 RefPtr<TimingFunction> cubicEaseInOutTiming2 = CubicBezierTimingFunction::pr
eset(CubicBezierTimingFunction::EaseInOut); |
150 EXPECT_EQ(*cubicEaseInOutTiming1, *cubicEaseInOutTiming1); | 150 EXPECT_EQ(*cubicEaseInOutTiming1, *cubicEaseInOutTiming1); |
151 EXPECT_EQ(*cubicEaseInOutTiming1, *cubicEaseInOutTiming2); | 151 EXPECT_EQ(*cubicEaseInOutTiming1, *cubicEaseInOutTiming2); |
152 | 152 |
153 RefPtr<TimingFunction> cubicCustomTiming1 = CubicBezierTimingFunction::creat
e(0.17, 0.67, 1, -1.73); | 153 RefPtr<TimingFunction> cubicCustomTiming1 = CubicBezierTimingFunction::creat
e(0.17, 0.67, 1, -1.73); |
154 RefPtr<TimingFunction> cubicCustomTiming2 = CubicBezierTimingFunction::creat
e(0.17, 0.67, 1, -1.73); | 154 RefPtr<TimingFunction> cubicCustomTiming2 = CubicBezierTimingFunction::creat
e(0.17, 0.67, 1, -1.73); |
155 EXPECT_EQ(*cubicCustomTiming1, *cubicCustomTiming1); | 155 EXPECT_EQ(*cubicCustomTiming1, *cubicCustomTiming1); |
156 EXPECT_EQ(*cubicCustomTiming1, *cubicCustomTiming2); | 156 EXPECT_EQ(*cubicCustomTiming1, *cubicCustomTiming2); |
157 | 157 |
158 Vector<std::pair<std::string, RefPtr<TimingFunction>> > v; | 158 Vector<std::pair<std::string, RefPtr<TimingFunction>>> v; |
159 v.append(std::make_pair("cubicEaseInTiming1", cubicEaseInTiming1)); | 159 v.append(std::make_pair("cubicEaseInTiming1", cubicEaseInTiming1)); |
160 v.append(std::make_pair("cubicEaseOutTiming1", cubicEaseOutTiming1)); | 160 v.append(std::make_pair("cubicEaseOutTiming1", cubicEaseOutTiming1)); |
161 v.append(std::make_pair("cubicEaseInOutTiming1", cubicEaseInOutTiming1)); | 161 v.append(std::make_pair("cubicEaseInOutTiming1", cubicEaseInOutTiming1)); |
162 v.append(std::make_pair("cubicCustomTiming1", cubicCustomTiming1)); | 162 v.append(std::make_pair("cubicCustomTiming1", cubicCustomTiming1)); |
163 notEqualHelperLoop(v); | 163 notEqualHelperLoop(v); |
164 } | 164 } |
165 | 165 |
166 TEST_F(TimingFunctionTest, CubicOperatorEqReflectivity) | 166 TEST_F(TimingFunctionTest, CubicOperatorEqReflectivity) |
167 { | 167 { |
168 RefPtr<TimingFunction> cubicA = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::EaseIn); | 168 RefPtr<TimingFunction> cubicA = CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::EaseIn); |
(...skipping 17 matching lines...) Expand all Loading... |
186 RefPtr<TimingFunction> stepsTimingCustom1 = StepsTimingFunction::create(5, S
tepsTimingFunction::Start); | 186 RefPtr<TimingFunction> stepsTimingCustom1 = StepsTimingFunction::create(5, S
tepsTimingFunction::Start); |
187 RefPtr<TimingFunction> stepsTimingCustom2 = StepsTimingFunction::create(5, S
tepsTimingFunction::End); | 187 RefPtr<TimingFunction> stepsTimingCustom2 = StepsTimingFunction::create(5, S
tepsTimingFunction::End); |
188 RefPtr<TimingFunction> stepsTimingCustom3 = StepsTimingFunction::create(7, S
tepsTimingFunction::Start); | 188 RefPtr<TimingFunction> stepsTimingCustom3 = StepsTimingFunction::create(7, S
tepsTimingFunction::Start); |
189 RefPtr<TimingFunction> stepsTimingCustom4 = StepsTimingFunction::create(7, S
tepsTimingFunction::End); | 189 RefPtr<TimingFunction> stepsTimingCustom4 = StepsTimingFunction::create(7, S
tepsTimingFunction::End); |
190 | 190 |
191 EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::Start), *step
sTimingCustom1); | 191 EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::Start), *step
sTimingCustom1); |
192 EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::End), *stepsT
imingCustom2); | 192 EXPECT_EQ(*StepsTimingFunction::create(5, StepsTimingFunction::End), *stepsT
imingCustom2); |
193 EXPECT_EQ(*StepsTimingFunction::create(7, StepsTimingFunction::Start), *step
sTimingCustom3); | 193 EXPECT_EQ(*StepsTimingFunction::create(7, StepsTimingFunction::Start), *step
sTimingCustom3); |
194 EXPECT_EQ(*StepsTimingFunction::create(7, StepsTimingFunction::End), *stepsT
imingCustom4); | 194 EXPECT_EQ(*StepsTimingFunction::create(7, StepsTimingFunction::End), *stepsT
imingCustom4); |
195 | 195 |
196 Vector<std::pair<std::string, RefPtr<TimingFunction>> > v; | 196 Vector<std::pair<std::string, RefPtr<TimingFunction>>> v; |
197 v.append(std::make_pair("stepsTimingStart1", stepsTimingStart1)); | 197 v.append(std::make_pair("stepsTimingStart1", stepsTimingStart1)); |
198 v.append(std::make_pair("stepsTimingEnd1", stepsTimingEnd1)); | 198 v.append(std::make_pair("stepsTimingEnd1", stepsTimingEnd1)); |
199 v.append(std::make_pair("stepsTimingCustom1", stepsTimingCustom1)); | 199 v.append(std::make_pair("stepsTimingCustom1", stepsTimingCustom1)); |
200 v.append(std::make_pair("stepsTimingCustom2", stepsTimingCustom2)); | 200 v.append(std::make_pair("stepsTimingCustom2", stepsTimingCustom2)); |
201 v.append(std::make_pair("stepsTimingCustom3", stepsTimingCustom3)); | 201 v.append(std::make_pair("stepsTimingCustom3", stepsTimingCustom3)); |
202 v.append(std::make_pair("stepsTimingCustom4", stepsTimingCustom4)); | 202 v.append(std::make_pair("stepsTimingCustom4", stepsTimingCustom4)); |
203 notEqualHelperLoop(v); | 203 notEqualHelperLoop(v); |
204 } | 204 } |
205 | 205 |
206 TEST_F(TimingFunctionTest, StepsOperatorEqPreset) | 206 TEST_F(TimingFunctionTest, StepsOperatorEqPreset) |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 checkCubicRegions2(0.0, 1.64, 0.0, -1.5); | 542 checkCubicRegions2(0.0, 1.64, 0.0, -1.5); |
543 | 543 |
544 // Curves with turning points touching y = 0.5 | 544 // Curves with turning points touching y = 0.5 |
545 checkCubicRegions2(0.0, 41.0 / 27.0, 1.0, -10.0 / 9.0); | 545 checkCubicRegions2(0.0, 41.0 / 27.0, 1.0, -10.0 / 9.0); |
546 checkCubicRegions2(0.0, 19.0 / 9.0, 1.0, -14.0 / 27.0); | 546 checkCubicRegions2(0.0, 19.0 / 9.0, 1.0, -14.0 / 27.0); |
547 } | 547 } |
548 | 548 |
549 } // namespace | 549 } // namespace |
550 | 550 |
551 } // namespace blink | 551 } // namespace blink |
OLD | NEW |