diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 12:41:29 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-28 12:41:29 +0000 |
commit | a14b16bd4b6d7fc3c1e3e83f16d1d59bc05f3dab (patch) | |
tree | b9f147f90989125906bc77282d41f166c57bb959 /base/file_path_unittest.cc | |
parent | c3b4463c325d5a7f512130c02a68913cc52d20fe (diff) | |
download | chromium_src-a14b16bd4b6d7fc3c1e3e83f16d1d59bc05f3dab.zip chromium_src-a14b16bd4b6d7fc3c1e3e83f16d1d59bc05f3dab.tar.gz chromium_src-a14b16bd4b6d7fc3c1e3e83f16d1d59bc05f3dab.tar.bz2 |
Get rid of FilePath::AppendAndResolveRelative().
To resolve the problem of '..' parent references as well as symbolic links on POSIX platforms, we can simply use the file_util::AbsolutePath() function.
This has the drawback of having a different behavior on Windows and POSIX platforms, in the way that it can return a canonical path that doesn't exists when ran on Windows, but it will return an empty path (or false) when run on a POSIX platform.
So we need to add an extra PathExists() call to unify the behavior.
BUG=25681,25131
Review URL: http://codereview.chromium.org/343003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_path_unittest.cc')
-rw-r--r-- | base/file_path_unittest.cc | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/base/file_path_unittest.cc b/base/file_path_unittest.cc index 2673220..92659f1 100644 --- a/base/file_path_unittest.cc +++ b/base/file_path_unittest.cc @@ -502,98 +502,6 @@ TEST_F(FilePathTest, PathComponentsTest) { } } -TEST_F(FilePathTest, AppendAndResolveRelativeTest) { - const struct BinaryTestData cases[] = { -#if defined(FILE_PATH_USES_DRIVE_LETTERS) - { { FPL("c:/"), FPL("foo") }, FPL("c:/foo") }, - { { FPL("f:/foo/bar"), FPL("..") }, FPL("f:/foo") }, - { { FPL("f:/foo.bar"), FPL("..") }, FPL("f:/") }, - { { FPL("F:/foo/.."), FPL("./bar/.") }, FPL("F:/bar") }, - { { FPL("E:/Foo/bar"), FPL("../..") }, FPL("E:/") }, - { { FPL("E:/Foo/bar/."), FPL("../..") }, FPL("E:/") }, - { { FPL("e:/foo/.."), FPL("bar/..") }, FPL("e:/") }, - { { FPL("c:/foo/./bar/.."), FPL("../baz") }, FPL("c:/baz") }, - { { FPL("E:/./foo/bar/.."), FPL("../baz/..") }, FPL("E:/") }, - { { FPL("x:/foo/../bar/.."), FPL("baz/../boo") }, FPL("x:/boo") }, - { { FPL("E:/foo.bar/.."), FPL("../baz/..") }, FPL("") }, - { { FPL("Z:/foo"), FPL("../..") }, FPL("") }, - { { FPL("y:/"), FPL("..") }, FPL("") }, - { { FPL("B:/.."), FPL("bar/.") }, FPL("") }, - { { FPL("a:/foo/.."), FPL("..") }, FPL("") }, - { { FPL("r:/.."), FPL("..") }, FPL("") }, - { { FPL("F:/foo/.."), FPL("../..") }, FPL("") }, - { { FPL("O:/foo/bar/.."), FPL("../..") }, FPL("") }, -#endif // FILE_PATH_USES_DRIVE_LETTERS -#if defined(FILE_PATH_USES_WIN_SEPARATORS) - { { FPL("\\\\"), FPL("foo") }, FPL("\\\\foo") }, - { { FPL("\\\\foo"), FPL("bar") }, FPL("\\\\foo\\bar") }, - { { FPL("\\\\foo\\bar"), FPL("..") }, FPL("\\\\foo") }, - { { FPL("\\\\foo.bar"), FPL("..") }, FPL("\\\\") }, - { { FPL("\\\\Foo\\bar"), FPL("..\\..") }, FPL("\\\\") }, - { { FPL("\\\\Foo\\bar\\."), FPL("..\\..") }, FPL("\\\\") }, - { { FPL("\\\\foo\\bar"), FPL("foo\\..\\baz") }, FPL("\\\\foo\\bar\\baz") }, - { { FPL("\\\\foo\\.\\bar"), FPL("..\\baz\\.") }, FPL("\\\\foo\\baz") }, - { { FPL("\\\\.\\foo\\.."), FPL("bar") }, FPL("\\\\bar") }, - { { FPL("\\\\foo\\.."), FPL(".\\bar\\..") }, FPL("\\\\") }, - { { FPL("\\\\foo\\bar\\.."), FPL("..\\baz") }, FPL("\\\\baz") }, - { { FPL("\\\\foo\\bar\\.."), FPL("..\\baz\\..") }, FPL("\\\\") }, - { { FPL("\\\\foo\\..\\bar\\.."), FPL("baz\\..\\boo") }, FPL("\\\\boo"), }, - { { FPL("\\\\foo.bar\\.."), FPL("..\\baz\\..") }, FPL("") }, - { { FPL("\\\\foo"), FPL("..\\..") }, FPL("") }, - { { FPL("\\\\"), FPL("..") }, FPL("") }, - { { FPL("\\\\.."), FPL("bar\\.") }, FPL("") }, - { { FPL("\\\\foo\\.."), FPL("..") }, FPL("") }, - { { FPL("\\\\.."), FPL("..") }, FPL("") }, - { { FPL("\\\\foo\\.."), FPL("..\\..") }, FPL("") }, - { { FPL("\\\\foo\\bar\\.."), FPL("..\\..") }, FPL("") }, -#if defined(FILE_PATH_USES_DRIVE_LETTERS) - { { FPL("E:/foo"), FPL("bar") }, FPL("E:/foo\\bar") }, - { { FPL("C:/foo/bar"), FPL("foo/../baz") }, FPL("C:/foo\\bar\\baz") }, - { { FPL("e:/foo/bar"), FPL("../baz") }, FPL("e:/foo\\baz") }, -#endif -#else // FILE_PATH_USES_WIN_SEPARAORS - { { FPL("/"), FPL("foo") }, FPL("/foo") }, - { { FPL("/foo"), FPL("bar") }, FPL("/foo/bar") }, - { { FPL("/foo/bar/"), FPL("..") }, FPL("/foo") }, - { { FPL("/foo.bar"), FPL("..") }, FPL("/") }, - { { FPL("//foo"), FPL("..") }, FPL("//") }, - { { FPL("/foo/./bar"), FPL("../..") }, FPL("/") }, - { { FPL("/foo/bar/."), FPL("foo/../baz") }, FPL("/foo/bar/baz") }, - { { FPL("/./foo/bar"), FPL("../baz/.") }, FPL("/foo/baz") }, - { { FPL("/foo/.."), FPL("./bar") }, FPL("/bar") }, - { { FPL("/foo/.."), FPL("bar/..") }, FPL("/") }, - { { FPL("//foo/bar/.."), FPL("../baz") }, FPL("//baz") }, - { { FPL("/foo/bar/.."), FPL("../baz/..") }, FPL("/") }, - { { FPL("/foo/../bar/.."), FPL("baz/../boo") }, FPL("/boo") }, - { { FPL("//foo.bar/.."), FPL("../baz") }, FPL("") }, - { { FPL("/foo"), FPL("../..") }, FPL("") }, - { { FPL("//"), FPL("..") }, FPL("") }, - { { FPL("/.."), FPL("./bar") }, FPL("") }, - { { FPL("/foo/.."), FPL("..") }, FPL("") }, - { { FPL("/.."), FPL("..") }, FPL("") }, - { { FPL("/foo/.."), FPL("../..") }, FPL("") }, - { { FPL("/foo/bar/.."), FPL("../..") }, FPL("") }, -#if defined(FILE_PATH_USES_DRIVE_LETTERS) - { { FPL("E:/foo"), FPL("bar") }, FPL("E:/foo/bar") }, - { { FPL("C:/foo/bar"), FPL("foo/../baz") }, FPL("C:/foo/bar/baz") }, - { { FPL("e:/foo/bar"), FPL("../baz") }, FPL("e:/foo/baz") }, -#endif -#endif // FILE_PATH_USES_WIN_SEPARAORS - }; - - for (size_t i = 0; i < arraysize(cases); ++i) { - FilePath parent(cases[i].inputs[0]); - FilePath child(cases[i].inputs[1]); - - FilePath result; - EXPECT_EQ(cases[i].expected[0] != '\0', - parent.AppendAndResolveRelative(child, &result)) << - "i: " << i << ", parent: " << parent.value() << ", child: " << - child.value(); - EXPECT_STREQ(cases[i].expected, result.value().c_str()); - } -} - TEST_F(FilePathTest, IsParentTest) { const struct BinaryBooleanTestData cases[] = { { { FPL("/"), FPL("/foo/bar/baz") }, true}, |