Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: components/url_fixer/url_fixer_unittest.cc

Issue 1200393002: Add more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string
Patch Set: Android Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 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/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 500
501 // test file in the subdir 501 // test file in the subdir
502 base::FilePath relative_file = sub_dir.Append(sub_file); 502 base::FilePath relative_file = sub_dir.Append(sub_file);
503 EXPECT_TRUE(IsMatchingFileURL( 503 EXPECT_TRUE(IsMatchingFileURL(
504 url_fixer::FixupRelativeFile(temp_dir_.path(), 504 url_fixer::FixupRelativeFile(temp_dir_.path(),
505 relative_file).possibly_invalid_spec(), full_path)); 505 relative_file).possibly_invalid_spec(), full_path));
506 506
507 // test file in the subdir with different slashes and escaping. 507 // test file in the subdir with different slashes and escaping.
508 base::FilePath::StringType relative_file_str = sub_dir.value() + 508 base::FilePath::StringType relative_file_str = sub_dir.value() +
509 FILE_PATH_LITERAL("/") + sub_file.value(); 509 FILE_PATH_LITERAL("/") + sub_file.value();
510 ReplaceSubstringsAfterOffset(&relative_file_str, 0, 510 base::ReplaceSubstringsAfterOffset(&relative_file_str, 0,
511 FILE_PATH_LITERAL(" "), FILE_PATH_LITERAL("%20")); 511 FILE_PATH_LITERAL(" "), FILE_PATH_LITERAL("%20"));
512 EXPECT_TRUE(IsMatchingFileURL( 512 EXPECT_TRUE(IsMatchingFileURL(
513 url_fixer::FixupRelativeFile(temp_dir_.path(), 513 url_fixer::FixupRelativeFile(temp_dir_.path(),
514 base::FilePath(relative_file_str)).possibly_invalid_spec(), 514 base::FilePath(relative_file_str)).possibly_invalid_spec(),
515 full_path)); 515 full_path));
516 516
517 // test relative directories and duplicate slashes 517 // test relative directories and duplicate slashes
518 // (should resolve to the same file as above) 518 // (should resolve to the same file as above)
519 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + 519 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") +
520 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); 520 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value();
521 EXPECT_TRUE(IsMatchingFileURL( 521 EXPECT_TRUE(IsMatchingFileURL(
522 url_fixer::FixupRelativeFile(temp_dir_.path(), 522 url_fixer::FixupRelativeFile(temp_dir_.path(),
523 base::FilePath(relative_file_str)).possibly_invalid_spec(), 523 base::FilePath(relative_file_str)).possibly_invalid_spec(),
524 full_path)); 524 full_path));
525 525
526 // done with the subdir 526 // done with the subdir
527 EXPECT_TRUE(base::DeleteFile(full_path, false)); 527 EXPECT_TRUE(base::DeleteFile(full_path, false));
528 EXPECT_TRUE(base::DeleteFile(new_dir, true)); 528 EXPECT_TRUE(base::DeleteFile(new_dir, true));
529 529
530 // Test that an obvious HTTP URL isn't accidentally treated as an absolute 530 // Test that an obvious HTTP URL isn't accidentally treated as an absolute
531 // file path (on account of system-specific craziness). 531 // file path (on account of system-specific craziness).
532 base::FilePath empty_path; 532 base::FilePath empty_path;
533 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../")); 533 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../"));
534 EXPECT_TRUE( 534 EXPECT_TRUE(
535 url_fixer::FixupRelativeFile(empty_path, http_url_path).SchemeIs("http")); 535 url_fixer::FixupRelativeFile(empty_path, http_url_path).SchemeIs("http"));
536 } 536 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url_unittest.cc ('k') | content/browser/android/java/java_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698