OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 // Unit tests for the SyncApi. Note that a lot of the underlying | 5 // Unit tests for the SyncApi. Note that a lot of the underlying |
6 // functionality is provided by the Syncable layer, which has its own | 6 // functionality is provided by the Syncable layer, which has its own |
7 // unit tests. We'll test SyncApi specific things in this harness. | 7 // unit tests. We'll test SyncApi specific things in this harness. |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 node_id); | 166 node_id); |
167 EXPECT_TRUE(entry.good()); | 167 EXPECT_TRUE(entry.good()); |
168 entry.PutBaseVersion(1); | 168 entry.PutBaseVersion(1); |
169 entry.PutServerVersion(1); | 169 entry.PutServerVersion(1); |
170 entry.PutIsUnappliedUpdate(false); | 170 entry.PutIsUnappliedUpdate(false); |
171 entry.PutParentId(syncable::Id::GetRoot()); | 171 entry.PutParentId(syncable::Id::GetRoot()); |
172 entry.PutServerParentId(syncable::Id::GetRoot()); | 172 entry.PutServerParentId(syncable::Id::GetRoot()); |
173 entry.PutServerIsDir(true); | 173 entry.PutServerIsDir(true); |
174 entry.PutIsDir(true); | 174 entry.PutIsDir(true); |
175 entry.PutServerSpecifics(specifics); | 175 entry.PutServerSpecifics(specifics); |
| 176 entry.PutSpecifics(specifics); |
176 entry.PutUniqueServerTag(type_tag); | 177 entry.PutUniqueServerTag(type_tag); |
177 entry.PutNonUniqueName(type_tag); | 178 entry.PutNonUniqueName(type_tag); |
178 entry.PutIsDel(false); | 179 entry.PutIsDel(false); |
179 entry.PutSpecifics(specifics); | |
180 return entry.GetMetahandle(); | 180 return entry.GetMetahandle(); |
181 } | 181 } |
182 | 182 |
183 // Simulates creating a "synced" node as a child of the root datatype node. | 183 // Simulates creating a "synced" node as a child of the root datatype node. |
184 int64 MakeServerNode(UserShare* share, ModelType model_type, | 184 int64 MakeServerNode(UserShare* share, ModelType model_type, |
185 const std::string& client_tag, | 185 const std::string& client_tag, |
186 const std::string& hashed_tag, | 186 const std::string& hashed_tag, |
187 const sync_pb::EntitySpecifics& specifics) { | 187 const sync_pb::EntitySpecifics& specifics) { |
188 syncable::WriteTransaction trans( | 188 syncable::WriteTransaction trans( |
189 FROM_HERE, syncable::UNITTEST, share->directory.get()); | 189 FROM_HERE, syncable::UNITTEST, share->directory.get()); |
190 syncable::Entry root_entry(&trans, syncable::GET_TYPE_ROOT, model_type); | 190 syncable::Entry root_entry(&trans, syncable::GET_TYPE_ROOT, model_type); |
191 EXPECT_TRUE(root_entry.good()); | 191 EXPECT_TRUE(root_entry.good()); |
192 syncable::Id root_id = root_entry.GetId(); | 192 syncable::Id root_id = root_entry.GetId(); |
193 syncable::Id node_id = syncable::Id::CreateFromServerId(client_tag); | 193 syncable::Id node_id = syncable::Id::CreateFromServerId(client_tag); |
194 syncable::MutableEntry entry(&trans, syncable::CREATE_NEW_UPDATE_ITEM, | 194 syncable::MutableEntry entry(&trans, syncable::CREATE_NEW_UPDATE_ITEM, |
195 node_id); | 195 node_id); |
196 EXPECT_TRUE(entry.good()); | 196 EXPECT_TRUE(entry.good()); |
197 entry.PutBaseVersion(1); | 197 entry.PutBaseVersion(1); |
198 entry.PutServerVersion(1); | 198 entry.PutServerVersion(1); |
199 entry.PutIsUnappliedUpdate(false); | 199 entry.PutIsUnappliedUpdate(false); |
200 entry.PutServerParentId(root_id); | 200 entry.PutServerParentId(root_id); |
201 entry.PutParentId(root_id); | 201 entry.PutParentId(root_id); |
202 entry.PutServerIsDir(false); | 202 entry.PutServerIsDir(false); |
203 entry.PutIsDir(false); | 203 entry.PutIsDir(false); |
204 entry.PutServerSpecifics(specifics); | 204 entry.PutServerSpecifics(specifics); |
| 205 entry.PutSpecifics(specifics); |
205 entry.PutNonUniqueName(client_tag); | 206 entry.PutNonUniqueName(client_tag); |
206 entry.PutUniqueClientTag(hashed_tag); | 207 entry.PutUniqueClientTag(hashed_tag); |
207 entry.PutIsDel(false); | 208 entry.PutIsDel(false); |
208 entry.PutSpecifics(specifics); | |
209 return entry.GetMetahandle(); | 209 return entry.GetMetahandle(); |
210 } | 210 } |
211 | 211 |
212 } // namespace | 212 } // namespace |
213 | 213 |
214 class SyncApiTest : public testing::Test { | 214 class SyncApiTest : public testing::Test { |
215 public: | 215 public: |
216 void SetUp() override { test_user_share_.SetUp(); } | 216 void SetUp() override { test_user_share_.SetUp(); } |
217 | 217 |
218 void TearDown() override { test_user_share_.TearDown(); } | 218 void TearDown() override { test_user_share_.TearDown(); } |
(...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3326 // SyncManagerInitInvalidStorageTest::GetFactory will return | 3326 // SyncManagerInitInvalidStorageTest::GetFactory will return |
3327 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. | 3327 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. |
3328 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's | 3328 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's |
3329 // task is to ensure that SyncManagerImpl reported initialization failure in | 3329 // task is to ensure that SyncManagerImpl reported initialization failure in |
3330 // OnInitializationComplete callback. | 3330 // OnInitializationComplete callback. |
3331 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { | 3331 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { |
3332 EXPECT_FALSE(initialization_succeeded_); | 3332 EXPECT_FALSE(initialization_succeeded_); |
3333 } | 3333 } |
3334 | 3334 |
3335 } // namespace syncer | 3335 } // namespace syncer |
OLD | NEW |