| 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 | |
| 138 // A test support macro which compares two NSRects for equality taking | 133 // A test support macro which compares two NSRects for equality taking |
| 139 // the float epsilon into consideration. | 134 // the float epsilon into consideration. |
| 140 #define EXPECT_NSRECT_EQ(expected, actual) \ | 135 #define EXPECT_NSRECT_EQ(expected, actual) \ |
| 141 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ | 136 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ |
| 142 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ | 137 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ |
| 143 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ | 138 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ |
| 144 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ | 139 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ |
| 145 "Rects do not match: " << \ | 140 "Rects do not match: " << \ |
| 146 [NSStringFromRect(expected) UTF8String] << \ | 141 [NSStringFromRect(expected) UTF8String] << \ |
| 147 " != " << [NSStringFromRect(actual) UTF8String] | 142 " != " << [NSStringFromRect(actual) UTF8String] |
| 148 | 143 |
| 149 #endif // UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ | 144 #endif // UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ |
| OLD | NEW |