| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 @end | 109 @end |
| 110 | 110 |
| 111 namespace { | 111 namespace { |
| 112 | 112 |
| 113 class AppControllerPlatformAppBrowserTest | 113 class AppControllerPlatformAppBrowserTest |
| 114 : public extensions::PlatformAppBrowserTest { | 114 : public extensions::PlatformAppBrowserTest { |
| 115 protected: | 115 protected: |
| 116 AppControllerPlatformAppBrowserTest() | 116 AppControllerPlatformAppBrowserTest() |
| 117 : active_browser_list_(BrowserList::GetInstance( | 117 : active_browser_list_(BrowserList::GetInstance()) {} |
| 118 chrome::GetActiveDesktop())) { | |
| 119 } | |
| 120 | 118 |
| 121 void SetUpCommandLine(base::CommandLine* command_line) override { | 119 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 122 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 120 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 123 command_line->AppendSwitchASCII(switches::kAppId, | 121 command_line->AppendSwitchASCII(switches::kAppId, |
| 124 "1234"); | 122 "1234"); |
| 125 } | 123 } |
| 126 | 124 |
| 127 const BrowserList* active_browser_list_; | 125 const BrowserList* active_browser_list_; |
| 128 }; | 126 }; |
| 129 | 127 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 [app_controller applicationShouldHandleReopen:NSApp | 163 [app_controller applicationShouldHandleReopen:NSApp |
| 166 hasVisibleWindows:YES]; | 164 hasVisibleWindows:YES]; |
| 167 chrome::testing::NSRunLoopRunAllPending(); | 165 chrome::testing::NSRunLoopRunAllPending(); |
| 168 EXPECT_LE([[NSApp orderedWindows] indexOfObject:browser_window], | 166 EXPECT_LE([[NSApp orderedWindows] indexOfObject:browser_window], |
| 169 [[NSApp orderedWindows] indexOfObject:app_window]); | 167 [[NSApp orderedWindows] indexOfObject:app_window]); |
| 170 } | 168 } |
| 171 | 169 |
| 172 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { | 170 class AppControllerWebAppBrowserTest : public InProcessBrowserTest { |
| 173 protected: | 171 protected: |
| 174 AppControllerWebAppBrowserTest() | 172 AppControllerWebAppBrowserTest() |
| 175 : active_browser_list_(BrowserList::GetInstance( | 173 : active_browser_list_(BrowserList::GetInstance()) {} |
| 176 chrome::GetActiveDesktop())) { | |
| 177 } | |
| 178 | 174 |
| 179 void SetUpCommandLine(base::CommandLine* command_line) override { | 175 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 180 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); | 176 command_line->AppendSwitchASCII(switches::kApp, GetAppURL()); |
| 181 } | 177 } |
| 182 | 178 |
| 183 std::string GetAppURL() const { | 179 std::string GetAppURL() const { |
| 184 return "http://example.com/"; | 180 return "http://example.com/"; |
| 185 } | 181 } |
| 186 | 182 |
| 187 const BrowserList* active_browser_list_; | 183 const BrowserList* active_browser_list_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 base::string16(), | 222 base::string16(), |
| 227 std::string(), | 223 std::string(), |
| 228 std::string()); | 224 std::string()); |
| 229 base::RunLoop().Run(); | 225 base::RunLoop().Run(); |
| 230 } | 226 } |
| 231 | 227 |
| 232 class AppControllerNewProfileManagementBrowserTest | 228 class AppControllerNewProfileManagementBrowserTest |
| 233 : public InProcessBrowserTest { | 229 : public InProcessBrowserTest { |
| 234 protected: | 230 protected: |
| 235 AppControllerNewProfileManagementBrowserTest() | 231 AppControllerNewProfileManagementBrowserTest() |
| 236 : active_browser_list_(BrowserList::GetInstance( | 232 : active_browser_list_(BrowserList::GetInstance()) {} |
| 237 chrome::GetActiveDesktop())) { | |
| 238 } | |
| 239 | 233 |
| 240 void SetUpCommandLine(base::CommandLine* command_line) override { | 234 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 241 switches::EnableNewProfileManagementForTesting(command_line); | 235 switches::EnableNewProfileManagementForTesting(command_line); |
| 242 } | 236 } |
| 243 | 237 |
| 244 const BrowserList* active_browser_list_; | 238 const BrowserList* active_browser_list_; |
| 245 }; | 239 }; |
| 246 | 240 |
| 247 // Test that for a regular last profile, a reopen event opens a browser. | 241 // Test that for a regular last profile, a reopen event opens a browser. |
| 248 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, | 242 IN_PROC_BROWSER_TEST_F(AppControllerNewProfileManagementBrowserTest, |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 EXPECT_EQ(g_handoff_url, test_url2); | 652 EXPECT_EQ(g_handoff_url, test_url2); |
| 659 | 653 |
| 660 // Test that opening a new browser window updates the handoff URL. | 654 // Test that opening a new browser window updates the handoff URL. |
| 661 GURL test_url3 = embedded_test_server()->GetURL("/title3.html"); | 655 GURL test_url3 = embedded_test_server()->GetURL("/title3.html"); |
| 662 ui_test_utils::NavigateToURLWithDisposition( | 656 ui_test_utils::NavigateToURLWithDisposition( |
| 663 browser(), GURL(test_url3), NEW_WINDOW, | 657 browser(), GURL(test_url3), NEW_WINDOW, |
| 664 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); | 658 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); |
| 665 EXPECT_EQ(g_handoff_url, test_url3); | 659 EXPECT_EQ(g_handoff_url, test_url3); |
| 666 | 660 |
| 667 // Check that there are exactly 2 browsers. | 661 // Check that there are exactly 2 browsers. |
| 668 BrowserList* active_browser_list = | 662 BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 669 BrowserList::GetInstance(chrome::GetActiveDesktop()); | |
| 670 EXPECT_EQ(2u, active_browser_list->size()); | 663 EXPECT_EQ(2u, active_browser_list->size()); |
| 671 | 664 |
| 672 // Close the second browser window (which only has 1 tab left). | 665 // Close the second browser window (which only has 1 tab left). |
| 673 Browser* browser2 = active_browser_list->get(1); | 666 Browser* browser2 = active_browser_list->get(1); |
| 674 CloseBrowserSynchronously(browser2); | 667 CloseBrowserSynchronously(browser2); |
| 675 EXPECT_EQ(g_handoff_url, test_url2); | 668 EXPECT_EQ(g_handoff_url, test_url2); |
| 676 | 669 |
| 677 // The URLs of incognito windows should not be passed to Handoff. | 670 // The URLs of incognito windows should not be passed to Handoff. |
| 678 GURL test_url4 = embedded_test_server()->GetURL("/simple.html"); | 671 GURL test_url4 = embedded_test_server()->GetURL("/simple.html"); |
| 679 ui_test_utils::NavigateToURLWithDisposition( | 672 ui_test_utils::NavigateToURLWithDisposition( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 693 ui_test_utils::NavigateToURL(browser3, test_url1); | 686 ui_test_utils::NavigateToURL(browser3, test_url1); |
| 694 EXPECT_EQ(g_handoff_url, GURL()); | 687 EXPECT_EQ(g_handoff_url, GURL()); |
| 695 | 688 |
| 696 // Activate the original browser window. | 689 // Activate the original browser window. |
| 697 Browser* browser1 = active_browser_list->get(0); | 690 Browser* browser1 = active_browser_list->get(0); |
| 698 browser1->window()->Show(); | 691 browser1->window()->Show(); |
| 699 EXPECT_EQ(g_handoff_url, test_url2); | 692 EXPECT_EQ(g_handoff_url, test_url2); |
| 700 } | 693 } |
| 701 | 694 |
| 702 } // namespace | 695 } // namespace |
| OLD | NEW |