summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_navigator_browsertest.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 00:53:35 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 00:53:35 +0000
commit52eed12eccb82f5402aaf044c49ce101d02fce6c (patch)
tree0670bdeef0de52289de7fb58c854edcd1e681dd8 /chrome/browser/ui/browser_navigator_browsertest.cc
parentfaccfa6d5acf1d0b548bb23b2e42a8065a7623be (diff)
downloadchromium_src-52eed12eccb82f5402aaf044c49ce101d02fce6c.zip
chromium_src-52eed12eccb82f5402aaf044c49ce101d02fce6c.tar.gz
chromium_src-52eed12eccb82f5402aaf044c49ce101d02fce6c.tar.bz2
Change the behavior of ignore_path in BrowserNavigator.
use an enum instead. The enum controls whether to replace the path or leave it alone when bringing an already-open tab to the front. BUG=71472 TEST=included Review URL: http://codereview.chromium.org/6579047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76329 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_navigator_browsertest.cc')
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.cc55
1 files changed, 42 insertions, 13 deletions
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index a9d153c..a65c1f4 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -555,7 +555,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) {
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
-// and |ignore_path| = true opens a new tab navigated to the specified URL if
+// and IGNORE_AND_NAVIGATE opens a new tab navigated to the specified URL if
// no previous tab with that URL (minus the path) exists.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_SingletonTabNew_IgnorePath) {
@@ -572,7 +572,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = GURL("chrome://settings/advanced");
p.show_window = true;
- p.ignore_path = true;
+ p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
browser::Navigate(&p);
// The last tab should now be selected and navigated to the sub-page of the
@@ -585,7 +585,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
-// and |ignore_path| = true opens an existing tab with the matching URL (minus
+// and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
// the path) which is navigated to the specified URL.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_SingletonTabExisting_IgnorePath) {
@@ -604,7 +604,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = GURL("chrome://settings/advanced");
p.show_window = true;
- p.ignore_path = true;
+ p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
browser::Navigate(&p);
// The middle tab should now be selected and navigated to the sub-page of the
@@ -617,7 +617,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
-// and |ignore_path| = true opens an existing tab with the matching URL (minus
+// and IGNORE_AND_NAVIGATE opens an existing tab with the matching URL (minus
// the path) which is navigated to the specified URL.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_SingletonTabExistingSubPath_IgnorePath) {
@@ -636,7 +636,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = GURL("chrome://settings/personal");
p.show_window = true;
- p.ignore_path = true;
+ p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
browser::Navigate(&p);
// The middle tab should now be selected and navigated to the sub-page of the
@@ -649,7 +649,38 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
-// and |ignore_path| = true will update the current tab's URL if the currently
+// and IGNORE_AND_STAY_PUT opens an existing tab with the matching URL (minus
+// the path).
+IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
+ Disposition_SingletonTabExistingSubPath_IgnorePath2) {
+ GURL singleton_url1("chrome://settings/advanced");
+ GURL url("http://www.google.com/");
+ browser()->AddSelectedTabWithURL(singleton_url1, PageTransition::LINK);
+ browser()->AddSelectedTabWithURL(url, PageTransition::LINK);
+
+ // We should have one browser with 3 tabs, the 3rd selected.
+ EXPECT_EQ(1u, BrowserList::size());
+ EXPECT_EQ(3, browser()->tab_count());
+ EXPECT_EQ(2, browser()->selected_index());
+
+ // Navigate to singleton_url1.
+ browser::NavigateParams p(MakeNavigateParams());
+ p.disposition = SINGLETON_TAB;
+ p.url = GURL("chrome://settings/personal");
+ p.show_window = true;
+ p.path_behavior = browser::NavigateParams::IGNORE_AND_STAY_PUT;
+ browser::Navigate(&p);
+
+ // The middle tab should now be selected.
+ EXPECT_EQ(browser(), p.browser);
+ EXPECT_EQ(3, browser()->tab_count());
+ EXPECT_EQ(1, browser()->selected_index());
+ EXPECT_EQ(singleton_url1,
+ browser()->GetSelectedTabContents()->GetURL());
+}
+
+// This test verifies that constructing params with disposition = SINGLETON_TAB
+// and IGNORE_AND_NAVIGATE will update the current tab's URL if the currently
// selected tab is a match but has a different path.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_SingletonTabFocused_IgnorePath) {
@@ -668,7 +699,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = singleton_url_target;
p.show_window = true;
- p.ignore_path = true;
+ p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
browser::Navigate(&p);
// The second tab should still be selected, but navigated to the new path.
@@ -680,8 +711,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
-// and |ignore_path| = true will open an existing matching tab
-// with a different query.
+// and IGNORE_AND_NAVIGATE will open an existing matching tab with a different
+// query.
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
Disposition_SingletonTabExisting_IgnoreQuery) {
int initial_tab_count = browser()->tab_count();
@@ -699,7 +730,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = singleton_url_target;
p.show_window = true;
- p.ignore_path = true;
+ p.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE;
browser::Navigate(&p);
// Last tab should still be selected.
@@ -723,7 +754,6 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = GURL("chrome://settings");
p.show_window = true;
- p.ignore_path = true;
browser::Navigate(&p);
// The settings page should be opened in browser() window.
@@ -749,7 +779,6 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
p.disposition = SINGLETON_TAB;
p.url = GURL("chrome://bookmarks");
p.show_window = true;
- p.ignore_path = true;
browser::Navigate(&p);
// The bookmarks page should be opened in browser() window.