| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 EXPECT_EQ(g_handoff_url, GURL(url::kAboutBlankURL)); | 635 EXPECT_EQ(g_handoff_url, GURL(url::kAboutBlankURL)); |
| 636 | 636 |
| 637 // Test that navigating to a URL updates the handoff URL. | 637 // Test that navigating to a URL updates the handoff URL. |
| 638 GURL test_url1 = embedded_test_server()->GetURL("/title1.html"); | 638 GURL test_url1 = embedded_test_server()->GetURL("/title1.html"); |
| 639 ui_test_utils::NavigateToURL(browser(), test_url1); | 639 ui_test_utils::NavigateToURL(browser(), test_url1); |
| 640 EXPECT_EQ(g_handoff_url, test_url1); | 640 EXPECT_EQ(g_handoff_url, test_url1); |
| 641 | 641 |
| 642 // Test that opening a new tab updates the handoff URL. | 642 // Test that opening a new tab updates the handoff URL. |
| 643 GURL test_url2 = embedded_test_server()->GetURL("/title2.html"); | 643 GURL test_url2 = embedded_test_server()->GetURL("/title2.html"); |
| 644 chrome::NavigateParams params(browser(), test_url2, ui::PAGE_TRANSITION_LINK); | 644 chrome::NavigateParams params(browser(), test_url2, ui::PAGE_TRANSITION_LINK); |
| 645 params.disposition = NEW_FOREGROUND_TAB; | 645 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 646 ui_test_utils::NavigateToURL(¶ms); | 646 ui_test_utils::NavigateToURL(¶ms); |
| 647 EXPECT_EQ(g_handoff_url, test_url2); | 647 EXPECT_EQ(g_handoff_url, test_url2); |
| 648 | 648 |
| 649 // Test that switching tabs updates the handoff URL. | 649 // Test that switching tabs updates the handoff URL. |
| 650 browser()->tab_strip_model()->ActivateTabAt(0, true); | 650 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 651 EXPECT_EQ(g_handoff_url, test_url1); | 651 EXPECT_EQ(g_handoff_url, test_url1); |
| 652 | 652 |
| 653 // Test that closing the current tab updates the handoff URL. | 653 // Test that closing the current tab updates the handoff URL. |
| 654 CloseTab(browser(), 0); | 654 CloseTab(browser(), 0); |
| 655 EXPECT_EQ(g_handoff_url, test_url2); | 655 EXPECT_EQ(g_handoff_url, test_url2); |
| 656 | 656 |
| 657 // Test that opening a new browser window updates the handoff URL. | 657 // Test that opening a new browser window updates the handoff URL. |
| 658 GURL test_url3 = embedded_test_server()->GetURL("/title3.html"); | 658 GURL test_url3 = embedded_test_server()->GetURL("/title3.html"); |
| 659 ui_test_utils::NavigateToURLWithDisposition( | 659 ui_test_utils::NavigateToURLWithDisposition( |
| 660 browser(), GURL(test_url3), NEW_WINDOW, | 660 browser(), GURL(test_url3), WindowOpenDisposition::NEW_WINDOW, |
| 661 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); | 661 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); |
| 662 EXPECT_EQ(g_handoff_url, test_url3); | 662 EXPECT_EQ(g_handoff_url, test_url3); |
| 663 | 663 |
| 664 // Check that there are exactly 2 browsers. | 664 // Check that there are exactly 2 browsers. |
| 665 BrowserList* active_browser_list = BrowserList::GetInstance(); | 665 BrowserList* active_browser_list = BrowserList::GetInstance(); |
| 666 EXPECT_EQ(2u, active_browser_list->size()); | 666 EXPECT_EQ(2u, active_browser_list->size()); |
| 667 | 667 |
| 668 // Close the second browser window (which only has 1 tab left). | 668 // Close the second browser window (which only has 1 tab left). |
| 669 Browser* browser2 = active_browser_list->get(1); | 669 Browser* browser2 = active_browser_list->get(1); |
| 670 CloseBrowserSynchronously(browser2); | 670 CloseBrowserSynchronously(browser2); |
| 671 EXPECT_EQ(g_handoff_url, test_url2); | 671 EXPECT_EQ(g_handoff_url, test_url2); |
| 672 | 672 |
| 673 // The URLs of incognito windows should not be passed to Handoff. | 673 // The URLs of incognito windows should not be passed to Handoff. |
| 674 GURL test_url4 = embedded_test_server()->GetURL("/simple.html"); | 674 GURL test_url4 = embedded_test_server()->GetURL("/simple.html"); |
| 675 ui_test_utils::NavigateToURLWithDisposition( | 675 ui_test_utils::NavigateToURLWithDisposition( |
| 676 browser(), GURL(test_url4), OFF_THE_RECORD, | 676 browser(), GURL(test_url4), WindowOpenDisposition::OFF_THE_RECORD, |
| 677 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); | 677 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); |
| 678 EXPECT_EQ(g_handoff_url, GURL()); | 678 EXPECT_EQ(g_handoff_url, GURL()); |
| 679 | 679 |
| 680 // Open a new tab in the incognito window. | 680 // Open a new tab in the incognito window. |
| 681 EXPECT_EQ(2u, active_browser_list->size()); | 681 EXPECT_EQ(2u, active_browser_list->size()); |
| 682 Browser* browser3 = active_browser_list->get(1); | 682 Browser* browser3 = active_browser_list->get(1); |
| 683 ui_test_utils::NavigateToURLWithDisposition( | 683 ui_test_utils::NavigateToURLWithDisposition( |
| 684 browser3, test_url4, NEW_FOREGROUND_TAB, | 684 browser3, test_url4, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 685 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 685 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 686 EXPECT_EQ(g_handoff_url, GURL()); | 686 EXPECT_EQ(g_handoff_url, GURL()); |
| 687 | 687 |
| 688 // Navigate the current tab in the incognito window. | 688 // Navigate the current tab in the incognito window. |
| 689 ui_test_utils::NavigateToURL(browser3, test_url1); | 689 ui_test_utils::NavigateToURL(browser3, test_url1); |
| 690 EXPECT_EQ(g_handoff_url, GURL()); | 690 EXPECT_EQ(g_handoff_url, GURL()); |
| 691 | 691 |
| 692 // Activate the original browser window. | 692 // Activate the original browser window. |
| 693 Browser* browser1 = active_browser_list->get(0); | 693 Browser* browser1 = active_browser_list->get(0); |
| 694 browser1->window()->Show(); | 694 browser1->window()->Show(); |
| 695 EXPECT_EQ(g_handoff_url, test_url2); | 695 EXPECT_EQ(g_handoff_url, test_url2); |
| 696 } | 696 } |
| 697 | 697 |
| 698 } // namespace | 698 } // namespace |
| OLD | NEW |