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

Unified Diff: third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp

Issue 2265453003: Add platform/transforms pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update per reviewer comments Created 4 years, 4 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 | « third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp
diff --git a/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp b/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp
index 92926e16ede702eff0b6ac5a85e75438baf1f4d6..28a9f991a54e7c66bf5ea3f8bd612d03a1e60c4a 100644
--- a/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp
+++ b/third_party/WebKit/Source/platform/transforms/TransformationMatrixTest.cpp
@@ -5,6 +5,7 @@
#include "platform/transforms/TransformationMatrix.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "wtf/text/WTFString.h"
namespace blink {
@@ -98,4 +99,32 @@ TEST(TransformationMatrixTest, Multiplication)
EXPECT_EQ(expectedAtimesB, a);
}
+TEST(TransformationMatrixTest, ToString)
+{
+ TransformationMatrix zeros(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ EXPECT_EQ("[0,0,0,0,\n0,0,0,0,\n0,0,0,0,\n0,0,0,0] (degenerate)", zeros.toString());
+ EXPECT_EQ("[0,0,0,0,\n0,0,0,0,\n0,0,0,0,\n0,0,0,0]", zeros.toString(true));
+
+ TransformationMatrix identity;
+ EXPECT_EQ("identity", identity.toString());
+ EXPECT_EQ("[1,0,0,0,\n0,1,0,0,\n0,0,1,0,\n0,0,0,1]", identity.toString(true));
+
+ TransformationMatrix translation;
+ translation.translate3d(3, 5, 7);
+ EXPECT_EQ("translation(3,5,7)", translation.toString());
+ EXPECT_EQ("[1,0,0,3,\n0,1,0,5,\n0,0,1,7,\n0,0,0,1]", translation.toString(true));
+
+ TransformationMatrix rotation;
+ rotation.rotate(180);
+ EXPECT_EQ("translation(0,0,0), scale(1,1,1), skew(0,0,0), quaternion(0,0,1,-6.12323e-17), perspective(0,0,0,1)", rotation.toString());
+ EXPECT_EQ("[-1,-1.22465e-16,0,0,\n1.22465e-16,-1,0,0,\n0,0,1,0,\n0,0,0,1]", rotation.toString(true));
+
+ TransformationMatrix columnMajorConstructor(1, 1, 1, 6, 2, 2, 0, 7, 3, 3, 3, 8, 4, 4, 4, 9);
+ // [ 1 2 3 4 ]
+ // [ 1 2 3 4 ]
+ // [ 1 0 3 4 ]
+ // [ 6 7 8 9 ]
+ EXPECT_EQ("[1,2,3,4,\n1,2,3,4,\n1,0,3,4,\n6,7,8,9]", columnMajorConstructor.toString(true));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698