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/engine/directory_update_handler.h" | 5 #include "sync/engine/directory_update_handler.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "sync/engine/syncer_proto_util.h" | 10 #include "sync/engine/syncer_proto_util.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "sync/syncable/syncable_read_transaction.h" | 22 #include "sync/syncable/syncable_read_transaction.h" |
23 #include "sync/syncable/syncable_write_transaction.h" | 23 #include "sync/syncable/syncable_write_transaction.h" |
24 #include "sync/test/engine/fake_model_worker.h" | 24 #include "sync/test/engine/fake_model_worker.h" |
25 #include "sync/test/engine/test_directory_setter_upper.h" | 25 #include "sync/test/engine/test_directory_setter_upper.h" |
26 #include "sync/test/engine/test_id_factory.h" | 26 #include "sync/test/engine/test_id_factory.h" |
27 #include "sync/test/engine/test_syncable_utils.h" | 27 #include "sync/test/engine/test_syncable_utils.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
29 | 29 |
30 namespace syncer { | 30 namespace syncer { |
31 | 31 |
32 using syncable::Id; | |
pavely
2014/12/22 21:38:09
nit: There are plenty of places in this file with
stanisc
2014/12/22 22:44:19
Done.
| |
32 using syncable::UNITTEST; | 33 using syncable::UNITTEST; |
33 | 34 |
34 static const int64 kDefaultVersion = 1000; | 35 static const int64 kDefaultVersion = 1000; |
35 | 36 |
36 // A test harness for tests that focus on processing updates. | 37 // A test harness for tests that focus on processing updates. |
37 // | 38 // |
38 // Update processing is what occurs when we first download updates. It converts | 39 // Update processing is what occurs when we first download updates. It converts |
39 // the received protobuf message into information in the syncable::Directory. | 40 // the received protobuf message into information in the syncable::Directory. |
40 // Any invalid or redundant updates will be dropped at this point. | 41 // Any invalid or redundant updates will be dropped at this point. |
41 class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test { | 42 class DirectoryUpdateHandlerProcessUpdateTest : public ::testing::Test { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 static const char kCacheGuid[] = "IrcjZ2jyzHDV9Io4+zKcXQ=="; | 130 static const char kCacheGuid[] = "IrcjZ2jyzHDV9Io4+zKcXQ=="; |
130 | 131 |
131 // Test that the bookmark tag is set on newly downloaded items. | 132 // Test that the bookmark tag is set on newly downloaded items. |
132 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) { | 133 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) { |
133 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); | 134 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); |
134 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); | 135 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); |
135 sync_pb::GetUpdatesResponse gu_response; | 136 sync_pb::GetUpdatesResponse gu_response; |
136 sessions::StatusController status; | 137 sessions::StatusController status; |
137 | 138 |
138 // Add a bookmark item to the update message. | 139 // Add a bookmark item to the update message. |
139 std::string root = syncable::GetNullId().GetServerId(); | 140 std::string root = Id::GetRoot().GetServerId(); |
140 syncable::Id server_id = syncable::Id::CreateFromServerId("b1"); | 141 syncable::Id server_id = syncable::Id::CreateFromServerId("b1"); |
141 scoped_ptr<sync_pb::SyncEntity> e = | 142 scoped_ptr<sync_pb::SyncEntity> e = |
142 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); | 143 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); |
143 e->set_originator_cache_guid( | 144 e->set_originator_cache_guid( |
144 std::string(kCacheGuid, arraysize(kCacheGuid)-1)); | 145 std::string(kCacheGuid, arraysize(kCacheGuid)-1)); |
145 syncable::Id client_id = syncable::Id::CreateFromClientString("-2"); | 146 syncable::Id client_id = syncable::Id::CreateFromClientString("-2"); |
146 e->set_originator_client_item_id(client_id.GetServerId()); | 147 e->set_originator_client_item_id(client_id.GetServerId()); |
147 e->set_position_in_parent(0); | 148 e->set_position_in_parent(0); |
148 | 149 |
149 // Add it to the applicable updates list. | 150 // Add it to the applicable updates list. |
(...skipping 19 matching lines...) Expand all Loading... | |
169 // Test the receipt of a type root node. | 170 // Test the receipt of a type root node. |
170 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, | 171 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, |
171 ReceiveServerCreatedBookmarkFolders) { | 172 ReceiveServerCreatedBookmarkFolders) { |
172 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); | 173 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); |
173 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); | 174 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); |
174 sync_pb::GetUpdatesResponse gu_response; | 175 sync_pb::GetUpdatesResponse gu_response; |
175 sessions::StatusController status; | 176 sessions::StatusController status; |
176 | 177 |
177 // Create an update that mimics the bookmark root. | 178 // Create an update that mimics the bookmark root. |
178 syncable::Id server_id = syncable::Id::CreateFromServerId("xyz"); | 179 syncable::Id server_id = syncable::Id::CreateFromServerId("xyz"); |
179 std::string root = syncable::GetNullId().GetServerId(); | 180 std::string root = Id::GetRoot().GetServerId(); |
180 scoped_ptr<sync_pb::SyncEntity> e = | 181 scoped_ptr<sync_pb::SyncEntity> e = |
181 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); | 182 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); |
182 e->set_server_defined_unique_tag("google_chrome_bookmarks"); | 183 e->set_server_defined_unique_tag("google_chrome_bookmarks"); |
183 e->set_folder(true); | 184 e->set_folder(true); |
184 | 185 |
185 // Add it to the applicable updates list. | 186 // Add it to the applicable updates list. |
186 SyncEntityList bookmark_updates; | 187 SyncEntityList bookmark_updates; |
187 bookmark_updates.push_back(e.get()); | 188 bookmark_updates.push_back(e.get()); |
188 | 189 |
189 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); | 190 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); |
(...skipping 12 matching lines...) Expand all Loading... | |
202 EXPECT_TRUE(entry.GetUniqueBookmarkTag().empty()); | 203 EXPECT_TRUE(entry.GetUniqueBookmarkTag().empty()); |
203 } | 204 } |
204 | 205 |
205 // Test the receipt of a non-bookmark item. | 206 // Test the receipt of a non-bookmark item. |
206 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) { | 207 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) { |
207 DirectoryTypeDebugInfoEmitter emitter(AUTOFILL, &type_observers_); | 208 DirectoryTypeDebugInfoEmitter emitter(AUTOFILL, &type_observers_); |
208 DirectoryUpdateHandler handler(dir(), AUTOFILL, ui_worker(), &emitter); | 209 DirectoryUpdateHandler handler(dir(), AUTOFILL, ui_worker(), &emitter); |
209 sync_pb::GetUpdatesResponse gu_response; | 210 sync_pb::GetUpdatesResponse gu_response; |
210 sessions::StatusController status; | 211 sessions::StatusController status; |
211 | 212 |
212 std::string root = syncable::GetNullId().GetServerId(); | 213 std::string root = Id::GetRoot().GetServerId(); |
213 syncable::Id server_id = syncable::Id::CreateFromServerId("xyz"); | 214 syncable::Id server_id = syncable::Id::CreateFromServerId("xyz"); |
214 scoped_ptr<sync_pb::SyncEntity> e = | 215 scoped_ptr<sync_pb::SyncEntity> e = |
215 CreateUpdate(SyncableIdToProto(server_id), root, AUTOFILL); | 216 CreateUpdate(SyncableIdToProto(server_id), root, AUTOFILL); |
216 e->set_server_defined_unique_tag("9PGRuKdX5sHyGMB17CvYTXuC43I="); | 217 e->set_server_defined_unique_tag("9PGRuKdX5sHyGMB17CvYTXuC43I="); |
217 | 218 |
218 // Add it to the applicable updates list. | 219 // Add it to the applicable updates list. |
219 SyncEntityList autofill_updates; | 220 SyncEntityList autofill_updates; |
220 autofill_updates.push_back(e.get()); | 221 autofill_updates.push_back(e.get()); |
221 | 222 |
222 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); | 223 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); | 266 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); |
266 | 267 |
267 sync_pb::DataTypeContext context; | 268 sync_pb::DataTypeContext context; |
268 context.set_data_type_id( | 269 context.set_data_type_id( |
269 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); | 270 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); |
270 context.set_context("context"); | 271 context.set_context("context"); |
271 context.set_version(1); | 272 context.set_version(1); |
272 | 273 |
273 scoped_ptr<sync_pb::SyncEntity> type_root = | 274 scoped_ptr<sync_pb::SyncEntity> type_root = |
274 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")), | 275 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")), |
275 syncable::GetNullId().GetServerId(), | 276 Id::GetRoot().GetServerId(), SYNCED_NOTIFICATIONS); |
276 SYNCED_NOTIFICATIONS); | |
277 type_root->set_server_defined_unique_tag( | 277 type_root->set_server_defined_unique_tag( |
278 ModelTypeToRootTag(SYNCED_NOTIFICATIONS)); | 278 ModelTypeToRootTag(SYNCED_NOTIFICATIONS)); |
279 type_root->set_folder(true); | 279 type_root->set_folder(true); |
280 | 280 |
281 scoped_ptr<sync_pb::SyncEntity> e1 = | 281 scoped_ptr<sync_pb::SyncEntity> e1 = |
282 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")), | 282 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")), |
283 type_root->id_string(), | 283 type_root->id_string(), |
284 SYNCED_NOTIFICATIONS); | 284 SYNCED_NOTIFICATIONS); |
285 | 285 |
286 scoped_ptr<sync_pb::SyncEntity> e2 = | 286 scoped_ptr<sync_pb::SyncEntity> e2 = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); | 329 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); |
330 progress.set_token("token"); | 330 progress.set_token("token"); |
331 | 331 |
332 sync_pb::DataTypeContext old_context; | 332 sync_pb::DataTypeContext old_context; |
333 old_context.set_version(1); | 333 old_context.set_version(1); |
334 old_context.set_context("data"); | 334 old_context.set_context("data"); |
335 old_context.set_data_type_id(field_number); | 335 old_context.set_data_type_id(field_number); |
336 | 336 |
337 scoped_ptr<sync_pb::SyncEntity> type_root = | 337 scoped_ptr<sync_pb::SyncEntity> type_root = |
338 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")), | 338 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")), |
339 syncable::GetNullId().GetServerId(), | 339 Id::GetRoot().GetServerId(), SYNCED_NOTIFICATIONS); |
340 SYNCED_NOTIFICATIONS); | |
341 type_root->set_server_defined_unique_tag( | 340 type_root->set_server_defined_unique_tag( |
342 ModelTypeToRootTag(SYNCED_NOTIFICATIONS)); | 341 ModelTypeToRootTag(SYNCED_NOTIFICATIONS)); |
343 type_root->set_folder(true); | 342 type_root->set_folder(true); |
344 scoped_ptr<sync_pb::SyncEntity> e1 = | 343 scoped_ptr<sync_pb::SyncEntity> e1 = |
345 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")), | 344 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")), |
346 type_root->id_string(), | 345 type_root->id_string(), |
347 SYNCED_NOTIFICATIONS); | 346 SYNCED_NOTIFICATIONS); |
348 | 347 |
349 SyncEntityList updates; | 348 SyncEntityList updates; |
350 updates.push_back(type_root.get()); | 349 updates.push_back(type_root.get()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 progress.set_token("token"); | 409 progress.set_token("token"); |
411 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); | 410 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); |
412 | 411 |
413 sync_pb::DataTypeContext context; | 412 sync_pb::DataTypeContext context; |
414 context.set_data_type_id(GetSpecificsFieldNumberFromModelType(ARTICLES)); | 413 context.set_data_type_id(GetSpecificsFieldNumberFromModelType(ARTICLES)); |
415 context.set_context("context"); | 414 context.set_context("context"); |
416 context.set_version(1); | 415 context.set_version(1); |
417 | 416 |
418 scoped_ptr<sync_pb::SyncEntity> type_root = | 417 scoped_ptr<sync_pb::SyncEntity> type_root = |
419 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")), | 418 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("root")), |
420 syncable::GetNullId().GetServerId(), | 419 Id::GetRoot().GetServerId(), ARTICLES); |
421 ARTICLES); | |
422 type_root->set_server_defined_unique_tag(ModelTypeToRootTag(ARTICLES)); | 420 type_root->set_server_defined_unique_tag(ModelTypeToRootTag(ARTICLES)); |
423 type_root->set_folder(true); | 421 type_root->set_folder(true); |
424 | 422 |
425 scoped_ptr<sync_pb::SyncEntity> e1 = | 423 scoped_ptr<sync_pb::SyncEntity> e1 = |
426 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")), | 424 CreateUpdate(SyncableIdToProto(syncable::Id::CreateFromServerId("e1")), |
427 type_root->id_string(), | 425 type_root->id_string(), |
428 ARTICLES); | 426 ARTICLES); |
429 sync_pb::AttachmentIdProto* attachment_id = e1->add_attachment_id(); | 427 sync_pb::AttachmentIdProto* attachment_id = e1->add_attachment_id(); |
430 *attachment_id = CreateAttachmentIdProto(); | 428 *attachment_id = CreateAttachmentIdProto(); |
431 | 429 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 sync_pb::EntitySpecifics result; | 566 sync_pb::EntitySpecifics result; |
569 AddDefaultFieldValue(BOOKMARKS, &result); | 567 AddDefaultFieldValue(BOOKMARKS, &result); |
570 return result; | 568 return result; |
571 } | 569 } |
572 } // namespace | 570 } // namespace |
573 | 571 |
574 // Test update application for a few bookmark items. | 572 // Test update application for a few bookmark items. |
575 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) { | 573 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, SimpleBookmark) { |
576 sessions::StatusController status; | 574 sessions::StatusController status; |
577 | 575 |
578 std::string root_server_id = syncable::GetNullId().GetServerId(); | 576 std::string root_server_id = Id::GetRoot().GetServerId(); |
579 int64 parent_handle = | 577 int64 parent_handle = |
580 entry_factory()->CreateUnappliedNewBookmarkItemWithParent( | 578 entry_factory()->CreateUnappliedNewBookmarkItemWithParent( |
581 "parent", DefaultBookmarkSpecifics(), root_server_id); | 579 "parent", DefaultBookmarkSpecifics(), root_server_id); |
582 int64 child_handle = | 580 int64 child_handle = |
583 entry_factory()->CreateUnappliedNewBookmarkItemWithParent( | 581 entry_factory()->CreateUnappliedNewBookmarkItemWithParent( |
584 "child", DefaultBookmarkSpecifics(), "parent"); | 582 "child", DefaultBookmarkSpecifics(), "parent"); |
585 | 583 |
586 ApplyBookmarkUpdates(&status); | 584 ApplyBookmarkUpdates(&status); |
587 | 585 |
588 const UpdateCounters& counter = GetBookmarksUpdateCounters(); | 586 const UpdateCounters& counter = GetBookmarksUpdateCounters(); |
(...skipping 17 matching lines...) Expand all Loading... | |
606 EXPECT_FALSE(parent.GetIsUnappliedUpdate()); | 604 EXPECT_FALSE(parent.GetIsUnappliedUpdate()); |
607 EXPECT_FALSE(child.GetIsUnsynced()); | 605 EXPECT_FALSE(child.GetIsUnsynced()); |
608 EXPECT_FALSE(child.GetIsUnappliedUpdate()); | 606 EXPECT_FALSE(child.GetIsUnappliedUpdate()); |
609 } | 607 } |
610 } | 608 } |
611 | 609 |
612 // Test that the applicator can handle updates delivered out of order. | 610 // Test that the applicator can handle updates delivered out of order. |
613 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, | 611 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, |
614 BookmarkChildrenBeforeParent) { | 612 BookmarkChildrenBeforeParent) { |
615 // Start with some bookmarks whose parents are unknown. | 613 // Start with some bookmarks whose parents are unknown. |
616 std::string root_server_id = syncable::GetNullId().GetServerId(); | 614 std::string root_server_id = Id::GetRoot().GetServerId(); |
617 int64 a_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent( | 615 int64 a_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent( |
618 "a_child_created_first", DefaultBookmarkSpecifics(), "parent"); | 616 "a_child_created_first", DefaultBookmarkSpecifics(), "parent"); |
619 int64 x_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent( | 617 int64 x_handle = entry_factory()->CreateUnappliedNewBookmarkItemWithParent( |
620 "x_child_created_first", DefaultBookmarkSpecifics(), "parent"); | 618 "x_child_created_first", DefaultBookmarkSpecifics(), "parent"); |
621 | 619 |
622 // Update application will fail. | 620 // Update application will fail. |
623 sessions::StatusController status1; | 621 sessions::StatusController status1; |
624 ApplyBookmarkUpdates(&status1); | 622 ApplyBookmarkUpdates(&status1); |
625 EXPECT_EQ(0, status1.num_updates_applied()); | 623 EXPECT_EQ(0, status1.num_updates_applied()); |
626 EXPECT_EQ(2, status1.num_hierarchy_conflicts()); | 624 EXPECT_EQ(2, status1.num_hierarchy_conflicts()); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
896 EXPECT_TRUE(y.GetIsUnappliedUpdate()); | 894 EXPECT_TRUE(y.GetIsUnappliedUpdate()); |
897 EXPECT_FALSE(x.GetIsUnsynced()); | 895 EXPECT_FALSE(x.GetIsUnsynced()); |
898 EXPECT_FALSE(y.GetIsUnsynced()); | 896 EXPECT_FALSE(y.GetIsUnsynced()); |
899 } | 897 } |
900 } | 898 } |
901 | 899 |
902 // Attempt application of a mix of items. Some update application attempts will | 900 // Attempt application of a mix of items. Some update application attempts will |
903 // fail due to hierarchy conflicts. Others should succeed. | 901 // fail due to hierarchy conflicts. Others should succeed. |
904 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, ItemsBothKnownAndUnknown) { | 902 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, ItemsBothKnownAndUnknown) { |
905 // See what happens when there's a mixture of good and bad updates. | 903 // See what happens when there's a mixture of good and bad updates. |
906 std::string root_server_id = syncable::GetNullId().GetServerId(); | 904 std::string root_server_id = Id::GetRoot().GetServerId(); |
907 int64 u1_handle = entry_factory()->CreateUnappliedNewItemWithParent( | 905 int64 u1_handle = entry_factory()->CreateUnappliedNewItemWithParent( |
908 "first_unknown_item", DefaultBookmarkSpecifics(), "unknown_parent"); | 906 "first_unknown_item", DefaultBookmarkSpecifics(), "unknown_parent"); |
909 int64 k1_handle = entry_factory()->CreateUnappliedNewItemWithParent( | 907 int64 k1_handle = entry_factory()->CreateUnappliedNewItemWithParent( |
910 "first_known_item", DefaultBookmarkSpecifics(), root_server_id); | 908 "first_known_item", DefaultBookmarkSpecifics(), root_server_id); |
911 int64 u2_handle = entry_factory()->CreateUnappliedNewItemWithParent( | 909 int64 u2_handle = entry_factory()->CreateUnappliedNewItemWithParent( |
912 "second_unknown_item", DefaultBookmarkSpecifics(), "unknown_parent"); | 910 "second_unknown_item", DefaultBookmarkSpecifics(), "unknown_parent"); |
913 int64 k2_handle = entry_factory()->CreateUnappliedNewItemWithParent( | 911 int64 k2_handle = entry_factory()->CreateUnappliedNewItemWithParent( |
914 "second_known_item", DefaultBookmarkSpecifics(), "first_known_item"); | 912 "second_known_item", DefaultBookmarkSpecifics(), "first_known_item"); |
915 int64 k3_handle = entry_factory()->CreateUnappliedNewItemWithParent( | 913 int64 k3_handle = entry_factory()->CreateUnappliedNewItemWithParent( |
916 "third_known_item", DefaultBookmarkSpecifics(), "fourth_known_item"); | 914 "third_known_item", DefaultBookmarkSpecifics(), "fourth_known_item"); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 EXPECT_FALSE(e.GetIsUnsynced()); | 985 EXPECT_FALSE(e.GetIsUnsynced()); |
988 } | 986 } |
989 } | 987 } |
990 | 988 |
991 // Attempt application of encrypted items when the passphrase is not known. | 989 // Attempt application of encrypted items when the passphrase is not known. |
992 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, UndecryptableData) { | 990 TEST_F(DirectoryUpdateHandlerApplyUpdateTest, UndecryptableData) { |
993 // Undecryptable updates should not be applied. | 991 // Undecryptable updates should not be applied. |
994 sync_pb::EntitySpecifics encrypted_bookmark; | 992 sync_pb::EntitySpecifics encrypted_bookmark; |
995 encrypted_bookmark.mutable_encrypted(); | 993 encrypted_bookmark.mutable_encrypted(); |
996 AddDefaultFieldValue(BOOKMARKS, &encrypted_bookmark); | 994 AddDefaultFieldValue(BOOKMARKS, &encrypted_bookmark); |
997 std::string root_server_id = syncable::GetNullId().GetServerId(); | 995 std::string root_server_id = Id::GetRoot().GetServerId(); |
998 int64 folder_handle = entry_factory()->CreateUnappliedNewItemWithParent( | 996 int64 folder_handle = entry_factory()->CreateUnappliedNewItemWithParent( |
999 "folder", | 997 "folder", |
1000 encrypted_bookmark, | 998 encrypted_bookmark, |
1001 root_server_id); | 999 root_server_id); |
1002 int64 bookmark_handle = entry_factory()->CreateUnappliedNewItem( | 1000 int64 bookmark_handle = entry_factory()->CreateUnappliedNewItem( |
1003 "item2", | 1001 "item2", |
1004 encrypted_bookmark, | 1002 encrypted_bookmark, |
1005 false); | 1003 false); |
1006 sync_pb::EntitySpecifics encrypted_password; | 1004 sync_pb::EntitySpecifics encrypted_password; |
1007 encrypted_password.mutable_password(); | 1005 encrypted_password.mutable_password(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1183 const UpdateCounters& counters = GetArticlesUpdateCounters(); | 1181 const UpdateCounters& counters = GetArticlesUpdateCounters(); |
1184 EXPECT_EQ(1, counters.num_updates_applied); | 1182 EXPECT_EQ(1, counters.num_updates_applied); |
1185 EXPECT_EQ(1, counters.num_local_overwrites); | 1183 EXPECT_EQ(1, counters.num_local_overwrites); |
1186 EXPECT_EQ(0, counters.num_server_overwrites); | 1184 EXPECT_EQ(0, counters.num_server_overwrites); |
1187 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); | 1185 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); |
1188 EXPECT_EQ(server_metadata.SerializeAsString(), | 1186 EXPECT_EQ(server_metadata.SerializeAsString(), |
1189 local_metadata.SerializeAsString()); | 1187 local_metadata.SerializeAsString()); |
1190 } | 1188 } |
1191 | 1189 |
1192 } // namespace syncer | 1190 } // namespace syncer |
OLD | NEW |