OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/transform_util.h" | 5 #include "ui/gfx/transform_util.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
9 #include "ui/gfx/geometry/point3_f.h" | 9 #include "ui/gfx/geometry/point3_f.h" |
10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 point = Point(0, 0); | 186 point = Point(0, 0); |
187 transform.TransformPoint(&point); | 187 transform.TransformPoint(&point); |
188 EXPECT_EQ(Point(-14, -24).ToString(), point.ToString()); | 188 EXPECT_EQ(Point(-14, -24).ToString(), point.ToString()); |
189 | 189 |
190 point = Point(1, 1); | 190 point = Point(1, 1); |
191 transform.TransformPoint(&point); | 191 transform.TransformPoint(&point); |
192 EXPECT_EQ(Point(-11, -20).ToString(), point.ToString()); | 192 EXPECT_EQ(Point(-11, -20).ToString(), point.ToString()); |
193 } | 193 } |
194 | 194 |
195 TEST(TransformUtilTest, MatrixDistance) { | |
196 Transform a; | |
197 Transform b(0, 1, 1, 1, | |
198 1, 0, 1, 1, | |
199 1, 1, 0, 1, | |
200 1, 1, 1, 0); | |
201 // Each entry in |a| should be 1 away from the corresponding entry in |b|. | |
202 // This means the matrix distance should be sqrt(num_entries) = 4. | |
203 EXPECT_EQ(4, MatrixDistance(a, b)); | |
204 | |
205 Transform c = b; | |
206 EXPECT_EQ(0, MatrixDistance(b, c)); | |
207 } | |
208 | |
209 } // namespace | 195 } // namespace |
210 } // namespace gfx | 196 } // namespace gfx |
OLD | NEW |