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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 EXPECT_EQ(0, info.size); | 510 EXPECT_EQ(0, info.size); |
511 } | 511 } |
512 #endif // defined(OS_WIN) | 512 #endif // defined(OS_WIN) |
513 | 513 |
514 #if defined(OS_POSIX) && defined(GTEST_HAS_DEATH_TEST) | 514 #if defined(OS_POSIX) && defined(GTEST_HAS_DEATH_TEST) |
515 TEST(FileTest, MemoryCorruption) { | 515 TEST(FileTest, MemoryCorruption) { |
516 { | 516 { |
517 // Test that changing the checksum value is detected. | 517 // Test that changing the checksum value is detected. |
518 base::File file; | 518 base::File file; |
519 EXPECT_NE(file.file_.file_memory_checksum_, | 519 EXPECT_NE(file.file_.file_memory_checksum_, |
520 implicit_cast<unsigned int>(file.GetPlatformFile())); | 520 static_cast<unsigned int>(file.GetPlatformFile())); |
521 file.file_.file_memory_checksum_ = file.GetPlatformFile(); | 521 file.file_.file_memory_checksum_ = file.GetPlatformFile(); |
522 EXPECT_DEATH(file.IsValid(), ""); | 522 EXPECT_DEATH(file.IsValid(), ""); |
523 | 523 |
524 file.file_.UpdateChecksum(); // Do not crash on File::~File(). | 524 file.file_.UpdateChecksum(); // Do not crash on File::~File(). |
525 } | 525 } |
526 | 526 |
527 { | 527 { |
528 // Test that changing the file descriptor value is detected. | 528 // Test that changing the file descriptor value is detected. |
529 base::File file; | 529 base::File file; |
530 file.file_.file_.reset(17); | 530 file.file_.file_.reset(17); |
(...skipping 40 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 |