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

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

Issue 14043009: Fall back to local page if online NTP fails to load. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix failing tests Created 7 years, 7 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 | Annotate | Revision Log
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/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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 }; 292 };
293 293
294 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 294 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
295 const SearchTestCase& test = kTestCases[i]; 295 const SearchTestCase& test = kTestCases[i];
296 EXPECT_EQ(test.expected_result, 296 EXPECT_EQ(test.expected_result,
297 ShouldAssignURLToInstantRenderer(GURL(test.url), profile())) 297 ShouldAssignURLToInstantRenderer(GURL(test.url), profile()))
298 << test.url << " " << test.comment; 298 << test.url << " " << test.comment;
299 } 299 }
300 } 300 }
301 301
302 TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabledOverridden) {
303 EnableInstantExtendedAPIForTesting();
304
305 // Override the instant url with the command line flag.
306 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kInstantURL,
307 "http://bar.com/searchingfast");
308
309 // Existing Instant URLs should all work, plus new ones matching the override.
310 const SearchTestCase kTestCases[] = {
311 {chrome::kChromeSearchLocalNtpUrl, true, ""},
312 {chrome::kChromeSearchLocalGoogleNtpUrl, true, ""},
313 {"https://foo.com/instant?strk", true, ""},
314 {"https://foo.com/instant#strk", true, ""},
315 {"https://foo.com/instant?strk=0", true, ""},
316 {"https://foo.com/url?strk", true, ""},
317 {"https://foo.com/alt?strk", true, ""},
318 {"http://bar.com/searchingfast", true, ""},
319 {"http://bar.com/alt?strk", true, ""},
320 {"https://bar.com/searchingfast", true, ""},
321 {"http://foo.com/instant", false, "Non-HTTPS"},
322 {"http://foo.com/instant?strk", false, "Non-HTTPS"},
323 {"http://foo.com/instant?strk=1", false, "Non-HTTPS"},
324 {"https://foo.com/instant", false, "No search terms replacement"},
325 {"https://foo.com/?strk", false, "Non-exact path"},
326 {"https://www.bar.com/searchingfast", false, "Host mismatch"},
327 };
328
329 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
330 const SearchTestCase& test = kTestCases[i];
331 EXPECT_EQ(test.expected_result,
332 ShouldAssignURLToInstantRenderer(GURL(test.url), profile()))
333 << test.url << " " << test.comment;
334 }
335 }
sreeram 2013/05/03 23:17:31 Given my comment earlier about not doing "return t
David Black 2013/05/04 00:49:23 Done.
336
302 TEST_F(SearchTest, CoerceCommandLineURLToTemplateURL) { 337 TEST_F(SearchTest, CoerceCommandLineURLToTemplateURL) {
303 TemplateURL* template_url = 338 TemplateURL* template_url =
304 TemplateURLServiceFactory::GetForProfile(profile())-> 339 TemplateURLServiceFactory::GetForProfile(profile())->
305 GetDefaultSearchProvider(); 340 GetDefaultSearchProvider();
306 EXPECT_EQ( 341 EXPECT_EQ(
307 GURL("https://foo.com/dev?bar=bar#bar=bar"), 342 GURL("https://foo.com/dev?bar=bar#bar=bar"),
308 CoerceCommandLineURLToTemplateURL( 343 CoerceCommandLineURLToTemplateURL(
309 GURL("http://myserver.com:9000/dev?bar=bar#bar=bar"), 344 GURL("http://myserver.com:9000/dev?bar=bar#bar=bar"),
310 template_url->instant_url_ref(), kDisableStartMargin)); 345 template_url->instant_url_ref(), kDisableStartMargin));
311 } 346 }
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 601 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
567 602
568 // Now that suggest is back on and the instant url is good, the checkbox 603 // Now that suggest is back on and the instant url is good, the checkbox
569 // should be enabled and checked again. 604 // should be enabled and checked again.
570 EXPECT_TRUE(IsInstantCheckboxEnabled(profile())); 605 EXPECT_TRUE(IsInstantCheckboxEnabled(profile()));
571 EXPECT_TRUE(IsInstantCheckboxChecked(profile())); 606 EXPECT_TRUE(IsInstantCheckboxChecked(profile()));
572 } 607 }
573 608
574 609
575 } // namespace chrome 610 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698