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

Unified Diff: components/omnibox/autocomplete_result_unittest.cc

Issue 879053002: Remove Omnibox Disallow Inlining Field Trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
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");

Powered by Google App Engine
This is Rietveld 408576698