OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
6 #import <Cocoa/Cocoa.h> | 6 #import <Cocoa/Cocoa.h> |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 #import <Foundation/NSAppleEventDescriptor.h> | 8 #import <Foundation/NSAppleEventDescriptor.h> |
9 #import <objc/message.h> | 9 #import <objc/message.h> |
10 #import <objc/runtime.h> | 10 #import <objc/runtime.h> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 namespace { | 82 namespace { |
83 | 83 |
84 class AppControllerPlatformAppBrowserTest | 84 class AppControllerPlatformAppBrowserTest |
85 : public extensions::PlatformAppBrowserTest { | 85 : public extensions::PlatformAppBrowserTest { |
86 protected: | 86 protected: |
87 AppControllerPlatformAppBrowserTest() | 87 AppControllerPlatformAppBrowserTest() |
88 : active_browser_list_(BrowserList::GetInstance( | 88 : active_browser_list_(BrowserList::GetInstance( |
89 chrome::GetActiveDesktop())) { | 89 chrome::GetActiveDesktop())) { |
90 } | 90 } |
91 | 91 |
92 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 92 virtual void SetUpCommandLine(CommandLine* command_line) override { |
93 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 93 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
94 command_line->AppendSwitchASCII(switches::kAppId, | 94 command_line->AppendSwitchASCII(switches::kAppId, |
95 "1234"); | 95 "1234"); |
96 } | 96 } |
97 | 97 |
98 const BrowserList* active_browser_list_; | 98 const BrowserList* active_browser_list_; |
99 }; | 99 }; |
100 | 100 |
101 // Test that if only a platform app window is open and no browser windows are | 101 // Test that if only a platform app window is open and no browser windows are |
102 // open then a reopen event does nothing. | 102 // open then a reopen event does nothing. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 [[NSApp orderedWindows] indexOfObject:app_window]); | 138 [[NSApp orderedWindows] indexOfObject:app_window]); |
139 } | 139 } |
140 | 140 |
141 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { | 141 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { |
142 protected: | 142 protected: |
143 AppControllerWebAppBrowserTest() | 143 AppControllerWebAppBrowserTest() |
144 : active_browser_list_(BrowserList::GetInstance( | 144 : active_browser_list_(BrowserList::GetInstance( |
145 chrome::GetActiveDesktop())) { | 145 chrome::GetActiveDesktop())) { |
146 } | 146 } |
147 | 147 |
148 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 148 virtual void SetUpCommandLine(CommandLine* command_line) override { |
149 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); | 149 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); |
150 } | 150 } |
151 | 151 |
152 std::string GetAppURL() const { | 152 std::string GetAppURL() const { |
153 return "http://example.com/"; | 153 return "http://example.com/"; |
154 } | 154 } |
155 | 155 |
156 const BrowserList* active_browser_list_; | 156 const BrowserList* active_browser_list_; |
157 }; | 157 }; |
158 | 158 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 199 } |
200 | 200 |
201 class AppControllerNewProfileManagementBrowserTest | 201 class AppControllerNewProfileManagementBrowserTest |
202 : public InProcessBrowserTest { | 202 : public InProcessBrowserTest { |
203 protected: | 203 protected: |
204 AppControllerNewProfileManagementBrowserTest() | 204 AppControllerNewProfileManagementBrowserTest() |
205 : active_browser_list_(BrowserList::GetInstance( | 205 : active_browser_list_(BrowserList::GetInstance( |
206 chrome::GetActiveDesktop())) { | 206 chrome::GetActiveDesktop())) { |
207 } | 207 } |
208 | 208 |
209 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 209 virtual void SetUpCommandLine(CommandLine* command_line) override { |
210 switches::EnableNewProfileManagementForTesting(command_line); | 210 switches::EnableNewProfileManagementForTesting(command_line); |
211 } | 211 } |
212 | 212 |
213 const BrowserList* active_browser_list_; | 213 const BrowserList* active_browser_list_; |
214 }; | 214 }; |
215 | 215 |
216 // Test that for a regular last profile, a reopen event opens a browser. | 216 // Test that for a regular last profile, a reopen event opens a browser. |
217 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, | 217 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, |
218 RegularProfileReopenWithNoWindows) { | 218 RegularProfileReopenWithNoWindows) { |
219 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); | 219 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 EXPECT_EQ(1u, active_browser_list_->size()); | 276 EXPECT_EQ(1u, active_browser_list_->size()); |
277 EXPECT_TRUE(UserManager::IsShowing()); | 277 EXPECT_TRUE(UserManager::IsShowing()); |
278 UserManager::Hide(); | 278 UserManager::Hide(); |
279 } | 279 } |
280 | 280 |
281 class AppControllerOpenShortcutBrowserTest : public InProcessBrowserTest { | 281 class AppControllerOpenShortcutBrowserTest : public InProcessBrowserTest { |
282 protected: | 282 protected: |
283 AppControllerOpenShortcutBrowserTest() { | 283 AppControllerOpenShortcutBrowserTest() { |
284 } | 284 } |
285 | 285 |
286 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 286 virtual void SetUpInProcessBrowserTestFixture() override { |
287 // In order to mimic opening shortcut during browser startup, we need to | 287 // In order to mimic opening shortcut during browser startup, we need to |
288 // send the event before -applicationDidFinishLaunching is called, but | 288 // send the event before -applicationDidFinishLaunching is called, but |
289 // after AppController is loaded. | 289 // after AppController is loaded. |
290 // | 290 // |
291 // Since -applicationWillFinishLaunching does nothing now, we swizzle it to | 291 // Since -applicationWillFinishLaunching does nothing now, we swizzle it to |
292 // our function to send the event. We need to do this early before running | 292 // our function to send the event. We need to do this early before running |
293 // the main message loop. | 293 // the main message loop. |
294 // | 294 // |
295 // NSApp does not exist yet. We need to get the AppController using | 295 // NSApp does not exist yet. We need to get the AppController using |
296 // reflection. | 296 // reflection. |
(...skipping 11 matching lines...) Expand all Loading... |
308 | 308 |
309 ASSERT_TRUE(original != NULL); | 309 ASSERT_TRUE(original != NULL); |
310 ASSERT_TRUE(destination != NULL); | 310 ASSERT_TRUE(destination != NULL); |
311 | 311 |
312 method_exchangeImplementations(original, destination); | 312 method_exchangeImplementations(original, destination); |
313 | 313 |
314 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 314 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
315 g_open_shortcut_url = embedded_test_server()->GetURL("/simple.html"); | 315 g_open_shortcut_url = embedded_test_server()->GetURL("/simple.html"); |
316 } | 316 } |
317 | 317 |
318 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 318 virtual void SetUpCommandLine(CommandLine* command_line) override { |
319 // If the arg is empty, PrepareTestCommandLine() after this function will | 319 // If the arg is empty, PrepareTestCommandLine() after this function will |
320 // append about:blank as default url. | 320 // append about:blank as default url. |
321 command_line->AppendArg(chrome::kChromeUINewTabURL); | 321 command_line->AppendArg(chrome::kChromeUINewTabURL); |
322 } | 322 } |
323 }; | 323 }; |
324 | 324 |
325 IN_PROC_BROWSER_TEST_F(AppControllerOpenShortcutBrowserTest, | 325 IN_PROC_BROWSER_TEST_F(AppControllerOpenShortcutBrowserTest, |
326 OpenShortcutOnStartup) { | 326 OpenShortcutOnStartup) { |
327 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 327 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
328 EXPECT_EQ(g_open_shortcut_url, | 328 EXPECT_EQ(g_open_shortcut_url, |
329 browser()->tab_strip_model()->GetActiveWebContents() | 329 browser()->tab_strip_model()->GetActiveWebContents() |
330 ->GetLastCommittedURL()); | 330 ->GetLastCommittedURL()); |
331 } | 331 } |
332 | 332 |
333 } // namespace | 333 } // namespace |
OLD | NEW |