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

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

Issue 13905008: Merge local_omnibox_popup into local_ntp. Render the Google logo and fakebox if Google is the sear… (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Address Samarth's comments. Created 7 years, 8 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 e6035e20e675cc22114cad0cefb8a8b82e130278..7a22b1c69ac0bb113846e202638f4ff9c8c48d4f 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -201,6 +201,18 @@ class SearchTest : public BrowserWithTestWindowTest {
template_url_service->Add(template_url);
template_url_service->SetDefaultSearchProvider(template_url);
}
+
+ void SetGoogleAsSearchProvider() {
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile());
+ TemplateURLData data;
+ data.SetURL("http://www.google.com/");
+ data.instant_url = "http://www.google.com/";
+ TemplateURL* template_url = new TemplateURL(profile(), data);
+ // Takes ownership of |template_url|.
+ template_url_service->Add(template_url);
+ template_url_service->SetDefaultSearchProvider(template_url);
+ }
};
struct SearchTestCase {
@@ -243,8 +255,8 @@ TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) {
EnableInstantExtendedAPIForTesting();
const SearchTestCase kTestCases[] = {
- {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""},
{chrome::kChromeSearchLocalNtpUrl, true, ""},
+ {chrome::kChromeSearchLocalGoogleNtpUrl, true, ""},
{"https://foo.com/instant?strk", true, ""},
{"https://foo.com/instant#strk", true, ""},
{"https://foo.com/instant?strk=0", true, ""},
@@ -277,23 +289,23 @@ TEST_F(SearchTest, CoerceCommandLineURLToTemplateURL) {
}
const SearchTestCase kInstantNTPTestCases[] = {
- {"https://foo.com/instant?strk", true, "Valid Instant URL"},
- {"https://foo.com/instant#strk", true, "Valid Instant URL"},
- {"https://foo.com/url?strk", true, "Valid search URL"},
- {"https://foo.com/url#strk", true, "Valid search URL"},
- {"https://foo.com/alt?strk", true, "Valid alternative URL"},
- {"https://foo.com/alt#strk", true, "Valid alternative URL"},
- {"https://foo.com/url?strk&bar=", true, "No query terms"},
- {"https://foo.com/url?strk&q=abc", true, "No query terms key"},
- {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"},
- {"https://foo.com/url?strk&bar=abc", false, "Has query terms"},
- {"http://foo.com/instant?strk=1", false, "Insecure URL"},
- {"https://foo.com/instant", false, "No search terms replacement"},
- {"chrome://blank/", false, "Chrome scheme"},
- {"chrome-search//foo", false, "Chrome-search scheme"},
- {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"},
- {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"},
- {"https://bar.com/instant?strk=1", false, "Random non-search page"},
+ {"https://foo.com/instant?strk", true, "Valid Instant URL"},
+ {"https://foo.com/instant#strk", true, "Valid Instant URL"},
+ {"https://foo.com/url?strk", true, "Valid search URL"},
+ {"https://foo.com/url#strk", true, "Valid search URL"},
+ {"https://foo.com/alt?strk", true, "Valid alternative URL"},
+ {"https://foo.com/alt#strk", true, "Valid alternative URL"},
+ {"https://foo.com/url?strk&bar=", true, "No query terms"},
+ {"https://foo.com/url?strk&q=abc", true, "No query terms key"},
+ {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"},
+ {"https://foo.com/url?strk&bar=abc", false, "Has query terms"},
+ {"http://foo.com/instant?strk=1", false, "Insecure URL"},
+ {"https://foo.com/instant", false, "No search term replacement"},
+ {"chrome://blank/", false, "Chrome scheme"},
+ {"chrome-search//foo", false, "Chrome-search scheme"},
+ {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"},
+ {chrome::kChromeSearchLocalGoogleNtpUrl, true, "Local new tab page"},
+ {"https://bar.com/instant?strk=1", false, "Random non-search page"},
};
TEST_F(SearchTest, InstantNTPExtendedEnabled) {
@@ -302,6 +314,10 @@ TEST_F(SearchTest, InstantNTPExtendedEnabled) {
for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) {
const SearchTestCase& test = kInstantNTPTestCases[i];
NavigateAndCommitActiveTab(GURL(test.url));
+
+ if (test.url == chrome::kChromeSearchLocalGoogleNtpUrl)
+ SetGoogleAsSearchProvider();
+
const content::WebContents* contents =
browser()->tab_strip_model()->GetWebContentsAt(0);
EXPECT_EQ(test.expected_result, IsInstantNTP(contents))
@@ -326,6 +342,9 @@ TEST_F(SearchTest, InstantNTPCustomNavigationEntry) {
for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) {
const SearchTestCase& test = kInstantNTPTestCases[i];
NavigateAndCommitActiveTab(GURL(test.url));
+ if (test.url == chrome::kChromeSearchLocalGoogleNtpUrl)
+ SetGoogleAsSearchProvider();
+
content::WebContents* contents =
browser()->tab_strip_model()->GetWebContentsAt(0);
content::NavigationController& controller = contents->GetController();

Powered by Google App Engine
This is Rietveld 408576698