OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "webkit/common/database/database_identifier.h" | 5 #include "webkit/common/database/database_identifier.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 {"https_google.com_0", | 181 {"https_google.com_0", |
182 "https", "google.com", 0, GURL("https://google.com"), false}, | 182 "https", "google.com", 0, GURL("https://google.com"), false}, |
183 {"ftp_google.com_0", | 183 {"ftp_google.com_0", |
184 "ftp", "google.com", 0, GURL("ftp://google.com"), false}, | 184 "ftp", "google.com", 0, GURL("ftp://google.com"), false}, |
185 {"unknown_google.com_0", | 185 {"unknown_google.com_0", |
186 "unknown", "", 0, GURL("unknown://"), false}, | 186 "unknown", "", 0, GURL("unknown://"), false}, |
187 {"http_nondefaultport.net_8001", | 187 {"http_nondefaultport.net_8001", |
188 "http", "nondefaultport.net", 8001, | 188 "http", "nondefaultport.net", 8001, |
189 GURL("http://nondefaultport.net:8001"), false}, | 189 GURL("http://nondefaultport.net:8001"), false}, |
190 {"file__0", | 190 {"file__0", |
191 "", "", 0, GURL(), true}, | 191 "", "", 0, GURL("file:///"), true}, |
192 {"__0", | 192 {"__0", |
193 "", "", 0, GURL(), true}, | 193 "", "", 0, GURL(), true}, |
194 {"http_foo_bar_baz.org_0", | 194 {"http_foo_bar_baz.org_0", |
195 "http", "foo_bar_baz.org", 0, GURL("http://foo_bar_baz.org"), false}, | 195 "http", "foo_bar_baz.org", 0, GURL("http://foo_bar_baz.org"), false}, |
196 {"http_xn--n3h.unicode.com_0", | 196 {"http_xn--n3h.unicode.com_0", |
197 "http", "xn--n3h.unicode.com", 0, | 197 "http", "xn--n3h.unicode.com", 0, |
198 GURL("http://xn--n3h.unicode.com"), false}, | 198 GURL("http://xn--n3h.unicode.com"), false}, |
199 {"http_dot.com_0", "http", "dot.com", 0, GURL("http://dot.com"), false}, | 199 {"http_dot.com_0", "http", "dot.com", 0, GURL("http://dot.com"), false}, |
200 {"http_escaped%3Dfun.com_0", "http", "escaped%3dfun.com", 0, | 200 {"http_escaped%3Dfun.com_0", "http", "escaped%3dfun.com", 0, |
201 GURL("http://escaped%3dfun.com"), false}, | 201 GURL("http://escaped%3dfun.com"), false}, |
(...skipping 17 matching lines...) Expand all Loading... |
219 std::string bogus_components[] = { | 219 std::string bogus_components[] = { |
220 "", "_", "__", std::string("\x00", 1), std::string("http_\x00_0", 8), | 220 "", "_", "__", std::string("\x00", 1), std::string("http_\x00_0", 8), |
221 "ht\x7ctp_badscheme.com_0", "http_unescaped_percent_%.com_0", | 221 "ht\x7ctp_badscheme.com_0", "http_unescaped_percent_%.com_0", |
222 "http_port_too_big.net_75000", "http_port_too_small.net_-25", | 222 "http_port_too_big.net_75000", "http_port_too_small.net_-25", |
223 "http_shouldbeescaped\x7c.com_0", "http_latin1\x8a.org_8001", | 223 "http_shouldbeescaped\x7c.com_0", "http_latin1\x8a.org_8001", |
224 "http_\xe2\x98\x83.unicode.com_0", | 224 "http_\xe2\x98\x83.unicode.com_0", |
225 "http_dot%252ecom_0", | 225 "http_dot%252ecom_0", |
226 "HtTp_NonCanonicalRepresenTation_0", | 226 "HtTp_NonCanonicalRepresenTation_0", |
227 "http_non_ascii.\xa1.com_0", | 227 "http_non_ascii.\xa1.com_0", |
228 "http_not_canonical_escape%3d_0", | 228 "http_not_canonical_escape%3d_0", |
| 229 "http_bytes_after_port_0abcd", |
229 }; | 230 }; |
230 | 231 |
231 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bogus_components); ++i) { | 232 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bogus_components); ++i) { |
232 DatabaseIdentifier identifier = | 233 DatabaseIdentifier identifier = |
233 DatabaseIdentifier::Parse(bogus_components[i]); | 234 DatabaseIdentifier::Parse(bogus_components[i]); |
234 EXPECT_EQ("__0", identifier.ToString()) | 235 EXPECT_EQ("__0", identifier.ToString()) |
235 << "test case " << bogus_components[i]; | 236 << "test case " << bogus_components[i]; |
236 EXPECT_EQ(GURL("null"), identifier.ToOrigin()) | 237 EXPECT_EQ(GURL("null"), identifier.ToOrigin()) |
237 << "test case " << bogus_components[i]; | 238 << "test case " << bogus_components[i]; |
238 EXPECT_EQ(true, identifier.is_unique()) | 239 EXPECT_EQ(true, identifier.is_unique()) |
239 << "test case " << bogus_components[i]; | 240 << "test case " << bogus_components[i]; |
240 } | 241 } |
241 } | 242 } |
242 | 243 |
243 } // namespace | 244 } // namespace |
244 } // namespace webkit_database | 245 } // namespace webkit_database |
OLD | NEW |