Skip to content

Commit

Permalink
Add test for sticker pack message extension
Browse files Browse the repository at this point in the history
  • Loading branch information
jbruechert committed Oct 2, 2022
1 parent 5270ae0 commit 3e99aba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/base/QXmppMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,7 @@ void QXmppMessage::serializeExtensions(QXmlStreamWriter *writer, QXmpp::SceMode
writer->writeStartElement("sticker");
writer->writeDefaultNamespace(ns_stickers);
writer->writeAttribute("pack", *d->stickerPackId);
writer->writeEndElement();
}
}
}
27 changes: 27 additions & 0 deletions tests/qxmppmessage/tst_qxmppmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private slots:
void testE2eeFallbackBody();
void testFileSharing();
void testEncryptedFileSource();
void testStickers();
};

void tst_QXmppMessage::testBasic_data()
Expand Down Expand Up @@ -1259,5 +1260,31 @@ void tst_QXmppMessage::testEncryptedFileSource()
}
}

void tst_QXmppMessage::testStickers()
{
QByteArray xml(
"<message id='sharing-a-file' to='[email protected]' from='[email protected]/pda' type='normal'>"
"<body>😘</body>"
"<file-sharing xmlns='urn:xmpp:sfs:0' disposition='inline'>"
"<file xmlns='urn:xmpp:file:metadata:0'>"
"<desc>😘</desc>"
"<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>gw+6xdCgOcvCYSKuQNrXH33lV9NMzuDf/s0huByCDsY=</hash>"
"<media-type>image/png</media-type>"
"<size>67016</size>"
"</file>"
"<sources>"
"<url-data xmlns='http://jabber.org/protocol/url-data' target='https://download.montague.lit/51078299-d071-46e1-b6d3-3de4a8ab67d6/sticker_marsey_kiss.png'/>"
"</sources>"
"</file-sharing>"
"<sticker xmlns='urn:xmpp:stickers:0' pack='EpRv28DHHzFrE4zd+xaNpVb4'/>"
"</message>");

QXmppMessage message1;
parsePacket(message1, xml);
QVERIFY(!message1.sharedFiles().empty());
QVERIFY(message1.stickerPackId().has_value());
serializePacket(message1, xml);
}

QTEST_MAIN(tst_QXmppMessage)
#include "tst_qxmppmessage.moc"

0 comments on commit 3e99aba

Please sign in to comment.