| 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 71e4a089caa9ab2600266d12e0613f6ec7893f93..f8787c22f853a72971dd48914bffea8e722d7c34 100644
|
| --- a/webkit/browser/appcache/appcache_database_unittest.cc
|
| +++ b/webkit/browser/appcache/appcache_database_unittest.cc
|
| @@ -73,6 +73,46 @@ TEST(AppCacheDatabaseTest, ReCreate) {
|
| EXPECT_FALSE(base::PathExists(kOtherFile));
|
| }
|
|
|
| +#ifdef NDEBUG
|
| +// Only run in release builds because sql::Connection and familiy
|
| +// crank up DLOG(FATAL)'ness and this test presents it with
|
| +// intentionally bad data which causes debug builds to exit instead
|
| +// of run to completion. In release builds, errors the are deliverd
|
| +// to the consumer so we can test the error handling of the consumer.
|
| +TEST(AppCacheDatabaseTest, QuickIntegrityCheck) {
|
| + // 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");
|
| + const std::string kCorruptData("deadbeef");
|
| + EXPECT_EQ(static_cast<int>(kCorruptData.length()),
|
| + file_util::WriteFile(
|
| + kDbFile, kCorruptData.data(), kCorruptData.length()));
|
| + const base::FilePath kOtherFile = temp_dir.path().AppendASCII("other_file");
|
| + EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3));
|
| +
|
| + // See that the sql::Connection opens, but fails to pass the integrity check.
|
| + sql::Connection raw_db;
|
| + std::vector<std::string> messages;
|
| + EXPECT_TRUE(raw_db.Open(kDbFile));
|
| + EXPECT_FALSE(raw_db.QuickIntegrityCheck(&messages));
|
| + raw_db.Close();
|
| +
|
| + // Should delete the corrupt data and start over.
|
| + AppCacheDatabase db(kDbFile);
|
| + EXPECT_TRUE(db.LazyOpen(true));
|
| + EXPECT_FALSE(base::PathExists(kOtherFile));
|
| + EXPECT_TRUE(base::PathExists(kDbFile));
|
| + db.CloseConnection();
|
| +
|
| + // See that the Connection now passes its integrity check.
|
| + EXPECT_TRUE(raw_db.Open(kDbFile));
|
| + EXPECT_TRUE(raw_db.QuickIntegrityCheck(&messages));
|
| + ASSERT_EQ(1u, messages.size());
|
| + EXPECT_EQ(std::string("ok"), messages[0]);
|
| +}
|
| +#endif // NDEBUG
|
| +
|
| TEST(AppCacheDatabaseTest, ExperimentalFlags) {
|
| const char kExperimentFlagsKey[] = "ExperimentFlags";
|
| std::string kInjectedFlags("exp1,exp2");
|
|
|