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

Unified Diff: ui/gfx/transform_util_unittest.cc

Issue 11774005: Migrate more functions from MathUtil to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: ui/gfx/transform_util_unittest.cc
diff --git a/ui/gfx/transform_util_unittest.cc b/ui/gfx/transform_util_unittest.cc
index 3cc39027581e9ee01c62c5a47662d8c5febf48b5..9a045e65b9eb0c7c837246f2f16c89e6b71c1fd5 100644
--- a/ui/gfx/transform_util_unittest.cc
+++ b/ui/gfx/transform_util_unittest.cc
@@ -4,8 +4,9 @@
#include "ui/gfx/transform_util.h"
-#include "ui/gfx/point.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/test/transform_test_common.h"
namespace gfx {
namespace {
@@ -30,5 +31,54 @@ TEST(TransformUtilTest, GetScaleTransform) {
}
}
+TEST(TransformUtilTest, verifyFlattenTo2DTransform)
+{
+ Transform A;
+ InitializeTestMatrix(&A);
+
+ Transform B = CreateFlattenedTransform(A);
+
+ EXPECT_ROW1_EQ(10, 14, 0, 22, B);
+ EXPECT_ROW2_EQ(11, 15, 0, 23, B);
+ EXPECT_ROW3_EQ(0, 0, 1, 0, B);
+ EXPECT_ROW4_EQ(13, 17, 0, 25, B);
+
+ // CreateFlattenedTransform should not have changed the original matrix.
+ EXPECT_ROW1_EQ(10, 14, 18, 22, A);
+ EXPECT_ROW2_EQ(11, 15, 19, 23, A);
+ EXPECT_ROW3_EQ(12, 16, 20, 24, A);
+ EXPECT_ROW4_EQ(13, 17, 21, 25, A);
+
+ // This version of the flatten operation should modify the matrix in-place.
+ FlattenTransformTo2d(A);
+ EXPECT_ROW1_EQ(10, 14, 0, 22, A);
+ EXPECT_ROW2_EQ(11, 15, 0, 23, A);
+ EXPECT_ROW3_EQ(0, 0, 1, 0, A);
+ EXPECT_ROW4_EQ(13, 17, 0, 25, A);
+}
+
+TEST(TransformUtilTest, verifyCreateGfxTransformForAllElements)
+{
+ Transform transform = CreateGfxTransform(
+ 1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16);
+
+ EXPECT_ROW1_EQ(1, 5, 9, 13, transform);
+ EXPECT_ROW2_EQ(2, 6, 10, 14, transform);
+ EXPECT_ROW3_EQ(3, 7, 11, 15, transform);
+ EXPECT_ROW4_EQ(4, 8, 12, 16, transform);
+}
+
+TEST(TransformUtilTest, verifyCreateGfxTransformFor2dElements)
+{
+ Transform transform = CreateGfxTransform(1, 2, 3, 4, 5, 6);
+ EXPECT_ROW1_EQ(1, 3, 0, 5, transform);
+ EXPECT_ROW2_EQ(2, 4, 0, 6, transform);
+ EXPECT_ROW3_EQ(0, 0, 1, 0, transform);
+ EXPECT_ROW4_EQ(0, 0, 0, 1, transform);
+}
+
} // namespace
} // namespace gfx
« ui/gfx/transform_util.h ('K') | « ui/gfx/transform_util.cc ('k') | ui/ui_unittests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698