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

Side by Side Diff: chrome/browser/instant/search_unittest.cc

Issue 12840003: Implement local NTP for fallback. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Respond to Samarth's comments. Created 7 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "chrome/browser/instant/search.h" 7 #include "chrome/browser/instant/search.h"
8 #include "chrome/browser/search_engines/template_url_service.h" 8 #include "chrome/browser/search_engines/template_url_service.h"
9 #include "chrome/browser/search_engines/template_url_service_factory.h" 9 #include "chrome/browser/search_engines/template_url_service_factory.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) 132 ShouldAssignURLToInstantRenderer(GURL(test.url), profile()))
133 << test.url << " " << test.comment; 133 << test.url << " " << test.comment;
134 } 134 }
135 } 135 }
136 136
137 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { 137 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) {
138 EnableInstantExtendedAPIForTesting(); 138 EnableInstantExtendedAPIForTesting();
139 139
140 const SearchTestCase kTestCases[] = { 140 const SearchTestCase kTestCases[] = {
141 {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""}, 141 {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""},
142 {chrome::kChromeSearchLocalNTPURL, true, ""},
142 {"https://foo.com/instant?strk", true, ""}, 143 {"https://foo.com/instant?strk", true, ""},
143 {"https://foo.com/instant#strk", true, ""}, 144 {"https://foo.com/instant#strk", true, ""},
144 {"https://foo.com/instant?strk=0", true, ""}, 145 {"https://foo.com/instant?strk=0", true, ""},
145 {"https://foo.com/url?strk", true, ""}, 146 {"https://foo.com/url?strk", true, ""},
146 {"https://foo.com/alt?strk", true, ""}, 147 {"https://foo.com/alt?strk", true, ""},
147 {"http://foo.com/instant", false, "Non-HTTPS"}, 148 {"http://foo.com/instant", false, "Non-HTTPS"},
148 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, 149 {"http://foo.com/instant?strk", false, "Non-HTTPS"},
149 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, 150 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"},
150 {"https://foo.com/instant", false, "No search terms replacement"}, 151 {"https://foo.com/instant", false, "No search terms replacement"},
151 {"https://foo.com/?strk", false, "Non-exact path"}, 152 {"https://foo.com/?strk", false, "Non-exact path"},
(...skipping 27 matching lines...) Expand all
179 {"https://foo.com/alt#strk", true, "Valid alternative URL"}, 180 {"https://foo.com/alt#strk", true, "Valid alternative URL"},
180 {"https://foo.com/url?strk&bar=", true, "No query terms"}, 181 {"https://foo.com/url?strk&bar=", true, "No query terms"},
181 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, 182 {"https://foo.com/url?strk&q=abc", true, "No query terms key"},
182 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, 183 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"},
183 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, 184 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"},
184 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, 185 {"http://foo.com/instant?strk=1", false, "Insecure URL"},
185 {"https://foo.com/instant", false, "No search terms replacement"}, 186 {"https://foo.com/instant", false, "No search terms replacement"},
186 {"chrome://blank/", false, "Chrome scheme"}, 187 {"chrome://blank/", false, "Chrome scheme"},
187 {"chrome-search//foo", false, "Chrome-search scheme"}, 188 {"chrome-search//foo", false, "Chrome-search scheme"},
188 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, 189 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"},
190 {chrome::kChromeSearchLocalNTPURL, true, "Local new tab page"},
samarth 2013/03/18 22:09:19 super nit: keep the columns aligned
jeremycho 2013/03/18 23:18:52 Done.
189 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, 191 {"https://bar.com/instant?strk=1", false, "Random non-search page"},
190 }; 192 };
191 193
192 TEST_F(SearchTest, InstantNTPExtendedEnabled) { 194 TEST_F(SearchTest, InstantNTPExtendedEnabled) {
193 EnableInstantExtendedAPIForTesting(); 195 EnableInstantExtendedAPIForTesting();
194 AddTab(browser(), GURL("chrome://blank")); 196 AddTab(browser(), GURL("chrome://blank"));
195 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { 197 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) {
196 const SearchTestCase& test = kInstantNTPTestCases[i]; 198 const SearchTestCase& test = kInstantNTPTestCases[i];
197 NavigateAndCommitActiveTab(GURL(test.url)); 199 NavigateAndCommitActiveTab(GURL(test.url));
198 const content::WebContents* contents = 200 const content::WebContents* contents =
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 EXPECT_EQ(GURL("http://myserver.com:9000/dev?bar=bar&strk#bar=bar"), 310 EXPECT_EQ(GURL("http://myserver.com:9000/dev?bar=bar&strk#bar=bar"),
309 GetInstantURL(profile())); 311 GetInstantURL(profile()));
310 312
311 // Disable suggest. No Instant URL. 313 // Disable suggest. No Instant URL.
312 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false); 314 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false);
313 EXPECT_EQ(GURL(), GetInstantURL(profile())); 315 EXPECT_EQ(GURL(), GetInstantURL(profile()));
314 } 316 }
315 317
316 } // namespace search 318 } // namespace search
317 } // namespace chrome 319 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698