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

Unified Diff: webkit/browser/appcache/appcache_database_unittest.cc

Issue 137493003: Appcache::OnCorruptionDetected handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/browser/appcache/appcache_database.cc ('k') | webkit/browser/appcache/appcache_disk_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/appcache/appcache_database_unittest.cc
diff --git a/webkit/browser/appcache/appcache_database_unittest.cc b/webkit/browser/appcache/appcache_database_unittest.cc
index b5f4e40152a9166e9a75c2785caac293f42aa71c..641ab06561eaf53e8b1fc5b3cbb6ac9b60c14337 100644
--- a/webkit/browser/appcache/appcache_database_unittest.cc
+++ b/webkit/browser/appcache/appcache_database_unittest.cc
@@ -109,11 +109,38 @@ TEST(AppCacheDatabaseTest, QuickIntegrityCheck) {
EXPECT_TRUE(db.LazyOpen(true));
EXPECT_FALSE(base::PathExists(kOtherFile));
EXPECT_TRUE(base::PathExists(kDbFile));
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
+ EXPECT_TRUE(ignore_errors.CheckIgnoredErrors());
}
}
#endif // NDEBUG
+TEST(AppCacheDatabaseTest, WasCorrutionDetected) {
+ // Real files on disk for this test too, a corrupt database file.
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ const base::FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db");
+
+ // First create a valid db file.
+ AppCacheDatabase db(kDbFile);
+ EXPECT_TRUE(db.LazyOpen(true));
+ EXPECT_TRUE(base::PathExists(kDbFile));
+ EXPECT_FALSE(db.was_corruption_detected());
+
+ // Break it.
+ ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile));
+
+ // See the the corruption is detected and reported.
+ {
+ sql::ScopedErrorIgnorer ignore_errors;
+ ignore_errors.IgnoreError(SQLITE_CORRUPT);
+ std::map<GURL, int64> usage_map;
+ EXPECT_FALSE(db.GetAllOriginUsage(&usage_map));
+ EXPECT_TRUE(db.was_corruption_detected());
+ EXPECT_TRUE(base::PathExists(kDbFile));
+ EXPECT_TRUE(ignore_errors.CheckIgnoredErrors());
+ }
+}
+
TEST(AppCacheDatabaseTest, ExperimentalFlags) {
const char kExperimentFlagsKey[] = "ExperimentFlags";
std::string kInjectedFlags("exp1,exp2");
« no previous file with comments | « webkit/browser/appcache/appcache_database.cc ('k') | webkit/browser/appcache/appcache_disk_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698