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

Unified Diff: content/browser/download/base_file_unittest.cc

Issue 10702130: Add test for failing rename in BaseFileTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/base_file.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « content/browser/download/base_file.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698