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
3 // found in the LICENSE file.
5 #ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_
6 #define CC_TEST_GEOMETRY_TEST_UTILS_H_
14 // These are macros instead of functions so that we get useful line numbers
15 // where a test failed.
16 #define EXPECT_FLOAT_RECT_EQ(expected, actual) \
18 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
19 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
20 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \
21 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \
24 #define EXPECT_RECT_NEAR(expected, actual, abs_error) \
26 EXPECT_NEAR((expected).x(), (actual).x(), (abs_error)); \
27 EXPECT_NEAR((expected).y(), (actual).y(), (abs_error)); \
28 EXPECT_NEAR((expected).width(), (actual).width(), (abs_error)); \
29 EXPECT_NEAR((expected).height(), (actual).height(), (abs_error)); \
32 #define EXPECT_RECT_EQ(expected, actual) \
34 EXPECT_EQ((expected).x(), (actual).x()); \
35 EXPECT_EQ((expected).y(), (actual).y()); \
36 EXPECT_EQ((expected).width(), (actual).width()); \
37 EXPECT_EQ((expected).height(), (actual).height()); \
40 #define EXPECT_SIZE_EQ(expected, actual) \
42 EXPECT_EQ((expected).width(), (actual).width()); \
43 EXPECT_EQ((expected).height(), (actual).height()); \
46 #define EXPECT_POINT_EQ(expected, actual) \
48 EXPECT_EQ((expected).x(), (actual).x()); \
49 EXPECT_EQ((expected).y(), (actual).y()); \
52 #define EXPECT_POINT3F_EQ(expected, actual) \
54 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
55 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
56 EXPECT_FLOAT_EQ((expected).z(), (actual).z()); \
59 #define EXPECT_VECTOR_EQ(expected, actual) \
61 EXPECT_EQ((expected).x(), (actual).x()); \
62 EXPECT_EQ((expected).y(), (actual).y()); \
65 #define EXPECT_VECTOR2DF_EQ(expected, actual) \
67 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
68 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
71 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \
73 for (int i = 0; i < count; i++) { \
74 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \
78 // 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
80 // problem exists with both gcc and clang, and bugs have been filed at
81 // http://llvm.org/bugs/show_bug.cgi?id=13651
82 // and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337
83 void ExpectTransformationMatrixEq(const gfx::Transform
& expected
,
84 const gfx::Transform
& actual
);
86 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \
89 ExpectTransformationMatrixEq(expected, actual); \
92 // Should be used in test code only, for convenience. Production code should use
93 // the gfx::Transform::GetInverse() API.
94 gfx::Transform
Inverse(const gfx::Transform
& transform
);
98 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_