| 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
|
|
|