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

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

Issue 330653004: Adds a field trial flag to control whether to use an alternate Instant search base page URL for pre… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/metrics/histogram_base.h" 7 #include "base/metrics/histogram_base.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 GetInstantURL(profile(), kDisableStartMargin, false)); 582 GetInstantURL(profile(), kDisableStartMargin, false));
583 583
584 // Enable suggest. No difference. 584 // Enable suggest. No difference.
585 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 585 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
586 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"), 586 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"),
587 GetInstantURL(profile(), kDisableStartMargin, false)); 587 GetInstantURL(profile(), kDisableStartMargin, false));
588 588
589 // Disable suggest. No Instant URL. 589 // Disable suggest. No Instant URL.
590 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false); 590 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, false);
591 EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false)); 591 EXPECT_EQ(GURL(), GetInstantURL(profile(), kDisableStartMargin, false));
592
593 // Use alternate Instant search base URL.
594 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
595 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
596 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1"));
597 EXPECT_EQ(GURL("https://foo.com/search?foo=foo&qbp=1#foo=foo&strk"),
598 GetInstantURL(profile(), kDisableStartMargin, false));
592 } 599 }
593 600
594 TEST_F(SearchTest, StartMarginCGI) { 601 TEST_F(SearchTest, StartMarginCGI) {
595 // No margin. 602 // No margin.
596 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 603 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
597 604
598 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"), 605 EXPECT_EQ(GURL("https://foo.com/instant?foo=foo#foo=foo&strk"),
599 GetInstantURL(profile(), kDisableStartMargin, false)); 606 GetInstantURL(profile(), kDisableStartMargin, false));
600 607
601 // With start margin. 608 // With start margin.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 } 689 }
683 690
684 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFieldTrial) { 691 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFieldTrial) {
685 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 692 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
686 "EmbeddedSearch", 693 "EmbeddedSearch",
687 "Group1 espv:80 prefetch_results:1")); 694 "Group1 espv:80 prefetch_results:1"));
688 EXPECT_TRUE(ShouldPrefetchSearchResults()); 695 EXPECT_TRUE(ShouldPrefetchSearchResults());
689 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); 696 EXPECT_EQ(80ul, EmbeddedSearchPageVersion());
690 } 697 }
691 698
699 TEST_F(SearchTest, ShouldUseAltInstantURL_DisabledViaFieldTrial) {
700 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
701 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:0"));
702 EXPECT_FALSE(ShouldUseAltInstantURL());
703 }
704
705 TEST_F(SearchTest, ShouldUseAltInstantURL_EnabledViaFieldTrial) {
706 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
707 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1"));
708 EXPECT_TRUE(ShouldUseAltInstantURL());
709 }
710
692 TEST_F(SearchTest, 711 TEST_F(SearchTest,
693 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { 712 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) {
694 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 713 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
695 "EmbeddedSearch", 714 "EmbeddedSearch",
696 "Group1 espv:80 prefetch_results:0 " 715 "Group1 espv:80 prefetch_results:0 "
697 "prerender_instant_url_on_omnibox_focus:1")); 716 "prerender_instant_url_on_omnibox_focus:1"));
698 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); 717 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus());
699 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); 718 EXPECT_EQ(80ul, EmbeddedSearchPageVersion());
700 } 719 }
701 720
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 } 1188 }
1170 1189
1171 TEST_F(OriginChipTest, CommandLineOnSrp) { 1190 TEST_F(OriginChipTest, CommandLineOnSrp) {
1172 CommandLine::ForCurrentProcess()->AppendSwitch( 1191 CommandLine::ForCurrentProcess()->AppendSwitch(
1173 switches::kEnableOriginChipOnSrp); 1192 switches::kEnableOriginChipOnSrp);
1174 EXPECT_TRUE(ShouldDisplayOriginChip()); 1193 EXPECT_TRUE(ShouldDisplayOriginChip());
1175 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); 1194 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition());
1176 } 1195 }
1177 1196
1178 } // namespace chrome 1197 } // namespace chrome
OLDNEW
« chrome/browser/search/search.cc ('K') | « chrome/browser/search/search.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698