OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/browser_navigator_browsertest.h" | 5 #include "chrome/browser/ui/browser_navigator_browsertest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 | 52 |
53 browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { | 53 browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { |
54 return MakeNavigateParams(browser()); | 54 return MakeNavigateParams(browser()); |
55 } | 55 } |
56 | 56 |
57 browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams( | 57 browser::NavigateParams BrowserNavigatorTest::MakeNavigateParams( |
58 Browser* browser) const { | 58 Browser* browser) const { |
59 browser::NavigateParams params(browser, GetGoogleURL(), | 59 browser::NavigateParams params(browser, GetGoogleURL(), |
60 PageTransition::LINK); | 60 content::PAGE_TRANSITION_LINK); |
61 params.window_action = browser::NavigateParams::SHOW_WINDOW; | 61 params.window_action = browser::NavigateParams::SHOW_WINDOW; |
62 return params; | 62 return params; |
63 } | 63 } |
64 | 64 |
65 Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, | 65 Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, |
66 Profile* profile) { | 66 Profile* profile) { |
67 Browser* browser = Browser::CreateForType(type, profile); | 67 Browser* browser = Browser::CreateForType(type, profile); |
68 browser->AddBlankTab(true); | 68 browser->AddBlankTab(true); |
69 return browser; | 69 return browser; |
70 } | 70 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 // Register for a notification if an additional tab_contents was instantiated. | 132 // Register for a notification if an additional tab_contents was instantiated. |
133 // Opening a Singleton tab that is already opened should not be opening a new | 133 // Opening a Singleton tab that is already opened should not be opening a new |
134 // tab nor be creating a new TabContents object | 134 // tab nor be creating a new TabContents object |
135 NotificationRegistrar registrar; | 135 NotificationRegistrar registrar; |
136 | 136 |
137 // As the registrar object goes out of scope, this will get unregistered | 137 // As the registrar object goes out of scope, this will get unregistered |
138 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 138 registrar.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
139 NotificationService::AllSources()); | 139 NotificationService::AllSources()); |
140 | 140 |
141 browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK); | 141 browser()->AddSelectedTabWithURL( |
142 browser()->AddSelectedTabWithURL(GetGoogleURL(), PageTransition::LINK); | 142 singleton_url1, content::PAGE_TRANSITION_LINK); |
| 143 browser()->AddSelectedTabWithURL( |
| 144 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
143 | 145 |
144 // We should have one browser with 3 tabs, the 3rd selected. | 146 // We should have one browser with 3 tabs, the 3rd selected. |
145 EXPECT_EQ(1u, BrowserList::size()); | 147 EXPECT_EQ(1u, BrowserList::size()); |
146 EXPECT_EQ(2, browser()->active_index()); | 148 EXPECT_EQ(2, browser()->active_index()); |
147 | 149 |
148 unsigned int previous_tab_contents_count = | 150 unsigned int previous_tab_contents_count = |
149 created_tab_contents_count_ = 0; | 151 created_tab_contents_count_ = 0; |
150 | 152 |
151 // Navigate to singleton_url1. | 153 // Navigate to singleton_url1. |
152 browser::NavigateParams p(MakeNavigateParams()); | 154 browser::NavigateParams p(MakeNavigateParams()); |
153 p.disposition = SINGLETON_TAB; | 155 p.disposition = SINGLETON_TAB; |
154 p.url = singleton_url1; | 156 p.url = singleton_url1; |
155 browser::Navigate(&p); | 157 browser::Navigate(&p); |
156 | 158 |
157 // The middle tab should now be selected. | 159 // The middle tab should now be selected. |
158 EXPECT_EQ(browser(), p.browser); | 160 EXPECT_EQ(browser(), p.browser); |
159 EXPECT_EQ(1, browser()->active_index()); | 161 EXPECT_EQ(1, browser()->active_index()); |
160 | 162 |
161 // No tab contents should have been created | 163 // No tab contents should have been created |
162 EXPECT_EQ(previous_tab_contents_count, | 164 EXPECT_EQ(previous_tab_contents_count, |
163 created_tab_contents_count_); | 165 created_tab_contents_count_); |
164 } | 166 } |
165 | 167 |
166 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 168 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
167 Disposition_SingletonTabRespectingRef) { | 169 Disposition_SingletonTabRespectingRef) { |
168 GURL singleton_ref_url1("http://maps.google.com/#a"); | 170 GURL singleton_ref_url1("http://maps.google.com/#a"); |
169 GURL singleton_ref_url2("http://maps.google.com/#b"); | 171 GURL singleton_ref_url2("http://maps.google.com/#b"); |
170 GURL singleton_ref_url3("http://maps.google.com/"); | 172 GURL singleton_ref_url3("http://maps.google.com/"); |
171 | 173 |
172 browser()->AddSelectedTabWithURL(singleton_ref_url1, PageTransition::LINK); | 174 browser()->AddSelectedTabWithURL( |
| 175 singleton_ref_url1, content::PAGE_TRANSITION_LINK); |
173 | 176 |
174 // We should have one browser with 2 tabs, 2nd selected. | 177 // We should have one browser with 2 tabs, 2nd selected. |
175 EXPECT_EQ(1u, BrowserList::size()); | 178 EXPECT_EQ(1u, BrowserList::size()); |
176 EXPECT_EQ(2, browser()->tab_count()); | 179 EXPECT_EQ(2, browser()->tab_count()); |
177 EXPECT_EQ(1, browser()->active_index()); | 180 EXPECT_EQ(1, browser()->active_index()); |
178 | 181 |
179 // Navigate to singleton_url2. | 182 // Navigate to singleton_url2. |
180 browser::NavigateParams p(MakeNavigateParams()); | 183 browser::NavigateParams p(MakeNavigateParams()); |
181 p.disposition = SINGLETON_TAB; | 184 p.disposition = SINGLETON_TAB; |
182 p.url = singleton_ref_url2; | 185 p.url = singleton_ref_url2; |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 EXPECT_EQ(2u, BrowserList::size()); | 696 EXPECT_EQ(2u, BrowserList::size()); |
694 EXPECT_EQ(1, browser()->tab_count()); | 697 EXPECT_EQ(1, browser()->tab_count()); |
695 EXPECT_EQ(1, p.browser->tab_count()); | 698 EXPECT_EQ(1, p.browser->tab_count()); |
696 } | 699 } |
697 | 700 |
698 // This test verifies that constructing params with disposition = SINGLETON_TAB | 701 // This test verifies that constructing params with disposition = SINGLETON_TAB |
699 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if | 702 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if |
700 // no previous tab with that URL (minus the path) exists. | 703 // no previous tab with that URL (minus the path) exists. |
701 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 704 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
702 Disposition_SingletonTabNew_IgnorePath) { | 705 Disposition_SingletonTabNew_IgnorePath) { |
703 browser()->AddSelectedTabWithURL(GetGoogleURL(), PageTransition::LINK); | 706 browser()->AddSelectedTabWithURL( |
| 707 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
704 | 708 |
705 // We should have one browser with 2 tabs, the 2nd selected. | 709 // We should have one browser with 2 tabs, the 2nd selected. |
706 EXPECT_EQ(1u, BrowserList::size()); | 710 EXPECT_EQ(1u, BrowserList::size()); |
707 EXPECT_EQ(2, browser()->tab_count()); | 711 EXPECT_EQ(2, browser()->tab_count()); |
708 EXPECT_EQ(1, browser()->active_index()); | 712 EXPECT_EQ(1, browser()->active_index()); |
709 | 713 |
710 // Navigate to a new singleton tab with a sub-page. | 714 // Navigate to a new singleton tab with a sub-page. |
711 browser::NavigateParams p(MakeNavigateParams()); | 715 browser::NavigateParams p(MakeNavigateParams()); |
712 p.disposition = SINGLETON_TAB; | 716 p.disposition = SINGLETON_TAB; |
713 p.url = GetSettingsAdvancedURL(); | 717 p.url = GetSettingsAdvancedURL(); |
714 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 718 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
715 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 719 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
716 browser::Navigate(&p); | 720 browser::Navigate(&p); |
717 | 721 |
718 // The last tab should now be selected and navigated to the sub-page of the | 722 // The last tab should now be selected and navigated to the sub-page of the |
719 // URL. | 723 // URL. |
720 EXPECT_EQ(browser(), p.browser); | 724 EXPECT_EQ(browser(), p.browser); |
721 EXPECT_EQ(3, browser()->tab_count()); | 725 EXPECT_EQ(3, browser()->tab_count()); |
722 EXPECT_EQ(2, browser()->active_index()); | 726 EXPECT_EQ(2, browser()->active_index()); |
723 EXPECT_EQ(GetSettingsAdvancedURL(), | 727 EXPECT_EQ(GetSettingsAdvancedURL(), |
724 browser()->GetSelectedTabContents()->GetURL()); | 728 browser()->GetSelectedTabContents()->GetURL()); |
725 } | 729 } |
726 | 730 |
727 // This test verifies that constructing params with disposition = SINGLETON_TAB | 731 // This test verifies that constructing params with disposition = SINGLETON_TAB |
728 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus | 732 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
729 // the path) which is navigated to the specified URL. | 733 // the path) which is navigated to the specified URL. |
730 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 734 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
731 Disposition_SingletonTabExisting_IgnorePath) { | 735 Disposition_SingletonTabExisting_IgnorePath) { |
732 GURL singleton_url1(GetSettingsURL()); | 736 GURL singleton_url1(GetSettingsURL()); |
733 browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK); | 737 browser()->AddSelectedTabWithURL( |
734 browser()->AddSelectedTabWithURL(GetGoogleURL(), PageTransition::LINK); | 738 singleton_url1, content::PAGE_TRANSITION_LINK); |
| 739 browser()->AddSelectedTabWithURL( |
| 740 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
735 | 741 |
736 // We should have one browser with 3 tabs, the 3rd selected. | 742 // We should have one browser with 3 tabs, the 3rd selected. |
737 EXPECT_EQ(1u, BrowserList::size()); | 743 EXPECT_EQ(1u, BrowserList::size()); |
738 EXPECT_EQ(3, browser()->tab_count()); | 744 EXPECT_EQ(3, browser()->tab_count()); |
739 EXPECT_EQ(2, browser()->active_index()); | 745 EXPECT_EQ(2, browser()->active_index()); |
740 | 746 |
741 // Navigate to singleton_url1. | 747 // Navigate to singleton_url1. |
742 browser::NavigateParams p(MakeNavigateParams()); | 748 browser::NavigateParams p(MakeNavigateParams()); |
743 p.disposition = SINGLETON_TAB; | 749 p.disposition = SINGLETON_TAB; |
744 p.url = GetSettingsAdvancedURL(); | 750 p.url = GetSettingsAdvancedURL(); |
745 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 751 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
746 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 752 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
747 browser::Navigate(&p); | 753 browser::Navigate(&p); |
748 | 754 |
749 // The middle tab should now be selected and navigated to the sub-page of the | 755 // The middle tab should now be selected and navigated to the sub-page of the |
750 // URL. | 756 // URL. |
751 EXPECT_EQ(browser(), p.browser); | 757 EXPECT_EQ(browser(), p.browser); |
752 EXPECT_EQ(3, browser()->tab_count()); | 758 EXPECT_EQ(3, browser()->tab_count()); |
753 EXPECT_EQ(1, browser()->active_index()); | 759 EXPECT_EQ(1, browser()->active_index()); |
754 EXPECT_EQ(GetSettingsAdvancedURL(), | 760 EXPECT_EQ(GetSettingsAdvancedURL(), |
755 browser()->GetSelectedTabContents()->GetURL()); | 761 browser()->GetSelectedTabContents()->GetURL()); |
756 } | 762 } |
757 | 763 |
758 // This test verifies that constructing params with disposition = SINGLETON_TAB | 764 // This test verifies that constructing params with disposition = SINGLETON_TAB |
759 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus | 765 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus |
760 // the path) which is navigated to the specified URL. | 766 // the path) which is navigated to the specified URL. |
761 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 767 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
762 Disposition_SingletonTabExistingSubPath_IgnorePath) { | 768 Disposition_SingletonTabExistingSubPath_IgnorePath) { |
763 GURL singleton_url1(GetSettingsAdvancedURL()); | 769 GURL singleton_url1(GetSettingsAdvancedURL()); |
764 browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK); | 770 browser()->AddSelectedTabWithURL( |
765 browser()->AddSelectedTabWithURL(GetGoogleURL(), PageTransition::LINK); | 771 singleton_url1, content::PAGE_TRANSITION_LINK); |
| 772 browser()->AddSelectedTabWithURL( |
| 773 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
766 | 774 |
767 // We should have one browser with 3 tabs, the 3rd selected. | 775 // We should have one browser with 3 tabs, the 3rd selected. |
768 EXPECT_EQ(1u, BrowserList::size()); | 776 EXPECT_EQ(1u, BrowserList::size()); |
769 EXPECT_EQ(3, browser()->tab_count()); | 777 EXPECT_EQ(3, browser()->tab_count()); |
770 EXPECT_EQ(2, browser()->active_index()); | 778 EXPECT_EQ(2, browser()->active_index()); |
771 | 779 |
772 // Navigate to singleton_url1. | 780 // Navigate to singleton_url1. |
773 browser::NavigateParams p(MakeNavigateParams()); | 781 browser::NavigateParams p(MakeNavigateParams()); |
774 p.disposition = SINGLETON_TAB; | 782 p.disposition = SINGLETON_TAB; |
775 p.url = GetSettingsPersonalURL(); | 783 p.url = GetSettingsPersonalURL(); |
776 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 784 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
777 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; | 785 p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; |
778 browser::Navigate(&p); | 786 browser::Navigate(&p); |
779 | 787 |
780 // The middle tab should now be selected and navigated to the sub-page of the | 788 // The middle tab should now be selected and navigated to the sub-page of the |
781 // URL. | 789 // URL. |
782 EXPECT_EQ(browser(), p.browser); | 790 EXPECT_EQ(browser(), p.browser); |
783 EXPECT_EQ(3, browser()->tab_count()); | 791 EXPECT_EQ(3, browser()->tab_count()); |
784 EXPECT_EQ(1, browser()->active_index()); | 792 EXPECT_EQ(1, browser()->active_index()); |
785 EXPECT_EQ(GetSettingsPersonalURL(), | 793 EXPECT_EQ(GetSettingsPersonalURL(), |
786 browser()->GetSelectedTabContents()->GetURL()); | 794 browser()->GetSelectedTabContents()->GetURL()); |
787 } | 795 } |
788 | 796 |
789 // This test verifies that constructing params with disposition = SINGLETON_TAB | 797 // This test verifies that constructing params with disposition = SINGLETON_TAB |
790 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus | 798 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus |
791 // the path). | 799 // the path). |
792 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 800 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
793 Disposition_SingletonTabExistingSubPath_IgnorePath2) { | 801 Disposition_SingletonTabExistingSubPath_IgnorePath2) { |
794 GURL singleton_url1(GetSettingsAdvancedURL()); | 802 GURL singleton_url1(GetSettingsAdvancedURL()); |
795 browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK); | 803 browser()->AddSelectedTabWithURL( |
796 browser()->AddSelectedTabWithURL(GetGoogleURL(), PageTransition::LINK); | 804 singleton_url1, content::PAGE_TRANSITION_LINK); |
| 805 browser()->AddSelectedTabWithURL( |
| 806 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
797 | 807 |
798 // We should have one browser with 3 tabs, the 3rd selected. | 808 // We should have one browser with 3 tabs, the 3rd selected. |
799 EXPECT_EQ(1u, BrowserList::size()); | 809 EXPECT_EQ(1u, BrowserList::size()); |
800 EXPECT_EQ(3, browser()->tab_count()); | 810 EXPECT_EQ(3, browser()->tab_count()); |
801 EXPECT_EQ(2, browser()->active_index()); | 811 EXPECT_EQ(2, browser()->active_index()); |
802 | 812 |
803 // Navigate to singleton_url1. | 813 // Navigate to singleton_url1. |
804 browser::NavigateParams p(MakeNavigateParams()); | 814 browser::NavigateParams p(MakeNavigateParams()); |
805 p.disposition = SINGLETON_TAB; | 815 p.disposition = SINGLETON_TAB; |
806 p.url = GetSettingsPersonalURL(); | 816 p.url = GetSettingsPersonalURL(); |
807 p.window_action = browser::NavigateParams::SHOW_WINDOW; | 817 p.window_action = browser::NavigateParams::SHOW_WINDOW; |
808 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; | 818 p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT; |
809 browser::Navigate(&p); | 819 browser::Navigate(&p); |
810 | 820 |
811 // The middle tab should now be selected. | 821 // The middle tab should now be selected. |
812 EXPECT_EQ(browser(), p.browser); | 822 EXPECT_EQ(browser(), p.browser); |
813 EXPECT_EQ(3, browser()->tab_count()); | 823 EXPECT_EQ(3, browser()->tab_count()); |
814 EXPECT_EQ(1, browser()->active_index()); | 824 EXPECT_EQ(1, browser()->active_index()); |
815 EXPECT_EQ(singleton_url1, | 825 EXPECT_EQ(singleton_url1, |
816 browser()->GetSelectedTabContents()->GetURL()); | 826 browser()->GetSelectedTabContents()->GetURL()); |
817 } | 827 } |
818 | 828 |
819 // This test verifies that constructing params with disposition = SINGLETON_TAB | 829 // This test verifies that constructing params with disposition = SINGLETON_TAB |
820 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently | 830 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently |
821 // selected tab is a match but has a different path. | 831 // selected tab is a match but has a different path. |
822 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 832 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
823 Disposition_SingletonTabFocused_IgnorePath) { | 833 Disposition_SingletonTabFocused_IgnorePath) { |
824 GURL singleton_url_current(GetSettingsAdvancedURL()); | 834 GURL singleton_url_current(GetSettingsAdvancedURL()); |
825 browser()->AddSelectedTabWithURL(singleton_url_current, PageTransition::LINK); | 835 browser()->AddSelectedTabWithURL( |
| 836 singleton_url_current, content::PAGE_TRANSITION_LINK); |
826 | 837 |
827 // We should have one browser with 2 tabs, the 2nd selected. | 838 // We should have one browser with 2 tabs, the 2nd selected. |
828 EXPECT_EQ(1u, BrowserList::size()); | 839 EXPECT_EQ(1u, BrowserList::size()); |
829 EXPECT_EQ(2, browser()->tab_count()); | 840 EXPECT_EQ(2, browser()->tab_count()); |
830 EXPECT_EQ(1, browser()->active_index()); | 841 EXPECT_EQ(1, browser()->active_index()); |
831 | 842 |
832 // Navigate to a different settings path. | 843 // Navigate to a different settings path. |
833 GURL singleton_url_target(GetSettingsPersonalURL()); | 844 GURL singleton_url_target(GetSettingsPersonalURL()); |
834 browser::NavigateParams p(MakeNavigateParams()); | 845 browser::NavigateParams p(MakeNavigateParams()); |
835 p.disposition = SINGLETON_TAB; | 846 p.disposition = SINGLETON_TAB; |
(...skipping 10 matching lines...) Expand all Loading... |
846 browser()->GetSelectedTabContents()->GetURL()); | 857 browser()->GetSelectedTabContents()->GetURL()); |
847 } | 858 } |
848 | 859 |
849 // This test verifies that constructing params with disposition = SINGLETON_TAB | 860 // This test verifies that constructing params with disposition = SINGLETON_TAB |
850 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different | 861 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different |
851 // query. | 862 // query. |
852 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 863 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
853 Disposition_SingletonTabExisting_IgnoreQuery) { | 864 Disposition_SingletonTabExisting_IgnoreQuery) { |
854 int initial_tab_count = browser()->tab_count(); | 865 int initial_tab_count = browser()->tab_count(); |
855 GURL singleton_url_current("chrome://settings/internet"); | 866 GURL singleton_url_current("chrome://settings/internet"); |
856 browser()->AddSelectedTabWithURL(singleton_url_current, PageTransition::LINK); | 867 browser()->AddSelectedTabWithURL( |
| 868 singleton_url_current, content::PAGE_TRANSITION_LINK); |
857 | 869 |
858 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); | 870 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); |
859 EXPECT_EQ(initial_tab_count, browser()->active_index()); | 871 EXPECT_EQ(initial_tab_count, browser()->active_index()); |
860 | 872 |
861 // Navigate to a different settings path. | 873 // Navigate to a different settings path. |
862 GURL singleton_url_target( | 874 GURL singleton_url_target( |
863 "chrome://settings/internet?" | 875 "chrome://settings/internet?" |
864 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); | 876 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); |
865 browser::NavigateParams p(MakeNavigateParams()); | 877 browser::NavigateParams p(MakeNavigateParams()); |
866 p.disposition = SINGLETON_TAB; | 878 p.disposition = SINGLETON_TAB; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 EXPECT_EQ(2, browser()->tab_count()); | 910 EXPECT_EQ(2, browser()->tab_count()); |
899 EXPECT_EQ(GetSettingsURL(), | 911 EXPECT_EQ(GetSettingsURL(), |
900 browser()->GetSelectedTabContents()->GetURL()); | 912 browser()->GetSelectedTabContents()->GetURL()); |
901 } | 913 } |
902 | 914 |
903 // This test verifies that the settings page isn't opened in the incognito | 915 // This test verifies that the settings page isn't opened in the incognito |
904 // window from a non-incognito window (bookmark open-in-incognito trigger). | 916 // window from a non-incognito window (bookmark open-in-incognito trigger). |
905 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 917 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
906 Disposition_Settings_UseNonIncognitoWindowForBookmark) { | 918 Disposition_Settings_UseNonIncognitoWindowForBookmark) { |
907 browser::NavigateParams params(browser(), GURL("chrome://settings"), | 919 browser::NavigateParams params(browser(), GURL("chrome://settings"), |
908 PageTransition::AUTO_BOOKMARK); | 920 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
909 params.disposition = OFF_THE_RECORD; | 921 params.disposition = OFF_THE_RECORD; |
910 { | 922 { |
911 ui_test_utils::WindowedNotificationObserver observer( | 923 ui_test_utils::WindowedNotificationObserver observer( |
912 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 924 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
913 browser::Navigate(¶ms); | 925 browser::Navigate(¶ms); |
914 observer.Wait(); | 926 observer.Wait(); |
915 } | 927 } |
916 | 928 |
917 EXPECT_EQ(1u, BrowserList::size()); | 929 EXPECT_EQ(1u, BrowserList::size()); |
918 EXPECT_EQ(GURL("chrome://settings"), | 930 EXPECT_EQ(GURL("chrome://settings"), |
(...skipping 22 matching lines...) Expand all Loading... |
941 EXPECT_EQ(browser(), p.browser); | 953 EXPECT_EQ(browser(), p.browser); |
942 EXPECT_EQ(2, browser()->tab_count()); | 954 EXPECT_EQ(2, browser()->tab_count()); |
943 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), | 955 EXPECT_EQ(GURL(chrome::kChromeUIBookmarksURL), |
944 browser()->GetSelectedTabContents()->GetURL()); | 956 browser()->GetSelectedTabContents()->GetURL()); |
945 } | 957 } |
946 | 958 |
947 // This test makes sure a crashed singleton tab reloads from a new navigation. | 959 // This test makes sure a crashed singleton tab reloads from a new navigation. |
948 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, | 960 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, |
949 NavigateToCrashedSingletonTab) { | 961 NavigateToCrashedSingletonTab) { |
950 GURL singleton_url(GetSettingsAdvancedURL()); | 962 GURL singleton_url(GetSettingsAdvancedURL()); |
951 TabContentsWrapper* wrapper = | 963 TabContentsWrapper* wrapper = browser()->AddSelectedTabWithURL( |
952 browser()->AddSelectedTabWithURL(singleton_url, PageTransition::LINK); | 964 singleton_url, content::PAGE_TRANSITION_LINK); |
953 TabContents* tab_contents = wrapper->tab_contents(); | 965 TabContents* tab_contents = wrapper->tab_contents(); |
954 | 966 |
955 // We should have one browser with 2 tabs, the 2nd selected. | 967 // We should have one browser with 2 tabs, the 2nd selected. |
956 EXPECT_EQ(1u, BrowserList::size()); | 968 EXPECT_EQ(1u, BrowserList::size()); |
957 EXPECT_EQ(2, browser()->tab_count()); | 969 EXPECT_EQ(2, browser()->tab_count()); |
958 EXPECT_EQ(1, browser()->active_index()); | 970 EXPECT_EQ(1, browser()->active_index()); |
959 | 971 |
960 // Kill the singleton tab. | 972 // Kill the singleton tab. |
961 tab_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 973 tab_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
962 EXPECT_TRUE(tab_contents->is_crashed()); | 974 EXPECT_TRUE(tab_contents->is_crashed()); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 NavigateFromOtherTabToSingletonOptions) { | 1107 NavigateFromOtherTabToSingletonOptions) { |
1096 { | 1108 { |
1097 ui_test_utils::WindowedNotificationObserver observer( | 1109 ui_test_utils::WindowedNotificationObserver observer( |
1098 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 1110 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
1099 browser()->OpenOptionsDialog(); | 1111 browser()->OpenOptionsDialog(); |
1100 observer.Wait(); | 1112 observer.Wait(); |
1101 } | 1113 } |
1102 { | 1114 { |
1103 ui_test_utils::WindowedNotificationObserver observer( | 1115 ui_test_utils::WindowedNotificationObserver observer( |
1104 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 1116 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
1105 browser()->AddSelectedTabWithURL(GetGoogleURL(), PageTransition::LINK); | 1117 browser()->AddSelectedTabWithURL( |
| 1118 GetGoogleURL(), content::PAGE_TRANSITION_LINK); |
1106 observer.Wait(); | 1119 observer.Wait(); |
1107 } | 1120 } |
1108 | 1121 |
1109 { | 1122 { |
1110 ui_test_utils::WindowedNotificationObserver observer( | 1123 ui_test_utils::WindowedNotificationObserver observer( |
1111 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 1124 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
1112 browser()->OpenOptionsDialog(); | 1125 browser()->OpenOptionsDialog(); |
1113 observer.Wait(); | 1126 observer.Wait(); |
1114 } | 1127 } |
1115 EXPECT_EQ(2, browser()->tab_count()); | 1128 EXPECT_EQ(2, browser()->tab_count()); |
(...skipping 16 matching lines...) Expand all Loading... |
1132 | 1145 |
1133 // Focus the omnibox. | 1146 // Focus the omnibox. |
1134 browser()->FocusLocationBar(); | 1147 browser()->FocusLocationBar(); |
1135 | 1148 |
1136 AutocompleteEditController* controller = | 1149 AutocompleteEditController* controller = |
1137 browser()->window()->GetLocationBar()->location_entry()->model()-> | 1150 browser()->window()->GetLocationBar()->location_entry()->model()-> |
1138 controller(); | 1151 controller(); |
1139 | 1152 |
1140 // Simulate an alt-enter. | 1153 // Simulate an alt-enter. |
1141 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, | 1154 controller->OnAutocompleteAccept(url2, NEW_FOREGROUND_TAB, |
1142 PageTransition::TYPED, GURL()); | 1155 content::PAGE_TRANSITION_TYPED, GURL()); |
1143 | 1156 |
1144 // Make sure the second tab is selected. | 1157 // Make sure the second tab is selected. |
1145 EXPECT_EQ(1, browser()->active_index()); | 1158 EXPECT_EQ(1, browser()->active_index()); |
1146 | 1159 |
1147 // The tab contents should have the focus in the second tab. | 1160 // The tab contents should have the focus in the second tab. |
1148 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), | 1161 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), |
1149 VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 1162 VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
1150 | 1163 |
1151 // Go back to the first tab. The focus should not be in the omnibox. | 1164 // Go back to the first tab. The focus should not be in the omnibox. |
1152 browser()->SelectPreviousTab(); | 1165 browser()->SelectPreviousTab(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 1201 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
1189 browser()->ShowDownloadsTab(); | 1202 browser()->ShowDownloadsTab(); |
1190 observer.Wait(); | 1203 observer.Wait(); |
1191 } | 1204 } |
1192 EXPECT_EQ(1, browser()->tab_count()); | 1205 EXPECT_EQ(1, browser()->tab_count()); |
1193 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), | 1206 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), |
1194 browser()->GetSelectedTabContents()->GetURL()); | 1207 browser()->GetSelectedTabContents()->GetURL()); |
1195 } | 1208 } |
1196 | 1209 |
1197 } // namespace | 1210 } // namespace |
OLD | NEW |