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

Side by Side Diff: sync/syncable/directory_unittest.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/syncable/directory_change_delegate.h ('k') | sync/syncable/directory_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_
6 #define SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_
7
8 #include <stdint.h>
9
10 #include <string>
11
12 #include "base/message_loop/message_loop.h"
13 #include "sync/syncable/in_memory_directory_backing_store.h"
14 #include "sync/syncable/mutable_entry.h"
15 #include "sync/syncable/syncable_read_transaction.h"
16 #include "sync/syncable/syncable_write_transaction.h"
17 #include "sync/test/engine/test_id_factory.h"
18 #include "sync/test/fake_encryptor.h"
19 #include "sync/test/null_directory_change_delegate.h"
20 #include "sync/test/null_transaction_observer.h"
21 #include "sync/util/test_unrecoverable_error_handler.h"
22 #include "testing/gtest/include/gtest/gtest.h"
23
24 namespace syncer {
25
26 namespace syncable {
27
28 class BaseTransaction;
29
30 // A test fixture for syncable::Directory. Uses an in-memory database to keep
31 // the unit tests fast.
32 //
33 // Serves as base class for several other test fixtures.
34 class SyncableDirectoryTest : public testing::Test {
35 protected:
36 static const char kDirectoryName[];
37
38 SyncableDirectoryTest();
39 ~SyncableDirectoryTest() override;
40
41 void SetUp() override;
42 void TearDown() override;
43
44 // Destroys any currently opened directory, creates and opens a new one.
45 //
46 // Returns result of the Open call.
47 DirOpenResult ReopenDirectory();
48
49 // Creates an empty entry and sets the ID field to a default one.
50 void CreateEntry(const ModelType& model_type, const std::string& entryname);
51
52 // Creates an empty entry and sets the ID field to id.
53 void CreateEntry(const ModelType& model_type,
54 const std::string& entryname,
55 const int id);
56
57 void CreateEntry(const ModelType& model_type,
58 const std::string& entryname,
59 const Id& id);
60
61 void CreateEntryWithAttachmentMetadata(
62 const ModelType& model_type,
63 const std::string& entryname,
64 const Id& id,
65 const sync_pb::AttachmentMetadata& attachment_metadata);
66
67 void DeleteEntry(const Id& id);
68
69 // When a directory is saved then loaded from disk, it will pass through
70 // DropDeletedEntries(). This will remove some entries from the directory.
71 // This function is intended to simulate that process.
72 //
73 // WARNING: The directory will be deleted by this operation. You should
74 // not have any pointers to the directory (open transactions included)
75 // when you call this.
76 DirOpenResult SimulateSaveAndReloadDir();
77
78 // This function will close and re-open the directory without saving any
79 // pending changes. This is intended to simulate the recovery from a crash
80 // scenario. The same warnings for SimulateSaveAndReloadDir apply here.
81 DirOpenResult SimulateCrashAndReloadDir();
82
83 void GetAllMetaHandles(BaseTransaction* trans, MetahandleSet* result);
84 void CheckPurgeEntriesWithTypeInSucceeded(ModelTypeSet types_to_purge,
85 bool before_reload);
86 bool IsInDirtyMetahandles(int64_t metahandle);
87 bool IsInMetahandlesToPurge(int64_t metahandle);
88
89 std::unique_ptr<Directory>& dir();
90 DirectoryChangeDelegate* directory_change_delegate();
91 Encryptor* encryptor();
92 TestUnrecoverableErrorHandler* unrecoverable_error_handler();
93
94 private:
95 void ValidateEntry(BaseTransaction* trans,
96 int64_t id,
97 bool check_name,
98 const std::string& name,
99 int64_t base_version,
100 int64_t server_version,
101 bool is_del);
102
103 base::MessageLoop message_loop_;
104 std::unique_ptr<Directory> dir_;
105 NullDirectoryChangeDelegate delegate_;
106 FakeEncryptor encryptor_;
107 TestUnrecoverableErrorHandler handler_;
108 sql::Connection connection_;
109 };
110
111 } // namespace syncable
112
113 } // namespace syncer
114
115 #endif // SYNC_SYNCABLE_DIRECTORY_UNITTEST_H_
OLDNEW
« no previous file with comments | « sync/syncable/directory_change_delegate.h ('k') | sync/syncable/directory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698