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

Side by Side Diff: ui/gfx/animation/tween_unittest.cc

Issue 2966723003: Add support for bounds animations (Closed)
Patch Set: address reviewer feedback Created 3 years, 5 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 | « ui/gfx/animation/tween.cc ('k') | ui/gfx/test/gfx_util.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/gfx/animation/tween.h" 5 #include "ui/gfx/animation/tween.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 base::TimeTicks t_before = t0 + base::TimeDelta::FromSecondsD(0.9); 149 base::TimeTicks t_before = t0 + base::TimeDelta::FromSecondsD(0.9);
150 base::TimeTicks t_between = t0 + base::TimeDelta::FromSecondsD(1.6); 150 base::TimeTicks t_between = t0 + base::TimeDelta::FromSecondsD(1.6);
151 base::TimeTicks t_after = t0 + base::TimeDelta::FromSecondsD(2.2); 151 base::TimeTicks t_after = t0 + base::TimeDelta::FromSecondsD(2.2);
152 152
153 EXPECT_EQ(v1, Tween::ClampedFloatValueBetween(t_before, from, v1, to, v2)); 153 EXPECT_EQ(v1, Tween::ClampedFloatValueBetween(t_before, from, v1, to, v2));
154 EXPECT_EQ(16.0, Tween::ClampedFloatValueBetween(t_between, from, v1, to, v2)); 154 EXPECT_EQ(16.0, Tween::ClampedFloatValueBetween(t_between, from, v1, to, v2));
155 EXPECT_EQ(v2, Tween::ClampedFloatValueBetween(t_after, from, v1, to, v2)); 155 EXPECT_EQ(v2, Tween::ClampedFloatValueBetween(t_after, from, v1, to, v2));
156 } 156 }
157 157
158 TEST(TweenTest, SizeValueBetween) {
159 const gfx::SizeF s1(12.0f, 24.0f);
160 const gfx::SizeF s2(36.0f, 48.0f);
161
162 double before = -0.125;
163 double from = 0.0;
164 double between = 0.5;
165 double to = 1.0;
166 double after = 1.125;
167
168 EXPECT_SIZEF_EQ(gfx::SizeF(9.0f, 21.0f),
169 Tween::SizeValueBetween(before, s1, s2));
170 EXPECT_SIZEF_EQ(s1, Tween::SizeValueBetween(from, s1, s2));
171 EXPECT_SIZEF_EQ(gfx::SizeF(24.0f, 36.0f),
172 Tween::SizeValueBetween(between, s1, s2));
173 EXPECT_SIZEF_EQ(s2, Tween::SizeValueBetween(to, s1, s2));
174 EXPECT_SIZEF_EQ(gfx::SizeF(39.0f, 51.0f),
175 Tween::SizeValueBetween(after, s1, s2));
176 }
177
178 TEST(TweenTest, SizeValueBetweenClampedExtrapolation) {
179 const gfx::SizeF s1(0.0f, 0.0f);
180 const gfx::SizeF s2(36.0f, 48.0f);
181
182 double before = -1.0f;
183
184 // We should not extrapolate in this case as it would result in a negative and
185 // invalid size.
186 EXPECT_SIZEF_EQ(s1, Tween::SizeValueBetween(before, s1, s2));
187 }
188
158 } // namespace 189 } // namespace
159 } // namespace gfx 190 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/animation/tween.cc ('k') | ui/gfx/test/gfx_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698