| 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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); | 1077 "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); |
| 1078 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); | 1078 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 typedef SearchTest OriginChipTest; | 1081 typedef SearchTest OriginChipTest; |
| 1082 | 1082 |
| 1083 TEST_F(OriginChipTest, NotSet) { | 1083 TEST_F(OriginChipTest, NotSet) { |
| 1084 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1084 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1085 "EmbeddedSearch", "Group1 espv:2")); | 1085 "EmbeddedSearch", "Group1 espv:2")); |
| 1086 EXPECT_FALSE(ShouldDisplayOriginChip()); | 1086 EXPECT_FALSE(ShouldDisplayOriginChip()); |
| 1087 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); | 1087 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 TEST_F(OriginChipTest, Disabled) { | 1090 TEST_F(OriginChipTest, Disabled) { |
| 1091 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1091 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1092 "EmbeddedSearch", "Group1 espv:2 origin_chip:0")); | 1092 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:0")); |
| 1093 EXPECT_FALSE(ShouldDisplayOriginChip()); | 1093 EXPECT_FALSE(ShouldDisplayOriginChip()); |
| 1094 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); | 1094 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 TEST_F(OriginChipTest, OriginChipLeadingLocationBar) { | 1097 TEST_F(OriginChipTest, Enabled) { |
| 1098 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1098 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1099 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); | 1099 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1")); |
| 1100 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1100 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 1101 EXPECT_EQ(ORIGIN_CHIP_LEADING_LOCATION_BAR, GetOriginChipPosition()); | 1101 EXPECT_EQ(ORIGIN_CHIP_ENABLED, GetOriginChipCondition()); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 TEST_F(OriginChipTest, OriginChipTrailingLocationBar) { | 1104 TEST_F(OriginChipTest, Placeholder) { |
| 1105 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1105 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1106 "EmbeddedSearch", "Group1 espv:2 origin_chip:2")); | 1106 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:2")); |
| 1107 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1107 EXPECT_FALSE(ShouldDisplayOriginChip()); |
| 1108 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition()); | 1108 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); |
| 1109 } | 1109 } |
| 1110 | 1110 |
| 1111 TEST_F(OriginChipTest, OriginChipLeadingMenuButton) { | 1111 TEST_F(OriginChipTest, OnSrp) { |
| 1112 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1112 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1113 "EmbeddedSearch", "Group1 espv:2 origin_chip:3")); | 1113 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:3")); |
| 1114 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1114 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 1115 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition()); | 1115 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 TEST_F(OriginChipTest, OriginChipInvalidValue) { | 1118 TEST_F(OriginChipTest, InvalidValue) { |
| 1119 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1119 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1120 "EmbeddedSearch", "Group1 espv:2 origin_chip:4")); | 1120 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:4")); |
| 1121 EXPECT_FALSE(ShouldDisplayOriginChip()); | 1121 EXPECT_FALSE(ShouldDisplayOriginChip()); |
| 1122 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); | 1122 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 TEST_F(OriginChipTest, CommandLineDisabled) { | 1125 TEST_F(OriginChipTest, CommandLineDisabled) { |
| 1126 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableOriginChip); | 1126 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1127 switches::kDisableOriginChip); |
| 1127 EXPECT_FALSE(ShouldDisplayOriginChip()); | 1128 EXPECT_FALSE(ShouldDisplayOriginChip()); |
| 1128 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); | 1129 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); |
| 1129 | |
| 1130 // Command-line disable should override the field trial. | |
| 1131 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1132 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); | |
| 1133 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
| 1134 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); | |
| 1135 } | |
| 1136 | |
| 1137 TEST_F(OriginChipTest, CommandLineOriginChip) { | |
| 1138 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip); | |
| 1139 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
| 1140 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition()); | |
| 1141 | |
| 1142 // Command-line enable should override the field trial. | |
| 1143 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1144 "EmbeddedSearch", "Group1 espv:2 origin_chip:0")); | |
| 1145 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
| 1146 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition()); | |
| 1147 } | |
| 1148 | |
| 1149 TEST_F(OriginChipTest, CommandLineOriginChipLeadingLocationBar) { | |
| 1150 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1151 switches::kEnableOriginChipLeadingLocationBar); | |
| 1152 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
| 1153 EXPECT_EQ(ORIGIN_CHIP_LEADING_LOCATION_BAR, GetOriginChipPosition()); | |
| 1154 } | |
| 1155 | |
| 1156 TEST_F(OriginChipTest, CommandLineOriginChipTrailingLocationBar) { | |
| 1157 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1158 switches::kEnableOriginChipTrailingLocationBar); | |
| 1159 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
| 1160 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition()); | |
| 1161 } | |
| 1162 | |
| 1163 TEST_F(OriginChipTest, CommandLineOriginChipLeadingMenuButton) { | |
| 1164 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1165 switches::kEnableOriginChipLeadingMenuButton); | |
| 1166 EXPECT_TRUE(ShouldDisplayOriginChip()); | |
| 1167 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition()); | |
| 1168 } | |
| 1169 | |
| 1170 typedef SearchTest OriginChipV2Test; | |
| 1171 | |
| 1172 TEST_F(OriginChipV2Test, NotSet) { | |
| 1173 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1174 "EmbeddedSearch", "Group1 espv:2")); | |
| 1175 EXPECT_FALSE(ShouldDisplayOriginChipV2()); | |
| 1176 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition()); | |
| 1177 } | |
| 1178 | |
| 1179 TEST_F(OriginChipV2Test, Disabled) { | |
| 1180 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1181 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:0")); | |
| 1182 EXPECT_FALSE(ShouldDisplayOriginChipV2()); | |
| 1183 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition()); | |
| 1184 } | |
| 1185 | |
| 1186 TEST_F(OriginChipV2Test, HideOnMouseRelease) { | |
| 1187 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1188 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1")); | |
| 1189 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | |
| 1190 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition()); | |
| 1191 } | |
| 1192 | |
| 1193 TEST_F(OriginChipV2Test, HideOnUserInput) { | |
| 1194 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1195 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:2")); | |
| 1196 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | |
| 1197 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2Condition()); | |
| 1198 } | |
| 1199 | |
| 1200 TEST_F(OriginChipV2Test, OnSrp) { | |
| 1201 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1202 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:3")); | |
| 1203 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | |
| 1204 EXPECT_EQ(ORIGIN_CHIP_V2_ON_SRP, GetOriginChipV2Condition()); | |
| 1205 } | |
| 1206 | |
| 1207 TEST_F(OriginChipV2Test, InvalidValue) { | |
| 1208 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1209 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:4")); | |
| 1210 EXPECT_FALSE(ShouldDisplayOriginChipV2()); | |
| 1211 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition()); | |
| 1212 } | |
| 1213 | |
| 1214 TEST_F(OriginChipV2Test, BothVersions) { | |
| 1215 // With both the original and v2 origin chip experiments enabled, v2 should | |
| 1216 // disable the original. | |
| 1217 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 1218 "EmbeddedSearch", "Group1 espv:2 origin_chip:1 origin_chip_v2:1")); | |
| 1219 EXPECT_FALSE(ShouldDisplayOriginChip()); | |
| 1220 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); | |
| 1221 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | |
| 1222 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition()); | |
| 1223 } | |
| 1224 | |
| 1225 TEST_F(OriginChipV2Test, CommandLineDisabled) { | |
| 1226 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1227 switches::kDisableOriginChipV2); | |
| 1228 EXPECT_FALSE(ShouldDisplayOriginChipV2()); | |
| 1229 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition()); | |
| 1230 | 1130 |
| 1231 // Command-line disable should override the field trial. | 1131 // Command-line disable should override the field trial. |
| 1232 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 1132 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1233 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1")); | 1133 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1")); |
| 1234 EXPECT_FALSE(ShouldDisplayOriginChipV2()); | 1134 EXPECT_FALSE(ShouldDisplayOriginChip()); |
| 1235 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition()); | 1135 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipCondition()); |
| 1236 } | 1136 } |
| 1237 | 1137 |
| 1238 TEST_F(OriginChipV2Test, CommandLineHideOnMouseRelease) { | 1138 TEST_F(OriginChipTest, CommandLineEnabled) { |
| 1239 CommandLine::ForCurrentProcess()->AppendSwitch( | 1139 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip); |
| 1240 switches::kEnableOriginChipV2HideOnMouseRelease); | 1140 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 1241 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | 1141 EXPECT_EQ(ORIGIN_CHIP_ENABLED, GetOriginChipCondition()); |
| 1242 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition()); | |
| 1243 } | 1142 } |
| 1244 | 1143 |
| 1245 TEST_F(OriginChipV2Test, CommandLineHideOnUserInput) { | 1144 TEST_F(OriginChipTest, CommandLineOnSrp) { |
| 1246 CommandLine::ForCurrentProcess()->AppendSwitch( | 1145 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1247 switches::kEnableOriginChipV2HideOnUserInput); | 1146 switches::kEnableOriginChipOnSrp); |
| 1248 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | 1147 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 1249 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2Condition()); | 1148 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); |
| 1250 } | |
| 1251 | |
| 1252 TEST_F(OriginChipV2Test, CommandLineOnSrp) { | |
| 1253 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 1254 switches::kEnableOriginChipV2OnSrp); | |
| 1255 EXPECT_TRUE(ShouldDisplayOriginChipV2()); | |
| 1256 EXPECT_EQ(ORIGIN_CHIP_V2_ON_SRP, GetOriginChipV2Condition()); | |
| 1257 } | 1149 } |
| 1258 | 1150 |
| 1259 } // namespace chrome | 1151 } // namespace chrome |
| OLD | NEW |