| 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 "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 <winioctl.h> | 9 #include <winioctl.h> |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 #elif defined(OS_POSIX) | 244 #elif defined(OS_POSIX) |
| 245 {L"/foo/bar", L"bar"}, | 245 {L"/foo/bar", L"bar"}, |
| 246 {L"/foo/bar/", L""}, | 246 {L"/foo/bar/", L""}, |
| 247 {L"/filename.exe", L"filename.exe"}, | 247 {L"/filename.exe", L"filename.exe"}, |
| 248 {L"filename.exe", L"filename.exe"}, | 248 {L"filename.exe", L"filename.exe"}, |
| 249 {L"", L""}, | 249 {L"", L""}, |
| 250 {L"/", L""}, | 250 {L"/", L""}, |
| 251 #endif | 251 #endif |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 #if defined(OS_WIN) | |
| 255 // This function is deprecated on non-Windows. | |
| 256 TEST_F(FileUtilTest, GetFilenameFromPath) { | |
| 257 for (unsigned int i = 0; i < arraysize(filename_cases); ++i) { | |
| 258 const filename_case& value = filename_cases[i]; | |
| 259 std::wstring result = file_util::GetFilenameFromPath(value.path); | |
| 260 EXPECT_EQ(value.filename, result); | |
| 261 } | |
| 262 } | |
| 263 #endif | |
| 264 | |
| 265 // Test finding the file type from a path name | 254 // Test finding the file type from a path name |
| 266 static const struct extension_case { | 255 static const struct extension_case { |
| 267 const wchar_t* path; | 256 const wchar_t* path; |
| 268 const wchar_t* extension; | 257 const wchar_t* extension; |
| 269 } extension_cases[] = { | 258 } extension_cases[] = { |
| 270 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
| 271 {L"C:\\colon\\backslash\\filename.extension", L"extension"}, | 260 {L"C:\\colon\\backslash\\filename.extension", L"extension"}, |
| 272 {L"C:\\colon\\backslash\\filename.", L""}, | 261 {L"C:\\colon\\backslash\\filename.", L""}, |
| 273 {L"C:\\colon\\backslash\\filename", L""}, | 262 {L"C:\\colon\\backslash\\filename", L""}, |
| 274 {L"C:\\colon\\backslash\\", L""}, | 263 {L"C:\\colon\\backslash\\", L""}, |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); | 1816 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); |
| 1828 | 1817 |
| 1829 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); | 1818 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); |
| 1830 std::string bar("baz"); | 1819 std::string bar("baz"); |
| 1831 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); | 1820 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); |
| 1832 | 1821 |
| 1833 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); | 1822 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); |
| 1834 } | 1823 } |
| 1835 | 1824 |
| 1836 } // namespace | 1825 } // namespace |
| OLD | NEW |