+// See that attachment metadata changes are not filtered out by
+// SyncManagerImpl::VisiblePropertiesDiffer.
+TEST_F(SyncManagerChangeProcessingTest, AttachmentMetadataOnlyChanges) {
+ // Create an article with no attachments. See that a change is generated.
+ int64 article_id = kInvalidId;
+ {
+ syncable::WriteTransaction trans(
+ FROM_HERE, syncable::SYNCER, share()->directory.get());
+ int64 type_root = GetIdForDataType(ARTICLES);
+ syncable::Entry root(&trans, syncable::GET_BY_HANDLE, type_root);
+ ASSERT_TRUE(root.good());
+ syncable::MutableEntry article(
+ &trans, syncable::CREATE, ARTICLES, root.GetId(), "article");
+ ASSERT_TRUE(article.good());
+ SetNodeProperties(&article);
+ article_id = article.GetMetahandle();
+ }
+ ASSERT_EQ(1UL, GetChangeListSize());
+ FindChangeInList(article_id, ChangeRecord::ACTION_ADD);
+ ClearChangeList();
+
+ // Modify the article by adding one attachment. Don't touch anything else.
+ // See that a change is generated.
+ {
+ syncable::WriteTransaction trans(
+ FROM_HERE, syncable::SYNCER, share()->directory.get());
+ syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id);
+ sync_pb::AttachmentMetadata metadata;
+ *metadata.add_record()->mutable_id() = CreateAttachmentIdProto();
+ article.PutAttachmentMetadata(metadata);
+ }
+ ASSERT_EQ(1UL, GetChangeListSize());
+ FindChangeInList(article_id, ChangeRecord::ACTION_UPDATE);
+ ClearChangeList();
+
+ // Modify the article by replacing its attachment with a different one. See
+ // that a change is generated.
+ {
+ syncable::WriteTransaction trans(
+ FROM_HERE, syncable::SYNCER, share()->directory.get());
+ syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id);
+ sync_pb::AttachmentMetadata metadata = article.GetAttachmentMetadata();
+ *metadata.add_record()->mutable_id() = CreateAttachmentIdProto();
+ article.PutAttachmentMetadata(metadata);
+ }
+ ASSERT_EQ(1UL, GetChangeListSize());
+ FindChangeInList(article_id, ChangeRecord::ACTION_UPDATE);
+ ClearChangeList();
+
+ // Modify the article by replacing its attachment metadata with the same
+ // attachment metadata. No change should be generated.
+ {
+ syncable::WriteTransaction trans(
+ FROM_HERE, syncable::SYNCER, share()->directory.get());
+ syncable::MutableEntry article(&trans, syncable::GET_BY_HANDLE, article_id);
+ article.PutAttachmentMetadata(article.GetAttachmentMetadata());
+ }
+ ASSERT_EQ(0UL, GetChangeListSize());
+}
+