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

Side by Side Diff: third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 EXPECT_EQ(35, calculateScaledActiveTime(40, 10, 5, timing)); 116 EXPECT_EQ(35, calculateScaledActiveTime(40, 10, 5, timing));
117 117
118 // otherwise 118 // otherwise
119 timing.playbackRate = 0; 119 timing.playbackRate = 0;
120 EXPECT_EQ(5, calculateScaledActiveTime(40, 10, 5, timing)); 120 EXPECT_EQ(5, calculateScaledActiveTime(40, 10, 5, timing));
121 timing.playbackRate = 1; 121 timing.playbackRate = 1;
122 EXPECT_EQ(15, calculateScaledActiveTime(40, 10, 5, timing)); 122 EXPECT_EQ(15, calculateScaledActiveTime(40, 10, 5, timing));
123 123
124 // infinte activeTime 124 // infinte activeTime
125 timing.playbackRate = 0; 125 timing.playbackRate = 0;
126 EXPECT_EQ(0, calculateScaledActiveTime( 126 EXPECT_EQ(0,
127 std::numeric_limits<double>::infinity(), 127 calculateScaledActiveTime(std::numeric_limits<double>::infinity(),
128 std::numeric_limits<double>::infinity(), 0, timing)); 128 std::numeric_limits<double>::infinity(),
129 0, timing));
129 timing.playbackRate = 1; 130 timing.playbackRate = 1;
130 EXPECT_EQ(std::numeric_limits<double>::infinity(), 131 EXPECT_EQ(std::numeric_limits<double>::infinity(),
131 calculateScaledActiveTime(std::numeric_limits<double>::infinity(), 132 calculateScaledActiveTime(std::numeric_limits<double>::infinity(),
132 std::numeric_limits<double>::infinity(), 133 std::numeric_limits<double>::infinity(),
133 0, timing)); 134 0, timing));
134 timing.playbackRate = -1; 135 timing.playbackRate = -1;
135 EXPECT_EQ(std::numeric_limits<double>::infinity(), 136 EXPECT_EQ(std::numeric_limits<double>::infinity(),
136 calculateScaledActiveTime(std::numeric_limits<double>::infinity(), 137 calculateScaledActiveTime(std::numeric_limits<double>::infinity(),
137 std::numeric_limits<double>::infinity(), 138 std::numeric_limits<double>::infinity(),
138 0, timing)); 139 0, timing));
139 } 140 }
140 141
141 TEST(AnimationTimingCalculationsTest, IterationTime) { 142 TEST(AnimationTimingCalculationsTest, IterationTime) {
142 Timing timing; 143 Timing timing;
143 144
144 // calculateIterationTime( 145 // calculateIterationTime(
145 // iterationDuration, repeatedDuration, scaledActiveTime, startOffset, 146 // iterationDuration, repeatedDuration, scaledActiveTime, startOffset,
146 // phase, timing) 147 // phase, timing)
147 148
148 // if the scaled active time is null 149 // if the scaled active time is null
149 EXPECT_TRUE(isNull(calculateIterationTime( 150 EXPECT_TRUE(isNull(calculateIterationTime(
150 1, 1, nullValue(), 1, AnimationEffectReadOnly::PhaseActive, timing))); 151 1, 1, nullValue(), 1, AnimationEffectReadOnly::PhaseActive, timing)));
151 152
152 // if (complex-conditions)... 153 // if (complex-conditions)...
153 EXPECT_EQ( 154 EXPECT_EQ(12,
154 12, calculateIterationTime(12, 12, 12, 0, 155 calculateIterationTime(
155 AnimationEffectReadOnly::PhaseActive, timing)); 156 12, 12, 12, 0, AnimationEffectReadOnly::PhaseActive, timing));
156 157
157 // otherwise 158 // otherwise
158 timing.iterationCount = 10; 159 timing.iterationCount = 10;
159 EXPECT_EQ( 160 EXPECT_EQ(5,
160 5, calculateIterationTime(10, 100, 25, 4, 161 calculateIterationTime(
161 AnimationEffectReadOnly::PhaseActive, timing)); 162 10, 100, 25, 4, AnimationEffectReadOnly::PhaseActive, timing));
162 EXPECT_EQ( 163 EXPECT_EQ(7,
163 7, calculateIterationTime(11, 110, 29, 1, 164 calculateIterationTime(
164 AnimationEffectReadOnly::PhaseActive, timing)); 165 11, 110, 29, 1, AnimationEffectReadOnly::PhaseActive, timing));
165 timing.iterationStart = 1.1; 166 timing.iterationStart = 1.1;
166 EXPECT_EQ( 167 EXPECT_EQ(8,
167 8, calculateIterationTime(12, 120, 20, 7, 168 calculateIterationTime(
168 AnimationEffectReadOnly::PhaseActive, timing)); 169 12, 120, 20, 7, AnimationEffectReadOnly::PhaseActive, timing));
169 } 170 }
170 171
171 TEST(AnimationTimingCalculationsTest, CurrentIteration) { 172 TEST(AnimationTimingCalculationsTest, CurrentIteration) {
172 Timing timing; 173 Timing timing;
173 174
174 // calculateCurrentIteration( 175 // calculateCurrentIteration(
175 // iterationDuration, iterationTime, scaledActiveTime, timing) 176 // iterationDuration, iterationTime, scaledActiveTime, timing)
176 177
177 // if the scaled active time is null 178 // if the scaled active time is null
178 EXPECT_TRUE(isNull(calculateCurrentIteration(1, 1, nullValue(), timing))); 179 EXPECT_TRUE(isNull(calculateCurrentIteration(1, 1, nullValue(), timing)));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 timing.timingFunction = 250 timing.timingFunction =
250 StepsTimingFunction::create(4, StepsTimingFunction::StepPosition::END); 251 StepsTimingFunction::create(4, StepsTimingFunction::StepPosition::END);
251 EXPECT_EQ(5, calculateTransformedTime(0, 20, 12, timing)); 252 EXPECT_EQ(5, calculateTransformedTime(0, 20, 12, timing));
252 EXPECT_EQ(5, calculateTransformedTime(1, 20, 12, timing)); 253 EXPECT_EQ(5, calculateTransformedTime(1, 20, 12, timing));
253 254
254 // Timing function when directed time is null. 255 // Timing function when directed time is null.
255 EXPECT_TRUE(isNull(calculateTransformedTime(1, 2, nullValue(), timing))); 256 EXPECT_TRUE(isNull(calculateTransformedTime(1, 2, nullValue(), timing)));
256 257
257 // Timing function when iterationDuration is infinity 258 // Timing function when iterationDuration is infinity
258 timing.direction = Timing::PlaybackDirection::NORMAL; 259 timing.direction = Timing::PlaybackDirection::NORMAL;
259 EXPECT_EQ(0, calculateTransformedTime( 260 EXPECT_EQ(0,
260 0, std::numeric_limits<double>::infinity(), 0, timing)); 261 calculateTransformedTime(0, std::numeric_limits<double>::infinity(),
261 EXPECT_EQ(1, calculateTransformedTime( 262 0, timing));
262 0, std::numeric_limits<double>::infinity(), 1, timing)); 263 EXPECT_EQ(1,
264 calculateTransformedTime(0, std::numeric_limits<double>::infinity(),
265 1, timing));
263 timing.direction = Timing::PlaybackDirection::REVERSE; 266 timing.direction = Timing::PlaybackDirection::REVERSE;
264 EXPECT_EQ(std::numeric_limits<double>::infinity(), 267 EXPECT_EQ(std::numeric_limits<double>::infinity(),
265 calculateTransformedTime(0, std::numeric_limits<double>::infinity(), 268 calculateTransformedTime(0, std::numeric_limits<double>::infinity(),
266 0, timing)); 269 0, timing));
267 EXPECT_EQ(std::numeric_limits<double>::infinity(), 270 EXPECT_EQ(std::numeric_limits<double>::infinity(),
268 calculateTransformedTime(0, std::numeric_limits<double>::infinity(), 271 calculateTransformedTime(0, std::numeric_limits<double>::infinity(),
269 1, timing)); 272 1, timing));
270 } 273 }
271 274
272 } // namespace blink 275 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698