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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, ""}, | 246 {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""}, |
247 {chrome::kChromeSearchLocalNtpUrl, true, ""}, | 247 {chrome::kChromeSearchLocalNtpUrl, true, ""}, |
| 248 {chrome::kChromeSearchLocalGoogleNtpUrl, 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", true, ""}, |
250 {"https://foo.com/instant?strk=0", true, ""}, | 251 {"https://foo.com/instant?strk=0", true, ""}, |
251 {"https://foo.com/url?strk", true, ""}, | 252 {"https://foo.com/url?strk", true, ""}, |
252 {"https://foo.com/alt?strk", true, ""}, | 253 {"https://foo.com/alt?strk", true, ""}, |
253 {"http://foo.com/instant", false, "Non-HTTPS"}, | 254 {"http://foo.com/instant", false, "Non-HTTPS"}, |
254 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, | 255 {"http://foo.com/instant?strk", false, "Non-HTTPS"}, |
255 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, | 256 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"}, |
256 {"https://foo.com/instant", false, "No search terms replacement"}, | 257 {"https://foo.com/instant", false, "No search terms replacement"}, |
257 {"https://foo.com/?strk", false, "Non-exact path"}, | 258 {"https://foo.com/?strk", false, "Non-exact path"}, |
(...skipping 28 matching lines...) Expand all Loading... |
286 {"https://foo.com/url?strk&bar=", true, "No query terms"}, | 287 {"https://foo.com/url?strk&bar=", true, "No query terms"}, |
287 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, | 288 {"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"}, | 289 {"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"}, | 290 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, |
290 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, | 291 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, |
291 {"https://foo.com/instant", false, "No search terms replacement"}, | 292 {"https://foo.com/instant", false, "No search terms replacement"}, |
292 {"chrome://blank/", false, "Chrome scheme"}, | 293 {"chrome://blank/", false, "Chrome scheme"}, |
293 {"chrome-search//foo", false, "Chrome-search scheme"}, | 294 {"chrome-search//foo", false, "Chrome-search scheme"}, |
294 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, | 295 {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, |
295 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, | 296 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, |
| 297 {chrome::kChromeSearchLocalGoogleNtpUrl, true, "Local new tab page"}, |
296 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, | 298 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, |
297 }; | 299 }; |
298 | 300 |
299 TEST_F(SearchTest, InstantNTPExtendedEnabled) { | 301 TEST_F(SearchTest, InstantNTPExtendedEnabled) { |
300 EnableInstantExtendedAPIForTesting(); | 302 EnableInstantExtendedAPIForTesting(); |
301 AddTab(browser(), GURL("chrome://blank")); | 303 AddTab(browser(), GURL("chrome://blank")); |
302 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { | 304 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
303 const SearchTestCase& test = kInstantNTPTestCases[i]; | 305 const SearchTestCase& test = kInstantNTPTestCases[i]; |
304 NavigateAndCommitActiveTab(GURL(test.url)); | 306 NavigateAndCommitActiveTab(GURL(test.url)); |
305 const content::WebContents* contents = | 307 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); | 500 TemplateURL* template_url = new TemplateURL(profile(), data); |
499 // Takes ownership of |template_url|. | 501 // Takes ownership of |template_url|. |
500 template_url_service->Add(template_url); | 502 template_url_service->Add(template_url); |
501 template_url_service->SetDefaultSearchProvider(template_url); | 503 template_url_service->SetDefaultSearchProvider(template_url); |
502 } | 504 } |
503 | 505 |
504 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); | 506 EXPECT_FALSE(DefaultSearchProviderSupportsInstant(profile())); |
505 } | 507 } |
506 | 508 |
507 } // namespace chrome | 509 } // namespace chrome |
OLD | NEW |