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 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #import "chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.h" | 10 #import "chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Close the additional browsers. | 40 // Close the additional browsers. |
41 b1->tab_strip_model()->CloseAllTabs(); | 41 b1->tab_strip_model()->CloseAllTabs(); |
42 b2->tab_strip_model()->CloseAllTabs(); | 42 b2->tab_strip_model()->CloseAllTabs(); |
43 } | 43 } |
44 | 44 |
45 // Insert a new window. | 45 // Insert a new window. |
46 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, InsertWindow) { | 46 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, InsertWindow) { |
47 // Emulate what applescript would do when creating a new window. | 47 // Emulate what applescript would do when creating a new window. |
48 // Emulate a script like |set var to make new window with properties | 48 // Emulate a script like |set var to make new window with properties |
49 // {visible:false}|. | 49 // {visible:false}|. |
50 scoped_nsobject<WindowAppleScript> aWindow([[WindowAppleScript alloc] init]); | 50 base::scoped_nsobject<WindowAppleScript> aWindow( |
51 scoped_nsobject<NSNumber> var([[aWindow.get() uniqueID] copy]); | 51 [[WindowAppleScript alloc] init]); |
| 52 base::scoped_nsobject<NSNumber> var([[aWindow.get() uniqueID] copy]); |
52 [aWindow.get() setValue:[NSNumber numberWithBool:YES] forKey:@"isVisible"]; | 53 [aWindow.get() setValue:[NSNumber numberWithBool:YES] forKey:@"isVisible"]; |
53 | 54 |
54 [NSApp insertInAppleScriptWindows:aWindow.get()]; | 55 [NSApp insertInAppleScriptWindows:aWindow.get()]; |
55 | 56 |
56 // Represents the window after it is added. | 57 // Represents the window after it is added. |
57 WindowAppleScript* window = [[NSApp appleScriptWindows] objectAtIndex:0]; | 58 WindowAppleScript* window = [[NSApp appleScriptWindows] objectAtIndex:0]; |
58 EXPECT_NSEQ([NSNumber numberWithBool:YES], | 59 EXPECT_NSEQ([NSNumber numberWithBool:YES], |
59 [aWindow.get() valueForKey:@"isVisible"]); | 60 [aWindow.get() valueForKey:@"isVisible"]); |
60 EXPECT_EQ([window container], NSApp); | 61 EXPECT_EQ([window container], NSApp); |
61 EXPECT_NSEQ(AppleScript::kWindowsProperty, | 62 EXPECT_NSEQ(AppleScript::kWindowsProperty, |
62 [window containerProperty]); | 63 [window containerProperty]); |
63 EXPECT_NSEQ(var, [window uniqueID]); | 64 EXPECT_NSEQ(var, [window uniqueID]); |
64 } | 65 } |
65 | 66 |
66 // Inserting and deleting windows. | 67 // Inserting and deleting windows. |
67 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, | 68 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, |
68 InsertAndDeleteWindows) { | 69 InsertAndDeleteWindows) { |
69 scoped_nsobject<WindowAppleScript> aWindow; | 70 base::scoped_nsobject<WindowAppleScript> aWindow; |
70 int count; | 71 int count; |
71 // Create a bunch of windows. | 72 // Create a bunch of windows. |
72 for (int i = 0; i < 5; ++i) { | 73 for (int i = 0; i < 5; ++i) { |
73 for (int j = 0; j < 3; ++j) { | 74 for (int j = 0; j < 3; ++j) { |
74 aWindow.reset([[WindowAppleScript alloc] init]); | 75 aWindow.reset([[WindowAppleScript alloc] init]); |
75 [NSApp insertInAppleScriptWindows:aWindow.get()]; | 76 [NSApp insertInAppleScriptWindows:aWindow.get()]; |
76 } | 77 } |
77 count = 3 * i + 4; | 78 count = 3 * i + 4; |
78 EXPECT_EQ(count, (int)[[NSApp appleScriptWindows] count]); | 79 EXPECT_EQ(count, (int)[[NSApp appleScriptWindows] count]); |
79 } | 80 } |
(...skipping 25 matching lines...) Expand all Loading... |
105 for (BookmarkFolderAppleScript* bookmarkFolder in bookmarkFolders) { | 106 for (BookmarkFolderAppleScript* bookmarkFolder in bookmarkFolders) { |
106 EXPECT_EQ(NSApp, | 107 EXPECT_EQ(NSApp, |
107 [bookmarkFolder container]); | 108 [bookmarkFolder container]); |
108 EXPECT_NSEQ(AppleScript::kBookmarkFoldersProperty, | 109 EXPECT_NSEQ(AppleScript::kBookmarkFoldersProperty, |
109 [bookmarkFolder containerProperty]); | 110 [bookmarkFolder containerProperty]); |
110 } | 111 } |
111 | 112 |
112 EXPECT_NSEQ(@"Other Bookmarks", [[NSApp otherBookmarks] title]); | 113 EXPECT_NSEQ(@"Other Bookmarks", [[NSApp otherBookmarks] title]); |
113 EXPECT_NSEQ(@"Bookmarks Bar", [[NSApp bookmarksBar] title]); | 114 EXPECT_NSEQ(@"Bookmarks Bar", [[NSApp bookmarksBar] title]); |
114 } | 115 } |
OLD | NEW |