Commit 47735b42 authored by Maxim Kolosovskiy's avatar Maxim Kolosovskiy Committed by Commit Bot

Revert "[omnibox] Handle URL ellision a little more consistently"

This reverts commit 7999f246.

Reason for revert: components_unittests failures
HistoryQuickProviderTest.DontTrimHttpSchemeIfInputHasScheme
HistoryQuickProviderTest.DoTrimHttpsSchemeIfFlag
HistoryQuickProviderTest.DontTrimHttpsScheme
HistoryQuickProviderTest.DontTrimHttpsSchemeDespiteFlag
HistoryQuickProviderTest.DontTrimHttpSchemeIfInputMatches
HistoryQuickProviderTest.DoTrimHttpScheme
 
first failed build 
https://uberchromegw.corp.google.com/i/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/65092

Original change's description:
> [omnibox] Handle URL ellision a little more consistently
> 
> When the option hide-suggestion-url-scheme is enabled, Omnibox
> suggestions exclude the scheme in some cases where they would
> be inconsistent with other suggestions. This change preserves
> schemes when the user specified one.
> 
> This change asserts 'preserve_scheme' to GetFormatTypes() now
> if alternatively the input, interpretted as a URL, has a scheme.
> This changes the treatment of http (and https when certain flags
> are set.) Previously it was only asserted if there was a match
> in the scheme.
> 
> Added many tests as well.
> 
> Bug: 761505
> Change-Id: I189ececbfad3baf8214e3f289e0c994d3cee9d55
> Reviewed-on: https://chromium-review.googlesource.com/794432
> Commit-Queue: Kevin Bailey <krb@chromium.org>
> Reviewed-by: Mark Pearson <mpearson@chromium.org>
> Reviewed-by: Justin Donnelly <jdonnelly@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#523003}

TBR=mpearson@chromium.org,krb@chromium.org,jdonnelly@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 761505
Change-Id: I2f7f3f747c45204bd4d7507f348cbd8141da41aa
Reviewed-on: https://chromium-review.googlesource.com/817298Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Commit-Queue: Maxim Kolosovskiy <kolos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523070}
parent 4a7c779e
......@@ -2816,92 +2816,6 @@ TEST_F(SearchProviderTest, NavigationInlineDomainClassify) {
match.contents_class[2].style);
}
// Verifies that "http://" is trimmed in the general case.
TEST_F(SearchProviderTest, DoTrimHttpScheme) {
const base::string16 input(ASCIIToUTF16("face book"));
const base::string16 url(ASCIIToUTF16("http://www.facebook.com"));
SearchSuggestionParser::NavigationResult result(
ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
false, 0, false, input);
// Generate the contents and check for the presence of a scheme.
QueryForInput(input, false, false);
AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match_inline.contents);
}
// Verifies that "http://" is not trimmed for input that has a scheme, even if
// the input doesn't match the URL.
TEST_F(SearchProviderTest, DontTrimHttpSchemeIfInputHasScheme) {
const base::string16 input(ASCIIToUTF16("https://face book"));
const base::string16 url(ASCIIToUTF16("http://www.facebook.com"));
SearchSuggestionParser::NavigationResult result(
ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
false, 0, false, input);
// Generate the contents and check for the presence of a scheme.
QueryForInput(input, false, false);
AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
EXPECT_EQ(url, match_inline.contents);
}
// Verifies that "https://" is not trimmed for input in the general case.
TEST_F(SearchProviderTest, DontTrimHttpsScheme) {
const base::string16 input(ASCIIToUTF16("face book"));
const base::string16 url(ASCIIToUTF16("https://www.facebook.com"));
SearchSuggestionParser::NavigationResult result(
ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
false, 0, false, input);
// Generate the contents and check for the presence of a scheme.
QueryForInput(input, false, false);
AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
EXPECT_EQ(url, match_inline.contents);
}
// Verifies that "https://" is not trimmed for input that has a (non-matching)
// scheme, even if flag requests it.
TEST_F(SearchProviderTest, DontTrimHttpsSchemeDespiteFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitAndEnableFeature(
omnibox::kUIExperimentHideSuggestionUrlScheme);
const base::string16 input(ASCIIToUTF16("http://face book"));
const base::string16 url(ASCIIToUTF16("https://www.facebook.com"));
SearchSuggestionParser::NavigationResult result(
ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
false, 0, false, input);
// Generate the contents and check for the presence of a scheme.
QueryForInput(input, false, false);
AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
EXPECT_EQ(url, match_inline.contents);
}
// Verifies that "https://" is trimmed if the flag requests it, and
// nothing else would prevent it.
TEST_F(SearchProviderTest, DoTrimHttpsSchemeIfFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitAndEnableFeature(
omnibox::kUIExperimentHideSuggestionUrlScheme);
const base::string16 input(ASCIIToUTF16("face book"));
const base::string16 url(ASCIIToUTF16("https://www.facebook.com"));
SearchSuggestionParser::NavigationResult result(
ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
false, 0, false, input);
// Generate the contents and check for the presence of a scheme.
QueryForInput(input, false, false);
AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match_inline.contents);
}
#if !defined(OS_WIN)
// Verify entity suggestion parsing.
TEST_F(SearchProviderTest, ParseEntitySuggestion) {
......
......@@ -244,10 +244,9 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch(
OffsetsFromTermMatches(history_match.url_matches);
match.contents = url_formatter::FormatUrlWithOffsets(
info.url(),
AutocompleteMatch::GetFormatTypes(
autocomplete_input_.parts().scheme.len > 0 ||
history_match.match_in_scheme,
history_match.match_in_subdomain, history_match.match_after_host),
AutocompleteMatch::GetFormatTypes(history_match.match_in_scheme,
history_match.match_in_subdomain,
history_match.match_after_host),
net::UnescapeRule::SPACES, nullptr, nullptr, &offsets);
TermMatches new_matches =
......
......@@ -41,15 +41,6 @@ class HistoryQuickProvider : public HistoryProvider {
friend class HistoryQuickProviderTest;
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, DoTrimHttpScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest,
DontTrimHttpSchemeIfInputHasScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest,
DontTrimHttpSchemeIfInputMatches);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, DontTrimHttpsScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest,
DontTrimHttpsSchemeDespiteFlag);
FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, DoTrimHttpsSchemeIfFlag);
~HistoryQuickProvider() override;
......
......@@ -17,7 +17,6 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_task_environment.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
......@@ -748,103 +747,6 @@ TEST_F(HistoryQuickProviderTest, DoesNotProvideMatchesOnFocus) {
EXPECT_TRUE(provider().matches().empty());
}
ScoredHistoryMatch BuildScoredHistoryMatch(const std::string& url_text) {
return ScoredHistoryMatch(
history::URLRow(GURL(url_text)), VisitInfoVector(), ASCIIToUTF16(""),
String16Vector(1, ASCIIToUTF16("")), WordStarts(1, 0), RowWordStarts(),
false, 0, base::Time());
}
// Trim the http:// scheme from the contents in the general case.
TEST_F(HistoryQuickProviderTest, DoTrimHttpScheme) {
AutocompleteInput input(ASCIIToUTF16("face"),
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("http://www.facebook.com");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents);
}
// Don't trim the http:// scheme from the match contents if
// the user input included a scheme.
TEST_F(HistoryQuickProviderTest, DontTrimHttpSchemeIfInputHasScheme) {
AutocompleteInput input(ASCIIToUTF16("http://face"),
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("http://www.facebook.com");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents);
}
// Don't trim the http:// scheme from the match contents if
// the user input matched it.
TEST_F(HistoryQuickProviderTest, DontTrimHttpSchemeIfInputMatches) {
AutocompleteInput input(ASCIIToUTF16("ht"), metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("http://www.facebook.com");
history_match.match_in_scheme = true;
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents);
}
// Don't trim the https:// scheme from the match contents in the general case.
TEST_F(HistoryQuickProviderTest, DontTrimHttpsScheme) {
AutocompleteInput input(ASCIIToUTF16("face"),
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("https://www.facebook.com");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents);
}
// Don't trim the https:// scheme from the match contents, if the feature
// to do so is enabled, if the user input included a scheme.
TEST_F(HistoryQuickProviderTest, DontTrimHttpsSchemeDespiteFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitAndEnableFeature(
omnibox::kUIExperimentHideSuggestionUrlScheme);
AutocompleteInput input(ASCIIToUTF16("https://face"),
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("https://www.facebook.com");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents);
}
// Trim the https:// scheme from the match contents, if the feature
// to do so is enabled, and nothing else prevents it.
TEST_F(HistoryQuickProviderTest, DoTrimHttpsSchemeIfFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitAndEnableFeature(
omnibox::kUIExperimentHideSuggestionUrlScheme);
AutocompleteInput input(ASCIIToUTF16("face"),
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
provider().Start(input, false);
ScoredHistoryMatch history_match =
BuildScoredHistoryMatch("https://www.facebook.com");
AutocompleteMatch match = provider().QuickMatchToACMatch(history_match, 100);
EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents);
}
// HQPOrderingTest -------------------------------------------------------------
class HQPOrderingTest : public HistoryQuickProviderTest {
......
......@@ -1226,8 +1226,7 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
history_match.input_location + params.input.text().length()};
const auto format_types = AutocompleteMatch::GetFormatTypes(
params.input.parts().scheme.len > 0 || !params.trim_http ||
history_match.match_in_scheme,
!params.trim_http || history_match.match_in_scheme,
history_match.match_in_subdomain, history_match.match_after_host);
match.contents = url_formatter::FormatUrlWithOffsets(
info.url(), format_types, net::UnescapeRule::SPACES, nullptr, nullptr,
......
......@@ -221,15 +221,6 @@ class HistoryURLProvider : public HistoryProvider {
private:
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, HUPScoringExperiment);
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, DoTrimHttpScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest,
DontTrimHttpSchemeIfInputHasScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest,
DontTrimHttpSchemeIfInputMatchesInScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, DontTrimHttpsScheme);
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest,
DontTrimHttpsSchemeDespiteFlag);
FRIEND_TEST_ALL_PREFIXES(HistoryURLProviderTest, DoTrimHttpsSchemeIfFlag);
enum MatchType {
NORMAL,
......
......@@ -1246,84 +1246,3 @@ TEST_F(HistoryURLProviderTest, MatchURLFormatting) {
omnibox::kUIExperimentElideSuggestionUrlAfterHost);
ExpectFormattedFullMatch("hij", L"https://www.hij.com/\x2026\x0000", 12, 3);
}
std::unique_ptr<HistoryURLProviderParams> BuildHistoryURLProviderParams(
const std::string& input_text,
const std::string& url_text,
bool match_in_scheme) {
AutocompleteInput input(ASCIIToUTF16(input_text),
metrics::OmniboxEventProto::OTHER,
TestSchemeClassifier());
history::HistoryMatch history_match;
history_match.url_info.set_url(GURL(url_text));
history_match.match_in_scheme = match_in_scheme;
auto params = std::make_unique<HistoryURLProviderParams>(
input, true, AutocompleteMatch(), nullptr, SearchTermsData());
params->matches.push_back(history_match);
return params;
}
// Make sure "http://" scheme is generally trimmed.
TEST_F(HistoryURLProviderTest, DoTrimHttpScheme) {
auto params =
BuildHistoryURLProviderParams("face", "http://www.facebook.com", false);
AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0);
EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents);
}
// Make sure "http://" scheme is not trimmed if input has a scheme too.
TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputHasScheme) {
auto params = BuildHistoryURLProviderParams("http://face",
"http://www.facebook.com", false);
AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0);
EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents);
}
// Make sure "http://" scheme is not trimmed if input matches in scheme.
TEST_F(HistoryURLProviderTest, DontTrimHttpSchemeIfInputMatchesInScheme) {
auto params =
BuildHistoryURLProviderParams("ht face", "http://www.facebook.com", true);
AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0);
EXPECT_EQ(ASCIIToUTF16("http://www.facebook.com"), match.contents);
}
// Make sure "https://" scheme is generally not trimmed.
TEST_F(HistoryURLProviderTest, DontTrimHttpsScheme) {
auto params =
BuildHistoryURLProviderParams("face", "https://www.facebook.com", false);
AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0);
EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents);
}
// Make sure "https://" scheme is not trimmed even when requested by flag
// if the input has a scheme.
TEST_F(HistoryURLProviderTest, DontTrimHttpsSchemeDespiteFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitWithFeatures(
{omnibox::kUIExperimentHideSuggestionUrlScheme}, {});
auto params = BuildHistoryURLProviderParams(
"https://face", "https://www.facebook.com", false);
AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0);
EXPECT_EQ(ASCIIToUTF16("https://www.facebook.com"), match.contents);
}
// Make sure "https://" scheme is trimmed if requested by flag, and nothing
// else prevents it.
TEST_F(HistoryURLProviderTest, DoTrimHttpsSchemeIfFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitWithFeatures(
{omnibox::kUIExperimentHideSuggestionUrlScheme}, {});
auto params =
BuildHistoryURLProviderParams("face", "https://www.facebook.com", false);
AutocompleteMatch match = autocomplete_->HistoryMatchToACMatch(*params, 0, 0);
EXPECT_EQ(ASCIIToUTF16("www.facebook.com"), match.contents);
}
......@@ -98,12 +98,6 @@ class SearchProvider : public BaseSearchProvider,
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveExtraAnswers);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoesNotProvideOnFocus);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SendsWarmUpRequestOnFocus);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoTrimHttpScheme);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest,
DontTrimHttpSchemeIfInputHasScheme);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DontTrimHttpsScheme);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DontTrimHttpsSchemeDespiteFlag);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, DoTrimHttpsSchemeIfFlag);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults);
FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery);
......
......@@ -288,8 +288,7 @@ SearchSuggestionParser::NavigationResult::CalculateAndClassifyMatchContents(
GURL(formatted_url_), {{match_start, match_start + input_text.length()}},
&match_in_scheme, &match_in_subdomain, &match_after_host);
auto format_types = AutocompleteMatch::GetFormatTypes(
GURL(input_text).has_scheme() || match_in_scheme, match_in_subdomain,
match_after_host);
match_in_scheme, match_in_subdomain, match_after_host);
base::string16 match_contents =
url_formatter::FormatUrl(url_, format_types, net::UnescapeRule::SPACES,
......
......@@ -79,8 +79,7 @@ AutocompleteMatch TitledUrlMatchToAutocompleteMatch(
url, titled_url_match.url_match_positions, &match_in_scheme,
&match_in_subdomain, &match_after_host);
auto format_types = AutocompleteMatch::GetFormatTypes(
input.parts().scheme.len > 0 || match_in_scheme, match_in_subdomain,
match_after_host);
match_in_scheme, match_in_subdomain, match_after_host);
std::vector<size_t> offsets = TitledUrlMatch::OffsetsFromMatchPositions(
titled_url_match.url_match_positions);
......
......@@ -7,13 +7,11 @@
#include <memory>
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/bookmarks/browser/titled_url_match.h"
#include "components/bookmarks/browser/titled_url_node.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_provider.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/test_scheme_classifier.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
......@@ -112,121 +110,6 @@ TEST(TitledUrlMatchUtilsTest, TitledUrlMatchToAutocompleteMatch) {
autocomplete_match.inline_autocompletion);
}
AutocompleteMatch BuildTestAutocompleteMatch(
const std::string& input_text_s,
const GURL& match_url,
const bookmarks::TitledUrlMatch::MatchPositions& match_positions) {
base::string16 input_text(base::ASCIIToUTF16(input_text_s));
base::string16 match_title(base::ASCIIToUTF16("The Facebook"));
AutocompleteMatchType::Type type = AutocompleteMatchType::BOOKMARK_TITLE;
int relevance = 123;
MockTitledUrlNode node(match_title, match_url);
bookmarks::TitledUrlMatch titled_url_match;
titled_url_match.node = &node;
titled_url_match.title_match_positions = {{0, 3}};
// Don't capture the scheme, so that it doesn't match.
titled_url_match.url_match_positions = match_positions;
scoped_refptr<MockAutocompleteProvider> provider =
new MockAutocompleteProvider(AutocompleteProvider::Type::TYPE_BOOKMARK);
TestSchemeClassifier classifier;
AutocompleteInput input(input_text, metrics::OmniboxEventProto::NTP,
classifier);
const base::string16 fixed_up_input(input_text);
return TitledUrlMatchToAutocompleteMatch(titled_url_match, type, relevance,
provider.get(), classifier, input,
fixed_up_input);
}
TEST(TitledUrlMatchUtilsTest, DoTrimHttpScheme) {
GURL match_url("http://www.facebook.com/");
AutocompleteMatch autocomplete_match =
BuildTestAutocompleteMatch("face", match_url, {{11, 15}});
ACMatchClassifications expected_contents_class = {
{0, ACMatchClassification::URL},
{4, ACMatchClassification::URL | ACMatchClassification::MATCH},
{8, ACMatchClassification::URL},
};
base::string16 expected_contents(base::ASCIIToUTF16("www.facebook.com"));
EXPECT_EQ(match_url, autocomplete_match.destination_url);
EXPECT_EQ(expected_contents, autocomplete_match.contents);
EXPECT_TRUE(std::equal(expected_contents_class.begin(),
expected_contents_class.end(),
autocomplete_match.contents_class.begin()));
EXPECT_TRUE(autocomplete_match.allowed_to_be_default_match);
}
TEST(TitledUrlMatchUtilsTest, DontTrimHttpSchemeIfInputHasScheme) {
GURL match_url("http://www.facebook.com/");
AutocompleteMatch autocomplete_match =
BuildTestAutocompleteMatch("http://face", match_url, {{11, 15}});
ACMatchClassifications expected_contents_class = {
{0, ACMatchClassification::URL},
{11, ACMatchClassification::URL | ACMatchClassification::MATCH},
{15, ACMatchClassification::URL},
};
base::string16 expected_contents(
base::ASCIIToUTF16("http://www.facebook.com"));
EXPECT_EQ(match_url, autocomplete_match.destination_url);
EXPECT_EQ(expected_contents, autocomplete_match.contents);
EXPECT_TRUE(std::equal(expected_contents_class.begin(),
expected_contents_class.end(),
autocomplete_match.contents_class.begin()));
EXPECT_FALSE(autocomplete_match.allowed_to_be_default_match);
}
TEST(TitledUrlMatchUtilsTest, DontTrimHttpsScheme) {
GURL match_url("https://www.facebook.com/");
AutocompleteMatch autocomplete_match =
BuildTestAutocompleteMatch("face", match_url, {{12, 16}});
ACMatchClassifications expected_contents_class = {
{0, ACMatchClassification::URL},
{12, ACMatchClassification::URL | ACMatchClassification::MATCH},
{16, ACMatchClassification::URL},
};
base::string16 expected_contents(
base::ASCIIToUTF16("https://www.facebook.com"));
EXPECT_EQ(match_url, autocomplete_match.destination_url);
EXPECT_EQ(expected_contents, autocomplete_match.contents);
EXPECT_TRUE(std::equal(expected_contents_class.begin(),
expected_contents_class.end(),
autocomplete_match.contents_class.begin()));
EXPECT_TRUE(autocomplete_match.allowed_to_be_default_match);
}
TEST(TitledUrlMatchUtilsTest, DontTrimHttpsSchemeDespiteFlag) {
auto feature_list = std::make_unique<base::test::ScopedFeatureList>();
feature_list->InitAndEnableFeature(
omnibox::kUIExperimentHideSuggestionUrlScheme);
GURL match_url("https://www.facebook.com/");
AutocompleteMatch autocomplete_match =
BuildTestAutocompleteMatch("https://face", match_url, {{12, 16}});
ACMatchClassifications expected_contents_class = {
{0, ACMatchClassification::URL},
{12, ACMatchClassification::URL | ACMatchClassification::MATCH},
{16, ACMatchClassification::URL},
};
base::string16 expected_contents(
base::ASCIIToUTF16("https://www.facebook.com"));
EXPECT_EQ(match_url, autocomplete_match.destination_url);
EXPECT_EQ(expected_contents, autocomplete_match.contents);
EXPECT_TRUE(std::equal(expected_contents_class.begin(),
expected_contents_class.end(),
autocomplete_match.contents_class.begin()));
EXPECT_FALSE(autocomplete_match.allowed_to_be_default_match);
}
TEST(TitledUrlMatchUtilsTest, EmptyInlineAutocompletion) {
// The search term matches the title but not the URL. Since there is no URL
// match, the inline autocompletion string will be empty.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment