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" | |
15 | 16 |
16 using base::ExpectDictBooleanValue; | 17 using base::ExpectDictBooleanValue; |
17 using base::ExpectDictStringValue; | 18 using base::ExpectDictStringValue; |
18 | 19 |
19 namespace syncer { | 20 namespace syncer { |
20 | 21 |
21 namespace syncable { | 22 namespace syncable { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2023 snapshot.delete_journals.insert(&kernel); | 2024 snapshot.delete_journals.insert(&kernel); |
2024 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); | 2025 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); |
2025 snapshot.delete_journals.clear(); | 2026 snapshot.delete_journals.clear(); |
2026 | 2027 |
2027 EXPECT_FALSE(snapshot.HasUnsavedMetahandleChanges()); | 2028 EXPECT_FALSE(snapshot.HasUnsavedMetahandleChanges()); |
2028 snapshot.delete_journals_to_purge.insert(1); | 2029 snapshot.delete_journals_to_purge.insert(1); |
2029 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); | 2030 EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); |
2030 snapshot.delete_journals_to_purge.clear(); | 2031 snapshot.delete_journals_to_purge.clear(); |
2031 } | 2032 } |
2032 | 2033 |
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. | |
2045 dir.OnCatastrophicError(); | |
Nicolas Zea
2015/04/27 19:17:32
out of curiosity, why twice?
maniscalco
2015/04/27 19:51:17
Just to make sure Directory can tolerate since tha
| |
2046 dir.OnCatastrophicError(); | |
2047 | |
2048 // See that the unrecoverable error handler has been invoked twice. | |
2049 ASSERT_EQ(2, unrecoverable_error_handler.invocation_count()); | |
2050 } | |
2051 | |
2033 } // namespace syncable | 2052 } // namespace syncable |
2034 | 2053 |
2035 } // namespace syncer | 2054 } // namespace syncer |
OLD | NEW |