OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/elide_url.h" | 5 #include "ui/secure_display/elide_url.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/font_list.h" | 9 #include "ui/gfx/font_list.h" |
10 #include "ui/gfx/text_elider.h" | 10 #include "ui/gfx/text_elider.h" |
11 #include "ui/gfx/text_utils.h" | 11 #include "ui/gfx/text_utils.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 using base::UTF8ToUTF16; | 14 using base::UTF8ToUTF16; |
15 using gfx::GetStringWidthF; | 15 using gfx::GetStringWidthF; |
16 using gfx::kEllipsis; | 16 using gfx::kEllipsis; |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 struct Testcase { | 20 struct Testcase { |
21 const std::string input; | 21 const std::string input; |
22 const std::string output; | 22 const std::string output; |
23 }; | 23 }; |
24 | 24 |
25 void RunUrlTest(Testcase* testcases, size_t num_testcases) { | 25 void RunUrlTest(Testcase* testcases, size_t num_testcases) { |
26 static const gfx::FontList font_list; | 26 static const gfx::FontList font_list; |
27 for (size_t i = 0; i < num_testcases; ++i) { | 27 for (size_t i = 0; i < num_testcases; ++i) { |
28 const GURL url(testcases[i].input); | 28 const GURL url(testcases[i].input); |
29 // Should we test with non-empty language list? | 29 // Should we test with non-empty language list? |
30 // That's kinda redundant with net_util_unittests. | 30 // That's kinda redundant with net_util_unittests. |
31 const float available_width = | 31 const float available_width = |
32 GetStringWidthF(UTF8ToUTF16(testcases[i].output), font_list); | 32 GetStringWidthF(UTF8ToUTF16(testcases[i].output), font_list); |
33 EXPECT_EQ(UTF8ToUTF16(testcases[i].output), | 33 EXPECT_EQ(UTF8ToUTF16(testcases[i].output), |
34 ElideUrl(url, font_list, available_width, std::string())); | 34 secure_display::ElideUrl(url, font_list, available_width, |
| 35 std::string())); |
35 } | 36 } |
36 } | 37 } |
37 | 38 |
38 // Test eliding of commonplace URLs. | 39 // Test eliding of commonplace URLs. |
39 TEST(TextEliderTest, TestGeneralEliding) { | 40 TEST(TextEliderTest, TestGeneralEliding) { |
40 const std::string kEllipsisStr(kEllipsis); | 41 const std::string kEllipsisStr(kEllipsis); |
41 Testcase testcases[] = { | 42 Testcase testcases[] = { |
42 {"http://www.google.com/intl/en/ads/", | 43 {"http://www.google.com/intl/en/ads/", "www.google.com/intl/en/ads/"}, |
43 "www.google.com/intl/en/ads/"}, | 44 {"http://www.google.com/intl/en/ads/", "www.google.com/intl/en/ads/"}, |
44 {"http://www.google.com/intl/en/ads/", "www.google.com/intl/en/ads/"}, | 45 {"http://www.google.com/intl/en/ads/", |
45 {"http://www.google.com/intl/en/ads/", | 46 "google.com/intl/" + kEllipsisStr + "/ads/"}, |
46 "google.com/intl/" + kEllipsisStr + "/ads/"}, | 47 {"http://www.google.com/intl/en/ads/", |
47 {"http://www.google.com/intl/en/ads/", | 48 "google.com/" + kEllipsisStr + "/ads/"}, |
48 "google.com/" + kEllipsisStr + "/ads/"}, | 49 {"http://www.google.com/intl/en/ads/", "google.com/" + kEllipsisStr}, |
49 {"http://www.google.com/intl/en/ads/", "google.com/" + kEllipsisStr}, | 50 {"http://www.google.com/intl/en/ads/", "goog" + kEllipsisStr}, |
50 {"http://www.google.com/intl/en/ads/", "goog" + kEllipsisStr}, | 51 {"https://subdomain.foo.com/bar/filename.html", |
51 {"https://subdomain.foo.com/bar/filename.html", | 52 "subdomain.foo.com/bar/filename.html"}, |
52 "subdomain.foo.com/bar/filename.html"}, | 53 {"https://subdomain.foo.com/bar/filename.html", |
53 {"https://subdomain.foo.com/bar/filename.html", | 54 "subdomain.foo.com/" + kEllipsisStr + "/filename.html"}, |
54 "subdomain.foo.com/" + kEllipsisStr + "/filename.html"}, | 55 {"http://subdomain.foo.com/bar/filename.html", |
55 {"http://subdomain.foo.com/bar/filename.html", | 56 kEllipsisStr + "foo.com/" + kEllipsisStr + "/filename.html"}, |
56 kEllipsisStr + "foo.com/" + kEllipsisStr + "/filename.html"}, | 57 {"http://www.google.com/intl/en/ads/?aLongQueryWhichIsNotRequired", |
57 {"http://www.google.com/intl/en/ads/?aLongQueryWhichIsNotRequired", | 58 "www.google.com/intl/en/ads/?aLongQ" + kEllipsisStr}, |
58 "www.google.com/intl/en/ads/?aLongQ" + kEllipsisStr}, | |
59 }; | 59 }; |
60 | 60 |
61 RunUrlTest(testcases, arraysize(testcases)); | 61 RunUrlTest(testcases, arraysize(testcases)); |
62 } | 62 } |
63 | 63 |
64 // When there is very little space available, the elision code will shorten | 64 // When there is very little space available, the elision code will shorten |
65 // both path AND file name to an ellipsis - ".../...". To avoid this result, | 65 // both path AND file name to an ellipsis - ".../...". To avoid this result, |
66 // there is a hack in place that simply treats them as one string in this | 66 // there is a hack in place that simply treats them as one string in this |
67 // case. | 67 // case. |
68 TEST(TextEliderTest, TestTrailingEllipsisSlashEllipsisHack) { | 68 TEST(TextEliderTest, TestTrailingEllipsisSlashEllipsisHack) { |
69 const std::string kEllipsisStr(kEllipsis); | 69 const std::string kEllipsisStr(kEllipsis); |
70 | 70 |
71 // Very little space, would cause double ellipsis. | 71 // Very little space, would cause double ellipsis. |
72 gfx::FontList font_list; | 72 gfx::FontList font_list; |
73 GURL url("http://battersbox.com/directory/foo/peter_paul_and_mary.html"); | 73 GURL url("http://battersbox.com/directory/foo/peter_paul_and_mary.html"); |
74 float available_width = GetStringWidthF( | 74 float available_width = GetStringWidthF( |
75 UTF8ToUTF16("battersbox.com/" + kEllipsisStr + "/" + kEllipsisStr), | 75 UTF8ToUTF16("battersbox.com/" + kEllipsisStr + "/" + kEllipsisStr), |
76 font_list); | 76 font_list); |
77 | 77 |
78 // Create the expected string, after elision. Depending on font size, the | 78 // Create the expected string, after elision. Depending on font size, the |
79 // directory might become /dir... or /di... or/d... - it never should be | 79 // directory might become /dir... or /di... or/d... - it never should be |
80 // shorter than that. (If it is, the font considers d... to be longer | 80 // shorter than that. (If it is, the font considers d... to be longer |
81 // than .../... - that should never happen). | 81 // than .../... - that should never happen). |
82 ASSERT_GT(GetStringWidthF(UTF8ToUTF16(kEllipsisStr + "/" + kEllipsisStr), | 82 ASSERT_GT(GetStringWidthF(UTF8ToUTF16(kEllipsisStr + "/" + kEllipsisStr), |
83 font_list), | 83 font_list), |
84 GetStringWidthF(UTF8ToUTF16("d" + kEllipsisStr), font_list)); | 84 GetStringWidthF(UTF8ToUTF16("d" + kEllipsisStr), font_list)); |
85 GURL long_url("http://battersbox.com/directorynameisreallylongtoforcetrunc"); | 85 GURL long_url("http://battersbox.com/directorynameisreallylongtoforcetrunc"); |
86 base::string16 expected = | 86 base::string16 expected = secure_display::ElideUrl( |
87 ElideUrl(long_url, font_list, available_width, std::string()); | 87 long_url, font_list, available_width, std::string()); |
88 // Ensure that the expected result still contains part of the directory name. | 88 // Ensure that the expected result still contains part of the directory name. |
89 ASSERT_GT(expected.length(), std::string("battersbox.com/d").length()); | 89 ASSERT_GT(expected.length(), std::string("battersbox.com/d").length()); |
90 EXPECT_EQ(expected, | 90 EXPECT_EQ(expected, secure_display::ElideUrl(url, font_list, available_width, |
91 ElideUrl(url, font_list, available_width, std::string())); | 91 std::string())); |
92 | 92 |
93 // More space available - elide directories, partially elide filename. | 93 // More space available - elide directories, partially elide filename. |
94 Testcase testcases[] = { | 94 Testcase testcases[] = { |
95 {"http://battersbox.com/directory/foo/peter_paul_and_mary.html", | 95 {"http://battersbox.com/directory/foo/peter_paul_and_mary.html", |
96 "battersbox.com/" + kEllipsisStr + "/peter" + kEllipsisStr}, | 96 "battersbox.com/" + kEllipsisStr + "/peter" + kEllipsisStr}, |
97 }; | 97 }; |
98 RunUrlTest(testcases, arraysize(testcases)); | 98 RunUrlTest(testcases, arraysize(testcases)); |
99 } | 99 } |
100 | 100 |
101 // Test eliding of empty strings, URLs with ports, passwords, queries, etc. | 101 // Test eliding of empty strings, URLs with ports, passwords, queries, etc. |
102 TEST(TextEliderTest, TestMoreEliding) { | 102 TEST(TextEliderTest, TestMoreEliding) { |
103 const std::string kEllipsisStr(kEllipsis); | 103 const std::string kEllipsisStr(kEllipsis); |
104 Testcase testcases[] = { | 104 Testcase testcases[] = { |
105 {"http://www.google.com/foo?bar", "www.google.com/foo?bar"}, | 105 {"http://www.google.com/foo?bar", "www.google.com/foo?bar"}, |
106 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo?" + kEllipsisStr}, | 106 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo?" + kEllipsisStr}, |
107 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo" + kEllipsisStr}, | 107 {"http://xyz.google.com/foo?bar", "xyz.google.com/foo" + kEllipsisStr}, |
108 {"http://xyz.google.com/foo?bar", "xyz.google.com/fo" + kEllipsisStr}, | 108 {"http://xyz.google.com/foo?bar", "xyz.google.com/fo" + kEllipsisStr}, |
109 {"http://a.b.com/pathname/c?d", "a.b.com/" + kEllipsisStr + "/c?d"}, | 109 {"http://a.b.com/pathname/c?d", "a.b.com/" + kEllipsisStr + "/c?d"}, |
110 {"", ""}, | 110 {"", ""}, |
111 {"http://foo.bar..example.com...hello/test/filename.html", | 111 {"http://foo.bar..example.com...hello/test/filename.html", |
112 "foo.bar..example.com...hello/" + kEllipsisStr + "/filename.html"}, | 112 "foo.bar..example.com...hello/" + kEllipsisStr + "/filename.html"}, |
113 {"http://foo.bar../", "foo.bar.."}, | 113 {"http://foo.bar../", "foo.bar.."}, |
114 {"http://xn--1lq90i.cn/foo", "\xe5\x8c\x97\xe4\xba\xac.cn/foo"}, | 114 {"http://xn--1lq90i.cn/foo", "\xe5\x8c\x97\xe4\xba\xac.cn/foo"}, |
115 {"http://me:mypass@secrethost.com:99/foo?bar#baz", | 115 {"http://me:mypass@secrethost.com:99/foo?bar#baz", |
116 "secrethost.com:99/foo?bar#baz"}, | 116 "secrethost.com:99/foo?bar#baz"}, |
117 {"http://me:mypass@ss%xxfdsf.com/foo", "ss%25xxfdsf.com/foo"}, | 117 {"http://me:mypass@ss%xxfdsf.com/foo", "ss%25xxfdsf.com/foo"}, |
118 {"mailto:elgoato@elgoato.com", "mailto:elgoato@elgoato.com"}, | 118 {"mailto:elgoato@elgoato.com", "mailto:elgoato@elgoato.com"}, |
119 {"javascript:click(0)", "javascript:click(0)"}, | 119 {"javascript:click(0)", "javascript:click(0)"}, |
120 {"https://chess.eecs.berkeley.edu:4430/login/arbitfilename", | 120 {"https://chess.eecs.berkeley.edu:4430/login/arbitfilename", |
121 "chess.eecs.berkeley.edu:4430/login/arbitfilename"}, | 121 "chess.eecs.berkeley.edu:4430/login/arbitfilename"}, |
122 {"https://chess.eecs.berkeley.edu:4430/login/arbitfilename", | 122 {"https://chess.eecs.berkeley.edu:4430/login/arbitfilename", |
123 kEllipsisStr + "berkeley.edu:4430/" + kEllipsisStr + "/arbitfilename"}, | 123 kEllipsisStr + "berkeley.edu:4430/" + kEllipsisStr + "/arbitfilename"}, |
124 | 124 |
125 // Unescaping. | 125 // Unescaping. |
126 {"http://www/%E4%BD%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0", | 126 {"http://www/%E4%BD%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0", |
127 "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"}, | 127 "www/\xe4\xbd\xa0\xe5\xa5\xbd?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"}, |
128 | 128 |
129 // Invalid unescaping for path. The ref will always be valid UTF-8. We don't | 129 // Invalid unescaping for path. The ref will always be valid UTF-8. We |
130 // bother to do too many edge cases, since these are handled by the escaper | 130 // don't |
131 // unittest. | 131 // bother to do too many edge cases, since these are handled by the |
132 {"http://www/%E4%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0", | 132 // escaper |
133 "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"}, | 133 // unittest. |
| 134 {"http://www/%E4%A0%E5%A5%BD?q=%E4%BD%A0%E5%A5%BD#\xe4\xbd\xa0", |
| 135 "www/%E4%A0%E5%A5%BD?q=\xe4\xbd\xa0\xe5\xa5\xbd#\xe4\xbd\xa0"}, |
134 }; | 136 }; |
135 | 137 |
136 RunUrlTest(testcases, arraysize(testcases)); | 138 RunUrlTest(testcases, arraysize(testcases)); |
137 } | 139 } |
138 | 140 |
139 // Test eliding of file: URLs. | 141 // Test eliding of file: URLs. |
140 TEST(TextEliderTest, TestFileURLEliding) { | 142 TEST(TextEliderTest, TestFileURLEliding) { |
141 const std::string kEllipsisStr(kEllipsis); | 143 const std::string kEllipsisStr(kEllipsis); |
142 Testcase testcases[] = { | 144 Testcase testcases[] = { |
143 {"file:///C:/path1/path2/path3/filename", | 145 {"file:///C:/path1/path2/path3/filename", |
144 "file:///C:/path1/path2/path3/filename"}, | 146 "file:///C:/path1/path2/path3/filename"}, |
145 {"file:///C:/path1/path2/path3/filename", | 147 {"file:///C:/path1/path2/path3/filename", "C:/path1/path2/path3/filename"}, |
146 "C:/path1/path2/path3/filename"}, | |
147 // GURL parses "file:///C:path" differently on windows than it does on posix. | 148 // GURL parses "file:///C:path" differently on windows than it does on posix. |
148 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
149 {"file:///C:path1/path2/path3/filename", | 150 {"file:///C:path1/path2/path3/filename", |
150 "C:/path1/path2/" + kEllipsisStr + "/filename"}, | 151 "C:/path1/path2/" + kEllipsisStr + "/filename"}, |
151 {"file:///C:path1/path2/path3/filename", | 152 {"file:///C:path1/path2/path3/filename", |
152 "C:/path1/" + kEllipsisStr + "/filename"}, | 153 "C:/path1/" + kEllipsisStr + "/filename"}, |
153 {"file:///C:path1/path2/path3/filename", | 154 {"file:///C:path1/path2/path3/filename", |
154 "C:/" + kEllipsisStr + "/filename"}, | 155 "C:/" + kEllipsisStr + "/filename"}, |
155 #endif | 156 #endif |
156 {"file://filer/foo/bar/file", "filer/foo/bar/file"}, | 157 {"file://filer/foo/bar/file", "filer/foo/bar/file"}, |
157 {"file://filer/foo/bar/file", "filer/foo/" + kEllipsisStr + "/file"}, | 158 {"file://filer/foo/bar/file", "filer/foo/" + kEllipsisStr + "/file"}, |
158 {"file://filer/foo/bar/file", "filer/" + kEllipsisStr + "/file"}, | 159 {"file://filer/foo/bar/file", "filer/" + kEllipsisStr + "/file"}, |
159 {"file://filer/foo/", "file://filer/foo/"}, | 160 {"file://filer/foo/", "file://filer/foo/"}, |
160 {"file://filer/foo/", "filer/foo/"}, | 161 {"file://filer/foo/", "filer/foo/"}, |
161 {"file://filer/foo/", "filer" + kEllipsisStr}, | 162 {"file://filer/foo/", "filer" + kEllipsisStr}, |
162 // Eliding file URLs with nothing after the ':' shouldn't crash. | 163 // Eliding file URLs with nothing after the ':' shouldn't crash. |
163 {"file:///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:", "aaa" + kEllipsisStr}, | 164 {"file:///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:", "aaa" + kEllipsisStr}, |
164 {"file:///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:/", "aaa" + kEllipsisStr}, | 165 {"file:///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:/", "aaa" + kEllipsisStr}, |
165 }; | 166 }; |
166 | 167 |
167 RunUrlTest(testcases, arraysize(testcases)); | 168 RunUrlTest(testcases, arraysize(testcases)); |
168 } | 169 } |
169 | 170 |
170 TEST(TextEliderTest, TestHostEliding) { | 171 TEST(TextEliderTest, TestHostEliding) { |
171 const std::string kEllipsisStr(kEllipsis); | 172 const std::string kEllipsisStr(kEllipsis); |
172 Testcase testcases[] = { | 173 Testcase testcases[] = { |
173 {"http://google.com", "google.com"}, | 174 {"http://google.com", "google.com"}, |
174 {"http://subdomain.google.com", kEllipsisStr + ".google.com"}, | 175 {"http://subdomain.google.com", kEllipsisStr + ".google.com"}, |
175 {"http://reallyreallyreallylongdomainname.com", | 176 {"http://reallyreallyreallylongdomainname.com", |
176 "reallyreallyreallylongdomainname.com"}, | 177 "reallyreallyreallylongdomainname.com"}, |
177 {"http://a.b.c.d.e.f.com", kEllipsisStr + "f.com"}, | 178 {"http://a.b.c.d.e.f.com", kEllipsisStr + "f.com"}, |
178 {"http://foo", "foo"}, | 179 {"http://foo", "foo"}, |
179 {"http://foo.bar", "foo.bar"}, | 180 {"http://foo.bar", "foo.bar"}, |
180 {"http://subdomain.foo.bar", kEllipsisStr + "in.foo.bar"}, | 181 {"http://subdomain.foo.bar", kEllipsisStr + "in.foo.bar"}, |
181 // IOS width calculations are off by a letter from other platforms for | 182 // IOS width calculations are off by a letter from other platforms for |
182 // some strings from other platforms, probably for strings with too | 183 // some strings from other platforms, probably for strings with too |
183 // many kerned letters on the default font set. | 184 // many kerned letters on the default font set. |
184 #if !defined(OS_IOS) | 185 #if !defined(OS_IOS) |
185 {"http://subdomain.reallylongdomainname.com", | 186 {"http://subdomain.reallylongdomainname.com", |
186 kEllipsisStr + "ain.reallylongdomainname.com"}, | 187 kEllipsisStr + "ain.reallylongdomainname.com"}, |
187 {"http://a.b.c.d.e.f.com", kEllipsisStr + ".e.f.com"}, | 188 {"http://a.b.c.d.e.f.com", kEllipsisStr + ".e.f.com"}, |
188 #endif | 189 #endif |
189 }; | 190 }; |
190 | 191 |
191 for (size_t i = 0; i < arraysize(testcases); ++i) { | 192 for (size_t i = 0; i < arraysize(testcases); ++i) { |
192 const float available_width = | 193 const float available_width = |
193 GetStringWidthF(UTF8ToUTF16(testcases[i].output), gfx::FontList()); | 194 GetStringWidthF(UTF8ToUTF16(testcases[i].output), gfx::FontList()); |
194 EXPECT_EQ(UTF8ToUTF16(testcases[i].output), ElideHost( | 195 EXPECT_EQ(UTF8ToUTF16(testcases[i].output), |
195 GURL(testcases[i].input), gfx::FontList(), available_width)); | 196 secure_display::ElideHost(GURL(testcases[i].input), |
| 197 gfx::FontList(), available_width)); |
196 } | 198 } |
197 | 199 |
198 // Trying to elide to a really short length will still keep the full TLD+1 | 200 // Trying to elide to a really short length will still keep the full TLD+1 |
199 EXPECT_EQ(base::ASCIIToUTF16("google.com"), | 201 EXPECT_EQ( |
200 ElideHost(GURL("http://google.com"), gfx::FontList(), 2)); | 202 base::ASCIIToUTF16("google.com"), |
| 203 secure_display::ElideHost(GURL("http://google.com"), gfx::FontList(), 2)); |
201 EXPECT_EQ(base::UTF8ToUTF16(kEllipsisStr + ".google.com"), | 204 EXPECT_EQ(base::UTF8ToUTF16(kEllipsisStr + ".google.com"), |
202 ElideHost(GURL("http://subdomain.google.com"), gfx::FontList(), 2)); | 205 secure_display::ElideHost(GURL("http://subdomain.google.com"), |
203 EXPECT_EQ(base::ASCIIToUTF16("foo.bar"), | 206 gfx::FontList(), 2)); |
204 ElideHost(GURL("http://foo.bar"), gfx::FontList(), 2)); | 207 EXPECT_EQ( |
| 208 base::ASCIIToUTF16("foo.bar"), |
| 209 secure_display::ElideHost(GURL("http://foo.bar"), gfx::FontList(), 2)); |
205 } | 210 } |
206 | 211 |
207 TEST(TextEliderTest, FormatUrlForSecurityDisplay) { | 212 TEST(TextEliderTest, FormatUrlForSecurityDisplay) { |
208 struct OriginTestData { | 213 struct OriginTestData { |
209 const char* const description; | 214 const char* const description; |
210 const char* const input; | 215 const char* const input; |
211 const wchar_t* const output; | 216 const wchar_t* const output; |
212 }; | 217 }; |
213 | 218 |
214 const OriginTestData tests[] = { | 219 const OriginTestData tests[] = { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 "https://www.example.com./get/goat", | 306 "https://www.example.com./get/goat", |
302 L"https://www.example.com."}, | 307 L"https://www.example.com."}, |
303 {"Blob URL", | 308 {"Blob URL", |
304 "blob:http%3A//www.html5rocks.com/4d4ff040-6d61-4446-86d3-13ca07ec9ab9", | 309 "blob:http%3A//www.html5rocks.com/4d4ff040-6d61-4446-86d3-13ca07ec9ab9", |
305 L"blob:http%3A//www.html5rocks.com/" | 310 L"blob:http%3A//www.html5rocks.com/" |
306 L"4d4ff040-6d61-4446-86d3-13ca07ec9ab9"}, | 311 L"4d4ff040-6d61-4446-86d3-13ca07ec9ab9"}, |
307 }; | 312 }; |
308 | 313 |
309 const char languages[] = "zh-TW,en-US,en,am,ar-EG,ar"; | 314 const char languages[] = "zh-TW,en-US,en,am,ar-EG,ar"; |
310 for (size_t i = 0; i < arraysize(tests); ++i) { | 315 for (size_t i = 0; i < arraysize(tests); ++i) { |
311 base::string16 formatted = | 316 base::string16 formatted = secure_display::FormatUrlForSecurityDisplay( |
312 FormatUrlForSecurityDisplay(GURL(tests[i].input), std::string()); | 317 GURL(tests[i].input), std::string()); |
313 EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted) | 318 EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted) |
314 << tests[i].description; | 319 << tests[i].description; |
315 base::string16 formatted_with_languages = | 320 base::string16 formatted_with_languages = |
316 FormatUrlForSecurityDisplay(GURL(tests[i].input), languages); | 321 secure_display::FormatUrlForSecurityDisplay(GURL(tests[i].input), |
| 322 languages); |
317 EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted_with_languages) | 323 EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted_with_languages) |
318 << tests[i].description; | 324 << tests[i].description; |
319 } | 325 } |
320 | 326 |
321 base::string16 formatted = FormatUrlForSecurityDisplay(GURL(), std::string()); | 327 base::string16 formatted = |
| 328 secure_display::FormatUrlForSecurityDisplay(GURL(), std::string()); |
322 EXPECT_EQ(base::string16(), formatted) | 329 EXPECT_EQ(base::string16(), formatted) |
323 << "Explicitly test the 0-argument GURL constructor"; | 330 << "Explicitly test the 0-argument GURL constructor"; |
324 } | 331 } |
325 | 332 |
326 } // namespace | 333 } // namespace |
OLD | NEW |