| 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 |
| 11 #import "base/chrome_application_mac.h" |
| 11 #include "base/debug_util.h" | 12 #include "base/debug_util.h" |
| 12 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 13 #include "base/mac_util.h" | 14 #include "base/mac_util.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #import "base/scoped_nsautorelease_pool.h" | 16 #import "base/scoped_nsautorelease_pool.h" |
| 16 #import "base/scoped_nsobject.h" | 17 #import "base/scoped_nsobject.h" |
| 17 #include "base/scoped_ptr.h" | 18 #include "base/scoped_ptr.h" |
| 18 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 19 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
| 20 | 21 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // testing::Test. | 132 // testing::Test. |
| 132 | 133 |
| 133 // Provides the Cocoa goodness without the extraneous window. | 134 // Provides the Cocoa goodness without the extraneous window. |
| 134 | 135 |
| 135 // DEPRECATED | 136 // DEPRECATED |
| 136 // TODO(dmaclach): remove as soon as I can get my other CLs in that get rid | 137 // TODO(dmaclach): remove as soon as I can get my other CLs in that get rid |
| 137 // of any dependencies on this. 10/30/09 at the latest. | 138 // of any dependencies on this. 10/30/09 at the latest. |
| 138 class CocoaNoWindowTestHelper { | 139 class CocoaNoWindowTestHelper { |
| 139 public: | 140 public: |
| 140 CocoaNoWindowTestHelper() { | 141 CocoaNoWindowTestHelper() { |
| 141 // Look in the framework bundle for resources. | 142 CocoaTest::BootstrapCocoa(); |
| 142 FilePath path; | |
| 143 PathService::Get(base::DIR_EXE, &path); | |
| 144 path = path.Append(chrome::kFrameworkName); | |
| 145 mac_util::SetOverrideAppBundlePath(path); | |
| 146 | |
| 147 // Bootstrap Cocoa. It's very unhappy without this. | |
| 148 [NSApplication sharedApplication]; | |
| 149 | 143 |
| 150 // Set the duration of AppKit-evaluated animations (such as frame changes) | 144 // Set the duration of AppKit-evaluated animations (such as frame changes) |
| 151 // to zero for testing purposes. That way they take effect immediately. | 145 // to zero for testing purposes. That way they take effect immediately. |
| 152 [[NSAnimationContext currentContext] setDuration:0.0]; | 146 [[NSAnimationContext currentContext] setDuration:0.0]; |
| 153 } | 147 } |
| 154 }; | 148 }; |
| 155 | 149 |
| 156 // DEPRECATED | 150 // DEPRECATED |
| 157 // TODO(dmaclach): remove as soon as I can get my other CLs in that get rid | 151 // TODO(dmaclach): remove as soon as I can get my other CLs in that get rid |
| 158 // of any dependencies on this. 10/30/09 at the latest. | 152 // of any dependencies on this. 11/30/09 at the latest. |
| 159 class CocoaTestHelper : public CocoaNoWindowTestHelper { | 153 class CocoaTestHelper : public CocoaNoWindowTestHelper { |
| 160 public: | 154 public: |
| 161 CocoaTestHelper() { | 155 CocoaTestHelper() { |
| 162 window_.reset([[CocoaTestHelperWindow alloc] init]); | 156 window_.reset([[CocoaTestHelperWindow alloc] init]); |
| 163 if (DebugUtil::BeingDebugged()) { | 157 if (DebugUtil::BeingDebugged()) { |
| 164 [window_ orderFront:nil]; | 158 [window_ orderFront:nil]; |
| 165 } else { | 159 } else { |
| 166 [window_ orderBack:nil]; | 160 [window_ orderBack:nil]; |
| 167 } | 161 } |
| 168 } | 162 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 182 void clearFirstResponder() { | 176 void clearFirstResponder() { |
| 183 [window_ setPretendIsKeyWindow:NO]; | 177 [window_ setPretendIsKeyWindow:NO]; |
| 184 [window_ makeFirstResponder:nil]; | 178 [window_ makeFirstResponder:nil]; |
| 185 } | 179 } |
| 186 | 180 |
| 187 private: | 181 private: |
| 188 scoped_nsobject<CocoaTestHelperWindow> window_; | 182 scoped_nsobject<CocoaTestHelperWindow> window_; |
| 189 }; | 183 }; |
| 190 | 184 |
| 191 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ | 185 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER_H_ |
| OLD | NEW |