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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 982883002: [Sync] Add size and crc32c to AttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 5 years, 9 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 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 node.InitByIdLookup(parent)); 669 node.InitByIdLookup(parent));
670 EXPECT_EQ(4, node.GetTotalNodeCount()); 670 EXPECT_EQ(4, node.GetTotalNodeCount());
671 } 671 }
672 } 672 }
673 673
674 // Verify that Directory keeps track of which attachments are referenced by 674 // Verify that Directory keeps track of which attachments are referenced by
675 // which entries. 675 // which entries.
676 TEST_F(SyncApiTest, AttachmentLinking) { 676 TEST_F(SyncApiTest, AttachmentLinking) {
677 // Add an entry with an attachment. 677 // Add an entry with an attachment.
678 std::string tag1("some tag"); 678 std::string tag1("some tag");
679 syncer::AttachmentId attachment_id(syncer::AttachmentId::Create()); 679 syncer::AttachmentId attachment_id(syncer::AttachmentId::Create(0, 0));
680 sync_pb::AttachmentMetadata attachment_metadata; 680 sync_pb::AttachmentMetadata attachment_metadata;
681 sync_pb::AttachmentMetadataRecord* record = attachment_metadata.add_record(); 681 sync_pb::AttachmentMetadataRecord* record = attachment_metadata.add_record();
682 *record->mutable_id() = attachment_id.GetProto(); 682 *record->mutable_id() = attachment_id.GetProto();
683 ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id.GetProto())); 683 ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id.GetProto()));
684 CreateEntryWithAttachmentMetadata(PREFERENCES, tag1, attachment_metadata); 684 CreateEntryWithAttachmentMetadata(PREFERENCES, tag1, attachment_metadata);
685 685
686 // See that the directory knows it's linked. 686 // See that the directory knows it's linked.
687 ASSERT_TRUE(dir()->IsAttachmentLinked(attachment_id.GetProto())); 687 ASSERT_TRUE(dir()->IsAttachmentLinked(attachment_id.GetProto()));
688 688
689 // Add a second entry referencing the same attachment. 689 // Add a second entry referencing the same attachment.
(...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 FindChangeInList(article_id, ChangeRecord::ACTION_ADD); 3105 FindChangeInList(article_id, ChangeRecord::ACTION_ADD);
3106 ClearChangeList(); 3106 ClearChangeList();
3107 3107
3108 // Modify the article by adding one attachment. Don't touch anything else. 3108 // Modify the article by adding one attachment. Don't touch anything else.
3109 // See that a change is generated. 3109 // See that a change is generated.
3110 { 3110 {
3111 syncable::WriteTransaction trans( 3111 syncable::WriteTransaction trans(
3112 FROM_HERE, syncable::SYNCER, share()->directory.get()); 3112 FROM_HERE, syncable::SYNCER, share()->directory.get());
3113 syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id); 3113 syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id);
3114 sync_pb::AttachmentMetadata metadata; 3114 sync_pb::AttachmentMetadata metadata;
3115 *metadata.add_record()->mutable_id() = CreateAttachmentIdProto(); 3115 *metadata.add_record()->mutable_id() = CreateAttachmentIdProto(0, 0);
3116 article.PutAttachmentMetadata(metadata); 3116 article.PutAttachmentMetadata(metadata);
3117 } 3117 }
3118 ASSERT_EQ(1UL, GetChangeListSize()); 3118 ASSERT_EQ(1UL, GetChangeListSize());
3119 FindChangeInList(article_id, ChangeRecord::ACTION_UPDATE); 3119 FindChangeInList(article_id, ChangeRecord::ACTION_UPDATE);
3120 ClearChangeList(); 3120 ClearChangeList();
3121 3121
3122 // Modify the article by replacing its attachment with a different one. See 3122 // Modify the article by replacing its attachment with a different one. See
3123 // that a change is generated. 3123 // that a change is generated.
3124 { 3124 {
3125 syncable::WriteTransaction trans( 3125 syncable::WriteTransaction trans(
3126 FROM_HERE, syncable::SYNCER, share()->directory.get()); 3126 FROM_HERE, syncable::SYNCER, share()->directory.get());
3127 syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id); 3127 syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id);
3128 sync_pb::AttachmentMetadata metadata = article.GetAttachmentMetadata(); 3128 sync_pb::AttachmentMetadata metadata = article.GetAttachmentMetadata();
3129 *metadata.add_record()->mutable_id() = CreateAttachmentIdProto(); 3129 *metadata.add_record()->mutable_id() = CreateAttachmentIdProto(0, 0);
3130 article.PutAttachmentMetadata(metadata); 3130 article.PutAttachmentMetadata(metadata);
3131 } 3131 }
3132 ASSERT_EQ(1UL, GetChangeListSize()); 3132 ASSERT_EQ(1UL, GetChangeListSize());
3133 FindChangeInList(article_id, ChangeRecord::ACTION_UPDATE); 3133 FindChangeInList(article_id, ChangeRecord::ACTION_UPDATE);
3134 ClearChangeList(); 3134 ClearChangeList();
3135 3135
3136 // Modify the article by replacing its attachment metadata with the same 3136 // Modify the article by replacing its attachment metadata with the same
3137 // attachment metadata. No change should be generated. 3137 // attachment metadata. No change should be generated.
3138 { 3138 {
3139 syncable::WriteTransaction trans( 3139 syncable::WriteTransaction trans(
(...skipping 24 matching lines...) Expand all
3164 // SyncManagerInitInvalidStorageTest::GetFactory will return 3164 // SyncManagerInitInvalidStorageTest::GetFactory will return
3165 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3165 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3166 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3166 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3167 // task is to ensure that SyncManagerImpl reported initialization failure in 3167 // task is to ensure that SyncManagerImpl reported initialization failure in
3168 // OnInitializationComplete callback. 3168 // OnInitializationComplete callback.
3169 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3169 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3170 EXPECT_FALSE(initialization_succeeded_); 3170 EXPECT_FALSE(initialization_succeeded_);
3171 } 3171 }
3172 3172
3173 } // namespace syncer 3173 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/public/base/attachment_id_proto_unittest.cc ('k') | sync/protocol/attachments.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698