| 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 } | 682 } |
| 683 | 683 |
| 684 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFieldTrial) { | 684 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFieldTrial) { |
| 685 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 685 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 686 "EmbeddedSearch", | 686 "EmbeddedSearch", |
| 687 "Group1 espv:80 prefetch_results:1")); | 687 "Group1 espv:80 prefetch_results:1")); |
| 688 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 688 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 689 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 689 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 690 } | 690 } |
| 691 | 691 |
| 692 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaCommandLine) { |
| 693 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 694 switches::kPrefetchSearchResults); |
| 695 // Command-line enable should override Finch. |
| 696 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 697 "EmbeddedSearch", "Group1 espv:80 prefetch_results:0")); |
| 698 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 699 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 700 } |
| 701 |
| 702 TEST_F(SearchTest, |
| 703 ShouldAllowPrefetchNonDefaultMatch_PrefetchResultsFlagDisabled) { |
| 704 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 705 "EmbeddedSearch", |
| 706 "Group1 espv:80 prefetch_results:0 allow_prefetch_non_default_match:1")); |
| 707 EXPECT_FALSE(ShouldAllowPrefetchNonDefaultMatch()); |
| 708 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 709 } |
| 710 |
| 711 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_DisabledViaFieldTrial) { |
| 712 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 713 "EmbeddedSearch", |
| 714 "Group1 espv:89 prefetch_results:1 allow_prefetch_non_default_match:0")); |
| 715 EXPECT_FALSE(ShouldAllowPrefetchNonDefaultMatch()); |
| 716 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
| 717 } |
| 718 |
| 719 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_EnabledViaFieldTrial) { |
| 720 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 721 "EmbeddedSearch", |
| 722 "Group1 espv:80 prefetch_results:1 allow_prefetch_non_default_match:1")); |
| 723 EXPECT_TRUE(ShouldAllowPrefetchNonDefaultMatch()); |
| 724 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 725 } |
| 726 |
| 692 TEST_F(SearchTest, | 727 TEST_F(SearchTest, |
| 693 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { | 728 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { |
| 694 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 729 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 695 "EmbeddedSearch", | 730 "EmbeddedSearch", |
| 696 "Group1 espv:80 prefetch_results:0 " | 731 "Group1 espv:80 prefetch_results:0 " |
| 697 "prerender_instant_url_on_omnibox_focus:1")); | 732 "prerender_instant_url_on_omnibox_focus:1")); |
| 698 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); | 733 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 699 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 734 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 700 } | 735 } |
| 701 | 736 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 712 TEST_F(SearchTest, | 747 TEST_F(SearchTest, |
| 713 ShouldPrerenderInstantUrlOnOmniboxFocus_EnabledViaFieldTrial) { | 748 ShouldPrerenderInstantUrlOnOmniboxFocus_EnabledViaFieldTrial) { |
| 714 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 749 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 715 "EmbeddedSearch", | 750 "EmbeddedSearch", |
| 716 "Group1 espv:80 prefetch_results:1 " | 751 "Group1 espv:80 prefetch_results:1 " |
| 717 "prerender_instant_url_on_omnibox_focus:1")); | 752 "prerender_instant_url_on_omnibox_focus:1")); |
| 718 EXPECT_TRUE(ShouldPrerenderInstantUrlOnOmniboxFocus()); | 753 EXPECT_TRUE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 719 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 754 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 720 } | 755 } |
| 721 | 756 |
| 722 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaCommandLine) { | |
| 723 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 724 switches::kPrefetchSearchResults); | |
| 725 // Command-line enable should override Finch. | |
| 726 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 727 "EmbeddedSearch", | |
| 728 "Group1 espv:80 prefetch_results:0")); | |
| 729 EXPECT_TRUE(ShouldPrefetchSearchResults()); | |
| 730 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | |
| 731 } | |
| 732 | |
| 733 TEST_F(SearchTest, | 757 TEST_F(SearchTest, |
| 734 ShouldReuseInstantSearchBasePage_PrefetchResultsFlagDisabled) { | 758 ShouldReuseInstantSearchBasePage_PrefetchResultsFlagDisabled) { |
| 735 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 759 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 736 "EmbeddedSearch", | 760 "EmbeddedSearch", |
| 737 "Group1 espv:89 prefetch_results:0 reuse_instant_search_base_page:1")); | 761 "Group1 espv:89 prefetch_results:0 reuse_instant_search_base_page:1")); |
| 738 EXPECT_FALSE(ShouldPrefetchSearchResults()); | 762 EXPECT_FALSE(ShouldPrefetchSearchResults()); |
| 739 EXPECT_FALSE(ShouldReuseInstantSearchBasePage()); | 763 EXPECT_FALSE(ShouldReuseInstantSearchBasePage()); |
| 740 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | 764 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
| 741 } | 765 } |
| 742 | 766 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 } | 1191 } |
| 1168 | 1192 |
| 1169 TEST_F(OriginChipTest, CommandLineOnSrp) { | 1193 TEST_F(OriginChipTest, CommandLineOnSrp) { |
| 1170 CommandLine::ForCurrentProcess()->AppendSwitch( | 1194 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1171 switches::kEnableOriginChipOnSrp); | 1195 switches::kEnableOriginChipOnSrp); |
| 1172 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1196 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 1173 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); | 1197 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); |
| 1174 } | 1198 } |
| 1175 | 1199 |
| 1176 } // namespace chrome | 1200 } // namespace chrome |
| OLD | NEW |