OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 url_parse::Component(7, 14), // host | 50 url_parse::Component(7, 14), // host |
51 url_parse::Component(), // port | 51 url_parse::Component(), // port |
52 url_parse::Component(21, 1), // path | 52 url_parse::Component(21, 1), // path |
53 url_parse::Component(), // query | 53 url_parse::Component(), // query |
54 url_parse::Component(), // ref | 54 url_parse::Component(), // ref |
55 }, | 55 }, |
56 { "aBoUt:vErSiOn", "about", | 56 { "aBoUt:vErSiOn", "about", |
57 url_parse::Component(0, 5), // scheme | 57 url_parse::Component(0, 5), // scheme |
58 url_parse::Component(), // username | 58 url_parse::Component(), // username |
59 url_parse::Component(), // password | 59 url_parse::Component(), // password |
60 url_parse::Component(), // host | 60 url_parse::Component(6, 7), // host |
61 url_parse::Component(), // port | 61 url_parse::Component(), // port |
62 url_parse::Component(), // path | 62 url_parse::Component(), // path |
63 url_parse::Component(), // query | 63 url_parse::Component(), // query |
64 url_parse::Component(), // ref | 64 url_parse::Component(), // ref |
65 }, | 65 }, |
| 66 { "about:host/path?query#ref", "about", |
| 67 url_parse::Component(0, 5), // scheme |
| 68 url_parse::Component(), // username |
| 69 url_parse::Component(), // password |
| 70 url_parse::Component(6, 4), // host |
| 71 url_parse::Component(), // port |
| 72 url_parse::Component(10, 5), // path |
| 73 url_parse::Component(16, 5), // query |
| 74 url_parse::Component(22, 3), // ref |
| 75 }, |
| 76 { "about://host/path?query#ref", "about", |
| 77 url_parse::Component(0, 5), // scheme |
| 78 url_parse::Component(), // username |
| 79 url_parse::Component(), // password |
| 80 url_parse::Component(8, 4), // host |
| 81 url_parse::Component(), // port |
| 82 url_parse::Component(12, 5), // path |
| 83 url_parse::Component(18, 5), // query |
| 84 url_parse::Component(24, 3), // ref |
| 85 }, |
| 86 { "chrome:host/path?query#ref", "chrome", |
| 87 url_parse::Component(0, 6), // scheme |
| 88 url_parse::Component(), // username |
| 89 url_parse::Component(), // password |
| 90 url_parse::Component(7, 4), // host |
| 91 url_parse::Component(), // port |
| 92 url_parse::Component(11, 5), // path |
| 93 url_parse::Component(17, 5), // query |
| 94 url_parse::Component(23, 3), // ref |
| 95 }, |
| 96 { "chrome://host/path?query#ref", "chrome", |
| 97 url_parse::Component(0, 6), // scheme |
| 98 url_parse::Component(), // username |
| 99 url_parse::Component(), // password |
| 100 url_parse::Component(9, 4), // host |
| 101 url_parse::Component(), // port |
| 102 url_parse::Component(13, 5), // path |
| 103 url_parse::Component(19, 5), // query |
| 104 url_parse::Component(25, 3), // ref |
| 105 }, |
66 { " www.google.com:124?foo#", "http", | 106 { " www.google.com:124?foo#", "http", |
67 url_parse::Component(), // scheme | 107 url_parse::Component(), // scheme |
68 url_parse::Component(), // username | 108 url_parse::Component(), // username |
69 url_parse::Component(), // password | 109 url_parse::Component(), // password |
70 url_parse::Component(4, 14), // host | 110 url_parse::Component(4, 14), // host |
71 url_parse::Component(19, 3), // port | 111 url_parse::Component(19, 3), // port |
72 url_parse::Component(), // path | 112 url_parse::Component(), // path |
73 url_parse::Component(23, 3), // query | 113 url_parse::Component(23, 3), // query |
74 url_parse::Component(27, 0), // ref | 114 url_parse::Component(27, 0), // ref |
75 }, | 115 }, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 const std::string output; | 251 const std::string output; |
212 } fixup_cases[] = { | 252 } fixup_cases[] = { |
213 {"www.google.com", "", "http://www.google.com/"}, | 253 {"www.google.com", "", "http://www.google.com/"}, |
214 {" www.google.com ", "", "http://www.google.com/"}, | 254 {" www.google.com ", "", "http://www.google.com/"}, |
215 {" foo.com/asdf bar", "", "http://foo.com/asdf%20%20bar"}, | 255 {" foo.com/asdf bar", "", "http://foo.com/asdf%20%20bar"}, |
216 {"..www.google.com..", "", "http://www.google.com./"}, | 256 {"..www.google.com..", "", "http://www.google.com./"}, |
217 {"http://......", "", "http://....../"}, | 257 {"http://......", "", "http://....../"}, |
218 {"http://host.com:ninety-two/", "", "http://host.com:ninety-two/"}, | 258 {"http://host.com:ninety-two/", "", "http://host.com:ninety-two/"}, |
219 {"http://host.com:ninety-two?foo", "", "http://host.com:ninety-two/?foo"}, | 259 {"http://host.com:ninety-two?foo", "", "http://host.com:ninety-two/?foo"}, |
220 {"google.com:123", "", "http://google.com:123/"}, | 260 {"google.com:123", "", "http://google.com:123/"}, |
221 {"about:", "", "about:"}, | 261 {"about:", "", "chrome://version/"}, |
222 {"about:version", "", "about:version"}, | 262 {"about:foo", "", "chrome://foo/"}, |
| 263 {"about:version", "", "chrome://version/"}, |
| 264 {"about:usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, |
| 265 {"about://usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, |
| 266 {"chrome:usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, |
| 267 {"chrome://usr:pwd@hst/pth?qry#ref", "", "chrome://usr:pwd@hst/pth?qry#ref"}, |
223 {"www:123", "", "http://www:123/"}, | 268 {"www:123", "", "http://www:123/"}, |
224 {" www:123", "", "http://www:123/"}, | 269 {" www:123", "", "http://www:123/"}, |
225 {"www.google.com?foo", "", "http://www.google.com/?foo"}, | 270 {"www.google.com?foo", "", "http://www.google.com/?foo"}, |
226 {"www.google.com#foo", "", "http://www.google.com/#foo"}, | 271 {"www.google.com#foo", "", "http://www.google.com/#foo"}, |
227 {"www.google.com?", "", "http://www.google.com/?"}, | 272 {"www.google.com?", "", "http://www.google.com/?"}, |
228 {"www.google.com#", "", "http://www.google.com/#"}, | 273 {"www.google.com#", "", "http://www.google.com/#"}, |
229 {"www.google.com:123?foo#bar", "", "http://www.google.com:123/?foo#bar"}, | 274 {"www.google.com:123?foo#bar", "", "http://www.google.com:123/?foo#bar"}, |
230 {"user@www.google.com", "", "http://user@www.google.com/"}, | 275 {"user@www.google.com", "", "http://user@www.google.com/"}, |
231 {"\xE6\xB0\xB4.com" , "", "http://xn--1rw.com/"}, | 276 {"\xE6\xB0\xB4.com" , "", "http://xn--1rw.com/"}, |
232 // It would be better if this next case got treated as http, but I don't see | 277 // It would be better if this next case got treated as http, but I don't see |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 // (should resolve to the same file as above) | 510 // (should resolve to the same file as above) |
466 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + | 511 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + |
467 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); | 512 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); |
468 EXPECT_TRUE(IsMatchingFileURL(URLFixerUpper::FixupRelativeFile(dir, | 513 EXPECT_TRUE(IsMatchingFileURL(URLFixerUpper::FixupRelativeFile(dir, |
469 FilePath(relative_file_str)).possibly_invalid_spec(), full_path)); | 514 FilePath(relative_file_str)).possibly_invalid_spec(), full_path)); |
470 | 515 |
471 // done with the subdir | 516 // done with the subdir |
472 EXPECT_TRUE(file_util::Delete(full_path, false)); | 517 EXPECT_TRUE(file_util::Delete(full_path, false)); |
473 EXPECT_TRUE(file_util::Delete(new_dir, true)); | 518 EXPECT_TRUE(file_util::Delete(new_dir, true)); |
474 } | 519 } |
OLD | NEW |