Chromium Code Reviews| 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..e9c74f8ca1320acc1a31a3afeba4a2aa9ba4dacb 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(String("degenerate"), zeros.toString()); |
|
jbroman
2016/08/21 16:21:07
nit: You shouldn't need to wrap the expected resul
|
| + EXPECT_EQ(String("[0,0,0,0,\n0,0,0,0,\n0,0,0,0,\n0,0,0,0]"), zeros.toString(true)); |
| + |
| + TransformationMatrix identity; |
| + EXPECT_EQ(String("identity"), identity.toString()); |
| + EXPECT_EQ(String("[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(String("translation(3,5,7)"), translation.toString()); |
| + EXPECT_EQ(String("[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(String("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(String("[-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(String("[1,2,3,4,\n1,2,3,4,\n1,0,3,4,\n6,7,8,9]"), columnMajorConstructor.toString(true)); |
| +} |
| + |
| } // namespace blink |