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

Unified Diff: chrome/browser/search/search_unittest.cc

Issue 150033002: NTP: add histogram to track New Tab page URL status. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix doc. Created 6 years, 11 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
Index: chrome/browser/search/search_unittest.cc
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index 6d76b0a8dce01d14a886f802485d0485e35ce806..6d81ecc7abbe649ccbbf07ea3508a4808d35dba6 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -218,6 +218,11 @@ class SearchTest : public BrowserWithTestWindowTest {
contents->GetRenderProcessHost()->GetID());
}
+ content::BrowserContext* AsBrowserContext(Profile* profile) {
+ // Following implementation of FromBrowserContext:
+ return static_cast<Profile*>(profile);
+ }
+
scoped_ptr<base::FieldTrialList> field_trial_list_;
};
@@ -521,23 +526,33 @@ TEST_F(SearchTest, InstantCacheableNTPNavigationEntryNewProfile) {
controller.GetLastCommittedEntry()));
}
-TEST_F(SearchTest, UseLocalNTPInIncognito) {
- EXPECT_EQ(GURL(), chrome::GetNewTabPageURL(
- profile()->GetOffTheRecordProfile()));
+TEST_F(SearchTest, NoRewriteInIncognito) {
+ profile()->ForceIncognito(true);
+ EXPECT_EQ(GURL(), chrome::GetNewTabPageURL(profile()));
+ GURL new_tab_url(chrome::kChromeUINewTabURL);
+ EXPECT_FALSE(HandleNewTabURLRewrite(&new_tab_url, AsBrowserContext(
+ profile())));
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), new_tab_url);
}
TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) {
// Set an insecure new tab page URL and verify that it's ignored.
SetSearchProvider(true, true);
- EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
- chrome::GetNewTabPageURL(profile()));
+ EXPECT_EQ(GURL(), chrome::GetNewTabPageURL(profile()));
+ GURL new_tab_url(chrome::kChromeUINewTabURL);
+ EXPECT_TRUE(
+ HandleNewTabURLRewrite(&new_tab_url, AsBrowserContext(profile())));
+ EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
}
TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) {
// Set an insecure new tab page URL and verify that it's ignored.
SetSearchProvider(false, true);
- EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
- chrome::GetNewTabPageURL(profile()));
+ EXPECT_EQ(GURL(), chrome::GetNewTabPageURL(profile()));
+ GURL new_tab_url(chrome::kChromeUINewTabURL);
+ EXPECT_TRUE(
+ HandleNewTabURLRewrite(&new_tab_url, AsBrowserContext(profile())));
+ EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
}
TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
@@ -550,8 +565,11 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
hosts["foo.com"] = false;
url_filter->SetManualHosts(&hosts);
- EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
- chrome::GetNewTabPageURL(profile()));
+ EXPECT_EQ(GURL(), chrome::GetNewTabPageURL(profile()));
+ GURL new_tab_url(chrome::kChromeUINewTabURL);
+ EXPECT_TRUE(
+ HandleNewTabURLRewrite(&new_tab_url, AsBrowserContext(profile())));
+ EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), new_tab_url);
EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false));
}

Powered by Google App Engine
This is Rietveld 408576698