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..2d9ac044ceb1b7e8339bdd3f6b2080bc29964665 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,43 @@ TEST(TransformUtilTest, GetScaleTransform) { |
} |
} |
+TEST(TransformUtilTest, SnapRotation) { |
+ gfx::Transform transform; |
+ |
+ // Translation must be a multiple of scale or else the back mapping will not |
+ // be an integer. |
+ transform.Translate(20.0, -30.0); |
+ transform.Scale(2.0, 2.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; |
+ |
+ // Translation must be a multiple of scale or else the back mapping will not |
+ // be an integer. |
+ transform.Translate(102.0, -96.0); |
+ transform.Scale(2.0, 2.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."; |
+} |
Ian Vollick
2013/09/11 12:19:48
Please add tests for a viewport that's far away fr
avallee
2013/09/14 01:32:25
Done.
|
+ |
} // namespace |
} // namespace gfx |