diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 18:27:04 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 18:27:04 +0000 |
commit | bb89e748843dc73b37f269eb6140fd8e1d5f5a1a (patch) | |
tree | d1c30243f7b1efa03c0331a84d7985dcd66b1784 /chrome/browser/ui/browser_navigator_browsertest.cc | |
parent | 501a6c88d1db53f0beffa9049d32f4a49b4c8818 (diff) | |
download | chromium_src-bb89e748843dc73b37f269eb6140fd8e1d5f5a1a.zip chromium_src-bb89e748843dc73b37f269eb6140fd8e1d5f5a1a.tar.gz chromium_src-bb89e748843dc73b37f269eb6140fd8e1d5f5a1a.tar.bz2 |
DOMUI: Add |ignore_path| to NavigateParams and use this to implement opening a singleton settings window.
BUG=59889
TEST=none
Review URL: http://codereview.chromium.org/4145013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_navigator_browsertest.cc')
-rw-r--r-- | chrome/browser/ui/browser_navigator_browsertest.cc | 104 |
1 files changed, 102 insertions, 2 deletions
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 350ad5c..7bad301 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc @@ -2,14 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/browser_list.h" -#include "chrome/browser/browser_window.h" +#include "base/command_line.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_navigator.h" +#include "chrome/browser/ui/browser_window.h" +#include "chrome/common/chrome_switches.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" #include "ipc/ipc_message.h" @@ -57,6 +59,11 @@ class BrowserNavigatorTest : public InProcessBrowserTest { EXPECT_EQ(1u, BrowserList::size()); EXPECT_EQ(old_url, browser()->GetSelectedTabContents()->GetURL()); } + + // TODO(jhawkins): Remove once tabbed options are enabled by default. + virtual void SetUpCommandLine(CommandLine* command_line) { + command_line->AppendSwitch(switches::kEnableTabbedOptions); + } }; // This test verifies that when a navigation occurs within a tab, the tab count @@ -463,5 +470,98 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { EXPECT_EQ(1, p.browser->tab_count()); } +// This test verifies that constructing params with disposition = SINGLETON_TAB +// and |ignore_paths| = true 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) { + GURL url("http://www.google.com/"); + browser()->AddSelectedTabWithURL(url, PageTransition::LINK); + + // We should have one browser with 2 tabs, the 2nd selected. + EXPECT_EQ(1u, BrowserList::size()); + EXPECT_EQ(2, browser()->tab_count()); + EXPECT_EQ(1, browser()->selected_index()); + + // Navigate to a new singleton tab with a sub-page. + browser::NavigateParams p(MakeNavigateParams()); + p.disposition = SINGLETON_TAB; + p.url = GURL("chrome://settings/advanced"); + p.show_window = true; + p.ignore_path = true; + browser::Navigate(&p); + + // The last tab should now be selected and navigated to the sub-page of the + // URL. + EXPECT_EQ(browser(), p.browser); + EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(2, browser()->selected_index()); + EXPECT_EQ(GURL("chrome://settings/advanced"), + browser()->GetSelectedTabContents()->GetURL()); +} + +// This test verifies that constructing params with disposition = SINGLETON_TAB +// and |ignore_paths| = true 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) { + GURL singleton_url1("chrome://settings"); + 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/advanced"); + p.show_window = true; + p.ignore_path = true; + browser::Navigate(&p); + + // The middle tab should now be selected and navigated to the sub-page of the + // URL. + EXPECT_EQ(browser(), p.browser); + EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(1, browser()->selected_index()); + EXPECT_EQ(GURL("chrome://settings/advanced"), + browser()->GetSelectedTabContents()->GetURL()); +} + +// This test verifies that constructing params with disposition = SINGLETON_TAB +// and |ignore_paths| = true 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) { + 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.ignore_path = true; + browser::Navigate(&p); + + // The middle tab should now be selected and navigated to the sub-page of the + // URL. + EXPECT_EQ(browser(), p.browser); + EXPECT_EQ(3, browser()->tab_count()); + EXPECT_EQ(1, browser()->selected_index()); + EXPECT_EQ(GURL("chrome://settings/personal"), + browser()->GetSelectedTabContents()->GetURL()); +} } // namespace |