aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-07-18 13:28:10 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-07-18 13:28:10 +0200
commit4e1d91e55fcdfc87cfb92dfbcb3e741cd4a450fd (patch)
tree2cc0caeec8a730f1206283478f99017edd0746fd /tests
parent30cb222f96d95d62ac75fdf454f8b4a20001d3d5 (diff)
downloadqxmpp-4e1d91e55fcdfc87cfb92dfbcb3e741cd4a450fd.tar.gz
split dataform tests
Diffstat (limited to 'tests')
-rw-r--r--tests/dataform.cpp90
-rw-r--r--tests/dataform.h35
-rw-r--r--tests/tests.cpp64
-rw-r--r--tests/tests.h9
-rw-r--r--tests/tests.pro2
5 files changed, 129 insertions, 71 deletions
diff --git a/tests/dataform.cpp b/tests/dataform.cpp
new file mode 100644
index 00000000..769d8339
--- /dev/null
+++ b/tests/dataform.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2008-2012 The QXmpp developers
+ *
+ * Authors:
+ * Andrey Batyiev
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#include "QXmppDataForm.h"
+
+#include "dataform.h"
+#include "tests.h"
+
+void tst_QXmppDataForm::testSimple()
+{
+ const QByteArray xml(
+ "<x xmlns=\"jabber:x:data\" type=\"form\">"
+ "<title>Joggle Search</title>"
+ "<instructions>Fill out this form to search for information!</instructions>"
+ "<field type=\"text-single\" var=\"search_request\">"
+ "<required/>"
+ "</field>"
+ "</x>");
+
+ QXmppDataForm form;
+ parsePacket(form, xml);
+
+ QCOMPARE(form.isNull(), false);
+ QCOMPARE(form.title(), QLatin1String("Joggle Search"));
+ QCOMPARE(form.instructions(), QLatin1String("Fill out this form to search for information!"));
+ QCOMPARE(form.fields().size(), 1);
+ QCOMPARE(form.fields().at(0).type(), QXmppDataForm::Field::TextSingleField);
+ QCOMPARE(form.fields().at(0).isRequired(), true);
+ QCOMPARE(form.fields().at(0).key(), QString("search_request"));
+
+ serializePacket(form, xml);
+}
+
+void tst_QXmppDataForm::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);
+}
+
diff --git a/tests/dataform.h b/tests/dataform.h
new file mode 100644
index 00000000..1b294d8b
--- /dev/null
+++ b/tests/dataform.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008-2012 The QXmpp developers
+ *
+ * Authors:
+ * Andrey Batyiev
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#include <QObject>
+
+class tst_QXmppDataForm : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testSimple();
+ void testMedia();
+};
+
diff --git a/tests/tests.cpp b/tests/tests.cpp
index 53cd1f3e..24ce8a2e 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -53,6 +53,7 @@
#include "QXmppGlobal.h"
#include "QXmppEntityTimeIq.h"
+#include "dataform.h"
#include "rtp.h"
#include "tests.h"
@@ -941,67 +942,6 @@ void TestCodec::testTheoraEncoder()
#endif
}
-void TestDataForm::testSimple()
-{
- const QByteArray xml(
- "<x xmlns=\"jabber:x:data\" type=\"form\">"
- "<title>Joggle Search</title>"
- "<instructions>Fill out this form to search for information!</instructions>"
- "<field type=\"text-single\" var=\"search_request\">"
- "<required/>"
- "</field>"
- "</x>");
-
- QXmppDataForm form;
- parsePacket(form, xml);
-
- QCOMPARE(form.isNull(), false);
- QCOMPARE(form.title(), QLatin1String("Joggle Search"));
- QCOMPARE(form.instructions(), QLatin1String("Fill out this form to search for information!"));
- QCOMPARE(form.fields().size(), 1);
- QCOMPARE(form.fields().at(0).type(), QXmppDataForm::Field::TextSingleField);
- QCOMPARE(form.fields().at(0).isRequired(), true);
- QCOMPARE(form.fields().at(0).key(), QString("search_request"));
-
- 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(
@@ -1794,7 +1734,7 @@ int main(int argc, char *argv[])
TestCodec testCodec;
errors += QTest::qExec(&testCodec);
- TestDataForm testDataForm;
+ tst_QXmppDataForm testDataForm;
errors += QTest::qExec(&testDataForm);
TestJingle testJingle;
diff --git a/tests/tests.h b/tests/tests.h
index 422c34f6..b3db0cf7 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -109,15 +109,6 @@ private slots:
void testTheoraEncoder();
};
-class TestDataForm : public QObject
-{
- Q_OBJECT
-
-private slots:
- void testSimple();
- void testMedia();
-};
-
class TestJingle : public QObject
{
Q_OBJECT
diff --git a/tests/tests.pro b/tests/tests.pro
index e41696d9..68e85927 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -6,9 +6,11 @@ TARGET = qxmpp-tests
RESOURCES += tests.qrc
SOURCES += \
+ dataform.cpp \
rtp.cpp \
tests.cpp
HEADERS += \
+ dataform.h \
rtp.h \
tests.h