| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 EXPECT_EQ(kPathComponents[i].result, result); | 977 EXPECT_EQ(kPathComponents[i].result, result); |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 | 980 |
| 981 TEST_F(FileUtilTest, Contains) { | 981 TEST_F(FileUtilTest, Contains) { |
| 982 FilePath data_dir; | 982 FilePath data_dir; |
| 983 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &data_dir)); | 983 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &data_dir)); |
| 984 data_dir = data_dir.Append(FILE_PATH_LITERAL("FilePathTest")); | 984 data_dir = data_dir.Append(FILE_PATH_LITERAL("FilePathTest")); |
| 985 | 985 |
| 986 // Create a fresh, empty copy of this directory. | 986 // Create a fresh, empty copy of this directory. |
| 987 ASSERT_TRUE(file_util::Delete(data_dir, true)); | 987 if (file_util::PathExists(data_dir)) { |
| 988 ASSERT_TRUE(file_util::Delete(data_dir, true)); |
| 989 } |
| 988 ASSERT_TRUE(file_util::CreateDirectory(data_dir)); | 990 ASSERT_TRUE(file_util::CreateDirectory(data_dir)); |
| 989 | 991 |
| 990 FilePath foo(data_dir.Append(FILE_PATH_LITERAL("foo"))); | 992 FilePath foo(data_dir.Append(FILE_PATH_LITERAL("foo"))); |
| 991 FilePath bar(foo.Append(FILE_PATH_LITERAL("bar.txt"))); | 993 FilePath bar(foo.Append(FILE_PATH_LITERAL("bar.txt"))); |
| 992 FilePath baz(data_dir.Append(FILE_PATH_LITERAL("baz.txt"))); | 994 FilePath baz(data_dir.Append(FILE_PATH_LITERAL("baz.txt"))); |
| 993 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); | 995 FilePath foobar(data_dir.Append(FILE_PATH_LITERAL("foobar.txt"))); |
| 994 | 996 |
| 995 // Annoyingly, the directories must actually exist in order for realpath(), | 997 // Annoyingly, the directories must actually exist in order for realpath(), |
| 996 // which Contains() relies on in posix, to work. | 998 // which Contains() relies on in posix, to work. |
| 997 ASSERT_TRUE(file_util::CreateDirectory(foo)); | 999 ASSERT_TRUE(file_util::CreateDirectory(foo)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1018 #elif defined(OS_LINUX) | 1020 #elif defined(OS_LINUX) |
| 1019 EXPECT_FALSE(file_util::ContainsPath(foo, | 1021 EXPECT_FALSE(file_util::ContainsPath(foo, |
| 1020 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); | 1022 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); |
| 1021 #else | 1023 #else |
| 1022 // We can't really do this test on osx since the case-sensitivity of the | 1024 // We can't really do this test on osx since the case-sensitivity of the |
| 1023 // filesystem is configurable. | 1025 // filesystem is configurable. |
| 1024 #endif | 1026 #endif |
| 1025 } | 1027 } |
| 1026 | 1028 |
| 1027 } // namespace | 1029 } // namespace |
| OLD | NEW |