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

Unified Diff: webkit/fileapi/obfuscated_file_system_file_util_unittest.cc

Issue 7608018: Handle inconsistency between DB and Files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed regression Created 9 years, 4 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 | « webkit/fileapi/obfuscated_file_system_file_util.cc ('k') | webkit/fileapi/sandbox_mount_point_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
diff --git a/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
index 509f8060882045897eecd2f7d0f2e95867b61732..051d37c7aeb4111498b0690e4acf441114acac8e 100644
--- a/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
+++ b/webkit/fileapi/obfuscated_file_system_file_util_unittest.cc
@@ -1335,3 +1335,80 @@ TEST_F(ObfuscatedFileSystemFileUtilTest, TestRevokeUsageCache) {
EXPECT_EQ(expected_quota, SizeInUsageFile());
EXPECT_EQ(expected_quota, usage());
}
+
+TEST_F(ObfuscatedFileSystemFileUtilTest, TestInconsistency) {
+ const FilePath kPath1 = FilePath().AppendASCII("hoge");
+ const FilePath kPath2 = FilePath().AppendASCII("fuga");
+
+ scoped_ptr<FileSystemOperationContext> context;
+ base::PlatformFile file;
+ base::PlatformFileInfo file_info;
+ FilePath data_path;
+ bool created = false;
+
+ // Create a non-empty file.
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->EnsureFileExists(context.get(), kPath1, &created));
+ EXPECT_TRUE(created);
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->Truncate(context.get(), kPath1, 10));
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->GetFileInfo(
+ context.get(), kPath1, &file_info, &data_path));
+ EXPECT_EQ(10, file_info.size);
+
+ // Destroy database to make inconsistency between database and filesystem.
+ ofsfu()->DestroyDirectoryDatabase(origin(), type());
+
+ // Try to get file info of broken file.
+ context.reset(NewContext(NULL));
+ EXPECT_FALSE(ofsfu()->PathExists(context.get(), kPath1));
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->EnsureFileExists(context.get(), kPath1, &created));
+ EXPECT_TRUE(created);
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->GetFileInfo(
+ context.get(), kPath1, &file_info, &data_path));
+ EXPECT_EQ(0, file_info.size);
+
+ // Make another broken file to |kPath2|.
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->EnsureFileExists(context.get(), kPath2, &created));
+ EXPECT_TRUE(created);
+
+ // Destroy again.
+ ofsfu()->DestroyDirectoryDatabase(origin(), type());
+
+ // Repair broken |kPath1|.
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
+ ofsfu()->Touch(context.get(), kPath1, base::Time::Now(),
+ base::Time::Now()));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->EnsureFileExists(context.get(), kPath1, &created));
+ EXPECT_TRUE(created);
+
+ // Copy from sound |kPath1| to broken |kPath2|.
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->CopyOrMoveFile(context.get(), kPath1, kPath2,
+ true /* copy */));
+
+ ofsfu()->DestroyDirectoryDatabase(origin(), type());
+ context.reset(NewContext(NULL));
+ EXPECT_EQ(base::PLATFORM_FILE_OK,
+ ofsfu()->CreateOrOpen(
+ context.get(), kPath1,
+ base::PLATFORM_FILE_READ | base::PLATFORM_FILE_CREATE,
+ &file, &created));
+ EXPECT_TRUE(created);
+ EXPECT_TRUE(base::GetPlatformFileInfo(file, &file_info));
+ EXPECT_EQ(0, file_info.size);
+ EXPECT_TRUE(base::ClosePlatformFile(file));
+}
« no previous file with comments | « webkit/fileapi/obfuscated_file_system_file_util.cc ('k') | webkit/fileapi/sandbox_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698