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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 switches::kEnableSearchButtonInOmniboxAlways); | 939 switches::kEnableSearchButtonInOmniboxAlways); |
940 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_ALWAYS, GetDisplaySearchButtonConditions()); | 940 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_ALWAYS, GetDisplaySearchButtonConditions()); |
941 } | 941 } |
942 | 942 |
943 TEST_F(DisplaySearchButtonTest, InvalidValue) { | 943 TEST_F(DisplaySearchButtonTest, InvalidValue) { |
944 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 944 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
945 "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); | 945 "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); |
946 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | 946 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); |
947 } | 947 } |
948 | 948 |
949 typedef SearchTest OriginChipTest; | |
950 | |
951 TEST_F(OriginChipTest, NotSet) { | |
952 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
953 "EmbeddedSearch", "Group1 espv:2")); | |
954 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
955 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); | |
956 } | |
957 | |
958 TEST_F(OriginChipTest, Disabled) { | |
959 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
960 "EmbeddedSearch", "Group1 espv:2 origin_chip:0")); | |
961 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
962 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); | |
963 } | |
964 | |
965 TEST_F(OriginChipTest, Always) { | |
966 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
967 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); | |
968 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
969 EXPECT_EQ(ORIGIN_CHIP_ALWAYS, GetOriginChipCondition()); | |
970 } | |
971 | |
972 TEST_F(OriginChipTest, OnSrp) { | |
973 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
974 "EmbeddedSearch", "Group1 espv:2 origin_chip:2")); | |
975 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
976 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); | |
977 } | |
978 | |
979 TEST_F(OriginChipTest, InvalidValue) { | |
980 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
981 "EmbeddedSearch", "Group1 espv:2 origin_chip:3")); | |
982 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
983 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); | |
984 } | |
985 | |
986 TEST_F(OriginChipTest, CommandLineDisabled) { | |
987 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
988 switches::kDisableOriginChip); | |
989 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
990 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); | |
991 | |
992 // Command-line disable should override the field trial. | |
993 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
994 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); | |
995 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
996 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); | |
997 } | |
998 | |
999 TEST_F(OriginChipTest, CommandLineAlways) { | |
1000 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
1001 switches::kEnableOriginChipAlways); | |
1002 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
1003 EXPECT_EQ(ORIGIN_CHIP_ALWAYS, GetOriginChipCondition()); | |
1004 } | |
1005 | |
1006 TEST_F(OriginChipTest, CommandLineOnSrp) { | |
1007 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
1008 switches::kEnableOriginChipOnSrp); | |
1009 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
1010 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); | |
1011 } | |
1012 | |
1013 } // namespace chrome | 949 } // namespace chrome |
OLD | NEW |