aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-07-18 10:33:33 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-07-18 10:33:33 +0200
commite4b6ead714de4912a5a8d10177843eed6c448a28 (patch)
treef1143790174ba17507575291ca481ab14151c49b /tests/tests.cpp
parent0ed84be38b159a32790cb074dc04760313ba27c2 (diff)
downloadqxmpp-e4b6ead714de4912a5a8d10177843eed6c448a28.tar.gz
add support for XEP-0221: Data Forms Media Element
Diffstat (limited to 'tests/tests.cpp')
-rw-r--r--tests/tests.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/tests.cpp b/tests/tests.cpp
index 223aecd9..3c3dcfbf 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -987,6 +987,42 @@ void TestDataForm::testSimple()
serializePacket(form, xml);
}
+void TestDataForm::testMedia()
+{
+ const QByteArray xml(
+ "<x xmlns=\"jabber:x:data\" type=\"form\">"
+ "<field type=\"text-single\" label=\"Enter the text you see\" var=\"ocr\">"
+ "<value/>"
+ "<media xmlns=\"urn:xmpp:media-element\" height=\"80\" width=\"290\">"
+ "<uri type=\"image/jpeg\">"
+ "http://www.victim.com/challenges/ocr.jpeg?F3A6292C"
+ "</uri>"
+ "<uri type=\"image/png\">"
+ "cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org"
+ "</uri>"
+ "</media>"
+ "</field>"
+ "</x>");
+
+ QXmppDataForm form;
+ parsePacket(form, xml);
+
+ QCOMPARE(form.isNull(), false);
+ QCOMPARE(form.fields().size(), 1);
+ QCOMPARE(form.fields().at(0).type(), QXmppDataForm::Field::TextSingleField);
+ QCOMPARE(form.fields().at(0).isRequired(), false);
+ QCOMPARE(form.fields().at(0).media().uris().size(), 2);
+ QCOMPARE(form.fields().at(0).media().isNull(), false);
+ QCOMPARE(form.fields().at(0).media().height(), 80);
+ QCOMPARE(form.fields().at(0).media().width(), 290);
+ QCOMPARE(form.fields().at(0).media().uris().at(0).first, QString("image/jpeg"));
+ QCOMPARE(form.fields().at(0).media().uris().at(0).second, QString("http://www.victim.com/challenges/ocr.jpeg?F3A6292C"));
+ QCOMPARE(form.fields().at(0).media().uris().at(1).first, QString("image/png"));
+ QCOMPARE(form.fields().at(0).media().uris().at(1).second, QString("cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org"));
+
+ serializePacket(form, xml);
+}
+
void TestJingle::testSession()
{
const QByteArray xml(