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 |