| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac/foundation_util.h" |
| 7 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 9 #import "chrome/browser/app_controller_mac.h" | 10 #import "chrome/browser/app_controller_mac.h" |
| 10 #import "chrome/browser/chrome_browser_application_mac.h" | 11 #import "chrome/browser/chrome_browser_application_mac.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #import "chrome/browser/ui/cocoa/applescript/constants_applescript.h" | 13 #import "chrome/browser/ui/cocoa/applescript/constants_applescript.h" |
| 13 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h" | 14 #import "chrome/browser/ui/cocoa/applescript/error_applescript.h" |
| 14 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" | 15 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" |
| 15 #import "chrome/browser/ui/cocoa/applescript/window_applescript.h" | 16 #import "chrome/browser/ui/cocoa/applescript/window_applescript.h" |
| 16 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | 17 #include "chrome/browser/ui/cocoa/run_loop_testing.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 | 34 |
| 34 // Create a window with a |NULL profile|. | 35 // Create a window with a |NULL profile|. |
| 35 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithNoProfile) { | 36 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithNoProfile) { |
| 36 base::scoped_nsobject<WindowAppleScript> aWindow( | 37 base::scoped_nsobject<WindowAppleScript> aWindow( |
| 37 [[WindowAppleScript alloc] initWithProfile:NULL]); | 38 [[WindowAppleScript alloc] initWithProfile:NULL]); |
| 38 EXPECT_FALSE(aWindow.get()); | 39 EXPECT_FALSE(aWindow.get()); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // Create a window with a particular profile. | 42 // Create a window with a particular profile. |
| 42 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithProfile) { | 43 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithProfile) { |
| 43 Profile* lastProfile = [[NSApp delegate] lastProfile]; | 44 AppController* appController = |
| 45 base::mac::ObjCCastStrict<AppController>([NSApp delegate]); |
| 46 Profile* lastProfile = [appController lastProfile]; |
| 44 base::scoped_nsobject<WindowAppleScript> aWindow( | 47 base::scoped_nsobject<WindowAppleScript> aWindow( |
| 45 [[WindowAppleScript alloc] initWithProfile:lastProfile]); | 48 [[WindowAppleScript alloc] initWithProfile:lastProfile]); |
| 46 EXPECT_TRUE(aWindow.get()); | 49 EXPECT_TRUE(aWindow.get()); |
| 47 EXPECT_TRUE([aWindow.get() uniqueID]); | 50 EXPECT_TRUE([aWindow.get() uniqueID]); |
| 48 } | 51 } |
| 49 | 52 |
| 50 // Create a window with no |Browser*|. | 53 // Create a window with no |Browser*|. |
| 51 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithNoBrowser) { | 54 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, CreationWithNoBrowser) { |
| 52 base::scoped_nsobject<WindowAppleScript> aWindow( | 55 base::scoped_nsobject<WindowAppleScript> aWindow( |
| 53 [[WindowAppleScript alloc] initWithBrowser:NULL]); | 56 [[WindowAppleScript alloc] initWithBrowser:NULL]); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, WindowOrder) { | 174 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, WindowOrder) { |
| 172 base::scoped_nsobject<WindowAppleScript> window2( | 175 base::scoped_nsobject<WindowAppleScript> window2( |
| 173 [[WindowAppleScript alloc] initWithBrowser:browser()]); | 176 [[WindowAppleScript alloc] initWithBrowser:browser()]); |
| 174 base::scoped_nsobject<WindowAppleScript> window1( | 177 base::scoped_nsobject<WindowAppleScript> window1( |
| 175 [[WindowAppleScript alloc] init]); | 178 [[WindowAppleScript alloc] init]); |
| 176 chrome::testing::NSRunLoopRunAllPending(); | 179 chrome::testing::NSRunLoopRunAllPending(); |
| 177 EXPECT_EQ([window1.get() windowComparator:window2.get()], NSOrderedAscending); | 180 EXPECT_EQ([window1.get() windowComparator:window2.get()], NSOrderedAscending); |
| 178 EXPECT_EQ([window2.get() windowComparator:window1.get()], | 181 EXPECT_EQ([window2.get() windowComparator:window1.get()], |
| 179 NSOrderedDescending); | 182 NSOrderedDescending); |
| 180 } | 183 } |
| OLD | NEW |