Chromium Code Reviews| Index: content/browser/download/base_file_unittest.cc |
| diff --git a/content/browser/download/base_file_unittest.cc b/content/browser/download/base_file_unittest.cc |
| index a25ba60e7f67522b5fa32fae78bdb9011a64237a..58a79538731d96fb2e80d39335adcc574b905830 100644 |
| --- a/content/browser/download/base_file_unittest.cc |
| +++ b/content/browser/download/base_file_unittest.cc |
| @@ -465,6 +465,27 @@ TEST_F(BaseFileTest, RenameWhileInProgress) { |
| base_file_->Finish(); |
| } |
| +// Test that a failed rename reports the correct error. |
| +TEST_F(BaseFileTest, RenameWithError) { |
| + ASSERT_EQ(net::OK, base_file_->Initialize()); |
| + |
| + // TestDir is a subdirectory in |temp_dir_| that we will make read-only so |
| + // that the rename will fail. |
| + FilePath test_dir(temp_dir_.path().AppendASCII("TestDir")); |
| + ASSERT_TRUE(file_util::CreateDirectory(test_dir)); |
| + |
| + FilePath new_path(test_dir.AppendASCII("TestFile")); |
| + EXPECT_FALSE(file_util::PathExists(new_path)); |
| + |
| + { |
| + file_util::PermissionRestorer restore_permissions_for(test_dir); |
| + ASSERT_TRUE(file_util::MakeFileUnwritable(test_dir)); |
| + EXPECT_EQ(net::ERR_ACCESS_DENIED, base_file_->Rename(new_path)); |
|
Randy Smith (Not in Mondays)
2012/07/11 17:13:17
I'm concerned about this test, for the reasons you
|
| + } |
| + |
| + base_file_->Finish(); |
| +} |
| + |
| // Write data to the file multiple times. |
| TEST_F(BaseFileTest, MultipleWritesWithError) { |
| ASSERT_TRUE(OpenMockFileStream()); |
| @@ -540,6 +561,9 @@ TEST_F(BaseFileTest, ReadonlyBaseFile) { |
| // Create a new file. |
| FilePath readonly_file_name = CreateTestFile(); |
| + // Restore permissions to the file when we are done with this test. |
| + file_util::PermissionRestorer restore_permissions(readonly_file_name); |
| + |
| // Make it read-only. |
| EXPECT_TRUE(file_util::MakeFileUnwritable(readonly_file_name)); |