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

Unified Diff: sync/syncable/directory_unittest.cc

Issue 272043002: Invoke AttachmentUploader and update AttachmentIds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android build Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/mutable_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory_unittest.cc
diff --git a/sync/syncable/directory_unittest.cc b/sync/syncable/directory_unittest.cc
index 6b6b8a2699c27a9fe2343d09aaa2a0dddf1f5cd0..adc4004682995e944223e942721868165979bcfd 100644
--- a/sync/syncable/directory_unittest.cc
+++ b/sync/syncable/directory_unittest.cc
@@ -1599,21 +1599,64 @@ TEST_F(SyncableDirectoryTest, MutableEntry_PutAttachmentMetadata) {
&trans, CREATE, PREFERENCES, trans.root_id(), "some entry");
entry.PutId(TestIdFactory::FromNumber(-1));
entry.PutIsUnsynced(true);
+
+ Directory::Metahandles metahandles;
ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id_proto));
+ dir()->GetMetahandlesByAttachmentId(
+ &trans, attachment_id_proto, &metahandles);
+ ASSERT_TRUE(metahandles.empty());
// Now add the attachment metadata and see that Directory believes it is
// linked.
entry.PutAttachmentMetadata(attachment_metadata);
ASSERT_TRUE(dir()->IsAttachmentLinked(attachment_id_proto));
+ dir()->GetMetahandlesByAttachmentId(
+ &trans, attachment_id_proto, &metahandles);
+ ASSERT_FALSE(metahandles.empty());
+ ASSERT_EQ(metahandles[0], entry.GetMetahandle());
// Clear out the attachment metadata and see that it's no longer linked.
sync_pb::AttachmentMetadata empty_attachment_metadata;
entry.PutAttachmentMetadata(empty_attachment_metadata);
ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id_proto));
+ dir()->GetMetahandlesByAttachmentId(
+ &trans, attachment_id_proto, &metahandles);
+ ASSERT_TRUE(metahandles.empty());
}
ASSERT_FALSE(dir()->IsAttachmentLinked(attachment_id_proto));
}
+// Verify that UpdateAttachmentId updates attachment_id and is_on_server flag.
+TEST_F(SyncableDirectoryTest, MutableEntry_UpdateAttachmentId) {
+ sync_pb::AttachmentMetadata attachment_metadata;
+ sync_pb::AttachmentMetadataRecord* r1 = attachment_metadata.add_record();
+ sync_pb::AttachmentMetadataRecord* r2 = attachment_metadata.add_record();
+ *r1->mutable_id() = syncer::CreateAttachmentIdProto();
+ *r2->mutable_id() = syncer::CreateAttachmentIdProto();
+ sync_pb::AttachmentIdProto attachment_id_proto = r1->id();
+
+ WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
+
+ MutableEntry entry(
+ &trans, CREATE, PREFERENCES, trans.root_id(), "some entry");
+ entry.PutId(TestIdFactory::FromNumber(-1));
+ entry.PutAttachmentMetadata(attachment_metadata);
+
+ const sync_pb::AttachmentMetadata& entry_metadata =
+ entry.GetAttachmentMetadata();
+ ASSERT_EQ(2, entry_metadata.record_size());
+ ASSERT_FALSE(entry_metadata.record(0).is_on_server());
+ ASSERT_FALSE(entry_metadata.record(1).is_on_server());
+ ASSERT_FALSE(entry.GetIsUnsynced());
+
+ // TODO(pavely): When we add server info to proto, add test for it here.
+ entry.UpdateAttachmentIdWithServerInfo(attachment_id_proto);
+
+ ASSERT_TRUE(entry_metadata.record(0).is_on_server());
+ ASSERT_FALSE(entry_metadata.record(1).is_on_server());
+ ASSERT_TRUE(entry.GetIsUnsynced());
+}
+
// Verify that deleted entries with attachments will retain the attachments.
TEST_F(SyncableDirectoryTest, Directory_DeleteDoesNotUnlinkAttachments) {
sync_pb::AttachmentMetadata attachment_metadata;
« no previous file with comments | « sync/syncable/directory.cc ('k') | sync/syncable/mutable_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698