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 where a test failed.
15 #define EXPECT_FLOAT_RECT_EQ(expected, actual) \
17 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
18 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
19 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \
20 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \
23 #define EXPECT_RECT_EQ(expected, actual) \
25 EXPECT_EQ((expected).x(), (actual).x()); \
26 EXPECT_EQ((expected).y(), (actual).y()); \
27 EXPECT_EQ((expected).width(), (actual).width()); \
28 EXPECT_EQ((expected).height(), (actual).height()); \
31 #define EXPECT_SIZE_EQ(expected, actual) \
33 EXPECT_EQ((expected).width(), (actual).width()); \
34 EXPECT_EQ((expected).height(), (actual).height()); \
37 #define EXPECT_POINT_EQ(expected, actual) \
39 EXPECT_EQ((expected).x(), (actual).x()); \
40 EXPECT_EQ((expected).y(), (actual).y()); \
43 #define EXPECT_POINT3F_EQ(expected, actual) \
45 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
46 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
47 EXPECT_FLOAT_EQ((expected).z(), (actual).z()); \
50 #define EXPECT_VECTOR_EQ(expected, actual) \
52 EXPECT_EQ((expected).x(), (actual).x()); \
53 EXPECT_EQ((expected).y(), (actual).y()); \
56 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \
58 for (int i = 0; i < count; i++) {\
59 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \
63 // This is a function rather than a macro because when this is included as a macro
64 // in bulk, it causes a significant slow-down in compilation time. This problem
65 // exists with both gcc and clang, and bugs have been filed at
66 // http://llvm.org/bugs/show_bug.cgi?id=13651 and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337
67 void ExpectTransformationMatrixEq(const gfx::Transform
& expected
,
68 const gfx::Transform
& actual
);
70 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \
73 cc::ExpectTransformationMatrixEq(expected, actual); \
76 // Should be used in test code only, for convenience. Production code should use
77 // the gfx::Transform::GetInverse() API.
78 gfx::Transform
inverse(const gfx::Transform
& transform
);
82 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_