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

Unified Diff: chrome/browser/ui/browser_navigator_browsertest.cc

Issue 10941050: Second try of 157576 https://chromiumcodereview.appspot.com/10780013/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/history_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_navigator_browsertest.cc
===================================================================
--- chrome/browser/ui/browser_navigator_browsertest.cc (revision 157505)
+++ chrome/browser/ui/browser_navigator_browsertest.cc (working copy)
@@ -40,8 +40,7 @@
}
GURL GetSettingsURL() {
- return GURL(chrome::kChromeUIUberURL).Resolve(
- chrome::kChromeUISettingsHost + std::string("/"));
+ return GURL(chrome::kChromeUISettingsURL);
}
GURL GetContentSettingsURL() {
@@ -52,6 +51,20 @@
return GetSettingsURL().Resolve(chrome::kClearBrowserDataSubPage);
}
+// Converts long uber URLs ("chrome://chrome/foo/") to short (virtual) URLs
+// ("chrome://foo/"). This should be used to convert the return value of
+// WebContentsImpl::GetURL before comparison because it can return either the
+// real URL or the virtual URL.
+GURL ShortenUberURL(const GURL& url) {
+ std::string url_string = url.spec();
+ const std::string long_prefix = "chrome://chrome/";
+ const std::string short_prefix = "chrome://";
+ if (url_string.find(long_prefix) != 0)
+ return url;
+ url_string.replace(0, long_prefix.length(), short_prefix);
+ return GURL(url_string);
+}
+
} // namespace
chrome::NavigateParams BrowserNavigatorTest::MakeNavigateParams() const {
@@ -722,7 +735,7 @@
EXPECT_EQ(3, browser()->tab_count());
EXPECT_EQ(2, browser()->active_index());
EXPECT_EQ(GetContentSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
@@ -755,7 +768,7 @@
EXPECT_EQ(3, browser()->tab_count());
EXPECT_EQ(1, browser()->active_index());
EXPECT_EQ(GetContentSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
@@ -788,7 +801,7 @@
EXPECT_EQ(3, browser()->tab_count());
EXPECT_EQ(1, browser()->active_index());
EXPECT_EQ(GetClearBrowsingDataURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
@@ -820,7 +833,7 @@
EXPECT_EQ(3, browser()->tab_count());
EXPECT_EQ(1, browser()->active_index());
EXPECT_EQ(singleton_url1,
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
@@ -851,7 +864,7 @@
EXPECT_EQ(2, browser()->tab_count());
EXPECT_EQ(1, browser()->active_index());
EXPECT_EQ(singleton_url_target,
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// This test verifies that constructing params with disposition = SINGLETON_TAB
@@ -910,7 +923,7 @@
EXPECT_EQ(1u, BrowserList::size());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// Settings page is expected to always open in normal mode regardless
@@ -994,7 +1007,7 @@
}
EXPECT_EQ(1, browser()->tab_count());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
@@ -1012,7 +1025,7 @@
}
EXPECT_EQ(1, browser()->tab_count());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
@@ -1033,7 +1046,7 @@
}
EXPECT_EQ(1, browser()->tab_count());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
@@ -1053,7 +1066,7 @@
}
EXPECT_EQ(2, browser()->tab_count());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
@@ -1079,7 +1092,7 @@
}
EXPECT_EQ(2, browser()->tab_count());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
@@ -1144,7 +1157,7 @@
}
EXPECT_EQ(2, browser()->tab_count());
EXPECT_EQ(GetSettingsURL(),
- chrome::GetActiveWebContents(browser())->GetURL());
+ ShortenUberURL(chrome::GetActiveWebContents(browser())->GetURL()));
}
// Tests that when a new tab is opened from the omnibox, the focus is moved from
« no previous file with comments | « chrome/browser/history/history_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698