OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
12 #include "chrome/browser/net/url_fixer_upper.h" | 12 #include "chrome/browser/net/url_fixer_upper.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "googleurl/src/url_parse.h" | 14 #include "googleurl/src/url_parse.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
| 19 namespace url_parse { |
| 20 std::ostream& operator<<(std::ostream& os, const Component& part) { |
| 21 return os << "(begin=" << part.begin << ", len=" << part.len << ")"; |
| 22 } |
| 23 } |
| 24 |
19 namespace { | 25 namespace { |
20 class URLFixerUpperTest : public testing::Test { | 26 class URLFixerUpperTest : public testing::Test { |
21 }; | 27 }; |
22 }; | 28 }; |
23 | 29 |
24 std::ostream& operator<<(std::ostream& os, const url_parse::Component& part) { | |
25 return os << "(begin=" << part.begin << ", len=" << part.len << ")"; | |
26 } | |
27 | |
28 struct segment_case { | 30 struct segment_case { |
29 const std::string input; | 31 const std::string input; |
30 const std::string result; | 32 const std::string result; |
31 const url_parse::Component scheme; | 33 const url_parse::Component scheme; |
32 const url_parse::Component username; | 34 const url_parse::Component username; |
33 const url_parse::Component password; | 35 const url_parse::Component password; |
34 const url_parse::Component host; | 36 const url_parse::Component host; |
35 const url_parse::Component port; | 37 const url_parse::Component port; |
36 const url_parse::Component path; | 38 const url_parse::Component path; |
37 const url_parse::Component query; | 39 const url_parse::Component query; |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 // (should resolve to the same file as above) | 463 // (should resolve to the same file as above) |
462 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + | 464 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + |
463 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); | 465 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); |
464 EXPECT_TRUE(IsMatchingFileURL(URLFixerUpper::FixupRelativeFile(dir, | 466 EXPECT_TRUE(IsMatchingFileURL(URLFixerUpper::FixupRelativeFile(dir, |
465 FilePath(relative_file_str)).possibly_invalid_spec(), full_path)); | 467 FilePath(relative_file_str)).possibly_invalid_spec(), full_path)); |
466 | 468 |
467 // done with the subdir | 469 // done with the subdir |
468 EXPECT_TRUE(file_util::Delete(full_path, false)); | 470 EXPECT_TRUE(file_util::Delete(full_path, false)); |
469 EXPECT_TRUE(file_util::Delete(new_dir, true)); | 471 EXPECT_TRUE(file_util::Delete(new_dir, true)); |
470 } | 472 } |
OLD | NEW |