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. 4 5 #ifndef CC_TEST_GEOMETRY_TEST_UTILS_H_ 6 #define CC_TEST_GEOMETRY_TEST_UTILS_H_ 7 8 namespace gfx { 9 class Transform; 10 } 11 12 namespace cc { 13 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) \ 17 do { \ 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()); \ 22 } while (false) 23 24 #define EXPECT_RECT_EQ(expected, actual) \ 25 do { \ 26 EXPECT_EQ((expected).x(), (actual).x()); \ 27 EXPECT_EQ((expected).y(), (actual).y()); \ 28 EXPECT_EQ((expected).width(), (actual).width()); \ 29 EXPECT_EQ((expected).height(), (actual).height()); \ 30 } while (false) 31 32 #define EXPECT_SIZE_EQ(expected, actual) \ 33 do { \ 34 EXPECT_EQ((expected).width(), (actual).width()); \ 35 EXPECT_EQ((expected).height(), (actual).height()); \ 36 } while (false) 37 38 #define EXPECT_POINT_EQ(expected, actual) \ 39 do { \ 40 EXPECT_EQ((expected).x(), (actual).x()); \ 41 EXPECT_EQ((expected).y(), (actual).y()); \ 42 } while (false) 43 44 #define EXPECT_POINT3F_EQ(expected, actual) \ 45 do { \ 46 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ 47 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ 48 EXPECT_FLOAT_EQ((expected).z(), (actual).z()); \ 49 } while (false) 50 51 #define EXPECT_VECTOR_EQ(expected, actual) \ 52 do { \ 53 EXPECT_EQ((expected).x(), (actual).x()); \ 54 EXPECT_EQ((expected).y(), (actual).y()); \ 55 } while (false) 56 57 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \ 58 do { \ 59 for (int i = 0; i < count; i++) { \ 60 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \ 61 } \ 62 } while (false) 63 64 // This is a function rather than a macro because when this is included as a 65 // macro in bulk, it causes a significant slow-down in compilation time. This 66 // problem exists with both gcc and clang, and bugs have been filed at 67 // http://llvm.org/bugs/show_bug.cgi?id=13651 68 // and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337 69 void ExpectTransformationMatrixEq(const gfx::Transform& expected, 70 const gfx::Transform& actual); 71 72 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ 73 do { \ 74 SCOPED_TRACE(""); \ 75 cc::ExpectTransformationMatrixEq(expected, actual); \ 76 } while (false) 77 78 // Should be used in test code only, for convenience. Production code should use 79 // the gfx::Transform::GetInverse() API. 80 gfx::Transform Inverse(const gfx::Transform& transform); 81 82 } // namespace cc 83 84 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_ 85