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

Unified Diff: chrome/browser/autocomplete/autocomplete_result_unittest.cc

Issue 55413002: Don't demote top match for certain match types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's comments Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_result.cc ('k') | chrome/browser/omnibox/omnibox_field_trial.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_result_unittest.cc
diff --git a/chrome/browser/autocomplete/autocomplete_result_unittest.cc b/chrome/browser/autocomplete/autocomplete_result_unittest.cc
index babf1ae2cf5d4768004eeab36a37811a54eddd8e..ab152fbce338c65d32f2cd1f202428720a9b84f7 100644
--- a/chrome/browser/autocomplete/autocomplete_result_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_result_unittest.cc
@@ -377,6 +377,56 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDemotionsByType) {
result.match_at(2)->destination_url.spec());
}
+TEST_F(AutocompleteResultTest, SortAndCullWithUndemotableTypes) {
+ // Add some matches.
+ ACMatches matches(3);
+ matches[0].destination_url = GURL("http://top-history-url/");
+ matches[0].relevance = 1400;
+ matches[0].allowed_to_be_default_match = true;
+ matches[0].type = AutocompleteMatchType::HISTORY_URL;
+ matches[1].destination_url = GURL("http://history-url2/");
+ matches[1].relevance = 1300;
+ matches[1].allowed_to_be_default_match = true;
+ matches[1].type = AutocompleteMatchType::HISTORY_URL;
+ matches[2].destination_url = GURL("http://search-what-you-typed/");
+ matches[2].relevance = 1200;
+ matches[2].allowed_to_be_default_match = true;
+ matches[2].type = AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED;
+
+ // Add a rule demoting history-url, but don't demote the top match.
+ {
+ std::map<std::string, std::string> params;
+ // 3 == HOME_PAGE
+ params[std::string(OmniboxFieldTrial::kDemoteByTypeRule) + ":3:*"] =
+ "1:50";
+ params[std::string(OmniboxFieldTrial::kUndemotableTopTypeRule) + ":3:*"] =
+ "1,5";
+ ASSERT_TRUE(chrome_variations::AssociateVariationParams(
+ OmniboxFieldTrial::kBundledExperimentFieldTrialName, "B", params));
+ }
+ base::FieldTrialList::CreateFieldTrial(
+ OmniboxFieldTrial::kBundledExperimentFieldTrialName, "B");
+
+ AutocompleteResult result;
+ result.AppendMatches(matches);
+ AutocompleteInput input(string16(), string16::npos, string16(), GURL(),
+ AutocompleteInput::HOME_PAGE, false, false, false,
+ AutocompleteInput::ALL_MATCHES);
+ result.SortAndCull(input, test_util_.profile());
+
+ // Check the new ordering. The first history-url result should not be
+ // demoted, but the second result should be.
+ // We cannot check relevance scores because the matches are sorted by
+ // demoted relevance but the actual relevance scores are not modified.
+ ASSERT_EQ(3u, result.size());
+ EXPECT_EQ("http://top-history-url/",
+ result.match_at(0)->destination_url.spec());
+ EXPECT_EQ("http://search-what-you-typed/",
+ result.match_at(1)->destination_url.spec());
+ EXPECT_EQ("http://history-url2/",
+ result.match_at(2)->destination_url.spec());
+}
+
TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) {
TestData data[] = {
{ 0, 0, 1300 },
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_result.cc ('k') | chrome/browser/omnibox/omnibox_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698