| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // then close them in TearDown before calling CocoaTest::TearDown. | 74 // then close them in TearDown before calling CocoaTest::TearDown. |
| 75 virtual void TearDown(); | 75 virtual void TearDown(); |
| 76 | 76 |
| 77 // Retuns a test window that can be used by views and other UI objects | 77 // Retuns a test window that can be used by views and other UI objects |
| 78 // as part of their tests. Is created lazily, and will be closed correctly | 78 // as part of their tests. Is created lazily, and will be closed correctly |
| 79 // in CocoaTest::TearDown. Note that it is a CocoaTestHelperWindow which | 79 // in CocoaTest::TearDown. Note that it is a CocoaTestHelperWindow which |
| 80 // has special handling for being Key. | 80 // has special handling for being Key. |
| 81 CocoaTestHelperWindow* test_window(); | 81 CocoaTestHelperWindow* test_window(); |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 // Return a vector of currently open windows. Note that it is a vector | 84 // Return a set of currently open windows. Avoiding NSArray so |
| 85 // instead of an NSArray because we don't want any retains placed on the | 85 // contents aren't retained, the pointer values can only be used for |
| 86 // windows in it and that the windows in this list may no longer be valid | 86 // comparison purposes. Using std::set to make progress-checking |
| 87 // NSWindows any time after this returns. You can only use the pointer values | 87 // convenient. |
| 88 // in the vector for comparison purposes. | 88 static std::set<NSWindow*> ApplicationWindows(); |
| 89 static std::vector<NSWindow*> ApplicationWindows(); | 89 |
| 90 // Return a set of windows which are in |ApplicationWindows()| but |
| 91 // not |initial_windows_|. |
| 92 std::set<NSWindow*> WindowsLeft(); |
| 90 | 93 |
| 91 bool called_tear_down_; | 94 bool called_tear_down_; |
| 92 base::ScopedNSAutoreleasePool pool_; | 95 base::ScopedNSAutoreleasePool pool_; |
| 93 std::vector<NSWindow*> initial_windows_; | 96 |
| 97 // Windows which existed at the beginning of the test. |
| 98 std::set<NSWindow*> initial_windows_; |
| 99 |
| 94 // Strong. Lazily created. This isn't wrapped in a scoped_nsobject because | 100 // Strong. Lazily created. This isn't wrapped in a scoped_nsobject because |
| 95 // we want to call [close] to destroy it rather than calling [release]. We | 101 // we want to call [close] to destroy it rather than calling [release]. We |
| 96 // want to verify that [close] is actually removing our window and that it's | 102 // want to verify that [close] is actually removing our window and that it's |
| 97 // not hanging around because releaseWhenClosed was set to "no" on the window. | 103 // not hanging around because releaseWhenClosed was set to "no" on the window. |
| 98 // It isn't wrapped in a different wrapper class to close it because we | 104 // It isn't wrapped in a different wrapper class to close it because we |
| 99 // need to close it at a very specific time; just before we enter our clean | 105 // need to close it at a very specific time; just before we enter our clean |
| 100 // up loop in TearDown. | 106 // up loop in TearDown. |
| 101 CocoaTestHelperWindow* test_window_; | 107 CocoaTestHelperWindow* test_window_; |
| 102 }; | 108 }; |
| 103 | 109 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void clearFirstResponder() { | 182 void clearFirstResponder() { |
| 177 [window_ setPretendIsKeyWindow:NO]; | 183 [window_ setPretendIsKeyWindow:NO]; |
| 178 [window_ makeFirstResponder:nil]; | 184 [window_ makeFirstResponder:nil]; |
| 179 } | 185 } |
| 180 | 186 |
| 181 private: | 187 private: |
| 182 scoped_nsobject<CocoaTestHelperWindow> window_; | 188 scoped_nsobject<CocoaTestHelperWindow> window_; |
| 183 }; | 189 }; |
| 184 | 190 |
| 185 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ | 191 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ |
| OLD | NEW |