Index: ui/gfx/transform_util_unittest.cc |
diff --git a/ui/gfx/transform_util_unittest.cc b/ui/gfx/transform_util_unittest.cc |
index 94195c29bb92f90641e8eecdfb87ae3bcb966b27..775d4426d8cf414e35922360713a100c07da34f5 100644 |
--- a/ui/gfx/transform_util_unittest.cc |
+++ b/ui/gfx/transform_util_unittest.cc |
@@ -6,6 +6,8 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/gfx/point.h" |
+#include "ui/gfx/point3_f.h" |
+#include "ui/gfx/rect_f.h" |
namespace gfx { |
namespace { |
@@ -30,5 +32,39 @@ TEST(TransformUtilTest, GetScaleTransform) { |
} |
} |
+TEST(TransformUtilTest, SnapRotation) { |
+ gfx::Transform transform; |
+ |
+ transform.Translate(103.0, -97.0); |
+ transform.Scale(2.0, 3.0); |
+ transform.RotateAboutZAxis(89.99); |
+ |
+ DecomposedTransform decomposed, result; |
+ |
+ DecomposeTransform(&decomposed, transform); |
+ |
+ RectF viewport(1920.0, 1200.0); |
+ bool snapped = SnapRotation(&result, decomposed, viewport); |
+ |
+ EXPECT_TRUE(snapped) << "Viewport should snap for this rotation."; |
+} |
+ |
+TEST(TransformUtilTest, NoSnapRotation) { |
+ gfx::Transform transform; |
+ |
+ transform.Translate(103.0, -97.0); |
+ transform.Scale(2.0, 3.0); |
+ transform.RotateAboutZAxis(89.9); |
+ |
+ DecomposedTransform decomposed, result; |
+ |
+ DecomposeTransform(&decomposed, transform); |
+ |
+ RectF viewport(1920.0, 1200.0); |
+ bool snapped = SnapRotation(&result, decomposed, viewport); |
+ |
+ EXPECT_FALSE(snapped) << "Viewport should not snap for this rotation."; |
+} |
+ |
} // namespace |
} // namespace gfx |