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> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #import "base/mac/scoped_nsautorelease_pool.h" | 13 #import "base/mac/scoped_nsautorelease_pool.h" |
14 #import "testing/gtest_mac.h" | |
danakj
2015/05/28 20:59:40
This is weird, no? Why not just include this at th
kkhorimoto
2015/05/30 00:29:49
Done.
| |
14 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
15 | 16 |
16 // Background windows normally will not display things such as focus | 17 // Background windows normally will not display things such as focus |
17 // rings. This class allows -isKeyWindow to be manipulated to test | 18 // rings. This class allows -isKeyWindow to be manipulated to test |
18 // such things. | 19 // such things. |
19 @interface CocoaTestHelperWindow : NSWindow { | 20 @interface CocoaTestHelperWindow : NSWindow { |
20 @private | 21 @private |
21 BOOL pretendIsKeyWindow_; | 22 BOOL pretendIsKeyWindow_; |
22 } | 23 } |
23 | 24 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 #else | 124 #else |
124 #define CGFLOAT_EPSILON FLT_EPSILON | 125 #define CGFLOAT_EPSILON FLT_EPSILON |
125 #endif | 126 #endif |
126 | 127 |
127 // A macro which which determines if two CGFloats are equal taking a | 128 // A macro which which determines if two CGFloats are equal taking a |
128 // proper epsilon into consideration. | 129 // proper epsilon into consideration. |
129 #define CGFLOAT_EQ(expected, actual) \ | 130 #define CGFLOAT_EQ(expected, actual) \ |
130 (actual >= (expected - CGFLOAT_EPSILON) && \ | 131 (actual >= (expected - CGFLOAT_EPSILON) && \ |
131 actual <= (expected + CGFLOAT_EPSILON)) | 132 actual <= (expected + CGFLOAT_EPSILON)) |
132 | 133 |
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 | 134 // A test support macro which compares two NSRects for equality taking |
139 // the float epsilon into consideration. | 135 // the float epsilon into consideration. |
140 #define EXPECT_NSRECT_EQ(expected, actual) \ | 136 #define EXPECT_NSRECT_EQ(expected, actual) \ |
141 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ | 137 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ |
142 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ | 138 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ |
143 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ | 139 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ |
144 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ | 140 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ |
145 "Rects do not match: " << \ | 141 "Rects do not match: " << \ |
146 [NSStringFromRect(expected) UTF8String] << \ | 142 [NSStringFromRect(expected) UTF8String] << \ |
147 " != " << [NSStringFromRect(actual) UTF8String] | 143 " != " << [NSStringFromRect(actual) UTF8String] |
148 | 144 |
149 #endif // UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ | 145 #endif // UI_GFX_TEST_UI_COCOA_TEST_HELPER_H_ |
OLD | NEW |