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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
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
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. 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
2033 } // namespace syncable 2053 } // namespace syncable
2034 2054
2035 } // namespace syncer 2055 } // namespace syncer
OLDNEW
« 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