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

Unified Diff: content/browser/quota/quota_database_unittest.cc

Issue 1236583002: Try to reset quota database which is suspected to be corrupted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reworked in more logical way. Added unittest Created 5 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 | « no previous file | storage/browser/quota/quota_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | storage/browser/quota/quota_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698