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

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

Issue 759063002: Move Screen Rotation from MaximizeModeController to ScreenOrientationController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Linux Compile Created 5 years, 11 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/geometry/vector3d_f.cc ('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 <cmath> 5 #include <cmath>
6 #include <limits> 6 #include <limits>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/geometry/vector3d_f.h" 10 #include "ui/gfx/geometry/vector3d_f.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 a.SetToMin(Vector3dF(7.5f, 11.5f, 13.5f)); 254 a.SetToMin(Vector3dF(7.5f, 11.5f, 13.5f));
255 EXPECT_EQ(Vector3dF(7.5f, 10.5f, 12.5f).ToString(), a.ToString()); 255 EXPECT_EQ(Vector3dF(7.5f, 10.5f, 12.5f).ToString(), a.ToString());
256 a.SetToMin(Vector3dF(9.5f, 9.5f, 13.5f)); 256 a.SetToMin(Vector3dF(9.5f, 9.5f, 13.5f));
257 EXPECT_EQ(Vector3dF(7.5f, 9.5f, 12.5f).ToString(), a.ToString()); 257 EXPECT_EQ(Vector3dF(7.5f, 9.5f, 12.5f).ToString(), a.ToString());
258 a.SetToMin(Vector3dF(9.5f, 11.5f, 11.5f)); 258 a.SetToMin(Vector3dF(9.5f, 11.5f, 11.5f));
259 EXPECT_EQ(Vector3dF(7.5f, 9.5f, 11.5f).ToString(), a.ToString()); 259 EXPECT_EQ(Vector3dF(7.5f, 9.5f, 11.5f).ToString(), a.ToString());
260 a.SetToMin(Vector3dF(3.5f, 5.5f, 7.5f)); 260 a.SetToMin(Vector3dF(3.5f, 5.5f, 7.5f));
261 EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString()); 261 EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString());
262 } 262 }
263 263
264 TEST(Vector3dTest, AngleBetweenVectorsInDegress) {
265 const struct {
266 float expected;
267 gfx::Vector3dF input1;
268 gfx::Vector3dF input2;
269 } tests[] = {
270 {0, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 1, 0)},
271 {90, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 0, 1)},
272 {45,
273 gfx::Vector3dF(0, 1, 0),
274 gfx::Vector3dF(0, 0.70710678188f, 0.70710678188f)},
275 {180, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, -1, 0)},
276 };
277
278 for (size_t i = 0; i < arraysize(tests); ++i) {
279 float actual =
280 gfx::AngleBetweenVectorsInDegrees(tests[i].input1, tests[i].input2);
281 EXPECT_FLOAT_EQ(tests[i].expected, actual);
282 actual =
283 gfx::AngleBetweenVectorsInDegrees(tests[i].input2, tests[i].input1);
284 EXPECT_FLOAT_EQ(tests[i].expected, actual);
285 }
286 }
287
288 TEST(Vector3dTest, ClockwiseAngleBetweenVectorsInDegress) {
289 const struct {
290 float expected;
291 gfx::Vector3dF input1;
292 gfx::Vector3dF input2;
293 } tests[] = {
294 {0, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 1, 0)},
295 {90, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 0, -1)},
296 {45,
297 gfx::Vector3dF(0, -1, 0),
298 gfx::Vector3dF(0, -0.70710678188f, 0.70710678188f)},
299 {180, gfx::Vector3dF(0, -1, 0), gfx::Vector3dF(0, 1, 0)},
300 {270, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 0, 1)},
301 };
302
303 const gfx::Vector3dF normal_vector(1.0f, 0.0f, 0.0f);
304
305 for (size_t i = 0; i < arraysize(tests); ++i) {
306 float actual = gfx::ClockwiseAngleBetweenVectorsInDegrees(
307 tests[i].input1, tests[i].input2, normal_vector);
308 EXPECT_FLOAT_EQ(tests[i].expected, actual);
309 actual = -gfx::ClockwiseAngleBetweenVectorsInDegrees(
310 tests[i].input2, tests[i].input1, normal_vector);
311 if (actual < 0.0f)
312 actual += 360.0f;
313 EXPECT_FLOAT_EQ(tests[i].expected, actual);
314 }
315 }
316
264 } // namespace gfx 317 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/vector3d_f.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698