Index: components/omnibox/autocomplete_result_unittest.cc |
diff --git a/components/omnibox/autocomplete_result_unittest.cc b/components/omnibox/autocomplete_result_unittest.cc |
index 9da4d45af8b4745b230d65eb06e4ef35a14ae492..c7ce401b9a2fcfcb434501448bfc480c75281e0e 100644 |
--- a/components/omnibox/autocomplete_result_unittest.cc |
+++ b/components/omnibox/autocomplete_result_unittest.cc |
@@ -557,172 +557,6 @@ TEST_F(AutocompleteResultTest, SortAndCullReorderForDefaultMatch) { |
} |
} |
- |
- |
-TEST_F(AutocompleteResultTest, SortAndCullWithDisableInlining) { |
- TestData data[] = { |
- { 0, 0, 1300 }, |
- { 1, 0, 1200 }, |
- { 2, 0, 1100 }, |
- { 3, 0, 1000 } |
- }; |
- |
- { |
- // Check that with the field trial disabled, we keep keep the first match |
- // first even if it has an inline autocompletion. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[0].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- AssertResultMatches(result, data, 4); |
- } |
- |
- // Enable the field trial to disable inlining. |
- { |
- std::map<std::string, std::string> params; |
- params[OmniboxFieldTrial::kDisableInliningRule] = "true"; |
- ASSERT_TRUE(variations::AssociateVariationParams( |
- OmniboxFieldTrial::kBundledExperimentFieldTrialName, "D", params)); |
- } |
- base::FieldTrialList::CreateFieldTrial( |
- OmniboxFieldTrial::kBundledExperimentFieldTrialName, "D"); |
- |
- { |
- // Now the first match should be demoted past the second. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[0].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- ASSERT_EQ(4U, result.size()); |
- EXPECT_EQ("http://b/", result.match_at(0)->destination_url.spec()); |
- EXPECT_EQ("http://a/", result.match_at(1)->destination_url.spec()); |
- EXPECT_EQ("http://c/", result.match_at(2)->destination_url.spec()); |
- EXPECT_EQ("http://d/", result.match_at(3)->destination_url.spec()); |
- } |
- |
- { |
- // But if there was no inline autocompletion on the first match, then |
- // the order should stay the same. This is true even if there are |
- // inline autocompletions elsewhere. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[2].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- AssertResultMatches(result, data, 4); |
- } |
- |
- { |
- // Try a more complicated situation. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[0].allowed_to_be_default_match = false; |
- matches[1].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- ASSERT_EQ(4U, result.size()); |
- EXPECT_EQ("http://c/", result.match_at(0)->destination_url.spec()); |
- EXPECT_EQ("http://a/", result.match_at(1)->destination_url.spec()); |
- EXPECT_EQ("http://b/", result.match_at(2)->destination_url.spec()); |
- EXPECT_EQ("http://d/", result.match_at(3)->destination_url.spec()); |
- } |
- |
- { |
- // Try another complicated situation. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[0].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- matches[1].allowed_to_be_default_match = false; |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- ASSERT_EQ(4U, result.size()); |
- EXPECT_EQ("http://c/", result.match_at(0)->destination_url.spec()); |
- EXPECT_EQ("http://a/", result.match_at(1)->destination_url.spec()); |
- EXPECT_EQ("http://b/", result.match_at(2)->destination_url.spec()); |
- EXPECT_EQ("http://d/", result.match_at(3)->destination_url.spec()); |
- } |
- |
- { |
- // Check that disaster doesn't strike if we can't demote the top inline |
- // autocompletion because every match either has a completion or isn't |
- // allowed to be the default match. In this case, we should leave |
- // everything untouched. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[0].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- matches[1].allowed_to_be_default_match = false; |
- matches[2].allowed_to_be_default_match = false; |
- matches[3].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- AssertResultMatches(result, data, 4); |
- } |
- |
- { |
- // Check a similar situation, except in this case the top match is not |
- // allowed to the default match, so it still needs to be demoted so we |
- // get a legal default match first. That match will have an inline |
- // autocompletion because we don't have any better options. |
- ACMatches matches; |
- PopulateAutocompleteMatches(data, arraysize(data), &matches); |
- matches[0].allowed_to_be_default_match = false; |
- matches[1].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- matches[2].allowed_to_be_default_match = false; |
- matches[3].inline_autocompletion = base::ASCIIToUTF16("completion"); |
- AutocompleteResult result; |
- result.AppendMatches(matches); |
- AutocompleteInput input(base::string16(), base::string16::npos, |
- std::string(), GURL(), |
- OmniboxEventProto::HOME_PAGE, false, false, false, |
- true, |
- TestSchemeClassifier()); |
- result.SortAndCull(input, template_url_service_.get()); |
- ASSERT_EQ(4U, result.size()); |
- EXPECT_EQ("http://b/", result.match_at(0)->destination_url.spec()); |
- EXPECT_EQ("http://a/", result.match_at(1)->destination_url.spec()); |
- EXPECT_EQ("http://c/", result.match_at(2)->destination_url.spec()); |
- EXPECT_EQ("http://d/", result.match_at(3)->destination_url.spec()); |
- } |
-} |
- |
TEST_F(AutocompleteResultTest, ShouldHideTopMatch) { |
base::FieldTrialList::CreateFieldTrial("InstantExtended", |
"Group1 hide_verbatim:1"); |