Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/search/search_unittest.cc

Issue 266263002: [OriginChip] Add an option to display only on search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 EXPECT_TRUE(ShouldDisplayOriginChip()); 1166 EXPECT_TRUE(ShouldDisplayOriginChip());
1167 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition()); 1167 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition());
1168 } 1168 }
1169 1169
1170 typedef SearchTest OriginChipV2Test; 1170 typedef SearchTest OriginChipV2Test;
1171 1171
1172 TEST_F(OriginChipV2Test, NotSet) { 1172 TEST_F(OriginChipV2Test, NotSet) {
1173 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1173 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1174 "EmbeddedSearch", "Group1 espv:2")); 1174 "EmbeddedSearch", "Group1 espv:2"));
1175 EXPECT_FALSE(ShouldDisplayOriginChipV2()); 1175 EXPECT_FALSE(ShouldDisplayOriginChipV2());
1176 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2HideTrigger()); 1176 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
1177 } 1177 }
1178 1178
1179 TEST_F(OriginChipV2Test, Disabled) { 1179 TEST_F(OriginChipV2Test, Disabled) {
1180 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1180 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1181 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:0")); 1181 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:0"));
1182 EXPECT_FALSE(ShouldDisplayOriginChipV2()); 1182 EXPECT_FALSE(ShouldDisplayOriginChipV2());
1183 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2HideTrigger()); 1183 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
1184 } 1184 }
1185 1185
1186 TEST_F(OriginChipV2Test, HideOnMouseRelease) { 1186 TEST_F(OriginChipV2Test, HideOnMouseRelease) {
1187 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1187 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1188 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1")); 1188 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1"));
1189 EXPECT_TRUE(ShouldDisplayOriginChipV2()); 1189 EXPECT_TRUE(ShouldDisplayOriginChipV2());
1190 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2HideTrigger()); 1190 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition());
1191 } 1191 }
1192 1192
1193 TEST_F(OriginChipV2Test, HideOnUserInput) { 1193 TEST_F(OriginChipV2Test, HideOnUserInput) {
1194 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1194 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1195 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:2")); 1195 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:2"));
1196 EXPECT_TRUE(ShouldDisplayOriginChipV2()); 1196 EXPECT_TRUE(ShouldDisplayOriginChipV2());
1197 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2HideTrigger()); 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());
1198 } 1205 }
1199 1206
1200 TEST_F(OriginChipV2Test, InvalidValue) { 1207 TEST_F(OriginChipV2Test, InvalidValue) {
1201 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1208 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1202 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:3")); 1209 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:4"));
1203 EXPECT_FALSE(ShouldDisplayOriginChipV2()); 1210 EXPECT_FALSE(ShouldDisplayOriginChipV2());
1204 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2HideTrigger()); 1211 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
1205 } 1212 }
1206 1213
1207 TEST_F(OriginChipV2Test, BothVersions) { 1214 TEST_F(OriginChipV2Test, BothVersions) {
1208 // With both the original and v2 origin chip experiments enabled, v2 should 1215 // With both the original and v2 origin chip experiments enabled, v2 should
1209 // disable the original. 1216 // disable the original.
1210 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1217 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1211 "EmbeddedSearch", "Group1 espv:2 origin_chip:1 origin_chip_v2:1")); 1218 "EmbeddedSearch", "Group1 espv:2 origin_chip:1 origin_chip_v2:1"));
1212 EXPECT_FALSE(ShouldDisplayOriginChip()); 1219 EXPECT_FALSE(ShouldDisplayOriginChip());
1213 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition()); 1220 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
1214 EXPECT_TRUE(ShouldDisplayOriginChipV2()); 1221 EXPECT_TRUE(ShouldDisplayOriginChipV2());
1215 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2HideTrigger()); 1222 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition());
1216 } 1223 }
1217 1224
1218 TEST_F(OriginChipV2Test, CommandLineDisabled) { 1225 TEST_F(OriginChipV2Test, CommandLineDisabled) {
1219 CommandLine::ForCurrentProcess()->AppendSwitch( 1226 CommandLine::ForCurrentProcess()->AppendSwitch(
1220 switches::kDisableOriginChipV2); 1227 switches::kDisableOriginChipV2);
1221 EXPECT_FALSE(ShouldDisplayOriginChipV2()); 1228 EXPECT_FALSE(ShouldDisplayOriginChipV2());
1222 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2HideTrigger()); 1229 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
1223 1230
1224 // Command-line disable should override the field trial. 1231 // Command-line disable should override the field trial.
1225 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 1232 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1226 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1")); 1233 "EmbeddedSearch", "Group1 espv:2 origin_chip_v2:1"));
1227 EXPECT_FALSE(ShouldDisplayOriginChipV2()); 1234 EXPECT_FALSE(ShouldDisplayOriginChipV2());
1228 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2HideTrigger()); 1235 EXPECT_EQ(ORIGIN_CHIP_V2_DISABLED, GetOriginChipV2Condition());
1229 } 1236 }
1230 1237
1231 TEST_F(OriginChipV2Test, CommandLineHideOnMouseRelease) { 1238 TEST_F(OriginChipV2Test, CommandLineHideOnMouseRelease) {
1232 CommandLine::ForCurrentProcess()->AppendSwitch( 1239 CommandLine::ForCurrentProcess()->AppendSwitch(
1233 switches::kEnableOriginChipV2HideOnMouseRelease); 1240 switches::kEnableOriginChipV2HideOnMouseRelease);
1234 EXPECT_TRUE(ShouldDisplayOriginChipV2()); 1241 EXPECT_TRUE(ShouldDisplayOriginChipV2());
1235 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2HideTrigger()); 1242 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE, GetOriginChipV2Condition());
1236 } 1243 }
1237 1244
1238 TEST_F(OriginChipV2Test, CommandLineHideOnUserInput) { 1245 TEST_F(OriginChipV2Test, CommandLineHideOnUserInput) {
1239 CommandLine::ForCurrentProcess()->AppendSwitch( 1246 CommandLine::ForCurrentProcess()->AppendSwitch(
1240 switches::kEnableOriginChipV2HideOnUserInput); 1247 switches::kEnableOriginChipV2HideOnUserInput);
1241 EXPECT_TRUE(ShouldDisplayOriginChipV2()); 1248 EXPECT_TRUE(ShouldDisplayOriginChipV2());
1242 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2HideTrigger()); 1249 EXPECT_EQ(ORIGIN_CHIP_V2_HIDE_ON_USER_INPUT, GetOriginChipV2Condition());
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());
1243 } 1257 }
1244 1258
1245 } // namespace chrome 1259 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698