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)); |
} |