Index: content/browser/quota/quota_database_unittest.cc |
diff --git a/content/browser/quota/quota_database_unittest.cc b/content/browser/quota/quota_database_unittest.cc |
index 8241c188d0b9ecbe23818cb4d617722c33b240d6..5f02df2fcf6563730870fc72af16e3eed9c119f1 100644 |
--- a/content/browser/quota/quota_database_unittest.cc |
+++ b/content/browser/quota/quota_database_unittest.cc |
@@ -15,6 +15,7 @@ |
#include "sql/connection.h" |
#include "sql/meta_table.h" |
#include "sql/statement.h" |
+#include "sql/test/test_helpers.h" |
#include "storage/browser/quota/quota_database.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "url/gurl.h" |
@@ -47,6 +48,13 @@ class QuotaDatabaseTest : public testing::Test { |
EXPECT_TRUE(kDbFile.empty() || base::PathExists(kDbFile)); |
} |
+ void Reopen(const base::FilePath& kDbFile) { |
michaeln
2015/07/25 00:54:58
very funky name for an a param but i see its in ke
|
+ QuotaDatabase db(kDbFile); |
+ ASSERT_TRUE(db.LazyOpen(false)); |
+ EXPECT_TRUE(db.db_.get()); |
+ EXPECT_TRUE(kDbFile.empty() || base::PathExists(kDbFile)); |
+ } |
+ |
void UpgradeSchemaV2toV3(const base::FilePath& kDbFile) { |
const QuotaTableEntry entries[] = { |
QuotaTableEntry("a", kStorageTypeTemporary, 1), |
@@ -563,4 +571,14 @@ TEST_F(QuotaDatabaseTest, DumpOriginInfoTable) { |
DumpOriginInfoTable(kDbFile); |
DumpOriginInfoTable(base::FilePath()); |
} |
+ |
+TEST_F(QuotaDatabaseTest, OpenCorruptedDatabase) { |
+ base::ScopedTempDir data_dir; |
+ ASSERT_TRUE(data_dir.CreateUniqueTempDir()); |
+ const base::FilePath kDbFile = data_dir.path().AppendASCII(kDBFileName); |
+ LazyOpen(kDbFile); |
+ ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile)); |
+ Reopen(kDbFile); |
+} |
+ |
} // namespace content |