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

Side by Side Diff: chrome/browser/cocoa/applescript/window_applescript_test.mm

Issue 3180006: Cleaned up the SDEF... (Closed) Base URL: http://src.chromium.org/svn/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
« no previous file with comments | « chrome/browser/cocoa/applescript/tab_applescript.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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/scoped_nsobject.h" 7 #import "base/scoped_nsobject.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #import "chrome/browser/app_controller_mac.h" 9 #import "chrome/browser/app_controller_mac.h"
10 #import "chrome/browser/chrome_browser_application_mac.h" 10 #import "chrome/browser/chrome_browser_application_mac.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 EXPECT_EQ(1U, [tabs count]); 69 EXPECT_EQ(1U, [tabs count]);
70 TabAppleScript* tab1 = [tabs objectAtIndex:0]; 70 TabAppleScript* tab1 = [tabs objectAtIndex:0];
71 EXPECT_EQ([tab1 container], aWindow.get()); 71 EXPECT_EQ([tab1 container], aWindow.get());
72 EXPECT_NSEQ(AppleScript::kTabsProperty, 72 EXPECT_NSEQ(AppleScript::kTabsProperty,
73 [tab1 containerProperty]); 73 [tab1 containerProperty]);
74 } 74 }
75 75
76 // Insert a new tab. 76 // Insert a new tab.
77 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, InsertTab) { 77 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, InsertTab) {
78 // Emulate what applescript would do when creating a new tab. 78 // Emulate what applescript would do when creating a new tab.
79 // Emulates a script like |set var to make new tab with
80 // properties URL:"http://google.com"}|.
79 scoped_nsobject<TabAppleScript> aTab([[TabAppleScript alloc] init]); 81 scoped_nsobject<TabAppleScript> aTab([[TabAppleScript alloc] init]);
82 scoped_nsobject<NSNumber> var([[aTab.get() uniqueID] copy]);
80 [aTab.get() setURL:@"http://google.com"]; 83 [aTab.get() setURL:@"http://google.com"];
81 scoped_nsobject<WindowAppleScript> aWindow( 84 scoped_nsobject<WindowAppleScript> aWindow(
82 [[WindowAppleScript alloc] initWithBrowser:browser()]); 85 [[WindowAppleScript alloc] initWithBrowser:browser()]);
83 [aWindow.get() insertInTabs:aTab.get()]; 86 [aWindow.get() insertInTabs:aTab.get()];
84 EXPECT_EQ([aTab.get() container], aWindow.get()); 87
88 // Represents the tab after it is inserted.
89 TabAppleScript* tab = [[aWindow.get() tabs] objectAtIndex:1];
90 EXPECT_EQ(GURL("http://google.com"),
91 GURL(base::SysNSStringToUTF8([tab URL])));
92 EXPECT_EQ([tab container], aWindow.get());
85 EXPECT_NSEQ(AppleScript::kTabsProperty, 93 EXPECT_NSEQ(AppleScript::kTabsProperty,
86 [aTab.get() containerProperty]); 94 [tab containerProperty]);
87 TabAppleScript* tab2 = [[aWindow.get() tabs] objectAtIndex:1]; 95 EXPECT_NSEQ(var.get(), [tab uniqueID]);
88 EXPECT_EQ(GURL("http://google.com"),
89 GURL(base::SysNSStringToUTF8([tab2 URL])));
90 } 96 }
91 97
92 // Insert a new tab at a particular position 98 // Insert a new tab at a particular position
93 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, InsertTabAtPosition) { 99 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, InsertTabAtPosition) {
94 scoped_nsobject<TabAppleScript> tab1([[TabAppleScript alloc] init]); 100 // Emulate what applescript would do when creating a new tab.
95 scoped_nsobject<TabAppleScript> tab2([[TabAppleScript alloc] init]); 101 // Emulates a script like |set var to make new tab with
102 // properties URL:"http://google.com"} at before tab 1|.
103 scoped_nsobject<TabAppleScript> aTab([[TabAppleScript alloc] init]);
104 scoped_nsobject<NSNumber> var([[aTab.get() uniqueID] copy]);
105 [aTab.get() setURL:@"http://google.com"];
96 scoped_nsobject<WindowAppleScript> aWindow( 106 scoped_nsobject<WindowAppleScript> aWindow(
97 [[WindowAppleScript alloc] initWithBrowser:browser()]); 107 [[WindowAppleScript alloc] initWithBrowser:browser()]);
98 [aWindow.get() insertInTabs:tab1.get()]; 108 [aWindow.get() insertInTabs:aTab.get() atIndex:0];
99 [aWindow.get() insertInTabs:tab2.get()];
100 109
101 scoped_nsobject<TabAppleScript> aTab([[TabAppleScript alloc] init]); 110 // Represents the tab after it is inserted.
102 [aWindow.get() insertInTabs:aTab.get() atIndex:1]; 111 TabAppleScript* tab = [[aWindow.get() tabs] objectAtIndex:0];
103 TabAppleScript* tab = [[aWindow.get() tabs] objectAtIndex:1]; 112 EXPECT_EQ(GURL("http://google.com"),
104 EXPECT_NSEQ([aTab.get() uniqueID], 113 GURL(base::SysNSStringToUTF8([tab URL])));
105 [tab uniqueID]); 114 EXPECT_EQ([tab container], aWindow.get());
115 EXPECT_NSEQ(AppleScript::kTabsProperty, [tab containerProperty]);
116 EXPECT_NSEQ(var.get(), [tab uniqueID]);
106 } 117 }
107 118
108 // Inserting and deleting tabs. 119 // Inserting and deleting tabs.
109 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, InsertAndDeleteTabs) { 120 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, InsertAndDeleteTabs) {
110 scoped_nsobject<WindowAppleScript> aWindow( 121 scoped_nsobject<WindowAppleScript> aWindow(
111 [[WindowAppleScript alloc] initWithBrowser:browser()]); 122 [[WindowAppleScript alloc] initWithBrowser:browser()]);
112 scoped_nsobject<TabAppleScript> aTab; 123 scoped_nsobject<TabAppleScript> aTab;
113 int count; 124 int count;
114 for (int i = 0; i < 5; ++i) { 125 for (int i = 0; i < 5; ++i) {
115 for (int j = 0; j < 3; ++j) { 126 for (int j = 0; j < 3; ++j) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Order of windows. 169 // Order of windows.
159 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, WindowOrder) { 170 IN_PROC_BROWSER_TEST_F(WindowAppleScriptTest, WindowOrder) {
160 scoped_nsobject<WindowAppleScript> window2( 171 scoped_nsobject<WindowAppleScript> window2(
161 [[WindowAppleScript alloc] initWithBrowser:browser()]); 172 [[WindowAppleScript alloc] initWithBrowser:browser()]);
162 scoped_nsobject<WindowAppleScript> window1( 173 scoped_nsobject<WindowAppleScript> window1(
163 [[WindowAppleScript alloc] init]); 174 [[WindowAppleScript alloc] init]);
164 EXPECT_EQ([window1.get() windowComparator:window2.get()], NSOrderedAscending); 175 EXPECT_EQ([window1.get() windowComparator:window2.get()], NSOrderedAscending);
165 EXPECT_EQ([window2.get() windowComparator:window1.get()], 176 EXPECT_EQ([window2.get() windowComparator:window1.get()],
166 NSOrderedDescending); 177 NSOrderedDescending);
167 } 178 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/applescript/tab_applescript.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698