diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-12 14:39:22 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-12 14:40:41 +0000 |
commit | 1736b4ede6df05fb9ced0c4c597f402a6046ac9f (patch) | |
tree | f15e284ebe9f9f0f89ecd87c3569959914c7a911 /components | |
parent | 535980d49413e42f0f9a3deb8e6e3e13a59b61d7 (diff) | |
download | chromium_src-1736b4ede6df05fb9ced0c4c597f402a6046ac9f.zip chromium_src-1736b4ede6df05fb9ced0c4c597f402a6046ac9f.tar.gz chromium_src-1736b4ede6df05fb9ced0c4c597f402a6046ac9f.tar.bz2 |
Move ShouldHideTopVerbatimMatch to components/search
To remove chrome/ dependency from AutocompleteResult
BUG=388504
TEST=components_unittest --gtest_filter="ShouldHideTopVerbatimTest.*"
Review URL: https://codereview.chromium.org/450663002
Cr-Commit-Position: refs/heads/master@{#288958}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288958 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r-- | components/search/search.cc | 8 | ||||
-rw-r--r-- | components/search/search.h | 5 | ||||
-rw-r--r-- | components/search/search_unittest.cc | 32 |
3 files changed, 45 insertions, 0 deletions
diff --git a/components/search/search.cc b/components/search/search.cc index 8689e51..d7e7276 100644 --- a/components/search/search.cc +++ b/components/search/search.cc @@ -35,6 +35,8 @@ const uint64 kEmbeddedSearchEnabledVersion = 2; const uint64 kEmbeddedPageVersionDefault = 2; #endif +const char kHideVerbatimFlagName[] = "hide_verbatim"; + // Constants for the field trial name and group prefix. // Note in M30 and below this field trial was named "InstantExtended" and in // M31 was renamed to EmbeddedSearch for clarity and cleanliness. Since we @@ -143,4 +145,10 @@ bool GetBoolValueForFlagWithDefault(const std::string& flag, return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); } +bool ShouldHideTopVerbatimMatch() { + FieldTrialFlags flags; + return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( + kHideVerbatimFlagName, false, flags); +} + } // namespace chrome diff --git a/components/search/search.h b/components/search/search.h index df27e60..6cc7927 100644 --- a/components/search/search.h +++ b/components/search/search.h @@ -54,6 +54,11 @@ bool GetBoolValueForFlagWithDefault(const std::string& flag, bool default_value, const FieldTrialFlags& flags); +// Returns true if 'hide_verbatim' flag is enabled in field trials +// to hide the top match in the native suggestions dropdown if it is a verbatim +// match. See comments on ShouldHideTopMatch in autocomplete_result.h. +bool ShouldHideTopVerbatimMatch(); + } // namespace chrome #endif // COMPONENTS_SEARCH_SEARCH_H_ diff --git a/components/search/search_unittest.cc b/components/search/search_unittest.cc index b8c4e1d..f4382cc 100644 --- a/components/search/search_unittest.cc +++ b/components/search/search_unittest.cc @@ -130,4 +130,36 @@ TEST_F(EmbeddedSearchFieldTrialTest, GetFieldTrialInfoControlFlags) { EXPECT_EQ(3ul, flags.size()); } +typedef EmbeddedSearchFieldTrialTest ShouldHideTopVerbatimTest; + +TEST_F(ShouldHideTopVerbatimTest, DoNotHideByDefault) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", + "Control")); + EXPECT_FALSE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, DoNotHideInInstantExtended) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", + "Group1")); + EXPECT_FALSE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, EnableByFlagInInstantExtended) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", + "Group1 hide_verbatim:1")); + EXPECT_TRUE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, EnableByFlagOutsideInstantExtended) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( + "EmbeddedSearch", "Controll1 hide_verbatim:1")); + EXPECT_TRUE(ShouldHideTopVerbatimMatch()); +} + +TEST_F(ShouldHideTopVerbatimTest, DisableByFlag) { + ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", + "Group1 hide_verbatim:0")); + EXPECT_FALSE(ShouldHideTopVerbatimMatch()); +} + } // namespace chrome |