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

Unified Diff: sync/syncable/directory_unittest.cc

Issue 1082893003: [Sync] Erase sync DB when corrupted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reduce test runtime by writing fewer bookmarks Created 5 years, 8 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 | « sync/syncable/directory_backing_store_unittest.cc ('k') | sync/syncable/on_disk_directory_backing_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory_unittest.cc
diff --git a/sync/syncable/directory_unittest.cc b/sync/syncable/directory_unittest.cc
index d802d4f2ccf5624e6af0dba22d1d4dbac748d52c..690af4ff4d6993b190872508f07e230f6db2296a 100644
--- a/sync/syncable/directory_unittest.cc
+++ b/sync/syncable/directory_unittest.cc
@@ -12,6 +12,7 @@
#include "sync/syncable/syncable_write_transaction.h"
#include "sync/test/engine/test_syncable_utils.h"
#include "sync/test/test_directory_backing_store.h"
+#include "sync/util/mock_unrecoverable_error_handler.h"
using base::ExpectDictBooleanValue;
using base::ExpectDictStringValue;
@@ -2030,6 +2031,25 @@ TEST_F(SyncableDirectoryTest, SaveChangesSnapshot_HasUnsavedMetahandleChanges) {
snapshot.delete_journals_to_purge.clear();
}
+// Verify that Directory triggers an unrecoverable error when a catastrophic
+// DirectoryBackingStore error is detected.
+TEST_F(SyncableDirectoryTest, CatastrophicError) {
+ MockUnrecoverableErrorHandler unrecoverable_error_handler;
+ Directory dir(new InMemoryDirectoryBackingStore("catastrophic_error"),
+ &unrecoverable_error_handler, nullptr, nullptr, nullptr);
+ ASSERT_EQ(OPENED, dir.Open(kDirectoryName, directory_change_delegate(),
+ NullTransactionObserver()));
+ ASSERT_EQ(0, unrecoverable_error_handler.invocation_count());
+
+ // Fire off two catastrophic errors. Call it twice to ensure Directory is
+ // tolerant of multiple invocations since that may happen in the real world.
+ dir.OnCatastrophicError();
+ dir.OnCatastrophicError();
+
+ // See that the unrecoverable error handler has been invoked twice.
+ ASSERT_EQ(2, unrecoverable_error_handler.invocation_count());
+}
+
} // namespace syncable
} // namespace syncer
« no previous file with comments | « sync/syncable/directory_backing_store_unittest.cc ('k') | sync/syncable/on_disk_directory_backing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698