OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 UI_BASE_TEST_UI_COCOA_TEST_HELPER_H_ | 5 #ifndef UI_BASE_TEST_UI_COCOA_TEST_HELPER_H_ |
6 #define UI_BASE_TEST_UI_COCOA_TEST_HELPER_H_ | 6 #define UI_BASE_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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 CocoaTestHelperWindow* test_window_; | 99 CocoaTestHelperWindow* test_window_; |
100 }; | 100 }; |
101 | 101 |
102 } // namespace ui | 102 } // namespace ui |
103 | 103 |
104 // A macro defining a standard set of tests to run on a view. Since we can't | 104 // A macro defining a standard set of tests to run on a view. Since we can't |
105 // inherit tests, this macro saves us a lot of duplicate code. Handles simply | 105 // inherit tests, this macro saves us a lot of duplicate code. Handles simply |
106 // displaying the view to make sure it won't crash, as well as removing it | 106 // displaying the view to make sure it won't crash, as well as removing it |
107 // from a window. All tests that work with NSView subclasses and/or | 107 // from a window. All tests that work with NSView subclasses and/or |
108 // NSViewController subclasses should use it. | 108 // NSViewController subclasses should use it. |
109 #define TEST_VIEW(test_fixture, test_view) \ | 109 #define TEST_VIEW(test_fixture, test_view) \ |
110 TEST_F(test_fixture, test_fixture##_TestViewMacroAddRemove) { \ | 110 TEST_F(test_fixture, test_fixture##_TestViewMacroAddRemove) { \ |
111 scoped_nsobject<NSView> view([test_view retain]); \ | 111 base::scoped_nsobject<NSView> view([test_view retain]); \ |
112 EXPECT_EQ([test_window() contentView], [view superview]); \ | 112 EXPECT_EQ([test_window() contentView], [view superview]); \ |
113 [view removeFromSuperview]; \ | 113 [view removeFromSuperview]; \ |
114 EXPECT_FALSE([view superview]); \ | 114 EXPECT_FALSE([view superview]); \ |
115 } \ | 115 } \ |
116 TEST_F(test_fixture, test_fixture##_TestViewMacroDisplay) { \ | 116 TEST_F(test_fixture, test_fixture##_TestViewMacroDisplay) { \ |
117 [test_view display]; \ | 117 [test_view display]; \ |
118 } | 118 } |
119 | 119 |
120 // A macro which determines the proper float epsilon for a CGFloat. | 120 // A macro which determines the proper float epsilon for a CGFloat. |
121 #if CGFLOAT_IS_DOUBLE | 121 #if CGFLOAT_IS_DOUBLE |
122 #define CGFLOAT_EPSILON DBL_EPSILON | 122 #define CGFLOAT_EPSILON DBL_EPSILON |
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 |
(...skipping 12 matching lines...) Expand all Loading... |
140 #define EXPECT_NSRECT_EQ(expected, actual) \ | 140 #define EXPECT_NSRECT_EQ(expected, actual) \ |
141 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ | 141 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ |
142 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ | 142 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ |
143 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ | 143 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ |
144 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ | 144 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ |
145 "Rects do not match: " << \ | 145 "Rects do not match: " << \ |
146 [NSStringFromRect(expected) UTF8String] << \ | 146 [NSStringFromRect(expected) UTF8String] << \ |
147 " != " << [NSStringFromRect(actual) UTF8String] | 147 " != " << [NSStringFromRect(actual) UTF8String] |
148 | 148 |
149 #endif // UI_BASE_TEST_UI_COCOA_TEST_HELPER_H_ | 149 #endif // UI_BASE_TEST_UI_COCOA_TEST_HELPER_H_ |
OLD | NEW |