Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/transforms/TransformationMatrix.h" | 5 #include "platform/transforms/TransformationMatrix.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "wtf/text/WTFString.h" | |
| 8 | 9 |
| 9 namespace blink { | 10 namespace blink { |
| 10 | 11 |
| 11 TEST(TransformationMatrixTest, NonInvertableBlendTest) | 12 TEST(TransformationMatrixTest, NonInvertableBlendTest) |
| 12 { | 13 { |
| 13 TransformationMatrix from; | 14 TransformationMatrix from; |
| 14 TransformationMatrix to(2.7133590938, 0.0, 0.0, 0.0, 0.0, 2.4645137761, 0.0, 0.0, 0.0, 0.0, 0.00, 0.01, 0.02, 0.03, 0.04, 0.05); | 15 TransformationMatrix to(2.7133590938, 0.0, 0.0, 0.0, 0.0, 2.4645137761, 0.0, 0.0, 0.0, 0.0, 0.00, 0.01, 0.02, 0.03, 0.04, 0.05); |
| 15 TransformationMatrix result; | 16 TransformationMatrix result; |
| 16 | 17 |
| 17 result = to; | 18 result = to; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 | 92 |
| 92 TransformationMatrix expectedAtimesB(34, 34, 34, 34, 30, 30, 30, 30, | 93 TransformationMatrix expectedAtimesB(34, 34, 34, 34, 30, 30, 30, 30, |
| 93 30, 30, 30, 30, 30, 30, 30, 30); | 94 30, 30, 30, 30, 30, 30, 30, 30); |
| 94 | 95 |
| 95 EXPECT_EQ(expectedAtimesB, a * b); | 96 EXPECT_EQ(expectedAtimesB, a * b); |
| 96 | 97 |
| 97 a.multiply(b); | 98 a.multiply(b); |
| 98 EXPECT_EQ(expectedAtimesB, a); | 99 EXPECT_EQ(expectedAtimesB, a); |
| 99 } | 100 } |
| 100 | 101 |
| 102 TEST(TransformationMatrixTest, ToString) | |
| 103 { | |
| 104 TransformationMatrix zeros(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 105 EXPECT_EQ(String("degenerate"), zeros.toString()); | |
|
jbroman
2016/08/21 16:21:07
nit: You shouldn't need to wrap the expected resul
| |
| 106 EXPECT_EQ(String("[0,0,0,0,\n0,0,0,0,\n0,0,0,0,\n0,0,0,0]"), zeros.toString( true)); | |
| 107 | |
| 108 TransformationMatrix identity; | |
| 109 EXPECT_EQ(String("identity"), identity.toString()); | |
| 110 EXPECT_EQ(String("[1,0,0,0,\n0,1,0,0,\n0,0,1,0,\n0,0,0,1]"), identity.toStri ng(true)); | |
| 111 | |
| 112 TransformationMatrix translation; | |
| 113 translation.translate3d(3, 5, 7); | |
| 114 EXPECT_EQ(String("translation(3,5,7)"), translation.toString()); | |
| 115 EXPECT_EQ(String("[1,0,0,3,\n0,1,0,5,\n0,0,1,7,\n0,0,0,1]"), translation.toS tring(true)); | |
| 116 | |
| 117 TransformationMatrix rotation; | |
| 118 rotation.rotate(180); | |
| 119 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()); | |
| 120 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)); | |
| 121 | |
| 122 TransformationMatrix columnMajorConstructor(1, 1, 1, 6, 2, 2, 0, 7, 3, 3, 3, 8, 4, 4, 4, 9); | |
| 123 // [ 1 2 3 4 ] | |
| 124 // [ 1 2 3 4 ] | |
| 125 // [ 1 0 3 4 ] | |
| 126 // [ 6 7 8 9 ] | |
| 127 EXPECT_EQ(String("[1,2,3,4,\n1,2,3,4,\n1,0,3,4,\n6,7,8,9]"), columnMajorCons tructor.toString(true)); | |
| 128 } | |
| 129 | |
| 101 } // namespace blink | 130 } // namespace blink |
| OLD | NEW |