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, |
| 693 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { |
| 694 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 695 "EmbeddedSearch", |
| 696 "Group1 espv:80 prefetch_results:0 " |
| 697 "prerender_instant_url_on_omnibox_focus:1")); |
| 698 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 699 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 700 } |
| 701 |
| 702 TEST_F(SearchTest, |
| 703 ShouldPrerenderInstantUrlOnOmniboxFocus_DisabledViaFieldTrial) { |
| 704 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 705 "EmbeddedSearch", |
| 706 "Group1 espv:89 prefetch_results:1 " |
| 707 "prerender_instant_url_on_omnibox_focus:0")); |
| 708 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 709 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
| 710 } |
| 711 |
| 712 TEST_F(SearchTest, |
| 713 ShouldPrerenderInstantUrlOnOmniboxFocus_EnabledViaFieldTrial) { |
| 714 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 715 "EmbeddedSearch", |
| 716 "Group1 espv:80 prefetch_results:1 " |
| 717 "prerender_instant_url_on_omnibox_focus:1")); |
| 718 EXPECT_TRUE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 719 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 720 } |
| 721 |
692 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaCommandLine) { | 722 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaCommandLine) { |
693 CommandLine::ForCurrentProcess()->AppendSwitch( | 723 CommandLine::ForCurrentProcess()->AppendSwitch( |
694 switches::kPrefetchSearchResults); | 724 switches::kPrefetchSearchResults); |
695 // Command-line enable should override Finch. | 725 // Command-line enable should override Finch. |
696 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 726 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
697 "EmbeddedSearch", | 727 "EmbeddedSearch", |
698 "Group1 espv:80 prefetch_results:0")); | 728 "Group1 espv:80 prefetch_results:0")); |
699 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 729 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
700 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 730 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
701 } | 731 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 "EmbeddedSearch", "Group1 espv:2 google_local_ntp:0")); | 771 "EmbeddedSearch", "Group1 espv:2 google_local_ntp:0")); |
742 EXPECT_FALSE(ShouldShowGoogleLocalNTP()); | 772 EXPECT_FALSE(ShouldShowGoogleLocalNTP()); |
743 } | 773 } |
744 | 774 |
745 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_EnabledViaCommandLine) { | 775 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_EnabledViaCommandLine) { |
746 CommandLine::ForCurrentProcess()->AppendSwitch( | 776 CommandLine::ForCurrentProcess()->AppendSwitch( |
747 switches::kPrefetchSearchResults); | 777 switches::kPrefetchSearchResults); |
748 // Command-line enable should override Finch. | 778 // Command-line enable should override Finch. |
749 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 779 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
750 "EmbeddedSearch", | 780 "EmbeddedSearch", |
751 "Group1 espv:89 prefetch_results:0 reuse_instant_search_base_page:0")); | 781 "Group1 espv:89 prefetch_results:0 reuse_instant_search_base_page:1")); |
752 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 782 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
753 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); | 783 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); |
754 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | 784 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
755 } | 785 } |
756 | 786 |
757 TEST_F(SearchTest, IsNTPURL) { | 787 TEST_F(SearchTest, IsNTPURL) { |
758 GURL invalid_url; | 788 GURL invalid_url; |
759 GURL ntp_url(chrome::kChromeUINewTabURL); | 789 GURL ntp_url(chrome::kChromeUINewTabURL); |
760 GURL local_ntp_url(GetLocalInstantURL(profile())); | 790 GURL local_ntp_url(GetLocalInstantURL(profile())); |
761 | 791 |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 } | 1167 } |
1138 | 1168 |
1139 TEST_F(OriginChipTest, CommandLineOnSrp) { | 1169 TEST_F(OriginChipTest, CommandLineOnSrp) { |
1140 CommandLine::ForCurrentProcess()->AppendSwitch( | 1170 CommandLine::ForCurrentProcess()->AppendSwitch( |
1141 switches::kEnableOriginChipOnSrp); | 1171 switches::kEnableOriginChipOnSrp); |
1142 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1172 EXPECT_TRUE(ShouldDisplayOriginChip()); |
1143 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); | 1173 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); |
1144 } | 1174 } |
1145 | 1175 |
1146 } // namespace chrome | 1176 } // namespace chrome |
OLD | NEW |