Index: components/sync_driver/generic_change_processor_unittest.cc |
diff --git a/components/sync_driver/generic_change_processor_unittest.cc b/components/sync_driver/generic_change_processor_unittest.cc |
index 073ffb0df91614bd8e20ccf52ababbcf621b9961..152dc06268f333665e009bce42043b4f8f407e88 100644 |
--- a/components/sync_driver/generic_change_processor_unittest.cc |
+++ b/components/sync_driver/generic_change_processor_unittest.cc |
@@ -30,6 +30,7 @@ namespace browser_sync { |
namespace { |
const char kTestData[] = "some data"; |
+const char kUrl[] = "http://attachment.server/url"; |
// A mock that keeps track of attachments passed to StoreAttachments. |
class MockAttachmentService : public syncer::AttachmentServiceImpl { |
@@ -346,6 +347,46 @@ TEST_F(SyncGenericChangeProcessorTest, |
ASSERT_EQ(new_attachments_added[0].GetId(), new_attachments[0].GetId()); |
} |
+// Verify that after attachment is uploaded GenericChangeProcessor updates |
+// corresponding entries |
+TEST_F(SyncGenericChangeProcessorTest, AttachmentUploaded) { |
+ std::string tag = "client_tag"; |
+ std::string title = "client_title"; |
+ sync_pb::EntitySpecifics specifics; |
+ sync_pb::PreferenceSpecifics* pref_specifics = specifics.mutable_preference(); |
+ pref_specifics->set_name("test"); |
+ syncer::AttachmentList attachments; |
+ scoped_refptr<base::RefCountedString> attachment_data = |
+ new base::RefCountedString; |
+ attachment_data->data() = kTestData; |
+ attachments.push_back(syncer::Attachment::Create(attachment_data)); |
+ |
+ // Add a SyncData with two attachments. |
+ syncer::SyncChangeList change_list; |
+ change_list.push_back( |
+ syncer::SyncChange(FROM_HERE, |
+ syncer::SyncChange::ACTION_ADD, |
+ syncer::SyncData::CreateLocalDataWithAttachments( |
+ tag, title, specifics, attachments))); |
+ ASSERT_FALSE( |
+ change_processor()->ProcessSyncChanges(FROM_HERE, change_list).IsSet()); |
+ |
+ sync_pb::AttachmentIdProto attachment_id_proto = |
+ attachments[0].GetId().GetProto(); |
+ attachment_id_proto.set_url(kUrl); |
+ syncer::AttachmentId attachment_id = |
+ syncer::AttachmentId::CreateFromProto(attachment_id_proto); |
+ |
+ change_processor()->OnAttachmentUploaded(attachment_id); |
+ syncer::ReadTransaction read_transaction(FROM_HERE, user_share()); |
+ syncer::ReadNode node(&read_transaction); |
+ ASSERT_EQ(node.InitByClientTagLookup(syncer::PREFERENCES, tag), |
+ syncer::BaseNode::INIT_OK); |
+ syncer::AttachmentIdList attachment_ids = node.GetAttachmentIds(); |
+ EXPECT_EQ(1U, attachment_ids.size()); |
+ EXPECT_EQ(kUrl, attachment_ids[0].GetProto().url()); |
+} |
+ |
} // namespace |
} // namespace browser_sync |