Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Side by Side Diff: chrome/browser/cocoa/applescript/browsercrapplication+applescript_test.mm

Issue 3163008: Removed a command which resulted in a crash.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <Cocoa/Cocoa.h>
6
7 #include "chrome/browser/browser.h"
8 #import "chrome/browser/cocoa/applescript/browsercrapplication+applescript.h"
9 #import "chrome/browser/cocoa/applescript/constants_applescript.h"
10 #import "chrome/browser/cocoa/applescript/window_applescript.h"
11 #include "chrome/browser/profile.h"
12 #include "chrome/test/in_process_browser_test.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "testing/gtest_mac.h"
15
16 typedef InProcessBrowserTest BrowserCrApplicationAppleScriptTest;
17
18 // Create windows of different |Type|.
19 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) {
20 // Create additional |Browser*| objects of different type.
21 Profile* profile = browser()->profile();
22 Browser* b1 = Browser::CreateForPopup(profile);
23 Browser* b2 = Browser::CreateForApp("", NULL, profile, true);
24 Browser* b3 = Browser::CreateForApp("", NULL, profile, false);
25
26 EXPECT_EQ(4U, [[NSApp appleScriptWindows] count]);
27 for (WindowAppleScript* window in [NSApp appleScriptWindows]) {
28 EXPECT_NSEQ(AppleScript::kWindowsProperty,
29 [window containerProperty]);
30 EXPECT_NSEQ(NSApp, [window container]);
31 }
32
33 // Close the additional browsers.
34 b1->CloseAllTabs();
35 b2->CloseAllTabs();
36 b3->CloseAllTabs();
37 }
38
39 // Insert a new window.
40 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, InsertWindow) {
41 // Emulate what applescript would do when creating a new window.
42 // Emulate a script like |set var to make new window with properties
43 // {visible:false}|.
44 scoped_nsobject<WindowAppleScript> aWindow([[WindowAppleScript alloc] init]);
45 scoped_nsobject<NSNumber> var([[aWindow.get() uniqueID] copy]);
46 [aWindow.get() setValue:[NSNumber numberWithBool:YES] forKey:@"isVisible"];
47
48 [NSApp insertInAppleScriptWindows:aWindow.get()];
49
50 // Represents the window after it is added.
51 WindowAppleScript* window = [[NSApp appleScriptWindows] objectAtIndex:0];
52 EXPECT_NSEQ([NSNumber numberWithBool:YES],
53 [aWindow.get() valueForKey:@"isVisible"]);
54 EXPECT_EQ([window container], NSApp);
55 EXPECT_NSEQ(AppleScript::kWindowsProperty,
56 [window containerProperty]);
57 EXPECT_NSEQ(var, [window uniqueID]);
58 }
59
60 // Inserting and deleting windows.
61 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest,
62 InsertAndDeleteWindows) {
63 scoped_nsobject<WindowAppleScript> aWindow;
64 int count;
65 // Create a bunch of windows.
66 for (int i = 0; i < 5; ++i) {
67 for (int j = 0; j < 3; ++j) {
68 aWindow.reset([[WindowAppleScript alloc] init]);
69 [NSApp insertInAppleScriptWindows:aWindow.get()];
70 }
71 count = 3 * i + 4;
72 EXPECT_EQ(count, (int)[[NSApp appleScriptWindows] count]);
73 }
74
75 // Remove all the windows, just created.
76 count = (int)[[NSApp appleScriptWindows] count];
77 for (int i = 0; i < 5; ++i) {
78 for(int j = 0; j < 3; ++j) {
79 [NSApp removeFromAppleScriptWindowsAtIndex:0];
80 }
81 count = count - 3;
82 EXPECT_EQ(count, (int)[[NSApp appleScriptWindows] count]);
83 }
84 }
85
86 // Check for objectSpecifer of the root scripting object.
87 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, ObjectSpecifier) {
88 // Should always return nil to indicate its the root scripting object.
89 EXPECT_EQ(nil, [NSApp objectSpecifier]);
90 }
91
92 // Bookmark folders at the root level.
93 IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, BookmarkFolders) {
94 NSArray* bookmarkFolders = [NSApp bookmarkFolders];
95 EXPECT_EQ(2U, [bookmarkFolders count]);
96
97 for (BookmarkFolderAppleScript* bookmarkFolder in bookmarkFolders) {
98 EXPECT_EQ(NSApp,
99 [bookmarkFolder container]);
100 EXPECT_NSEQ(AppleScript::kBookmarkFoldersProperty,
101 [bookmarkFolder containerProperty]);
102 }
103
104 EXPECT_NSEQ(@"Other Bookmarks", [[NSApp otherBookmarks] title]);
105 EXPECT_NSEQ(@"Bookmarks Bar", [[NSApp bookmarksBar] title]);
106 }
107
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698