| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 namespace { | 99 namespace { |
| 100 | 100 |
| 101 class AppControllerPlatformAppBrowserTest | 101 class AppControllerPlatformAppBrowserTest |
| 102 : public extensions::PlatformAppBrowserTest { | 102 : public extensions::PlatformAppBrowserTest { |
| 103 protected: | 103 protected: |
| 104 AppControllerPlatformAppBrowserTest() | 104 AppControllerPlatformAppBrowserTest() |
| 105 : active_browser_list_(BrowserList::GetInstance( | 105 : active_browser_list_(BrowserList::GetInstance( |
| 106 chrome::GetActiveDesktop())) { | 106 chrome::GetActiveDesktop())) { |
| 107 } | 107 } |
| 108 | 108 |
| 109 void SetUpCommandLine(CommandLine* command_line) override { | 109 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 110 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 110 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 111 command_line->AppendSwitchASCII(switches::kAppId, | 111 command_line->AppendSwitchASCII(switches::kAppId, |
| 112 "1234"); | 112 "1234"); |
| 113 } | 113 } |
| 114 | 114 |
| 115 const BrowserList* active_browser_list_; | 115 const BrowserList* active_browser_list_; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 // Test that if only a platform app window is open and no browser windows are | 118 // Test that if only a platform app window is open and no browser windows are |
| 119 // open then a reopen event does nothing. | 119 // open then a reopen event does nothing. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 [[NSApp orderedWindows] indexOfObject:app_window]); | 155 [[NSApp orderedWindows] indexOfObject:app_window]); |
| 156 } | 156 } |
| 157 | 157 |
| 158 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { | 158 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { |
| 159 protected: | 159 protected: |
| 160 AppControllerWebAppBrowserTest() | 160 AppControllerWebAppBrowserTest() |
| 161 : active_browser_list_(BrowserList::GetInstance( | 161 : active_browser_list_(BrowserList::GetInstance( |
| 162 chrome::GetActiveDesktop())) { | 162 chrome::GetActiveDesktop())) { |
| 163 } | 163 } |
| 164 | 164 |
| 165 void SetUpCommandLine(CommandLine* command_line) override { | 165 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 166 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); | 166 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 std::string GetAppURL() const { | 169 std::string GetAppURL() const { |
| 170 return "http://example.com/"; | 170 return "http://example.com/"; |
| 171 } | 171 } |
| 172 | 172 |
| 173 const BrowserList* active_browser_list_; | 173 const BrowserList* active_browser_list_; |
| 174 }; | 174 }; |
| 175 | 175 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 | 217 |
| 218 class AppControllerNewProfileManagementBrowserTest | 218 class AppControllerNewProfileManagementBrowserTest |
| 219 : public InProcessBrowserTest { | 219 : public InProcessBrowserTest { |
| 220 protected: | 220 protected: |
| 221 AppControllerNewProfileManagementBrowserTest() | 221 AppControllerNewProfileManagementBrowserTest() |
| 222 : active_browser_list_(BrowserList::GetInstance( | 222 : active_browser_list_(BrowserList::GetInstance( |
| 223 chrome::GetActiveDesktop())) { | 223 chrome::GetActiveDesktop())) { |
| 224 } | 224 } |
| 225 | 225 |
| 226 void SetUpCommandLine(CommandLine* command_line) override { | 226 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 227 switches::EnableNewProfileManagementForTesting(command_line); | 227 switches::EnableNewProfileManagementForTesting(command_line); |
| 228 } | 228 } |
| 229 | 229 |
| 230 const BrowserList* active_browser_list_; | 230 const BrowserList* active_browser_list_; |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 // Test that for a regular last profile, a reopen event opens a browser. | 233 // Test that for a regular last profile, a reopen event opens a browser. |
| 234 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, | 234 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, |
| 235 RegularProfileReopenWithNoWindows) { | 235 RegularProfileReopenWithNoWindows) { |
| 236 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); | 236 base::scoped_nsobject<AppController> ac([[AppController alloc] init]); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 ASSERT_TRUE(original != NULL); | 356 ASSERT_TRUE(original != NULL); |
| 357 ASSERT_TRUE(destination != NULL); | 357 ASSERT_TRUE(destination != NULL); |
| 358 | 358 |
| 359 method_exchangeImplementations(original, destination); | 359 method_exchangeImplementations(original, destination); |
| 360 | 360 |
| 361 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 361 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 362 g_open_shortcut_url = embedded_test_server()->GetURL("/simple.html"); | 362 g_open_shortcut_url = embedded_test_server()->GetURL("/simple.html"); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void SetUpCommandLine(CommandLine* command_line) override { | 365 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 366 // If the arg is empty, PrepareTestCommandLine() after this function will | 366 // If the arg is empty, PrepareTestCommandLine() after this function will |
| 367 // append about:blank as default url. | 367 // append about:blank as default url. |
| 368 command_line->AppendArg(chrome::kChromeUINewTabURL); | 368 command_line->AppendArg(chrome::kChromeUINewTabURL); |
| 369 } | 369 } |
| 370 }; | 370 }; |
| 371 | 371 |
| 372 IN_PROC_BROWSER_TEST_F(AppControllerOpenShortcutBrowserTest, | 372 IN_PROC_BROWSER_TEST_F(AppControllerOpenShortcutBrowserTest, |
| 373 OpenShortcutOnStartup) { | 373 OpenShortcutOnStartup) { |
| 374 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 374 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 375 EXPECT_EQ(g_open_shortcut_url, | 375 EXPECT_EQ(g_open_shortcut_url, |
| 376 browser()->tab_strip_model()->GetActiveWebContents() | 376 browser()->tab_strip_model()->GetActiveWebContents() |
| 377 ->GetLastCommittedURL()); | 377 ->GetLastCommittedURL()); |
| 378 } | 378 } |
| 379 | 379 |
| 380 class AppControllerReplaceNTPBrowserTest : public InProcessBrowserTest { | 380 class AppControllerReplaceNTPBrowserTest : public InProcessBrowserTest { |
| 381 protected: | 381 protected: |
| 382 AppControllerReplaceNTPBrowserTest() {} | 382 AppControllerReplaceNTPBrowserTest() {} |
| 383 | 383 |
| 384 void SetUpInProcessBrowserTestFixture() override { | 384 void SetUpInProcessBrowserTestFixture() override { |
| 385 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 385 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void SetUpCommandLine(CommandLine* command_line) override { | 388 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 389 // If the arg is empty, PrepareTestCommandLine() after this function will | 389 // If the arg is empty, PrepareTestCommandLine() after this function will |
| 390 // append about:blank as default url. | 390 // append about:blank as default url. |
| 391 command_line->AppendArg(chrome::kChromeUINewTabURL); | 391 command_line->AppendArg(chrome::kChromeUINewTabURL); |
| 392 } | 392 } |
| 393 }; | 393 }; |
| 394 | 394 |
| 395 // Tests that when a GURL is opened after startup, it replaces the NTP. | 395 // Tests that when a GURL is opened after startup, it replaces the NTP. |
| 396 IN_PROC_BROWSER_TEST_F(AppControllerReplaceNTPBrowserTest, | 396 IN_PROC_BROWSER_TEST_F(AppControllerReplaceNTPBrowserTest, |
| 397 ReplaceNTPAfterStartup) { | 397 ReplaceNTPAfterStartup) { |
| 398 // Ensure that there is exactly 1 tab showing, and the tab is the NTP. | 398 // Ensure that there is exactly 1 tab showing, and the tab is the NTP. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 ui_test_utils::NavigateToURL(browser3, test_url1); | 615 ui_test_utils::NavigateToURL(browser3, test_url1); |
| 616 EXPECT_EQ(g_handoff_url, GURL()); | 616 EXPECT_EQ(g_handoff_url, GURL()); |
| 617 | 617 |
| 618 // Activate the original browser window. | 618 // Activate the original browser window. |
| 619 Browser* browser1 = active_browser_list->get(0); | 619 Browser* browser1 = active_browser_list->get(0); |
| 620 browser1->window()->Show(); | 620 browser1->window()->Show(); |
| 621 EXPECT_EQ(g_handoff_url, test_url2); | 621 EXPECT_EQ(g_handoff_url, test_url2); |
| 622 } | 622 } |
| 623 | 623 |
| 624 } // namespace | 624 } // namespace |
| OLD | NEW |