| Index: chrome/browser/sync/syncable/directory_backing_store_unittest.cc
|
| diff --git a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
|
| index bf5dfde678162d8a3a2a6d7ee9d780e1523e4ecb..777a163a09d9b42c4c5d0f4279e1ca10ab1c7197 100644
|
| --- a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
|
| +++ b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "app/sql/statement.h"
|
| #include "app/sql/transaction.h"
|
| #include "base/file_path.h"
|
| +#include "base/file_util.h"
|
| #include "base/scoped_ptr.h"
|
| #include "base/scoped_temp_dir.h"
|
| #include "base/stl_util-inl.h"
|
| @@ -870,4 +871,27 @@ TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
|
| }
|
| }
|
|
|
| +TEST_F(DirectoryBackingStoreTest, Corruption) {
|
| + {
|
| + scoped_ptr<DirectoryBackingStore> dbs(
|
| + new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
|
| + EXPECT_TRUE(dbs->BeginLoad());
|
| + }
|
| + std::string bad_data("BAD DATA");
|
| + EXPECT_TRUE(file_util::WriteFile(GetDatabasePath(), bad_data.data(),
|
| + bad_data.size()));
|
| + {
|
| + scoped_ptr<DirectoryBackingStore> dbs(
|
| + new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
|
| +
|
| + // In release mode, we expect the sync database to nuke itself and start
|
| + // over if it detects invalid/corrupted data.
|
| +#if defined(NDEBUG)
|
| + EXPECT_TRUE(dbs->BeginLoad());
|
| +#else
|
| + EXPECT_DEATH(dbs->BeginLoad(), "sqlite error");
|
| +#endif
|
| + }
|
| +}
|
| +
|
| } // namespace syncable
|
|
|