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

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

Issue 2204363003: Remove search::ShouldUseAltInstantURL and ShouldUseSearchPathForInstant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests Created 4 years, 4 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
« no previous file with comments | « chrome/browser/search/search.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 GetInstantURL(profile(), false)); 476 GetInstantURL(profile(), false));
477 477
478 // Enable suggest. No difference. 478 // Enable suggest. No difference.
479 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 479 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
480 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"), 480 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"),
481 GetInstantURL(profile(), false)); 481 GetInstantURL(profile(), false));
482 482
483 // Disable suggest. No Instant URL. 483 // Disable suggest. No Instant URL.
484 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false); 484 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false);
485 EXPECT_EQ(GURL(), GetInstantURL(profile(), false)); 485 EXPECT_EQ(GURL(), GetInstantURL(profile(), false));
486
487 // Use alternate Instant search base URL.
488 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
489 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
490 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1"));
491 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo&qbp=1#foo=foo&strk"),
492 GetInstantURL(profile(), false));
493 }
494
495 TEST_F(SearchTest, UseSearchPathForInstant) {
496 // Use alternate Instant search base URL path.
497 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
498 "EmbeddedSearch",
499 "Group1 use_alternate_instant_url:1 use_search_path_for_instant:1"));
500 EXPECT_EQ(GURL("https://foo.com/search?foo=foo&qbp=1#foo=foo&strk"),
501 GetInstantURL(profile(), false));
502 } 486 }
503 487
504 TEST_F(SearchTest, InstantSearchEnabledCGI) { 488 TEST_F(SearchTest, InstantSearchEnabledCGI) {
505 // Disable Instant Search. 489 // Disable Instant Search.
506 // Make sure {google:forceInstantResults} is not set in the Instant URL. 490 // Make sure {google:forceInstantResults} is not set in the Instant URL.
507 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"), 491 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"),
508 GetInstantURL(profile(), false)); 492 GetInstantURL(profile(), false));
509 493
510 // Enable Instant Search. 494 // Enable Instant Search.
511 // Make sure {google:forceInstantResults} is set in the Instant URL. 495 // Make sure {google:forceInstantResults} is set in the Instant URL.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 528
545 // If we specify extra search query params, they should be inserted into the 529 // If we specify extra search query params, they should be inserted into the
546 // query portion of the instant URL. 530 // query portion of the instant URL.
547 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 531 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
548 switches::kExtraSearchQueryParams, "a=b"); 532 switches::kExtraSearchQueryParams, "a=b");
549 instant_url = GetInstantURL(profile(), false); 533 instant_url = GetInstantURL(profile(), false);
550 ASSERT_TRUE(instant_url.is_valid()); 534 ASSERT_TRUE(instant_url.is_valid());
551 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec()); 535 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec());
552 } 536 }
553 537
554 TEST_F(SearchTest, ShouldUseAltInstantURL_DisabledViaFieldTrial) {
555 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
556 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:0"));
557 EXPECT_FALSE(ShouldUseAltInstantURL());
558 }
559
560 TEST_F(SearchTest, ShouldUseAltInstantURL_EnabledViaFieldTrial) {
561 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
562 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1"));
563 EXPECT_TRUE(ShouldUseAltInstantURL());
564 }
565
566 TEST_F(SearchTest, ShouldUseSearchPathForInstant_DisabledViaFieldTrial) {
567 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
568 "EmbeddedSearch",
569 "Group1 use_alternate_instant_url:1 use_search_path_for_instant:0"));
570 EXPECT_FALSE(ShouldUseSearchPathForInstant());
571 }
572
573 TEST_F(SearchTest, ShouldUseSearchPathForInstant_EnabledViaFieldTrial) {
574 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
575 "EmbeddedSearch",
576 "Group1 use_alternate_instant_url:1 use_search_path_for_instant:1"));
577 EXPECT_TRUE(ShouldUseSearchPathForInstant());
578 }
579
580
581 TEST_F(SearchTest, IsNTPURL) { 538 TEST_F(SearchTest, IsNTPURL) {
582 GURL invalid_url; 539 GURL invalid_url;
583 GURL ntp_url(chrome::kChromeUINewTabURL); 540 GURL ntp_url(chrome::kChromeUINewTabURL);
584 GURL local_ntp_url(chrome::kChromeSearchLocalNtpUrl); 541 GURL local_ntp_url(chrome::kChromeSearchLocalNtpUrl);
585 542
586 EXPECT_FALSE(IsNTPURL(invalid_url, profile())); 543 EXPECT_FALSE(IsNTPURL(invalid_url, profile()));
587 // No margin. 544 // No margin.
588 EnableQueryExtractionForTesting(); 545 EnableQueryExtractionForTesting();
589 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 546 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
590 GURL remote_ntp_url(GetInstantURL(profile(), false)); 547 GURL remote_ntp_url(GetInstantURL(profile(), false));
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 TemplateURLRef::SearchTermsArgs search_terms_args(base::ASCIIToUTF16("foo")); 695 TemplateURLRef::SearchTermsArgs search_terms_args(base::ASCIIToUTF16("foo"));
739 GURL result(template_url_->url_ref().ReplaceSearchTerms( 696 GURL result(template_url_->url_ref().ReplaceSearchTerms(
740 search_terms_args, UIThreadSearchTermsData(profile()))); 697 search_terms_args, UIThreadSearchTermsData(profile())));
741 ASSERT_TRUE(result.is_valid()); 698 ASSERT_TRUE(result.is_valid());
742 // Query extraction is disabled. Make sure 699 // Query extraction is disabled. Make sure
743 // {google:instantExtendedEnabledParameter} is not set in the search URL. 700 // {google:instantExtendedEnabledParameter} is not set in the search URL.
744 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec()); 701 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec());
745 } 702 }
746 703
747 } // namespace search 704 } // namespace search
OLDNEW
« no previous file with comments | « chrome/browser/search/search.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698