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/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 Loading... |
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 724 } |
718 | 725 |
719 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_EnabledViaFieldTrial) { | 726 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_EnabledViaFieldTrial) { |
720 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 727 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
721 "EmbeddedSearch", | 728 "EmbeddedSearch", |
722 "Group1 espv:80 prefetch_results:1 allow_prefetch_non_default_match:1")); | 729 "Group1 espv:80 prefetch_results:1 allow_prefetch_non_default_match:1")); |
723 EXPECT_TRUE(ShouldAllowPrefetchNonDefaultMatch()); | 730 EXPECT_TRUE(ShouldAllowPrefetchNonDefaultMatch()); |
724 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 731 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
725 } | 732 } |
726 | 733 |
| 734 TEST_F(SearchTest, ShouldUseAltInstantURL_DisabledViaFieldTrial) { |
| 735 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 736 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:0")); |
| 737 EXPECT_FALSE(ShouldUseAltInstantURL()); |
| 738 } |
| 739 |
| 740 TEST_F(SearchTest, ShouldUseAltInstantURL_EnabledViaFieldTrial) { |
| 741 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 742 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1")); |
| 743 EXPECT_TRUE(ShouldUseAltInstantURL()); |
| 744 } |
| 745 |
727 TEST_F(SearchTest, | 746 TEST_F(SearchTest, |
728 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { | 747 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { |
729 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 748 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
730 "EmbeddedSearch", | 749 "EmbeddedSearch", |
731 "Group1 espv:80 prefetch_results:0 " | 750 "Group1 espv:80 prefetch_results:0 " |
732 "prerender_instant_url_on_omnibox_focus:1")); | 751 "prerender_instant_url_on_omnibox_focus:1")); |
733 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); | 752 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
734 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 753 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
735 } | 754 } |
736 | 755 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 } | 1212 } |
1194 | 1213 |
1195 TEST_F(OriginChipTest, CommandLineOnSrp) { | 1214 TEST_F(OriginChipTest, CommandLineOnSrp) { |
1196 CommandLine::ForCurrentProcess()->AppendSwitch( | 1215 CommandLine::ForCurrentProcess()->AppendSwitch( |
1197 switches::kEnableOriginChipOnSrp); | 1216 switches::kEnableOriginChipOnSrp); |
1198 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1217 EXPECT_TRUE(ShouldDisplayOriginChip()); |
1199 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); | 1218 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); |
1200 } | 1219 } |
1201 | 1220 |
1202 } // namespace chrome | 1221 } // namespace chrome |
OLD | NEW |