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

Side by Side Diff: ui/gfx/vector3d_unittest.cc

Issue 11361186: ui: Add methods to clamp Sizes, Points, and Vectors from above or below. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: varnames Created 8 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 | Annotate | Revision Log
« ui/gfx/vector3d_f.h ('K') | « ui/gfx/vector3d_f.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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/gfx/vector3d_f.h" 7 #include "ui/gfx/vector3d_f.h"
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 { Vector3dF(0, -1, 1), Vector3dF(1, 0, 0), Vector3dF(1, 1, 1) } 205 { Vector3dF(0, -1, 1), Vector3dF(1, 0, 0), Vector3dF(1, 1, 1) }
206 }; 206 };
207 207
208 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 208 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
209 Vector3dF actual = gfx::CrossProduct(tests[i].input1, tests[i].input2); 209 Vector3dF actual = gfx::CrossProduct(tests[i].input1, tests[i].input2);
210 EXPECT_EQ(tests[i].expected.ToString(), actual.ToString()); 210 EXPECT_EQ(tests[i].expected.ToString(), actual.ToString());
211 } 211 }
212 212
213 } 213 }
214 214
215 TEST(Vector3dFTest, ClampVector3dF) {
216 Vector3dF a;
217
218 a = Vector3dF(3.5f, 5.5f, 7.5f);
219 EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString());
220 a.ClampToMin(Vector3dF(2, 4.5f, 6.5f));
221 EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString());
222 a.ClampToMin(Vector3dF(3.5f, 5.5f, 7.5f));
223 EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString());
224 a.ClampToMin(Vector3dF(4.5f, 2, 6.5f));
225 EXPECT_EQ(Vector3dF(4.5f, 5.5f, 7.5f).ToString(), a.ToString());
226 a.ClampToMin(Vector3dF(3.5f, 6.5f, 6.5f));
227 EXPECT_EQ(Vector3dF(4.5f, 6.5f, 7.5f).ToString(), a.ToString());
228 a.ClampToMin(Vector3dF(3.5f, 5.5f, 8.5f));
229 EXPECT_EQ(Vector3dF(4.5f, 6.5f, 8.5f).ToString(), a.ToString());
230 a.ClampToMin(Vector3dF(8.5f, 10.5f, 12.5f));
231 EXPECT_EQ(Vector3dF(8.5f, 10.5f, 12.5f).ToString(), a.ToString());
232
233 a.ClampToMax(Vector3dF(9.5f, 11.5f, 13.5f));
234 EXPECT_EQ(Vector3dF(8.5f, 10.5f, 12.5f).ToString(), a.ToString());
235 a.ClampToMax(Vector3dF(8.5f, 10.5f, 12.5f));
236 EXPECT_EQ(Vector3dF(8.5f, 10.5f, 12.5f).ToString(), a.ToString());
237 a.ClampToMax(Vector3dF(7.5f, 11.5f, 13.5f));
238 EXPECT_EQ(Vector3dF(7.5f, 10.5f, 12.5f).ToString(), a.ToString());
239 a.ClampToMax(Vector3dF(9.5f, 9.5f, 13.5f));
240 EXPECT_EQ(Vector3dF(7.5f, 9.5f, 12.5f).ToString(), a.ToString());
241 a.ClampToMax(Vector3dF(9.5f, 11.5f, 11.5f));
242 EXPECT_EQ(Vector3dF(7.5f, 9.5f, 11.5f).ToString(), a.ToString());
243 a.ClampToMax(Vector3dF(3.5f, 5.5f, 7.5f));
244 EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString());
245 }
246
215 } // namespace gfx 247 } // namespace gfx
OLDNEW
« ui/gfx/vector3d_f.h ('K') | « ui/gfx/vector3d_f.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698