OLD | NEW |
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 "base/files/file.h" | 5 #include "base/files/file.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 | 488 |
489 #if defined(OS_WIN) | 489 #if defined(OS_WIN) |
490 TEST(FileTest, GetInfoForDirectory) { | 490 TEST(FileTest, GetInfoForDirectory) { |
491 base::ScopedTempDir temp_dir; | 491 base::ScopedTempDir temp_dir; |
492 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 492 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
493 FilePath empty_dir = temp_dir.path().Append(FILE_PATH_LITERAL("gpfi_test")); | 493 FilePath empty_dir = temp_dir.path().Append(FILE_PATH_LITERAL("gpfi_test")); |
494 ASSERT_TRUE(CreateDirectory(empty_dir)); | 494 ASSERT_TRUE(CreateDirectory(empty_dir)); |
495 | 495 |
496 base::File dir( | 496 base::File dir( |
497 ::CreateFile(empty_dir.value().c_str(), | 497 ::CreateFile(empty_dir.value().c_str(), |
498 FILE_ALL_ACCESS, | 498 GENERIC_READ | GENERIC_WRITE, |
499 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 499 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
500 NULL, | 500 NULL, |
501 OPEN_EXISTING, | 501 OPEN_EXISTING, |
502 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. | 502 FILE_FLAG_BACKUP_SEMANTICS, // Needed to open a directory. |
503 NULL)); | 503 NULL)); |
504 ASSERT_TRUE(dir.IsValid()); | 504 ASSERT_TRUE(dir.IsValid()); |
505 | 505 |
506 base::File::Info info; | 506 base::File::Info info; |
507 EXPECT_TRUE(dir.GetInfo(&info)); | 507 EXPECT_TRUE(dir.GetInfo(&info)); |
508 EXPECT_TRUE(info.is_directory); | 508 EXPECT_TRUE(info.is_directory); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 EXPECT_DEATH(file.Seek(File::FROM_BEGIN, 0), ""); | 571 EXPECT_DEATH(file.Seek(File::FROM_BEGIN, 0), ""); |
572 EXPECT_DEATH(file.Read(0, NULL, 0), ""); | 572 EXPECT_DEATH(file.Read(0, NULL, 0), ""); |
573 EXPECT_DEATH(file.ReadAtCurrentPos(NULL, 0), ""); | 573 EXPECT_DEATH(file.ReadAtCurrentPos(NULL, 0), ""); |
574 EXPECT_DEATH(file.Write(0, NULL, 0), ""); | 574 EXPECT_DEATH(file.Write(0, NULL, 0), ""); |
575 | 575 |
576 ignore_result(file.file_.file_.release()); | 576 ignore_result(file.file_.file_.release()); |
577 file.file_.UpdateChecksum(); | 577 file.file_.UpdateChecksum(); |
578 } | 578 } |
579 } | 579 } |
580 #endif // defined(OS_POSIX) | 580 #endif // defined(OS_POSIX) |
OLD | NEW |