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 WebKit { | 8 namespace WebKit { |
9 class WebTransformationMatrix; | 9 class WebTransformationMatrix; |
10 } | 10 } |
11 | 11 |
12 namespace WebKitTests { | 12 namespace WebKitTests { |
13 | 13 |
14 // These are macros instead of functions so that we get useful line numbers wher
e a test failed. | 14 // These are macros instead of functions so that we get useful line numbers wher
e a test failed. |
15 #define EXPECT_FLOAT_RECT_EQ(expected, actual) \ | 15 #define EXPECT_FLOAT_RECT_EQ(expected, actual) \ |
16 { \ | 16 do { \ |
17 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ | 17 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
18 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ | 18 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
19 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ | 19 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ |
20 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ | 20 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ |
21 } | 21 } while (false) |
22 | 22 |
23 #define EXPECT_RECT_EQ(expected, actual) \ | 23 #define EXPECT_RECT_EQ(expected, actual) \ |
24 { \ | 24 do { \ |
25 EXPECT_EQ((expected).x(), (actual).x()); \ | 25 EXPECT_EQ((expected).x(), (actual).x()); \ |
26 EXPECT_EQ((expected).y(), (actual).y()); \ | 26 EXPECT_EQ((expected).y(), (actual).y()); \ |
27 EXPECT_EQ((expected).width(), (actual).width()); \ | 27 EXPECT_EQ((expected).width(), (actual).width()); \ |
28 EXPECT_EQ((expected).height(), (actual).height()); \ | 28 EXPECT_EQ((expected).height(), (actual).height()); \ |
29 } | 29 } while (false) |
30 | 30 |
31 #define EXPECT_SIZE_EQ(expected, actual) \ | 31 #define EXPECT_SIZE_EQ(expected, actual) \ |
32 { \ | 32 do { \ |
33 EXPECT_EQ((expected).width(), (actual).width()); \ | 33 EXPECT_EQ((expected).width(), (actual).width()); \ |
34 EXPECT_EQ((expected).height(), (actual).height()); \ | 34 EXPECT_EQ((expected).height(), (actual).height()); \ |
35 } | 35 } while (false) |
36 | 36 |
37 #define EXPECT_POINT_EQ(expected, actual) \ | 37 #define EXPECT_POINT_EQ(expected, actual) \ |
38 { \ | 38 do { \ |
39 EXPECT_EQ((expected).x(), (actual).x()); \ | 39 EXPECT_EQ((expected).x(), (actual).x()); \ |
40 EXPECT_EQ((expected).y(), (actual).y()); \ | 40 EXPECT_EQ((expected).y(), (actual).y()); \ |
41 } | 41 } while (false) |
| 42 |
| 43 #define EXPECT_VECTOR_EQ(expected, actual) \ |
| 44 do { \ |
| 45 EXPECT_EQ((expected).x(), (actual).x()); \ |
| 46 EXPECT_EQ((expected).y(), (actual).y()); \ |
| 47 } while (false) |
42 | 48 |
43 // This is a function rather than a macro because when this is included as a mac
ro | 49 // This is a function rather than a macro because when this is included as a mac
ro |
44 // in bulk, it causes a significant slow-down in compilation time. This problem | 50 // in bulk, it causes a significant slow-down in compilation time. This problem |
45 // exists with both gcc and clang, and bugs have been filed at | 51 // exists with both gcc and clang, and bugs have been filed at |
46 // http://llvm.org/bugs/show_bug.cgi?id=13651 and http://gcc.gnu.org/bugzilla/sh
ow_bug.cgi?id=54337 | 52 // http://llvm.org/bugs/show_bug.cgi?id=13651 and http://gcc.gnu.org/bugzilla/sh
ow_bug.cgi?id=54337 |
47 void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expecte
d, | 53 void ExpectTransformationMatrixEq(const WebKit::WebTransformationMatrix& expecte
d, |
48 const WebKit::WebTransformationMatrix& actual)
; | 54 const WebKit::WebTransformationMatrix& actual)
; |
49 | 55 |
50 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ | 56 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ |
51 { \ | 57 { \ |
52 SCOPED_TRACE(""); \ | 58 SCOPED_TRACE(""); \ |
53 WebKitTests::ExpectTransformationMatrixEq(expected, actual); \ | 59 WebKitTests::ExpectTransformationMatrixEq(expected, actual); \ |
54 } | 60 } |
55 | 61 |
56 } // namespace WebKitTests | 62 } // namespace WebKitTests |
57 | 63 |
58 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_ | 64 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_ |
OLD | NEW |