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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/geometry/vector3d_f.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/vector3d_unittest.cc
diff --git a/ui/gfx/geometry/vector3d_unittest.cc b/ui/gfx/geometry/vector3d_unittest.cc
index d058ad12224d70ba874ad46fb3e0a1fe2f685209..2a3a1a0c5d836503e0814c43dbb77e5d41952af7 100644
--- a/ui/gfx/geometry/vector3d_unittest.cc
+++ b/ui/gfx/geometry/vector3d_unittest.cc
@@ -261,4 +261,57 @@ TEST(Vector3dFTest, ClampVector3dF) {
EXPECT_EQ(Vector3dF(3.5f, 5.5f, 7.5f).ToString(), a.ToString());
}
+TEST(Vector3dTest, AngleBetweenVectorsInDegress) {
+ const struct {
+ float expected;
+ gfx::Vector3dF input1;
+ gfx::Vector3dF input2;
+ } tests[] = {
+ {0, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 1, 0)},
+ {90, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 0, 1)},
+ {45,
+ gfx::Vector3dF(0, 1, 0),
+ gfx::Vector3dF(0, 0.70710678188f, 0.70710678188f)},
+ {180, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, -1, 0)},
+ };
+
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ float actual =
+ gfx::AngleBetweenVectorsInDegrees(tests[i].input1, tests[i].input2);
+ EXPECT_FLOAT_EQ(tests[i].expected, actual);
+ actual =
+ gfx::AngleBetweenVectorsInDegrees(tests[i].input2, tests[i].input1);
+ EXPECT_FLOAT_EQ(tests[i].expected, actual);
+ }
+}
+
+TEST(Vector3dTest, ClockwiseAngleBetweenVectorsInDegress) {
+ const struct {
+ float expected;
+ gfx::Vector3dF input1;
+ gfx::Vector3dF input2;
+ } tests[] = {
+ {0, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 1, 0)},
+ {90, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 0, -1)},
+ {45,
+ gfx::Vector3dF(0, -1, 0),
+ gfx::Vector3dF(0, -0.70710678188f, 0.70710678188f)},
+ {180, gfx::Vector3dF(0, -1, 0), gfx::Vector3dF(0, 1, 0)},
+ {270, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, 0, 1)},
+ };
+
+ const gfx::Vector3dF normal_vector(1.0f, 0.0f, 0.0f);
+
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ float actual = gfx::ClockwiseAngleBetweenVectorsInDegrees(
+ tests[i].input1, tests[i].input2, normal_vector);
+ EXPECT_FLOAT_EQ(tests[i].expected, actual);
+ actual = -gfx::ClockwiseAngleBetweenVectorsInDegrees(
+ tests[i].input2, tests[i].input1, normal_vector);
+ if (actual < 0.0f)
+ actual += 360.0f;
+ EXPECT_FLOAT_EQ(tests[i].expected, actual);
+ }
+}
+
} // namespace gfx
« 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