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

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: Respond to comments 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
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_view.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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
916 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
916 } 917 }
917 918
918 TEST_F(OriginChipTest, NoOriginChip) { 919 TEST_F(OriginChipTest, NoOriginChip) {
919 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 920 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
920 "EmbeddedSearch", "Group1 espv:2 origin_chip:0")); 921 "EmbeddedSearch", "Group1 espv:2 origin_chip:0"));
921 EXPECT_FALSE(ShouldDisplayOriginChip()); 922 EXPECT_FALSE(ShouldDisplayOriginChip());
923 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
924 }
925
926 TEST_F(OriginChipTest, OriginChipLeadingLocationBar) {
927 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
928 "EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
929 EXPECT_TRUE(ShouldDisplayOriginChip());
930 EXPECT_EQ(ORIGIN_CHIP_LEADING_LOCATION_BAR, GetOriginChipPosition());
931 }
932
933 TEST_F(OriginChipTest, OriginChipTrailingLocationBar) {
934 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
935 "EmbeddedSearch", "Group1 espv:2 origin_chip:2"));
936 EXPECT_TRUE(ShouldDisplayOriginChip());
937 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
938 }
939
940 TEST_F(OriginChipTest, OriginChipLeadingMenuButton) {
941 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
942 "EmbeddedSearch", "Group1 espv:2 origin_chip:3"));
943 EXPECT_TRUE(ShouldDisplayOriginChip());
944 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition());
945 }
946
947 TEST_F(OriginChipTest, OriginChipInvalidValue) {
948 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
949 "EmbeddedSearch", "Group1 espv:2 origin_chip:4"));
950 EXPECT_FALSE(ShouldDisplayOriginChip());
951 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
922 } 952 }
923 953
924 TEST_F(OriginChipTest, CommandLineNoOriginChip) { 954 TEST_F(OriginChipTest, CommandLineNoOriginChip) {
925 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableOriginChip); 955 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableOriginChip);
926 EXPECT_FALSE(ShouldDisplayOriginChip()); 956 EXPECT_FALSE(ShouldDisplayOriginChip());
957 EXPECT_EQ(ORIGIN_CHIP_DISABLED, GetOriginChipPosition());
927 958
928 // Command-line disable should override Finch. 959 // Command-line disable should override Finch.
929 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 960 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
930 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); 961 "EmbeddedSearch", "Group1 espv:2 origin_chip:1"));
931 EXPECT_FALSE(ShouldDisplayOriginChip()); 962 EXPECT_FALSE(ShouldDisplayOriginChip());
932 } 963 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 } 964 }
939 965
940 TEST_F(OriginChipTest, CommandLineOriginChip) { 966 TEST_F(OriginChipTest, CommandLineOriginChip) {
941 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip); 967 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip);
942 EXPECT_TRUE(ShouldDisplayOriginChip()); 968 EXPECT_TRUE(ShouldDisplayOriginChip());
969 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
970
971 // Command-line enable should override Finch.
972 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
973 "EmbeddedSearch", "Group1 espv:2 origin_chip:0"));
974 EXPECT_TRUE(ShouldDisplayOriginChip());
975 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
976 }
977
978 TEST_F(OriginChipTest, CommandLineOriginChipLeadingLocationBar) {
979 CommandLine::ForCurrentProcess()->AppendSwitch(
980 switches::kEnableOriginChipLeadingLocationBar);
981 EXPECT_TRUE(ShouldDisplayOriginChip());
982 EXPECT_EQ(ORIGIN_CHIP_LEADING_LOCATION_BAR, GetOriginChipPosition());
983 }
984
985 TEST_F(OriginChipTest, CommandLineOriginChipTrailingLocationBar) {
986 CommandLine::ForCurrentProcess()->AppendSwitch(
987 switches::kEnableOriginChipTrailingLocationBar);
988 EXPECT_TRUE(ShouldDisplayOriginChip());
989 EXPECT_EQ(ORIGIN_CHIP_TRAILING_LOCATION_BAR, GetOriginChipPosition());
990 }
991
992 TEST_F(OriginChipTest, CommandLineOriginChipLeadingMenuButton) {
993 CommandLine::ForCurrentProcess()->AppendSwitch(
994 switches::kEnableOriginChipLeadingMenuButton);
995 EXPECT_TRUE(ShouldDisplayOriginChip());
996 EXPECT_EQ(ORIGIN_CHIP_LEADING_MENU_BUTTON, GetOriginChipPosition());
943 } 997 }
944 998
945 } // namespace chrome 999 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/browser/ui/views/toolbar/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698