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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 FilePath fileF = test_dir_.Append(FILE_PATH_LITERAL("f")); | 1028 FilePath fileF = test_dir_.Append(FILE_PATH_LITERAL("f")); |
1029 | 1029 |
1030 // Create files/directories in near random order. | 1030 // Create files/directories in near random order. |
1031 CreateTextFile(fileF, L""); | 1031 CreateTextFile(fileF, L""); |
1032 CreateTextFile(fileA, L""); | 1032 CreateTextFile(fileA, L""); |
1033 CreateTextFile(fileB, L""); | 1033 CreateTextFile(fileB, L""); |
1034 EXPECT_TRUE(file_util::CreateDirectory(dirE)); | 1034 EXPECT_TRUE(file_util::CreateDirectory(dirE)); |
1035 EXPECT_TRUE(file_util::CreateDirectory(dirC)); | 1035 EXPECT_TRUE(file_util::CreateDirectory(dirC)); |
1036 EXPECT_TRUE(file_util::CreateDirectory(dirD)); | 1036 EXPECT_TRUE(file_util::CreateDirectory(dirD)); |
1037 | 1037 |
1038 // Files and directories are enumerated in the lexicographical order, | 1038 // On Windows, files and directories are enumerated in the lexicographical |
1039 // ignoring case and whether they are files or directories. | 1039 // order, ignoring case and whether they are files or directories. On posix, |
| 1040 // we order directories before files. |
1040 file_util::FileEnumerator enumerator(test_dir_, false, FILES_AND_DIRECTORIES); | 1041 file_util::FileEnumerator enumerator(test_dir_, false, FILES_AND_DIRECTORIES); |
1041 FilePath cur_file = enumerator.Next(); | 1042 FilePath cur_file = enumerator.Next(); |
| 1043 #if defined(OS_WIN) |
1042 EXPECT_EQ(fileA.value(), cur_file.value()); | 1044 EXPECT_EQ(fileA.value(), cur_file.value()); |
1043 cur_file = enumerator.Next(); | 1045 cur_file = enumerator.Next(); |
1044 EXPECT_EQ(fileB.value(), cur_file.value()); | 1046 EXPECT_EQ(fileB.value(), cur_file.value()); |
1045 cur_file = enumerator.Next(); | 1047 cur_file = enumerator.Next(); |
1046 EXPECT_EQ(dirC.value(), cur_file.value()); | 1048 EXPECT_EQ(dirC.value(), cur_file.value()); |
1047 cur_file = enumerator.Next(); | 1049 cur_file = enumerator.Next(); |
1048 EXPECT_EQ(dirD.value(), cur_file.value()); | 1050 EXPECT_EQ(dirD.value(), cur_file.value()); |
1049 cur_file = enumerator.Next(); | 1051 cur_file = enumerator.Next(); |
1050 EXPECT_EQ(dirE.value(), cur_file.value()); | 1052 EXPECT_EQ(dirE.value(), cur_file.value()); |
1051 cur_file = enumerator.Next(); | 1053 cur_file = enumerator.Next(); |
1052 EXPECT_EQ(fileF.value(), cur_file.value()); | 1054 EXPECT_EQ(fileF.value(), cur_file.value()); |
1053 cur_file = enumerator.Next(); | 1055 cur_file = enumerator.Next(); |
| 1056 #elif defined(OS_POSIX) |
| 1057 EXPECT_EQ(dirC.value(), cur_file.value()); |
| 1058 cur_file = enumerator.Next(); |
| 1059 EXPECT_EQ(dirD.value(), cur_file.value()); |
| 1060 cur_file = enumerator.Next(); |
| 1061 EXPECT_EQ(dirE.value(), cur_file.value()); |
| 1062 cur_file = enumerator.Next(); |
| 1063 EXPECT_EQ(fileA.value(), cur_file.value()); |
| 1064 cur_file = enumerator.Next(); |
| 1065 EXPECT_EQ(fileB.value(), cur_file.value()); |
| 1066 cur_file = enumerator.Next(); |
| 1067 EXPECT_EQ(fileF.value(), cur_file.value()); |
| 1068 cur_file = enumerator.Next(); |
| 1069 #endif |
| 1070 |
1054 EXPECT_EQ(FILE_PATH_LITERAL(""), cur_file.value()); | 1071 EXPECT_EQ(FILE_PATH_LITERAL(""), cur_file.value()); |
1055 } | 1072 } |
1056 | 1073 |
1057 void PathComponents(const std::wstring& path, | 1074 void PathComponents(const std::wstring& path, |
1058 std::vector<std::wstring>* components) { | 1075 std::vector<std::wstring>* components) { |
1059 DCHECK(components != NULL); | 1076 DCHECK(components != NULL); |
1060 if (components == NULL) | 1077 if (components == NULL) |
1061 return; | 1078 return; |
1062 std::wstring::size_type start = 0; | 1079 std::wstring::size_type start = 0; |
1063 std::wstring::size_type end = path.find('/', start); | 1080 std::wstring::size_type end = path.find('/', start); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 #elif defined(OS_LINUX) | 1159 #elif defined(OS_LINUX) |
1143 EXPECT_FALSE(file_util::ContainsPath(foo, | 1160 EXPECT_FALSE(file_util::ContainsPath(foo, |
1144 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); | 1161 foo_caps.Append(FILE_PATH_LITERAL("bar.txt")))); |
1145 #else | 1162 #else |
1146 // We can't really do this test on osx since the case-sensitivity of the | 1163 // We can't really do this test on osx since the case-sensitivity of the |
1147 // filesystem is configurable. | 1164 // filesystem is configurable. |
1148 #endif | 1165 #endif |
1149 } | 1166 } |
1150 | 1167 |
1151 } // namespace | 1168 } // namespace |
OLD | NEW |