OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ | 5 #ifndef UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ |
6 #define UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ | 6 #define UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 #else | 123 #else |
124 #define CGFLOAT_EPSILON FLT_EPSILON | 124 #define CGFLOAT_EPSILON FLT_EPSILON |
125 #endif | 125 #endif |
126 | 126 |
127 // A macro which which determines if two CGFloats are equal taking a | 127 // A macro which which determines if two CGFloats are equal taking a |
128 // proper epsilon into consideration. | 128 // proper epsilon into consideration. |
129 #define CGFLOAT_EQ(expected, actual) \ | 129 #define CGFLOAT_EQ(expected, actual) \ |
130 (actual >= (expected - CGFLOAT_EPSILON) && \ | 130 (actual >= (expected - CGFLOAT_EPSILON) && \ |
131 actual <= (expected + CGFLOAT_EPSILON)) | 131 actual <= (expected + CGFLOAT_EPSILON)) |
132 | 132 |
| 133 // A test support macro which ascertains if two CGFloats are equal. |
| 134 #define EXPECT_CGFLOAT_EQ(expected, actual) \ |
| 135 EXPECT_TRUE(CGFLOAT_EQ(expected, actual)) << \ |
| 136 expected << " != " << actual |
| 137 |
133 // A test support macro which compares two NSRects for equality taking | 138 // A test support macro which compares two NSRects for equality taking |
134 // the float epsilon into consideration. | 139 // the float epsilon into consideration. |
135 #define EXPECT_NSRECT_EQ(expected, actual) \ | 140 #define EXPECT_NSRECT_EQ(expected, actual) \ |
136 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ | 141 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ |
137 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ | 142 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ |
138 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ | 143 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ |
139 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ | 144 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ |
140 "Rects do not match: " << \ | 145 "Rects do not match: " << \ |
141 [NSStringFromRect(expected) UTF8String] << \ | 146 [NSStringFromRect(expected) UTF8String] << \ |
142 " != " << [NSStringFromRect(actual) UTF8String] | 147 " != " << [NSStringFromRect(actual) UTF8String] |
143 | 148 |
144 #endif // UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ | 149 #endif // UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ |
OLD | NEW |