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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 | 869 |
870 TEST_F(IsQueryExtractionEnabledTest, EnabledViaCommandLine) { | 870 TEST_F(IsQueryExtractionEnabledTest, EnabledViaCommandLine) { |
871 EnableQueryExtractionForTesting(); | 871 EnableQueryExtractionForTesting(); |
872 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 872 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
873 "EmbeddedSearch", "Group1 espv:2 query_extraction:0")); | 873 "EmbeddedSearch", "Group1 espv:2 query_extraction:0")); |
874 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | 874 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); |
875 EXPECT_TRUE(IsQueryExtractionEnabled()); | 875 EXPECT_TRUE(IsQueryExtractionEnabled()); |
876 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | 876 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); |
877 } | 877 } |
878 | 878 |
879 typedef SearchTest DisplaySearchButtonTest; | |
880 | |
881 TEST_F(DisplaySearchButtonTest, NotSet) { | |
882 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
883 "EmbeddedSearch", "Group1 espv:2")); | |
884 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | |
885 } | |
886 | |
887 TEST_F(DisplaySearchButtonTest, Never) { | |
888 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
889 "EmbeddedSearch", "Group1 espv:2 display_search_button:0")); | |
890 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | |
891 } | |
892 | |
893 TEST_F(DisplaySearchButtonTest, CommandLineNever) { | |
894 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
895 switches::kDisableSearchButtonInOmnibox); | |
896 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | |
897 | |
898 // Command-line disable should override the field trial. | |
899 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
900 "EmbeddedSearch", "Group1 espv:2 display_search_button:1")); | |
901 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | |
902 } | |
903 | |
904 TEST_F(DisplaySearchButtonTest, ForSearchTermReplacement) { | |
905 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
906 "EmbeddedSearch", "Group1 espv:2 display_search_button:1")); | |
907 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR, GetDisplaySearchButtonConditions()); | |
908 } | |
909 | |
910 TEST_F(DisplaySearchButtonTest, CommandLineForSearchTermReplacement) { | |
911 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
912 switches::kEnableSearchButtonInOmniboxForStr); | |
913 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR, GetDisplaySearchButtonConditions()); | |
914 } | |
915 | |
916 TEST_F(DisplaySearchButtonTest, ForSearchTermReplacementOrInputInProgress) { | |
917 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
918 "EmbeddedSearch", "Group1 espv:2 display_search_button:2")); | |
919 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP, | |
920 GetDisplaySearchButtonConditions()); | |
921 } | |
922 | |
923 TEST_F(DisplaySearchButtonTest, | |
924 CommandLineForSearchTermReplacementOrInputInProgress) { | |
925 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
926 switches::kEnableSearchButtonInOmniboxForStrOrIip); | |
927 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP, | |
928 GetDisplaySearchButtonConditions()); | |
929 } | |
930 | |
931 TEST_F(DisplaySearchButtonTest, Always) { | |
932 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
933 "EmbeddedSearch", "Group1 espv:2 display_search_button:3")); | |
934 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_ALWAYS, GetDisplaySearchButtonConditions()); | |
935 } | |
936 | |
937 TEST_F(DisplaySearchButtonTest, CommandLineAlways) { | |
938 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
939 switches::kEnableSearchButtonInOmniboxAlways); | |
940 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_ALWAYS, GetDisplaySearchButtonConditions()); | |
941 } | |
942 | |
943 TEST_F(DisplaySearchButtonTest, InvalidValue) { | |
944 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
945 "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); | |
946 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | |
947 } | |
948 | |
949 } // namespace chrome | 879 } // namespace chrome |
OLD | NEW |