| 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 | 5 #ifndef CHROME_BROWSER_COCOA_COCOA_TEST_HELPER |
| 6 #define CHROME_BROWSER_COCOA_COCOA_TEST_HELPER | 6 #define CHROME_BROWSER_COCOA_COCOA_TEST_HELPER |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/debug_util.h" |
| 10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 11 #include "base/mac_util.h" | 12 #include "base/mac_util.h" |
| 12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 13 #import "base/scoped_nsobject.h" | 14 #import "base/scoped_nsobject.h" |
| 14 #include "chrome/common/mac_app_names.h" | 15 #include "chrome/common/mac_app_names.h" |
| 15 | 16 |
| 16 // A class that initializes Cocoa and sets up resources for many of our | 17 // A class that initializes Cocoa and sets up resources for many of our |
| 17 // Cocoa controller unit tests. It does several key things: | 18 // Cocoa controller unit tests. It does several key things: |
| 18 // - Creates and displays an empty Cocoa window for views to live in | 19 // - Creates and displays an empty Cocoa window for views to live in |
| 19 // - Loads the appropriate bundle so nib loading works. When loading the | 20 // - Loads the appropriate bundle so nib loading works. When loading the |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 | 36 |
| 36 // Bootstrap Cocoa. It's very unhappy without this. | 37 // Bootstrap Cocoa. It's very unhappy without this. |
| 37 [NSApplication sharedApplication]; | 38 [NSApplication sharedApplication]; |
| 38 | 39 |
| 39 // Create a window. | 40 // Create a window. |
| 40 NSRect frame = NSMakeRect(0, 0, 800, 600); | 41 NSRect frame = NSMakeRect(0, 0, 800, 600); |
| 41 window_.reset([[NSWindow alloc] initWithContentRect:frame | 42 window_.reset([[NSWindow alloc] initWithContentRect:frame |
| 42 styleMask:0 | 43 styleMask:0 |
| 43 backing:NSBackingStoreBuffered | 44 backing:NSBackingStoreBuffered |
| 44 defer:NO]); | 45 defer:NO]); |
| 45 [window_ orderFront:nil]; | 46 if (DebugUtil::BeingDebugged()) { |
| 47 [window_ orderFront:nil]; |
| 48 } else { |
| 49 [window_ orderBack:nil]; |
| 50 } |
| 46 | 51 |
| 47 // Set the duration of AppKit-evaluated animations (such as frame changes) | 52 // Set the duration of AppKit-evaluated animations (such as frame changes) |
| 48 // to zero for testing purposes. That way they take effect immediately. | 53 // to zero for testing purposes. That way they take effect immediately. |
| 49 [[NSAnimationContext currentContext] setDuration:0.0]; | 54 [[NSAnimationContext currentContext] setDuration:0.0]; |
| 50 } | 55 } |
| 51 | 56 |
| 52 // Access the Cocoa window created for the test. | 57 // Access the Cocoa window created for the test. |
| 53 NSWindow* window() const { return window_.get(); } | 58 NSWindow* window() const { return window_.get(); } |
| 54 NSView* contentView() const { return [window_ contentView]; } | 59 NSView* contentView() const { return [window_ contentView]; } |
| 55 | 60 |
| 56 private: | 61 private: |
| 57 scoped_nsobject<NSWindow> window_; | 62 scoped_nsobject<NSWindow> window_; |
| 58 }; | 63 }; |
| 59 | 64 |
| 60 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER | 65 #endif // CHROME_BROWSER_COCOA_COCOA_TEST_HELPER |
| OLD | NEW |