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

Unified Diff: components/omnibox/browser/autocomplete_match_unittest.cc

Issue 2961393002: Omnibox UI Experiments: Hook up elide-after-host feature flag. (Closed)
Patch Set: merge Created 3 years, 5 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
« no previous file with comments | « components/omnibox/browser/autocomplete_match.cc ('k') | components/omnibox/browser/omnibox_field_trial.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/autocomplete_match_unittest.cc
diff --git a/components/omnibox/browser/autocomplete_match_unittest.cc b/components/omnibox/browser/autocomplete_match_unittest.cc
index e6627425c16662723f27faad514eab087dfd1f2a..ad9aad6584a44e5131a75512611a512b179538fe 100644
--- a/components/omnibox/browser/autocomplete_match_unittest.cc
+++ b/components/omnibox/browser/autocomplete_match_unittest.cc
@@ -115,44 +115,58 @@ TEST(AutocompleteMatchTest, FormatUrlForSuggestionDisplay) {
struct FormatUrlTestData {
const std::string url;
bool trim_scheme;
- const std::string expected_result;
+ const wchar_t* expected_result;
void Validate() {
SCOPED_TRACE(testing::Message()
<< " url= " << url << " trim_scheme=" << trim_scheme
<< " expected_result=" << expected_result);
auto format_types = AutocompleteMatch::GetFormatTypes(trim_scheme);
- EXPECT_EQ(expected_result,
- base::UTF16ToASCII(url_formatter::FormatUrl(
- GURL(url), format_types, net::UnescapeRule::SPACES, nullptr,
- nullptr, nullptr)));
+ EXPECT_EQ(base::WideToUTF16(expected_result),
+ url_formatter::FormatUrl(GURL(url), format_types,
+ net::UnescapeRule::SPACES, nullptr,
+ nullptr, nullptr));
};
};
- // Sanity check that the trim_strings parameter works.
FormatUrlTestData normal_cases[] = {
- {"http://google.com", true, "google.com"},
- {"https://google.com", true, "https://google.com"},
- {"http://google.com", false, "http://google.com"},
- {"https://google.com", false, "https://google.com"},
+ // Sanity check that the trim_scheme parameter works.
+ {"http://google.com", true, L"google.com"},
+ {"https://google.com", true, L"https://google.com"},
+ {"http://google.com", false, L"http://google.com"},
+ {"https://google.com", false, L"https://google.com"},
+
+ // Test that paths are preserved in the default case.
+ {"http://google.com/foobar", true, L"google.com/foobar"},
};
for (FormatUrlTestData& test_case : normal_cases)
test_case.Validate();
- // Test the hide-scheme feature flag.
+ // Test the hide-scheme feature flag with the trim_scheme parameter.
std::unique_ptr<base::test::ScopedFeatureList> feature_list(
new base::test::ScopedFeatureList);
feature_list->InitAndEnableFeature(
omnibox::kUIExperimentHideSuggestionUrlScheme);
FormatUrlTestData omit_scheme_cases[] = {
- {"http://google.com", true, "google.com"},
- {"https://google.com", true, "google.com"},
- {"http://google.com", false, "http://google.com"},
- {"https://google.com", false, "https://google.com"},
+ {"http://google.com", true, L"google.com"},
+ {"https://google.com", true, L"google.com"},
+ {"http://google.com", false, L"http://google.com"},
+ {"https://google.com", false, L"https://google.com"},
};
for (FormatUrlTestData& test_case : omit_scheme_cases)
test_case.Validate();
+
+ // Test the elide-after-host feature flag.
+ feature_list.reset(new base::test::ScopedFeatureList);
+ feature_list->InitAndEnableFeature(
+ omnibox::kUIExperimentElideSuggestionUrlAfterHost);
+ FormatUrlTestData hide_path_cases[] = {
+ {"http://google.com/foobar", true, L"google.com/\x2026\x0000"},
+ {"http://google.com/foobar", false, L"http://google.com/\x2026\x0000"},
+ };
+ for (FormatUrlTestData& test_case : hide_path_cases)
+ test_case.Validate();
}
TEST(AutocompleteMatchTest, SupportsDeletion) {
« no previous file with comments | « components/omnibox/browser/autocomplete_match.cc ('k') | components/omnibox/browser/omnibox_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698