Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: base/file_util_unittest.cc

Issue 101143006: Convert base::file_util to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base:: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 ASSERT_FALSE(DevicePathToDriveLetterPath( 479 ASSERT_FALSE(DevicePathToDriveLetterPath(
480 real_device_path_plus_numbers, 480 real_device_path_plus_numbers,
481 &win32_path)); 481 &win32_path));
482 482
483 ASSERT_FALSE(DevicePathToDriveLetterPath( 483 ASSERT_FALSE(DevicePathToDriveLetterPath(
484 real_device_path_plus_numbers.Append(kRelativePath), 484 real_device_path_plus_numbers.Append(kRelativePath),
485 &win32_path)); 485 &win32_path));
486 } 486 }
487 487
488 TEST_F(FileUtilTest, GetPlatformFileInfoForDirectory) {
489 FilePath empty_dir = temp_dir_.path().Append(FPL("gpfi_test"));
490 ASSERT_TRUE(CreateDirectory(empty_dir));
491 win::ScopedHandle dir(
492 ::CreateFile(empty_dir.value().c_str(),
493 FILE_ALL_ACCESS,
494 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
495 NULL,
496 OPEN_EXISTING,
497 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory.
498 NULL));
499 ASSERT_TRUE(dir.IsValid());
500 PlatformFileInfo info;
501 EXPECT_TRUE(GetPlatformFileInfo(dir.Get(), &info));
502 EXPECT_TRUE(info.is_directory);
503 EXPECT_FALSE(info.is_symbolic_link);
504 EXPECT_EQ(0, info.size);
505 }
506
507 TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) { 488 TEST_F(FileUtilTest, CreateTemporaryFileInDirLongPathTest) {
508 // Test that CreateTemporaryFileInDir() creates a path and returns a long path 489 // Test that CreateTemporaryFileInDir() creates a path and returns a long path
509 // if it is available. This test requires that: 490 // if it is available. This test requires that:
510 // - the filesystem at |temp_dir_| supports long filenames. 491 // - the filesystem at |temp_dir_| supports long filenames.
511 // - the account has FILE_LIST_DIRECTORY permission for all ancestor 492 // - the account has FILE_LIST_DIRECTORY permission for all ancestor
512 // directories of |temp_dir_|. 493 // directories of |temp_dir_|.
513 const FilePath::CharType kLongDirName[] = FPL("A long path"); 494 const FilePath::CharType kLongDirName[] = FPL("A long path");
514 const FilePath::CharType kTestSubDirName[] = FPL("test"); 495 const FilePath::CharType kTestSubDirName[] = FPL("test");
515 FilePath long_test_dir = temp_dir_.path().Append(kLongDirName); 496 FilePath long_test_dir = temp_dir_.path().Append(kLongDirName);
516 ASSERT_TRUE(CreateDirectory(long_test_dir)); 497 ASSERT_TRUE(CreateDirectory(long_test_dir));
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 ASSERT_TRUE(Time::FromString("Wed, 16 Nov 1994, 00:00:00", 1886 ASSERT_TRUE(Time::FromString("Wed, 16 Nov 1994, 00:00:00",
1906 &access_time)); 1887 &access_time));
1907 1888
1908 Time modification_time; 1889 Time modification_time;
1909 // Note that this timestamp is divisible by two (seconds) - FAT stores 1890 // Note that this timestamp is divisible by two (seconds) - FAT stores
1910 // modification times with 2s resolution. 1891 // modification times with 2s resolution.
1911 ASSERT_TRUE(Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", 1892 ASSERT_TRUE(Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT",
1912 &modification_time)); 1893 &modification_time));
1913 1894
1914 ASSERT_TRUE(TouchFile(foobar, access_time, modification_time)); 1895 ASSERT_TRUE(TouchFile(foobar, access_time, modification_time));
1915 PlatformFileInfo file_info; 1896 File::Info file_info;
1916 ASSERT_TRUE(GetFileInfo(foobar, &file_info)); 1897 ASSERT_TRUE(GetFileInfo(foobar, &file_info));
1917 EXPECT_EQ(file_info.last_accessed.ToInternalValue(), 1898 EXPECT_EQ(file_info.last_accessed.ToInternalValue(),
1918 access_time.ToInternalValue()); 1899 access_time.ToInternalValue());
1919 EXPECT_EQ(file_info.last_modified.ToInternalValue(), 1900 EXPECT_EQ(file_info.last_modified.ToInternalValue(),
1920 modification_time.ToInternalValue()); 1901 modification_time.ToInternalValue());
1921 } 1902 }
1922 1903
1923 TEST_F(FileUtilTest, IsDirectoryEmpty) { 1904 TEST_F(FileUtilTest, IsDirectoryEmpty) {
1924 FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir")); 1905 FilePath empty_dir = temp_dir_.path().Append(FILE_PATH_LITERAL("EmptyDir"));
1925 1906
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2347 int fd = OpenContentUriForRead(path); 2328 int fd = OpenContentUriForRead(path);
2348 EXPECT_EQ(-1, fd); 2329 EXPECT_EQ(-1, fd);
2349 } 2330 }
2350 #endif 2331 #endif
2351 2332
2352 #endif // defined(OS_POSIX) 2333 #endif // defined(OS_POSIX)
2353 2334
2354 } // namespace 2335 } // namespace
2355 2336
2356 } // namespace base 2337 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698