| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/syncable/directory_unittest.h" | 5 #include "sync/syncable/directory_unittest.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/test/values_test_util.h" | 8 #include "base/test/values_test_util.h" |
| 9 #include "sync/internal_api/public/base/attachment_id_proto.h" | 9 #include "sync/internal_api/public/base/attachment_id_proto.h" |
| 10 #include "sync/syncable/syncable_proto_util.h" | 10 #include "sync/syncable/syncable_proto_util.h" |
| 11 #include "sync/syncable/syncable_util.h" | 11 #include "sync/syncable/syncable_util.h" |
| 12 #include "sync/syncable/syncable_write_transaction.h" | 12 #include "sync/syncable/syncable_write_transaction.h" |
| 13 #include "sync/test/engine/test_syncable_utils.h" | 13 #include "sync/test/engine/test_syncable_utils.h" |
| 14 #include "sync/test/test_directory_backing_store.h" | 14 #include "sync/test/test_directory_backing_store.h" |
| 15 #include "sync/util/mock_unrecoverable_error_handler.h" | |
| 16 | 15 |
| 17 using base::ExpectDictBooleanValue; | 16 using base::ExpectDictBooleanValue; |
| 18 using base::ExpectDictStringValue; | 17 using base::ExpectDictStringValue; |
| 19 | 18 |
| 20 namespace syncer { | 19 namespace syncer { |
| 21 | 20 |
| 22 namespace syncable { | 21 namespace syncable { |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| (...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 snapshot.delete_journals.insert(&kernel); | 2023 snapshot.delete_journals.insert(&kernel); |
| 2025 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); | 2024 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); |
| 2026 snapshot.delete_journals.clear(); | 2025 snapshot.delete_journals.clear(); |
| 2027 | 2026 |
| 2028 EXPECT_FALSE(snapshot.HasUnsavedMetahandleChanges()); | 2027 EXPECT_FALSE(snapshot.HasUnsavedMetahandleChanges()); |
| 2029 snapshot.delete_journals_to_purge.insert(1); | 2028 snapshot.delete_journals_to_purge.insert(1); |
| 2030 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); | 2029 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); |
| 2031 snapshot.delete_journals_to_purge.clear(); | 2030 snapshot.delete_journals_to_purge.clear(); |
| 2032 } | 2031 } |
| 2033 | 2032 |
| 2034 // Verify that Directory triggers an unrecoverable error when a catastrophic | |
| 2035 // DirectoryBackingStore error is detected. | |
| 2036 TEST_F(SyncableDirectoryTest, CatastrophicError) { | |
| 2037 MockUnrecoverableErrorHandler unrecoverable_error_handler; | |
| 2038 Directory dir(new InMemoryDirectoryBackingStore("catastrophic_error"), | |
| 2039 &unrecoverable_error_handler, nullptr, nullptr, nullptr); | |
| 2040 ASSERT_EQ(OPENED, dir.Open(kDirectoryName, directory_change_delegate(), | |
| 2041 NullTransactionObserver())); | |
| 2042 ASSERT_EQ(0, unrecoverable_error_handler.invocation_count()); | |
| 2043 | |
| 2044 // Fire off two catastrophic errors. Call it twice to ensure Directory is | |
| 2045 // tolerant of multiple invocations since that may happen in the real world. | |
| 2046 dir.OnCatastrophicError(); | |
| 2047 dir.OnCatastrophicError(); | |
| 2048 | |
| 2049 // See that the unrecoverable error handler has been invoked twice. | |
| 2050 ASSERT_EQ(2, unrecoverable_error_handler.invocation_count()); | |
| 2051 } | |
| 2052 | |
| 2053 } // namespace syncable | 2033 } // namespace syncable |
| 2054 | 2034 |
| 2055 } // namespace syncer | 2035 } // namespace syncer |
| OLD | NEW |