| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ |
| 6 #define CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ | 6 #define CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| 11 #import "base/chrome_application_mac.h" | 11 #import "base/chrome_application_mac.h" |
| 12 #include "base/debug_util.h" | 12 #include "base/debug_util.h" |
| 13 #include "base/mac_util.h" | 13 #include "base/mac_util.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #import "base/scoped_nsautorelease_pool.h" | 15 #import "base/mac/scoped_nsautorelease_pool.h" |
| 16 #import "base/scoped_nsobject.h" | 16 #import "base/scoped_nsobject.h" |
| 17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 18 #include "testing/platform_test.h" | 18 #include "testing/platform_test.h" |
| 19 | 19 |
| 20 // Background windows normally will not display things such as focus | 20 // Background windows normally will not display things such as focus |
| 21 // rings. This class allows -isKeyWindow to be manipulated to test | 21 // rings. This class allows -isKeyWindow to be manipulated to test |
| 22 // such things. | 22 // such things. |
| 23 @interface CocoaTestHelperWindow : NSWindow { | 23 @interface CocoaTestHelperWindow : NSWindow { |
| 24 @private | 24 @private |
| 25 BOOL pretendIsKeyWindow_; | 25 BOOL pretendIsKeyWindow_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // contents aren't retained, the pointer values can only be used for | 83 // contents aren't retained, the pointer values can only be used for |
| 84 // comparison purposes. Using std::set to make progress-checking | 84 // comparison purposes. Using std::set to make progress-checking |
| 85 // convenient. | 85 // convenient. |
| 86 static std::set<NSWindow*> ApplicationWindows(); | 86 static std::set<NSWindow*> ApplicationWindows(); |
| 87 | 87 |
| 88 // Return a set of windows which are in |ApplicationWindows()| but | 88 // Return a set of windows which are in |ApplicationWindows()| but |
| 89 // not |initial_windows_|. | 89 // not |initial_windows_|. |
| 90 std::set<NSWindow*> WindowsLeft(); | 90 std::set<NSWindow*> WindowsLeft(); |
| 91 | 91 |
| 92 bool called_tear_down_; | 92 bool called_tear_down_; |
| 93 base::ScopedNSAutoreleasePool pool_; | 93 base::mac::ScopedNSAutoreleasePool pool_; |
| 94 | 94 |
| 95 // Windows which existed at the beginning of the test. | 95 // Windows which existed at the beginning of the test. |
| 96 std::set<NSWindow*> initial_windows_; | 96 std::set<NSWindow*> initial_windows_; |
| 97 | 97 |
| 98 // Strong. Lazily created. This isn't wrapped in a scoped_nsobject because | 98 // Strong. Lazily created. This isn't wrapped in a scoped_nsobject because |
| 99 // we want to call [close] to destroy it rather than calling [release]. We | 99 // we want to call [close] to destroy it rather than calling [release]. We |
| 100 // want to verify that [close] is actually removing our window and that it's | 100 // want to verify that [close] is actually removing our window and that it's |
| 101 // not hanging around because releaseWhenClosed was set to "no" on the window. | 101 // not hanging around because releaseWhenClosed was set to "no" on the window. |
| 102 // It isn't wrapped in a different wrapper class to close it because we | 102 // It isn't wrapped in a different wrapper class to close it because we |
| 103 // need to close it at a very specific time; just before we enter our clean | 103 // need to close it at a very specific time; just before we enter our clean |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 #define EXPECT_NSRECT_EQ(expected, actual) \ | 144 #define EXPECT_NSRECT_EQ(expected, actual) \ |
| 145 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ | 145 EXPECT_TRUE(CGFLOAT_EQ(expected.origin.x, actual.origin.x) && \ |
| 146 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ | 146 CGFLOAT_EQ(expected.origin.y, actual.origin.y) && \ |
| 147 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ | 147 CGFLOAT_EQ(expected.size.width, actual.size.width) && \ |
| 148 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ | 148 CGFLOAT_EQ(expected.size.height, actual.size.height)) << \ |
| 149 "Rects do not match: " << \ | 149 "Rects do not match: " << \ |
| 150 [NSStringFromRect(expected) UTF8String] << \ | 150 [NSStringFromRect(expected) UTF8String] << \ |
| 151 " != " << [NSStringFromRect(actual) UTF8String] | 151 " != " << [NSStringFromRect(actual) UTF8String] |
| 152 | 152 |
| 153 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ | 153 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ |
| OLD | NEW |