Chromium Code Reviews| 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..839e4331fa6b05a6f9b0d2b7e58ca96c51cfa518 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_result_unittest.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_result_unittest.cc |
| @@ -377,6 +377,67 @@ TEST_F(AutocompleteResultTest, SortAndCullWithDemotionsByType) { |
| result.match_at(2)->destination_url.spec()); |
| } |
| +TEST_F(AutocompleteResultTest, SortAndCullWithUndemotableTypes) { |
| + // Add some matches. |
| + ACMatches matches; |
| + { |
|
Peter Kasting
2013/11/05 04:09:55
Nit: Rather than these sub-blocks, you could simpl
H Fung
2013/11/05 06:11:27
Done.
|
| + AutocompleteMatch match; |
| + match.destination_url = GURL("http://history-url/"); |
| + match.relevance = 1400; |
| + match.allowed_to_be_default_match = true; |
| + match.type = AutocompleteMatchType::HISTORY_URL; |
| + matches.push_back(match); |
| + } |
| + { |
| + AutocompleteMatch match; |
| + match.destination_url = GURL("http://history-url2/"); |
| + match.relevance = 1300; |
| + match.allowed_to_be_default_match = true; |
| + match.type = AutocompleteMatchType::HISTORY_URL; |
| + matches.push_back(match); |
| + } |
| + { |
| + AutocompleteMatch match; |
| + match.destination_url = GURL("http://search-what-you-typed/"); |
| + match.relevance = 1200; |
| + match.allowed_to_be_default_match = true; |
| + match.type = AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED; |
| + matches.push_back(match); |
| + } |
| + |
| + // Add a rule demoting history-url, but don't demote the top match. |
| + { |
| + std::map<std::string, std::string> params; |
| + params[std::string(OmniboxFieldTrial::kDemoteByTypeRule) + ":3:*"] = |
| + "1:50"; // 3 == HOME_PAGE |
|
Peter Kasting
2013/11/05 04:09:55
Nit: Since the '3' is not on the same physical lin
H Fung
2013/11/05 06:11:27
Done. I kept the comment since HOME_PAGE is used
|
| + params[std::string(OmniboxFieldTrial::kUndemotableTopTypeRule) + ":3:*"] = |
| + "1,5"; // 3 == HOME_PAGE |
| + 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://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 }, |