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

Side by Side Diff: sync/syncable/deferred_on_disk_directory_backing_store_unittest.cc

Issue 1072093002: [Sync] Update DirectoryBackingStore to detect Sync DB corruption (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. 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 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 "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/message_loop/message_loop.h"
6 #include "base/stl_util.h" 7 #include "base/stl_util.h"
7 #include "sync/syncable/deferred_on_disk_directory_backing_store.h" 8 #include "sync/syncable/deferred_on_disk_directory_backing_store.h"
8 #include "sync/syncable/directory.h" 9 #include "sync/syncable/directory.h"
9 #include "sync/syncable/entry_kernel.h" 10 #include "sync/syncable/entry_kernel.h"
10 #include "sync/syncable/on_disk_directory_backing_store.h" 11 #include "sync/syncable/on_disk_directory_backing_store.h"
11 #include "sync/syncable/syncable_delete_journal.h" 12 #include "sync/syncable/syncable_delete_journal.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace syncer { 15 namespace syncer {
15 namespace syncable { 16 namespace syncable {
16 namespace { 17 namespace {
17 18
18 static const base::FilePath::CharType kSyncDataFolderName[] = 19 static const base::FilePath::CharType kSyncDataFolderName[] =
19 FILE_PATH_LITERAL("Sync Data"); 20 FILE_PATH_LITERAL("Sync Data");
20 21
21 class DeferredOnDiskDirectoryBackingStoreTest : public testing::Test { 22 class DeferredOnDiskDirectoryBackingStoreTest : public testing::Test {
22 protected: 23 protected:
23 void SetUp() override { 24 void SetUp() override {
24 CHECK(temp_dir_.CreateUniqueTempDir()); 25 CHECK(temp_dir_.CreateUniqueTempDir());
25 db_path_ = temp_dir_.path().Append(kSyncDataFolderName); 26 db_path_ = temp_dir_.path().Append(kSyncDataFolderName);
26 } 27 }
27 28
28 void TearDown() override { STLDeleteValues(&handles_map_); } 29 void TearDown() override { STLDeleteValues(&handles_map_); }
29 30
31 base::MessageLoop message_loop_;
30 base::ScopedTempDir temp_dir_; 32 base::ScopedTempDir temp_dir_;
31 base::FilePath db_path_; 33 base::FilePath db_path_;
32 Directory::MetahandlesMap handles_map_; 34 Directory::MetahandlesMap handles_map_;
33 JournalIndex delete_journals_; 35 JournalIndex delete_journals_;
34 MetahandleSet metahandles_to_purge_; 36 MetahandleSet metahandles_to_purge_;
35 Directory::KernelLoadInfo kernel_load_info_; 37 Directory::KernelLoadInfo kernel_load_info_;
36 }; 38 };
37 39
38 // Test initialization of root entry when calling Load(). 40 // Test initialization of root entry when calling Load().
39 TEST_F(DeferredOnDiskDirectoryBackingStoreTest, Load) { 41 TEST_F(DeferredOnDiskDirectoryBackingStoreTest, Load) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ASSERT_EQ(2u, handles_map_.size()); 108 ASSERT_EQ(2u, handles_map_.size());
107 ASSERT_TRUE(handles_map_.count(1)); // root node 109 ASSERT_TRUE(handles_map_.count(1)); // root node
108 ASSERT_TRUE(handles_map_.count(2)); 110 ASSERT_TRUE(handles_map_.count(2));
109 EntryKernel* entry = handles_map_[2]; 111 EntryKernel* entry = handles_map_[2];
110 EXPECT_EQ(Id::CreateFromClientString("test_entry"), entry->ref(ID)); 112 EXPECT_EQ(Id::CreateFromClientString("test_entry"), entry->ref(ID));
111 } 113 }
112 114
113 } // namespace 115 } // namespace
114 } // namespace syncable 116 } // namespace syncable
115 } // namespace syncer 117 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698