Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: chrome/browser/ui/browser_navigator_browsertest.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #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 "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 } // namespace 68 } // namespace
69 69
70 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const { 70 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const {
71 return MakeNavigateParams(browser()); 71 return MakeNavigateParams(browser());
72 } 72 }
73 73
74 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams( 74 chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams(
75 Browser* browser) const { 75 Browser* browser) const {
76 chrome::NavigateParams params(browser, GetGoogleURL(), 76 chrome::NavigateParams params(browser, GetGoogleURL(),
77 content::PAGE_TRANSITION_LINK); 77 ui::PAGE_TRANSITION_LINK);
78 params.window_action = chrome::NavigateParams::SHOW_WINDOW; 78 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
79 return params; 79 return params;
80 } 80 }
81 81
82 bool BrowserNavigatorTest::OpenPOSTURLInNewForegroundTabAndGetTitle( 82 bool BrowserNavigatorTest::OpenPOSTURLInNewForegroundTabAndGetTitle(
83 const GURL& url, const std::string& post_data, bool is_browser_initiated, 83 const GURL& url, const std::string& post_data, bool is_browser_initiated,
84 base::string16* title) { 84 base::string16* title) {
85 chrome::NavigateParams param(MakeNavigateParams()); 85 chrome::NavigateParams param(MakeNavigateParams());
86 param.disposition = NEW_FOREGROUND_TAB; 86 param.disposition = NEW_FOREGROUND_TAB;
87 param.url = url; 87 param.url = url;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Opening a Singleton tab that is already opened should not be opening a new 241 // Opening a Singleton tab that is already opened should not be opening a new
242 // tab nor be creating a new WebContents object. 242 // tab nor be creating a new WebContents object.
243 content::NotificationRegistrar registrar; 243 content::NotificationRegistrar registrar;
244 244
245 // As the registrar object goes out of scope, this will get unregistered 245 // As the registrar object goes out of scope, this will get unregistered
246 registrar.Add(this, 246 registrar.Add(this,
247 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 247 content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
248 content::NotificationService::AllSources()); 248 content::NotificationService::AllSources());
249 249
250 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 250 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
251 content::PAGE_TRANSITION_LINK); 251 ui::PAGE_TRANSITION_LINK);
252 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 252 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
253 content::PAGE_TRANSITION_LINK); 253 ui::PAGE_TRANSITION_LINK);
254 254
255 // We should have one browser with 3 tabs, the 3rd selected. 255 // We should have one browser with 3 tabs, the 3rd selected.
256 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 256 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
257 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 257 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
258 258
259 unsigned int previous_tab_contents_count = 259 unsigned int previous_tab_contents_count =
260 created_tab_contents_count_ = 0; 260 created_tab_contents_count_ = 0;
261 261
262 // Navigate to singleton_url1. 262 // Navigate to singleton_url1.
263 chrome::NavigateParams p(MakeNavigateParams()); 263 chrome::NavigateParams p(MakeNavigateParams());
(...skipping 10 matching lines...) Expand all
274 created_tab_contents_count_); 274 created_tab_contents_count_);
275 } 275 }
276 276
277 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 277 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
278 Disposition_SingletonTabRespectingRef) { 278 Disposition_SingletonTabRespectingRef) {
279 GURL singleton_ref_url1("http://maps.google.com/#a"); 279 GURL singleton_ref_url1("http://maps.google.com/#a");
280 GURL singleton_ref_url2("http://maps.google.com/#b"); 280 GURL singleton_ref_url2("http://maps.google.com/#b");
281 GURL singleton_ref_url3("http://maps.google.com/"); 281 GURL singleton_ref_url3("http://maps.google.com/");
282 282
283 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1, 283 chrome::AddSelectedTabWithURL(browser(), singleton_ref_url1,
284 content::PAGE_TRANSITION_LINK); 284 ui::PAGE_TRANSITION_LINK);
285 285
286 // We should have one browser with 2 tabs, 2nd selected. 286 // We should have one browser with 2 tabs, 2nd selected.
287 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 287 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
288 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 288 EXPECT_EQ(2, browser()->tab_strip_model()->count());
289 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 289 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
290 290
291 // Navigate to singleton_url2. 291 // Navigate to singleton_url2.
292 chrome::NavigateParams p(MakeNavigateParams()); 292 chrome::NavigateParams p(MakeNavigateParams());
293 p.disposition = SINGLETON_TAB; 293 p.disposition = SINGLETON_TAB;
294 p.url = singleton_ref_url2; 294 p.url = singleton_ref_url2;
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 772 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
773 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 773 EXPECT_EQ(2, browser()->tab_strip_model()->count());
774 } 774 }
775 775
776 // This test verifies that constructing params with disposition = SINGLETON_TAB 776 // This test verifies that constructing params with disposition = SINGLETON_TAB
777 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if 777 // and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if
778 // no previous tab with that URL (minus the path) exists. 778 // no previous tab with that URL (minus the path) exists.
779 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 779 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
780 Disposition_SingletonTabNew_IgnorePath) { 780 Disposition_SingletonTabNew_IgnorePath) {
781 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 781 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
782 content::PAGE_TRANSITION_LINK); 782 ui::PAGE_TRANSITION_LINK);
783 783
784 // We should have one browser with 2 tabs, the 2nd selected. 784 // We should have one browser with 2 tabs, the 2nd selected.
785 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 785 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
786 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 786 EXPECT_EQ(2, browser()->tab_strip_model()->count());
787 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 787 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
788 788
789 // Navigate to a new singleton tab with a sub-page. 789 // Navigate to a new singleton tab with a sub-page.
790 chrome::NavigateParams p(MakeNavigateParams()); 790 chrome::NavigateParams p(MakeNavigateParams());
791 p.disposition = SINGLETON_TAB; 791 p.disposition = SINGLETON_TAB;
792 p.url = GetContentSettingsURL(); 792 p.url = GetContentSettingsURL();
(...skipping 11 matching lines...) Expand all
804 GetActiveWebContents()->GetURL())); 804 GetActiveWebContents()->GetURL()));
805 } 805 }
806 806
807 // This test verifies that constructing params with disposition = SINGLETON_TAB 807 // This test verifies that constructing params with disposition = SINGLETON_TAB
808 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 808 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
809 // the path) which is navigated to the specified URL. 809 // the path) which is navigated to the specified URL.
810 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 810 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
811 Disposition_SingletonTabExisting_IgnorePath) { 811 Disposition_SingletonTabExisting_IgnorePath) {
812 GURL singleton_url1(GetSettingsURL()); 812 GURL singleton_url1(GetSettingsURL());
813 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 813 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
814 content::PAGE_TRANSITION_LINK); 814 ui::PAGE_TRANSITION_LINK);
815 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 815 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
816 content::PAGE_TRANSITION_LINK); 816 ui::PAGE_TRANSITION_LINK);
817 817
818 // We should have one browser with 3 tabs, the 3rd selected. 818 // We should have one browser with 3 tabs, the 3rd selected.
819 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 819 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
820 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 820 EXPECT_EQ(3, browser()->tab_strip_model()->count());
821 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 821 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
822 822
823 // Navigate to singleton_url1. 823 // Navigate to singleton_url1.
824 chrome::NavigateParams p(MakeNavigateParams()); 824 chrome::NavigateParams p(MakeNavigateParams());
825 p.disposition = SINGLETON_TAB; 825 p.disposition = SINGLETON_TAB;
826 p.url = GetContentSettingsURL(); 826 p.url = GetContentSettingsURL();
(...skipping 11 matching lines...) Expand all
838 GetActiveWebContents()->GetURL())); 838 GetActiveWebContents()->GetURL()));
839 } 839 }
840 840
841 // This test verifies that constructing params with disposition = SINGLETON_TAB 841 // This test verifies that constructing params with disposition = SINGLETON_TAB
842 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus 842 // and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
843 // the path) which is navigated to the specified URL. 843 // the path) which is navigated to the specified URL.
844 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 844 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
845 Disposition_SingletonTabExistingSubPath_IgnorePath) { 845 Disposition_SingletonTabExistingSubPath_IgnorePath) {
846 GURL singleton_url1(GetContentSettingsURL()); 846 GURL singleton_url1(GetContentSettingsURL());
847 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 847 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
848 content::PAGE_TRANSITION_LINK); 848 ui::PAGE_TRANSITION_LINK);
849 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 849 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
850 content::PAGE_TRANSITION_LINK); 850 ui::PAGE_TRANSITION_LINK);
851 851
852 // We should have one browser with 3 tabs, the 3rd selected. 852 // We should have one browser with 3 tabs, the 3rd selected.
853 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 853 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
854 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 854 EXPECT_EQ(3, browser()->tab_strip_model()->count());
855 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 855 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
856 856
857 // Navigate to singleton_url1. 857 // Navigate to singleton_url1.
858 chrome::NavigateParams p(MakeNavigateParams()); 858 chrome::NavigateParams p(MakeNavigateParams());
859 p.disposition = SINGLETON_TAB; 859 p.disposition = SINGLETON_TAB;
860 p.url = GetClearBrowsingDataURL(); 860 p.url = GetClearBrowsingDataURL();
(...skipping 11 matching lines...) Expand all
872 GetActiveWebContents()->GetURL())); 872 GetActiveWebContents()->GetURL()));
873 } 873 }
874 874
875 // This test verifies that constructing params with disposition = SINGLETON_TAB 875 // This test verifies that constructing params with disposition = SINGLETON_TAB
876 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus 876 // and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus
877 // the path). 877 // the path).
878 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 878 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
879 Disposition_SingletonTabExistingSubPath_IgnorePath2) { 879 Disposition_SingletonTabExistingSubPath_IgnorePath2) {
880 GURL singleton_url1(GetContentSettingsURL()); 880 GURL singleton_url1(GetContentSettingsURL());
881 chrome::AddSelectedTabWithURL(browser(), singleton_url1, 881 chrome::AddSelectedTabWithURL(browser(), singleton_url1,
882 content::PAGE_TRANSITION_LINK); 882 ui::PAGE_TRANSITION_LINK);
883 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 883 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
884 content::PAGE_TRANSITION_LINK); 884 ui::PAGE_TRANSITION_LINK);
885 885
886 // We should have one browser with 3 tabs, the 3rd selected. 886 // We should have one browser with 3 tabs, the 3rd selected.
887 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 887 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
888 EXPECT_EQ(3, browser()->tab_strip_model()->count()); 888 EXPECT_EQ(3, browser()->tab_strip_model()->count());
889 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); 889 EXPECT_EQ(2, browser()->tab_strip_model()->active_index());
890 890
891 // Navigate to singleton_url1. 891 // Navigate to singleton_url1.
892 chrome::NavigateParams p(MakeNavigateParams()); 892 chrome::NavigateParams p(MakeNavigateParams());
893 p.disposition = SINGLETON_TAB; 893 p.disposition = SINGLETON_TAB;
894 p.url = GetClearBrowsingDataURL(); 894 p.url = GetClearBrowsingDataURL();
(...skipping 10 matching lines...) Expand all
905 GetActiveWebContents()->GetURL())); 905 GetActiveWebContents()->GetURL()));
906 } 906 }
907 907
908 // This test verifies that constructing params with disposition = SINGLETON_TAB 908 // This test verifies that constructing params with disposition = SINGLETON_TAB
909 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently 909 // and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently
910 // selected tab is a match but has a different path. 910 // selected tab is a match but has a different path.
911 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 911 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
912 Disposition_SingletonTabFocused_IgnorePath) { 912 Disposition_SingletonTabFocused_IgnorePath) {
913 GURL singleton_url_current(GetContentSettingsURL()); 913 GURL singleton_url_current(GetContentSettingsURL());
914 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, 914 chrome::AddSelectedTabWithURL(browser(), singleton_url_current,
915 content::PAGE_TRANSITION_LINK); 915 ui::PAGE_TRANSITION_LINK);
916 916
917 // We should have one browser with 2 tabs, the 2nd selected. 917 // We should have one browser with 2 tabs, the 2nd selected.
918 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 918 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
919 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 919 EXPECT_EQ(2, browser()->tab_strip_model()->count());
920 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 920 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
921 921
922 // Navigate to a different settings path. 922 // Navigate to a different settings path.
923 GURL singleton_url_target(GetClearBrowsingDataURL()); 923 GURL singleton_url_target(GetClearBrowsingDataURL());
924 chrome::NavigateParams p(MakeNavigateParams()); 924 chrome::NavigateParams p(MakeNavigateParams());
925 p.disposition = SINGLETON_TAB; 925 p.disposition = SINGLETON_TAB;
(...skipping 12 matching lines...) Expand all
938 } 938 }
939 939
940 // This test verifies that constructing params with disposition = SINGLETON_TAB 940 // This test verifies that constructing params with disposition = SINGLETON_TAB
941 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different 941 // and IGNORE_AND_NAVIGATE will open an existing matching tab with a different
942 // query. 942 // query.
943 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 943 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
944 Disposition_SingletonTabExisting_IgnoreQuery) { 944 Disposition_SingletonTabExisting_IgnoreQuery) {
945 int initial_tab_count = browser()->tab_strip_model()->count(); 945 int initial_tab_count = browser()->tab_strip_model()->count();
946 GURL singleton_url_current("chrome://settings/internet"); 946 GURL singleton_url_current("chrome://settings/internet");
947 chrome::AddSelectedTabWithURL(browser(), singleton_url_current, 947 chrome::AddSelectedTabWithURL(browser(), singleton_url_current,
948 content::PAGE_TRANSITION_LINK); 948 ui::PAGE_TRANSITION_LINK);
949 949
950 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count()); 950 EXPECT_EQ(initial_tab_count + 1, browser()->tab_strip_model()->count());
951 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index()); 951 EXPECT_EQ(initial_tab_count, browser()->tab_strip_model()->active_index());
952 952
953 // Navigate to a different settings path. 953 // Navigate to a different settings path.
954 GURL singleton_url_target( 954 GURL singleton_url_target(
955 "chrome://settings/internet?" 955 "chrome://settings/internet?"
956 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1"); 956 "servicePath=/profile/ethernet_00aa00aa00aa&networkType=1");
957 chrome::NavigateParams p(MakeNavigateParams()); 957 chrome::NavigateParams p(MakeNavigateParams());
958 p.disposition = SINGLETON_TAB; 958 p.disposition = SINGLETON_TAB;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 view_source.append(chrome::kChromeUISettingsURL); 996 view_source.append(chrome::kChromeUISettingsURL);
997 RunUseNonIncognitoWindowTest(GURL(view_source)); 997 RunUseNonIncognitoWindowTest(GURL(view_source));
998 } 998 }
999 999
1000 // This test verifies that the settings page isn't opened in the incognito 1000 // This test verifies that the settings page isn't opened in the incognito
1001 // window from a non-incognito window (bookmark open-in-incognito trigger). 1001 // window from a non-incognito window (bookmark open-in-incognito trigger).
1002 // Disabled until fixed for uber settings: http://crbug.com/111243 1002 // Disabled until fixed for uber settings: http://crbug.com/111243
1003 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1003 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1004 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) { 1004 DISABLED_Disposition_Settings_UseNonIncognitoWindowForBookmark) {
1005 chrome::NavigateParams params(browser(), GetSettingsURL(), 1005 chrome::NavigateParams params(browser(), GetSettingsURL(),
1006 content::PAGE_TRANSITION_AUTO_BOOKMARK); 1006 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
1007 params.disposition = OFF_THE_RECORD; 1007 params.disposition = OFF_THE_RECORD;
1008 { 1008 {
1009 content::WindowedNotificationObserver observer( 1009 content::WindowedNotificationObserver observer(
1010 content::NOTIFICATION_LOAD_STOP, 1010 content::NOTIFICATION_LOAD_STOP,
1011 content::NotificationService::AllSources()); 1011 content::NotificationService::AllSources());
1012 chrome::Navigate(&params); 1012 chrome::Navigate(&params);
1013 observer.Wait(); 1013 observer.Wait();
1014 } 1014 }
1015 1015
1016 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1016 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
(...skipping 27 matching lines...) Expand all
1044 Disposition_Bookmarks_DoNothingIfIncognitoIsForced) { 1044 Disposition_Bookmarks_DoNothingIfIncognitoIsForced) {
1045 RunDoNothingIfIncognitoIsForcedTest(GURL(chrome::kChromeUIBookmarksURL)); 1045 RunDoNothingIfIncognitoIsForcedTest(GURL(chrome::kChromeUIBookmarksURL));
1046 } 1046 }
1047 1047
1048 // This test makes sure a crashed singleton tab reloads from a new navigation. 1048 // This test makes sure a crashed singleton tab reloads from a new navigation.
1049 // http://crbug.com/396371 1049 // http://crbug.com/396371
1050 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1050 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1051 DISABLED_NavigateToCrashedSingletonTab) { 1051 DISABLED_NavigateToCrashedSingletonTab) {
1052 GURL singleton_url(GetContentSettingsURL()); 1052 GURL singleton_url(GetContentSettingsURL());
1053 WebContents* web_contents = chrome::AddSelectedTabWithURL( 1053 WebContents* web_contents = chrome::AddSelectedTabWithURL(
1054 browser(), singleton_url, content::PAGE_TRANSITION_LINK); 1054 browser(), singleton_url, ui::PAGE_TRANSITION_LINK);
1055 1055
1056 // We should have one browser with 2 tabs, the 2nd selected. 1056 // We should have one browser with 2 tabs, the 2nd selected.
1057 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1057 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1058 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 1058 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1059 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 1059 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
1060 1060
1061 // Kill the singleton tab. 1061 // Kill the singleton tab.
1062 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 1062 web_contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
1063 EXPECT_TRUE(web_contents->IsCrashed()); 1063 EXPECT_TRUE(web_contents->IsCrashed());
1064 1064
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 content::NOTIFICATION_LOAD_STOP, 1213 content::NOTIFICATION_LOAD_STOP,
1214 content::NotificationService::AllSources()); 1214 content::NotificationService::AllSources());
1215 chrome::ShowSettings(browser()); 1215 chrome::ShowSettings(browser());
1216 observer.Wait(); 1216 observer.Wait();
1217 } 1217 }
1218 { 1218 {
1219 content::WindowedNotificationObserver observer( 1219 content::WindowedNotificationObserver observer(
1220 content::NOTIFICATION_LOAD_STOP, 1220 content::NOTIFICATION_LOAD_STOP,
1221 content::NotificationService::AllSources()); 1221 content::NotificationService::AllSources());
1222 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 1222 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
1223 content::PAGE_TRANSITION_LINK); 1223 ui::PAGE_TRANSITION_LINK);
1224 observer.Wait(); 1224 observer.Wait();
1225 } 1225 }
1226 1226
1227 // This load should simply cause a tab switch. 1227 // This load should simply cause a tab switch.
1228 chrome::ShowSettings(browser()); 1228 chrome::ShowSettings(browser());
1229 1229
1230 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 1230 EXPECT_EQ(2, browser()->tab_strip_model()->count());
1231 EXPECT_EQ(GetSettingsURL(), 1231 EXPECT_EQ(GetSettingsURL(),
1232 ShortenUberURL(browser()->tab_strip_model()-> 1232 ShortenUberURL(browser()->tab_strip_model()->
1233 GetActiveWebContents()->GetURL())); 1233 GetActiveWebContents()->GetURL()));
1234 } 1234 }
1235 1235
1236 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, CloseSingletonTab) { 1236 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, CloseSingletonTab) {
1237 for (int i = 0; i < 2; ++i) { 1237 for (int i = 0; i < 2; ++i) {
1238 content::WindowedNotificationObserver observer( 1238 content::WindowedNotificationObserver observer(
1239 content::NOTIFICATION_LOAD_STOP, 1239 content::NOTIFICATION_LOAD_STOP,
1240 content::NotificationService::AllSources()); 1240 content::NotificationService::AllSources());
1241 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(), 1241 chrome::AddSelectedTabWithURL(browser(), GetGoogleURL(),
1242 content::PAGE_TRANSITION_TYPED); 1242 ui::PAGE_TRANSITION_TYPED);
1243 observer.Wait(); 1243 observer.Wait();
1244 } 1244 }
1245 1245
1246 browser()->tab_strip_model()->ActivateTabAt(0, true); 1246 browser()->tab_strip_model()->ActivateTabAt(0, true);
1247 1247
1248 { 1248 {
1249 content::WindowedNotificationObserver observer( 1249 content::WindowedNotificationObserver observer(
1250 content::NOTIFICATION_LOAD_STOP, 1250 content::NOTIFICATION_LOAD_STOP,
1251 content::NotificationService::AllSources()); 1251 content::NotificationService::AllSources());
1252 chrome::ShowSettings(browser()); 1252 chrome::ShowSettings(browser());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 1307 EXPECT_EQ(1, browser()->tab_strip_model()->count());
1308 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL), 1308 EXPECT_EQ(GURL(chrome::kChromeUIDownloadsURL),
1309 browser()->tab_strip_model()->GetActiveWebContents()->GetURL()); 1309 browser()->tab_strip_model()->GetActiveWebContents()->GetURL());
1310 } 1310 }
1311 1311
1312 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1312 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1313 NavigateWithoutBrowser) { 1313 NavigateWithoutBrowser) {
1314 // First navigate using the profile of the existing browser window, and 1314 // First navigate using the profile of the existing browser window, and
1315 // check that the window is reused. 1315 // check that the window is reused.
1316 chrome::NavigateParams params(browser()->profile(), GetGoogleURL(), 1316 chrome::NavigateParams params(browser()->profile(), GetGoogleURL(),
1317 content::PAGE_TRANSITION_LINK); 1317 ui::PAGE_TRANSITION_LINK);
1318 ui_test_utils::NavigateToURL(&params); 1318 ui_test_utils::NavigateToURL(&params);
1319 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1319 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1320 1320
1321 // Now navigate using the incognito profile and check that a new window 1321 // Now navigate using the incognito profile and check that a new window
1322 // is created. 1322 // is created.
1323 chrome::NavigateParams params_incognito( 1323 chrome::NavigateParams params_incognito(
1324 browser()->profile()->GetOffTheRecordProfile(), 1324 browser()->profile()->GetOffTheRecordProfile(),
1325 GetGoogleURL(), content::PAGE_TRANSITION_LINK); 1325 GetGoogleURL(), ui::PAGE_TRANSITION_LINK);
1326 ui_test_utils::NavigateToURL(&params_incognito); 1326 ui_test_utils::NavigateToURL(&params_incognito);
1327 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 1327 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
1328 } 1328 }
1329 1329
1330 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, ViewSourceIsntSingleton) { 1330 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, ViewSourceIsntSingleton) {
1331 const std::string viewsource_ntp_url = 1331 const std::string viewsource_ntp_url =
1332 std::string(content::kViewSourceScheme) + ":" + 1332 std::string(content::kViewSourceScheme) + ":" +
1333 chrome::kChromeUIVersionURL; 1333 chrome::kChromeUIVersionURL;
1334 1334
1335 chrome::NavigateParams viewsource_params(browser(), 1335 chrome::NavigateParams viewsource_params(browser(),
1336 GURL(viewsource_ntp_url), 1336 GURL(viewsource_ntp_url),
1337 content::PAGE_TRANSITION_LINK); 1337 ui::PAGE_TRANSITION_LINK);
1338 ui_test_utils::NavigateToURL(&viewsource_params); 1338 ui_test_utils::NavigateToURL(&viewsource_params);
1339 1339
1340 chrome::NavigateParams singleton_params(browser(), 1340 chrome::NavigateParams singleton_params(browser(),
1341 GURL(chrome::kChromeUIVersionURL), 1341 GURL(chrome::kChromeUIVersionURL),
1342 content::PAGE_TRANSITION_LINK); 1342 ui::PAGE_TRANSITION_LINK);
1343 singleton_params.disposition = SINGLETON_TAB; 1343 singleton_params.disposition = SINGLETON_TAB;
1344 EXPECT_EQ(-1, chrome::GetIndexOfSingletonTab(&singleton_params)); 1344 EXPECT_EQ(-1, chrome::GetIndexOfSingletonTab(&singleton_params));
1345 } 1345 }
1346 1346
1347 // This test verifies that browser initiated navigations can send requests 1347 // This test verifies that browser initiated navigations can send requests
1348 // using POST. 1348 // using POST.
1349 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, 1349 IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
1350 SendBrowserInitiatedRequestUsingPOST) { 1350 SendBrowserInitiatedRequestUsingPOST) {
1351 // Uses a test sever to verify POST request. 1351 // Uses a test sever to verify POST request.
1352 ASSERT_TRUE(test_server()->Start()); 1352 ASSERT_TRUE(test_server()->Start());
(...skipping 17 matching lines...) Expand all
1370 // Open a renderer initiated POST request in new foreground tab. 1370 // Open a renderer initiated POST request in new foreground tab.
1371 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle)); 1371 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle));
1372 std::string post_data = kExpectedTitle; 1372 std::string post_data = kExpectedTitle;
1373 base::string16 title; 1373 base::string16 title;
1374 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle( 1374 ASSERT_TRUE(OpenPOSTURLInNewForegroundTabAndGetTitle(
1375 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title)); 1375 test_server()->GetURL(kEchoTitleCommand), post_data, false, &title));
1376 EXPECT_NE(expected_title, title); 1376 EXPECT_NE(expected_title, title);
1377 } 1377 }
1378 1378
1379 } // namespace 1379 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_navigator.cc ('k') | chrome/browser/ui/browser_tab_strip_model_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698