Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: cc/test/geometry_test_utils.h

Issue 2966793002: NOT FOR REVIEW - convert to cc animation
Patch Set: switch to transform operations Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/animation_timelines_test_common.h ('k') | cc/test/geometry_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "cc/cc_export.h"
9
8 namespace gfx { 10 namespace gfx {
9 class Transform; 11 class Transform;
10 } 12 }
11 13
12 namespace cc { 14 namespace cc {
13 15
14 // These are macros instead of functions so that we get useful line numbers 16 // These are macros instead of functions so that we get useful line numbers
15 // where a test failed. 17 // where a test failed.
16 #define EXPECT_FLOAT_RECT_EQ(expected, actual) \ 18 #define EXPECT_FLOAT_RECT_EQ(expected, actual) \
17 do { \ 19 do { \
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ 58 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
57 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ 59 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
58 } while (false) 60 } while (false)
59 61
60 #define EXPECT_VECTOR2DF_NEAR(expected, actual, abs_error) \ 62 #define EXPECT_VECTOR2DF_NEAR(expected, actual, abs_error) \
61 do { \ 63 do { \
62 EXPECT_NEAR((expected).x(), (actual).x(), (abs_error)); \ 64 EXPECT_NEAR((expected).x(), (actual).x(), (abs_error)); \
63 EXPECT_NEAR((expected).y(), (actual).y(), (abs_error)); \ 65 EXPECT_NEAR((expected).y(), (actual).y(), (abs_error)); \
64 } while (false) 66 } while (false)
65 67
68 #define EXPECT_VECTOR3DF_EQ(expected, actual) \
69 do { \
70 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \
71 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
72 EXPECT_FLOAT_EQ((expected).z(), (actual).z()); \
73 } while (false)
74
75 #define EXPECT_VECTOR3DF_NEAR(expected, actual, abs_error) \
76 do { \
77 EXPECT_NEAR((expected).x(), (actual).x(), (abs_error)); \
78 EXPECT_NEAR((expected).y(), (actual).y(), (abs_error)); \
79 EXPECT_NEAR((expected).z(), (actual).z(), (abs_error)); \
80 } while (false)
81
66 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \ 82 #define EXPECT_FLOAT_ARRAY_EQ(expected, actual, count) \
67 do { \ 83 do { \
68 for (int i = 0; i < count; i++) { \ 84 for (int i = 0; i < count; i++) { \
69 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \ 85 EXPECT_FLOAT_EQ((expected)[i], (actual)[i]); \
70 } \ 86 } \
71 } while (false) 87 } while (false)
72 88
73 #define EXPECT_FLOAT_SIZE_EQ(expected, actual) \ 89 #define EXPECT_FLOAT_SIZE_EQ(expected, actual) \
74 do { \ 90 do { \
75 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ 91 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \
76 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ 92 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \
77 } while (false) 93 } while (false)
78 94
79 #define EXPECT_SIZE_EQ(expected, actual) \ 95 #define EXPECT_SIZE_EQ(expected, actual) \
80 do { \ 96 do { \
81 EXPECT_EQ((expected).width(), (actual).width()); \ 97 EXPECT_EQ((expected).width(), (actual).width()); \
82 EXPECT_EQ((expected).height(), (actual).height()); \ 98 EXPECT_EQ((expected).height(), (actual).height()); \
83 } while (false) 99 } while (false)
84 100
85 // This is a function rather than a macro because when this is included as a 101 // This is a function rather than a macro because when this is included as a
86 // macro in bulk, it causes a significant slow-down in compilation time. This 102 // macro in bulk, it causes a significant slow-down in compilation time. This
87 // problem exists with both gcc and clang, and bugs have been filed at 103 // problem exists with both gcc and clang, and bugs have been filed at
88 // http://llvm.org/bugs/show_bug.cgi?id=13651 104 // http://llvm.org/bugs/show_bug.cgi?id=13651
89 // and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337 105 // and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54337
90 void ExpectTransformationMatrixEq(const gfx::Transform& expected, 106 void CC_EXPORT ExpectTransformationMatrixEq(const gfx::Transform& expected,
91 const gfx::Transform& actual); 107 const gfx::Transform& actual);
92 108
93 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ 109 #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \
94 do { \ 110 do { \
95 SCOPED_TRACE(""); \ 111 SCOPED_TRACE(""); \
96 ExpectTransformationMatrixEq(expected, actual); \ 112 ExpectTransformationMatrixEq(expected, actual); \
97 } while (false) 113 } while (false)
98 114
115 void CC_EXPORT ExpectTransformationMatrixNear(const gfx::Transform& expected,
116 const gfx::Transform& actual,
117 float abs_error);
118
119 #define EXPECT_TRANSFORMATION_MATRIX_NEAR(expected, actual, abs_error) \
120 do { \
121 SCOPED_TRACE(""); \
122 ExpectTransformationMatrixNear(expected, actual, abs_error); \
123 } while (false)
124
99 // Should be used in test code only, for convenience. Production code should use 125 // Should be used in test code only, for convenience. Production code should use
100 // the gfx::Transform::GetInverse() API. 126 // the gfx::Transform::GetInverse() API.
101 gfx::Transform Inverse(const gfx::Transform& transform); 127 gfx::Transform Inverse(const gfx::Transform& transform);
102 128
103 } // namespace cc 129 } // namespace cc
104 130
105 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_ 131 #endif // CC_TEST_GEOMETRY_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « cc/test/animation_timelines_test_common.h ('k') | cc/test/geometry_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698