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

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

Issue 2963883002: Omnibox UI Experiments: Refactor HTTPS trimming into UrlFormatter. (Closed)
Patch Set: update comment Created 3 years, 6 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/browser/autocomplete_match_unittest.cc
diff --git a/components/omnibox/browser/autocomplete_match_unittest.cc b/components/omnibox/browser/autocomplete_match_unittest.cc
index dc0eb46461caa0edb5a74c1675cb657ce5f422b9..b89eeec39a917ce20a3b68b1513df972e2170d43 100644
--- a/components/omnibox/browser/autocomplete_match_unittest.cc
+++ b/components/omnibox/browser/autocomplete_match_unittest.cc
@@ -111,59 +111,29 @@ TEST(AutocompleteMatchTest, MergeClassifications) {
"0,2," "1,0," "5,7," "6,1," "17,0"))));
}
-TEST(AutocompleteMatchTest, FormatUrlForSuggestionDisplay) {
- struct FormatUrlTestData {
- const std::string url;
- bool trim_scheme;
- size_t offset_for_adjustment;
- const std::string expected_result;
- size_t expected_adjusted_offset;
-
- void Validate() {
- SCOPED_TRACE(testing::Message()
- << " url= " << url << " trim_scheme=" << trim_scheme
- << " offset_for_adjustment=" << offset_for_adjustment
- << " expected_result=" << expected_result
- << " expected_adjusted_offset=" << expected_adjusted_offset);
-
- size_t offset_result = offset_for_adjustment;
- base::string16 result = AutocompleteMatch::FormatUrlForSuggestionDisplay(
- GURL(url), trim_scheme, &offset_result);
-
- EXPECT_EQ(expected_result, base::UTF16ToASCII(result));
- EXPECT_EQ(expected_adjusted_offset, offset_result);
- };
- };
-
- FormatUrlTestData normal_cases[] = {
- {"http://google.com", true, 9, "google.com", 2},
- {"https://google.com", true, 9, "https://google.com", 9},
- {"http://google.com", false, 9, "http://google.com", 9},
- {"https://google.com", false, 9, "https://google.com", 9},
- };
- for (size_t i = 0; i < arraysize(normal_cases); ++i) {
- normal_cases[i].Validate();
- }
-
+TEST(AutocompleteMatchTest, GetFormatForSuggestionDisplay) {
Peter Kasting 2017/06/29 01:05:44 It's OK I guess, but this test does seem a bit cha
tommycli 2017/06/29 16:46:46 Done. No problem. I changed it back to just sanity
+ EXPECT_EQ(
+ url_formatter::kFormatUrlOmitAll,
+ AutocompleteMatch::GetFormatForSuggestionDisplay(true /* trim_scheme */));
+ EXPECT_EQ(
+ url_formatter::kFormatUrlOmitAll & ~url_formatter::kFormatUrlOmitHTTP,
+ AutocompleteMatch::GetFormatForSuggestionDisplay(
+ false /* trim_scheme */));
+
+ // Test the hide scheme feature flag.
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, 9, "google.com", 2},
- {"https://google.com", true, 9, "google.com", 1},
- {"https://username:password@google.com", true, 9, "google.com",
- base::string16::npos},
- {"https://username:password@google.com", true, 29, "google.com", 3},
- {"http://google.com", false, 9, "http://google.com", 9},
- {"https://google.com", false, 9, "https://google.com", 9},
- {"http://username:password@google.com", false, 9, "http://google.com",
- base::string16::npos},
- };
- for (size_t i = 0; i < arraysize(omit_scheme_cases); ++i) {
- omit_scheme_cases[i].Validate();
- }
+ EXPECT_EQ(
+ url_formatter::kFormatUrlOmitAll |
+ url_formatter::kFormatUrlExperimentalOmitHTTPS,
+ AutocompleteMatch::GetFormatForSuggestionDisplay(true /* trim_scheme */));
+ EXPECT_EQ(
+ url_formatter::kFormatUrlOmitAll & ~url_formatter::kFormatUrlOmitHTTP,
+ AutocompleteMatch::GetFormatForSuggestionDisplay(
+ false /* trim_scheme */));
}
TEST(AutocompleteMatchTest, SupportsDeletion) {

Powered by Google App Engine
This is Rietveld 408576698