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

Unified Diff: net/base/net_util_icu_unittest.cc

Issue 532523002: Create net::FormatOriginForDisplay helper function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another newline EOF fix... Created 6 years, 4 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
« net/base/net_util_icu.cc ('K') | « net/base/net_util_icu.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util_icu_unittest.cc
diff --git a/net/base/net_util_icu_unittest.cc b/net/base/net_util_icu_unittest.cc
index 9beb4349b57d6fcffd78df70d564e387f30bb2a3..892bca90c8786c36a2b2a4706b917bc40878bc0a 100644
--- a/net/base/net_util_icu_unittest.cc
+++ b/net/base/net_util_icu_unittest.cc
@@ -363,6 +363,14 @@ struct UrlTestData {
size_t prefix_len;
};
+struct OriginTestData {
+ const char* description;
+ const char* input;
+ const char* languages;
+ const bool always_show_scheme;
+ const wchar_t* output;
+};
+
// A helper for IDN*{Fast,Slow}.
// Append "::<language list>" to |expected| and |actual| to make it
// easy to tell which sub-case fails without debugging.
@@ -1068,4 +1076,51 @@ TEST(NetUtilTest, FormatUrlWithOffsets) {
UnescapeRule::NORMAL, omit_all_offsets);
}
+TEST(NetUtilTest, FormatOriginForDisplay) {
+ const OriginTestData tests[] = {
+ {"Empty URL", "", "", false, L""},
+ {"HTTP URL, forcing bool",
+ "http://www.google.com/", "", true, L"http://www.google.com"},
+ {"HTTP URL, no forcing bool",
+ "http://www.google.com/", "", false, L"http://www.google.com"},
+ {"HTTPS URL, forcing bool",
+ "https://www.google.com/", "", true, L"https://www.google.com"},
+ {"HTTPS URL, no forcing bool",
+ "https://www.google.com/", "", false, L"www.google.com"},
+ {"Standard HTTP port",
+ "http://www.google.com:80/", "", false, L"http://www.google.com"},
+ {"Standard HTTPS port",
+ "https://www.google.com:443/", "", false, L"www.google.com"},
+ {"Non-standard HTTP port",
+ "http://www.google.com:9000/", "", false, L"http://www.google.com:9000"},
+ {"Non-standard HTTPS port",
+ "https://www.google.com:9000/", "", false, L"www.google.com:9000"},
+ {"File URI, forcing bool",
+ "file://usr/example/file.html", "", true, L"file://usr/example/file.html"},
+ {"File URI, no forcing bool",
+ "file://usr/example/file.html", "", true, L"file://usr/example/file.html"},
+ {"HTTP URL with path",
+ "http://www.google.com/test.html", "", false, L"http://www.google.com"},
+ {"HTTPS URL with path",
+ "https://www.google.com/test.html", "", false, L"www.google.com"},
+ {"Unusual secure scheme (wss)",
+ "wss://www.google.com/", "", false, L"www.google.com"},
+ {"Unusual non-secure scheme (gopher)",
+ "gopher://www.google.com/", "", false, L"gopher://www.google.com"},
+ {"Unlisted scheme (chrome)",
+ "chrome://version", "", false, L"chrome://version"},
+ {"HTTP IP address",
+ "http://173.194.65.103", "", false, L"http://173.194.65.103"},
+ {"HTTPS IP address, no forcing bool",
+ "https://173.194.65.103", "", false, L"173.194.65.103"},
+ {"HTTPS IP address, forcing bool",
+ "https://173.194.65.103", "", true, L"https://173.194.65.103"},
+ };
+ for (size_t i = 0; i < arraysize(tests); ++i) {
+ base::string16 formatted = FormatOriginForDisplay(
+ GURL(tests[i].input), tests[i].languages, tests[i].always_show_scheme);
+ EXPECT_EQ(WideToUTF16(tests[i].output), formatted) << tests[i].description;
+ }
+}
+
} // namespace net
« net/base/net_util_icu.cc ('K') | « net/base/net_util_icu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698