OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 #ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_ | 5 #ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_ |
6 #define CC_TEST_GEOMETRY_TEST_UTILS_H_ | 6 #define CC_TEST_GEOMETRY_TEST_UTILS_H_ |
7 | 7 |
8 namespace gfx { | 8 namespace gfx { |
9 class Transform; | 9 class Transform; |
10 } | 10 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 EXPECT_EQ((expected).x(), (actual).x()); \ | 61 EXPECT_EQ((expected).x(), (actual).x()); \ |
62 EXPECT_EQ((expected).y(), (actual).y()); \ | 62 EXPECT_EQ((expected).y(), (actual).y()); \ |
63 } while (false) | 63 } while (false) |
64 | 64 |
65 #define EXPECT_VECTOR2DF_EQ(expected, actual) \ | 65 #define EXPECT_VECTOR2DF_EQ(expected, actual) \ |
66 do { \ | 66 do { \ |
67 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ | 67 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
68 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ | 68 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
69 } while (false) | 69 } while (false) |
70 | 70 |
| 71 #define EXPECT_VECTOR2DF_NEAR(expected, actual, abs_error) \ |
| 72 do { \ |
| 73 EXPECT_NEAR((expected).x(), (actual).x(), (abs_error)); \ |
| 74 EXPECT_NEAR((expected).y(), (actual).y(), (abs_error)); \ |
| 75 } while (false) |
| 76 |
71 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \ | 77 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \ |
72 do { \ | 78 do { \ |
73 for (int i = 0; i < count; i++) { \ | 79 for (int i = 0; i < count; i++) { \ |
74 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \ | 80 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \ |
75 } \ | 81 } \ |
76 } while (false) | 82 } while (false) |
77 | 83 |
78 // This is a function rather than a macro because when this is included as a | 84 // This is a function rather than a macro because when this is included as a |
79 // macro in bulk, it causes a significant slow-down in compilation time. This | 85 // macro in bulk, it causes a significant slow-down in compilation time. This |
80 // problem exists with both gcc and clang, and bugs have been filed at | 86 // problem exists with both gcc and clang, and bugs have been filed at |
81 // http://llvm.org/bugs/show_bug.cgi?id=13651 | 87 // http://llvm.org/bugs/show_bug.cgi?id=13651 |
82 // and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337 | 88 // and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337 |
83 void ExpectTransformationMatrixEq(const gfx::Transform& expected, | 89 void ExpectTransformationMatrixEq(const gfx::Transform& expected, |
84 const gfx::Transform& actual); | 90 const gfx::Transform& actual); |
85 | 91 |
86 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ | 92 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ |
87 do { \ | 93 do { \ |
88 SCOPED_TRACE(""); \ | 94 SCOPED_TRACE(""); \ |
89 ExpectTransformationMatrixEq(expected, actual); \ | 95 ExpectTransformationMatrixEq(expected, actual); \ |
90 } while (false) | 96 } while (false) |
91 | 97 |
92 // Should be used in test code only, for convenience. Production code should use | 98 // Should be used in test code only, for convenience. Production code should use |
93 // the gfx::Transform::GetInverse() API. | 99 // the gfx::Transform::GetInverse() API. |
94 gfx::Transform Inverse(const gfx::Transform& transform); | 100 gfx::Transform Inverse(const gfx::Transform& transform); |
95 | 101 |
96 } // namespace cc | 102 } // namespace cc |
97 | 103 |
98 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_ | 104 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_ |
OLD | NEW |