OLD | NEW |
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/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/search/search.h" | 8 #include "chrome/browser/search/search.h" |
9 #include "chrome/browser/search_engines/template_url_service.h" | 9 #include "chrome/browser/search_engines/template_url_service.h" |
10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 EXPECT_EQ(test.expected_result, | 236 EXPECT_EQ(test.expected_result, |
237 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) | 237 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) |
238 << test.url << " " << test.comment; | 238 << test.url << " " << test.comment; |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { | 242 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { |
243 EnableInstantExtendedAPIForTesting(); | 243 EnableInstantExtendedAPIForTesting(); |
244 | 244 |
245 const SearchTestCase kTestCases[] = { | 245 const SearchTestCase kTestCases[] = { |
246 {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""}, | |
247 {chrome::kChromeSearchLocalNtpUrl, true, ""}, | 246 {chrome::kChromeSearchLocalNtpUrl, true, ""}, |
| 247 {chrome::kChromeSearchLocalGoogleNtpUrl, true, ""}, |
248 {"https://foo.com/instant?strk", true, ""}, | 248 {"https://foo.com/instant?strk", true, ""}, |
249 {"https://foo.com/instant#strk", true, ""}, | 249 {"https://foo.com/instant#strk", true, ""}, |
250 {"https://foo.com/instant?strk=0", true, ""}, | 250 {"https://foo.com/instant?strk=0", true, ""}, |
251 {"https://foo.com/url?strk", true, ""}, | 251 {"https://foo.com/url?strk", true, ""}, |
252 {"https://foo.com/alt?strk", true, ""}, | 252 {"https://foo.com/alt?strk", true, ""}, |
253 {"http://foo.com/instant", false, "Non-HTTPS"}, | 253 {"http://foo.com/instant", false, "Non-HTTPS"}, |
254 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, | 254 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, |
255 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, | 255 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, |
256 {"https://foo.com/instant", false, "No search terms replacement"}, | 256 {"https://foo.com/instant", false, "No search terms replacement"}, |
257 {"https://foo.com/?strk", false, "Non-exact path"}, | 257 {"https://foo.com/?strk", false, "Non-exact path"}, |
(...skipping 26 matching lines...) Expand all Loading... |
284 {"https://foo.com/alt?strk", true, "Valid alternative URL"}, | 284 {"https://foo.com/alt?strk", true, "Valid alternative URL"}, |
285 {"https://foo.com/alt#strk", true, "Valid alternative URL"}, | 285 {"https://foo.com/alt#strk", true, "Valid alternative URL"}, |
286 {"https://foo.com/url?strk&bar=", true, "No query terms"}, | 286 {"https://foo.com/url?strk&bar=", true, "No query terms"}, |
287 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, | 287 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, |
288 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, | 288 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, |
289 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, | 289 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, |
290 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, | 290 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, |
291 {"https://foo.com/instant", false, "No search terms replacement"}, | 291 {"https://foo.com/instant", false, "No search terms replacement"}, |
292 {"chrome://blank/", false, "Chrome scheme"}, | 292 {"chrome://blank/", false, "Chrome scheme"}, |
293 {"chrome-search//foo", false, "Chrome-search scheme"}, | 293 {"chrome-search//foo", false, "Chrome-search scheme"}, |
294 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, | |
295 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, | 294 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, |
| 295 {chrome::kChromeSearchLocalGoogleNtpUrl, true, "Local new tab page"}, |
296 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, | 296 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, |
297 }; | 297 }; |
298 | 298 |
299 TEST_F(SearchTest, InstantNTPExtendedEnabled) { | 299 TEST_F(SearchTest, InstantNTPExtendedEnabled) { |
300 EnableInstantExtendedAPIForTesting(); | 300 EnableInstantExtendedAPIForTesting(); |
301 AddTab(browser(), GURL("chrome://blank")); | 301 AddTab(browser(), GURL("chrome://blank")); |
302 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { | 302 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
303 const SearchTestCase& test = kInstantNTPTestCases[i]; | 303 const SearchTestCase& test = kInstantNTPTestCases[i]; |
304 NavigateAndCommitActiveTab(GURL(test.url)); | 304 NavigateAndCommitActiveTab(GURL(test.url)); |
305 const content::WebContents* contents = | 305 const content::WebContents* contents = |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 TemplateURL* template_url = new TemplateURL(profile(), data); | 498 TemplateURL* template_url = new TemplateURL(profile(), data); |
499 // Takes ownership of |template_url|. | 499 // Takes ownership of |template_url|. |
500 template_url_service->Add(template_url); | 500 template_url_service->Add(template_url); |
501 template_url_service->SetDefaultSearchProvider(template_url); | 501 template_url_service->SetDefaultSearchProvider(template_url); |
502 } | 502 } |
503 | 503 |
504 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); | 504 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); |
505 } | 505 } |
506 | 506 |
507 } // namespace chrome | 507 } // namespace chrome |
OLD | NEW |