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

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

Issue 134013004: [OriginChip] Add options for the position of the origin chip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 905 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
906 "EmbeddedSearch", "Group1 espv:2 display_search_button:4")); 906 "EmbeddedSearch", "Group1 espv:2 display_search_button:4"));
907 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions()); 907 EXPECT_EQ(DISPLAY_SEARCH_BUTTON_NEVER, GetDisplaySearchButtonConditions());
908 } 908 }
909 909
910 typedef SearchTest OriginChipTest; 910 typedef SearchTest OriginChipTest;
911 911
912 TEST_F(OriginChipTest, NotSet) { 912 TEST_F(OriginChipTest, NotSet) {
913 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 913 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
914 "EmbeddedSearch", "Group1 espv:2")); 914 "EmbeddedSearch", "Group1 espv:2"));
915 EXPECT_FALSE(ShouldDisplayOriginChip()); 915 EXPECT_FALSE(ShouldDisplayOriginChip());
msw 2014/01/10 18:26:04 nit: also check EXPECT_EQ(ORIGIN_CHIP_DISABLED, Ge
Justin Donnelly 2014/01/10 20:11:31 Oops, yeah, meant to add this everywhere but misse
916 } 916 }
917 917
918 TEST_F(OriginChipTest, NoOriginChip) { 918 TEST_F(OriginChipTest, NoOriginChip) {
919 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 919 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
920 "EmbeddedSearch", "Group1 espv:2 origin_chip:0")); 920 "EmbeddedSearch", "Group1 espv:2 origin_chip:0"));
921 EXPECT_FALSE(ShouldDisplayOriginChip()); 921 EXPECT_FALSE(ShouldDisplayOriginChip());
922 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
923 }
924
925 TEST_F(OriginChipTest, OriginChipLeftOfLocationBar) {
926 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
927 "EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
928 EXPECT_TRUE(ShouldDisplayOriginChip());
929 EXPECT_EQ(ORIGIN_CHIP_LEFT_OF_LOCATION_BAR, GetOriginChipPosition());
930 }
931
932 TEST_F(OriginChipTest, OriginChipRightOfLocationBar) {
933 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
934 "EmbeddedSearch", "Group1 espv:2 origin_chip:2"));
935 EXPECT_TRUE(ShouldDisplayOriginChip());
936 EXPECT_EQ(ORIGIN_CHIP_RIGHT_OF_LOCATION_BAR, GetOriginChipPosition());
937 }
938
939 TEST_F(OriginChipTest, OriginChipLeftOfMenu) {
940 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
941 "EmbeddedSearch", "Group1 espv:2 origin_chip:3"));
942 EXPECT_TRUE(ShouldDisplayOriginChip());
943 EXPECT_EQ(ORIGIN_CHIP_LEFT_OF_MENU, GetOriginChipPosition());
944 }
945
946 TEST_F(OriginChipTest, OriginChipInvalidValue) {
947 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
948 "EmbeddedSearch", "Group1 espv:2 origin_chip:4"));
949 EXPECT_FALSE(ShouldDisplayOriginChip());
950 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
922 } 951 }
923 952
924 TEST_F(OriginChipTest, CommandLineNoOriginChip) { 953 TEST_F(OriginChipTest, CommandLineNoOriginChip) {
925 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableOriginChip); 954 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableOriginChip);
926 EXPECT_FALSE(ShouldDisplayOriginChip()); 955 EXPECT_FALSE(ShouldDisplayOriginChip());
956 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
927 957
928 // Command-line disable should override Finch. 958 // Command-line disable should override Finch.
929 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 959 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
930 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); 960 "EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
931 EXPECT_FALSE(ShouldDisplayOriginChip()); 961 EXPECT_FALSE(ShouldDisplayOriginChip());
932 } 962 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
933
934 TEST_F(OriginChipTest, OriginChip) {
935 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
936 "EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
937 EXPECT_TRUE(ShouldDisplayOriginChip());
938 } 963 }
939 964
940 TEST_F(OriginChipTest, CommandLineOriginChip) { 965 TEST_F(OriginChipTest, CommandLineOriginChip) {
941 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip); 966 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip);
942 EXPECT_TRUE(ShouldDisplayOriginChip()); 967 EXPECT_TRUE(ShouldDisplayOriginChip());
968 EXPECT_EQ(ORIGIN_CHIP_RIGHT_OF_LOCATION_BAR, GetOriginChipPosition());
969
970 // Command-line enable should override Finch.
971 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
972 "EmbeddedSearch", "Group1 espv:2 origin_chip:0"));
973 EXPECT_TRUE(ShouldDisplayOriginChip());
974 EXPECT_EQ(ORIGIN_CHIP_RIGHT_OF_LOCATION_BAR, GetOriginChipPosition());
975 }
976
977 TEST_F(OriginChipTest, CommandLineOriginChipLeftOfLocationBar) {
978 CommandLine::ForCurrentProcess()->AppendSwitch(
979 switches::kEnableOriginChipLeftOfLocationBar);
980 EXPECT_TRUE(ShouldDisplayOriginChip());
981 EXPECT_EQ(ORIGIN_CHIP_LEFT_OF_LOCATION_BAR, GetOriginChipPosition());
982 }
983
984 TEST_F(OriginChipTest, CommandLineOriginChipRightOfLocationBar) {
985 CommandLine::ForCurrentProcess()->AppendSwitch(
986 switches::kEnableOriginChipRightOfLocationBar);
987 EXPECT_TRUE(ShouldDisplayOriginChip());
988 EXPECT_EQ(ORIGIN_CHIP_RIGHT_OF_LOCATION_BAR, GetOriginChipPosition());
989 }
990
991 TEST_F(OriginChipTest, CommandLineOriginChipLeftOfMenu) {
992 CommandLine::ForCurrentProcess()->AppendSwitch(
993 switches::kEnableOriginChipLeftOfMenu);
994 EXPECT_TRUE(ShouldDisplayOriginChip());
995 EXPECT_EQ(ORIGIN_CHIP_LEFT_OF_MENU, GetOriginChipPosition());
943 } 996 }
944 997
945 } // namespace chrome 998 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698