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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 #elif defined(OS_POSIX) | 318 #elif defined(OS_POSIX) |
319 {L"/foo/bar", L"bar"}, | 319 {L"/foo/bar", L"bar"}, |
320 {L"/foo/bar/", L""}, | 320 {L"/foo/bar/", L""}, |
321 {L"/filename.exe", L"filename.exe"}, | 321 {L"/filename.exe", L"filename.exe"}, |
322 {L"filename.exe", L"filename.exe"}, | 322 {L"filename.exe", L"filename.exe"}, |
323 {L"", L""}, | 323 {L"", L""}, |
324 {L"/", L""}, | 324 {L"/", L""}, |
325 #endif | 325 #endif |
326 }; | 326 }; |
327 | 327 |
| 328 #if defined(OS_WIN) |
| 329 // This function is deprecated on non-Windows. |
328 TEST_F(FileUtilTest, GetFilenameFromPath) { | 330 TEST_F(FileUtilTest, GetFilenameFromPath) { |
329 for (unsigned int i = 0; i < arraysize(filename_cases); ++i) { | 331 for (unsigned int i = 0; i < arraysize(filename_cases); ++i) { |
330 const filename_case& value = filename_cases[i]; | 332 const filename_case& value = filename_cases[i]; |
331 std::wstring result = file_util::GetFilenameFromPath(value.path); | 333 std::wstring result = file_util::GetFilenameFromPath(value.path); |
332 EXPECT_EQ(value.filename, result); | 334 EXPECT_EQ(value.filename, result); |
333 } | 335 } |
334 } | 336 } |
| 337 #endif |
335 | 338 |
336 // Test finding the file type from a path name | 339 // Test finding the file type from a path name |
337 static const struct extension_case { | 340 static const struct extension_case { |
338 const wchar_t* path; | 341 const wchar_t* path; |
339 const wchar_t* extension; | 342 const wchar_t* extension; |
340 } extension_cases[] = { | 343 } extension_cases[] = { |
341 #if defined(OS_WIN) | 344 #if defined(OS_WIN) |
342 {L"C:\\colon\\backslash\\filename.extension", L"extension"}, | 345 {L"C:\\colon\\backslash\\filename.extension", L"extension"}, |
343 {L"C:\\colon\\backslash\\filename.", L""}, | 346 {L"C:\\colon\\backslash\\filename.", L""}, |
344 {L"C:\\colon\\backslash\\filename", L""}, | 347 {L"C:\\colon\\backslash\\filename", L""}, |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); | 1851 EXPECT_TRUE(file_util::IsDirectoryEmpty(empty_dir)); |
1849 | 1852 |
1850 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); | 1853 FilePath foo(empty_dir.Append(FILE_PATH_LITERAL("foo.txt"))); |
1851 std::string bar("baz"); | 1854 std::string bar("baz"); |
1852 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); | 1855 ASSERT_TRUE(file_util::WriteFile(foo, bar.c_str(), bar.length())); |
1853 | 1856 |
1854 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); | 1857 EXPECT_FALSE(file_util::IsDirectoryEmpty(empty_dir)); |
1855 } | 1858 } |
1856 | 1859 |
1857 } // namespace | 1860 } // namespace |
OLD | NEW |