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

Unified Diff: webkit/fileapi/file_system_origin_database_unittest.cc

Issue 9663021: Add database recovery for FileSystemOriginDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bool -> enum Created 8 years, 9 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
Index: webkit/fileapi/file_system_origin_database_unittest.cc
diff --git a/webkit/fileapi/file_system_origin_database_unittest.cc b/webkit/fileapi/file_system_origin_database_unittest.cc
index c34e636a6a3160dee82561be6c43cf3c583d1652..2e8426b8992dfb6bf93617ec1d110f8036e0ca13 100644
--- a/webkit/fileapi/file_system_origin_database_unittest.cc
+++ b/webkit/fileapi/file_system_origin_database_unittest.cc
@@ -163,4 +163,38 @@ TEST(FileSystemOriginDatabaseTest, ListOriginsTest) {
}
}
+TEST(FileSystemOriginDatabaseTest, DatabaseRecoveryTest) {
+ ScopedTempDir dir;
+ ASSERT_TRUE(dir.CreateUniqueTempDir());
+ const FilePath kDBFile = dir.path().AppendASCII("fsod.db");
+ EXPECT_FALSE(file_util::PathExists(kDBFile));
+
+ const std::string origin("example.com");
+ {
+ FilePath path;
+ FileSystemOriginDatabase database(kDBFile);
+ EXPECT_FALSE(database.HasOriginPath(origin));
+ EXPECT_TRUE(database.GetPathForOrigin(origin, &path));
+ EXPECT_FALSE(path.empty());
+ EXPECT_TRUE(database.HasOriginPath(origin));
+ }
+
+ bool created = false;
+ base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ base::PlatformFile file = base::CreatePlatformFile(
+ kDBFile.AppendASCII("CURRENT"),
+ base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE,
+ &created, &error);
+ EXPECT_EQ(base::PLATFORM_FILE_OK, error);
+ EXPECT_TRUE(created);
+ EXPECT_TRUE(base::ClosePlatformFile(file));
+
+ FilePath path;
+ FileSystemOriginDatabase database(kDBFile);
+ EXPECT_FALSE(database.HasOriginPath(origin));
+ EXPECT_TRUE(database.GetPathForOrigin(origin, &path));
+ EXPECT_FALSE(path.empty());
+ EXPECT_TRUE(database.HasOriginPath(origin));
+}
+
} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698