From 42b6f0eca69e5ca1b23750a6baba3fb9b66e7b26 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 15:37:05 +0200 Subject: split QXmppDataForm tests --- tests/all/all.pro | 2 - tests/all/dataform.cpp | 105 --------------------------- tests/all/dataform.h | 36 ---------- tests/all/tests.cpp | 13 ---- tests/all/vcard.h | 38 ---------- tests/qxmppdataform/qxmppdataform.pro | 3 + tests/qxmppdataform/tst_qxmppdataform.cpp | 116 ++++++++++++++++++++++++++++++ tests/tests.pro | 1 + 8 files changed, 120 insertions(+), 194 deletions(-) delete mode 100644 tests/all/dataform.cpp delete mode 100644 tests/all/dataform.h delete mode 100644 tests/all/vcard.h create mode 100644 tests/qxmppdataform/qxmppdataform.pro create mode 100644 tests/qxmppdataform/tst_qxmppdataform.cpp (limited to 'tests') diff --git a/tests/all/all.pro b/tests/all/all.pro index da74f3cb..68ebce94 100644 --- a/tests/all/all.pro +++ b/tests/all/all.pro @@ -4,7 +4,6 @@ TARGET = tst_all RESOURCES += tests.qrc SOURCES += \ - dataform.cpp \ jingle.cpp \ register.cpp \ roster.cpp \ @@ -15,7 +14,6 @@ SOURCES += \ stun.cpp \ tests.cpp HEADERS += \ - dataform.h \ jingle.h \ register.h \ roster.h \ diff --git a/tests/all/dataform.cpp b/tests/all/dataform.cpp deleted file mode 100644 index da9f62b6..00000000 --- a/tests/all/dataform.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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 "util.h" - -void tst_QXmppDataForm::testSimple() -{ - const QByteArray xml( - "" - "Joggle Search" - "Fill out this form to search for information!" - "" - "" - "" - ""); - - 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::testSubmit() -{ - const QByteArray xml( - "" - "" - "verona" - "" - ""); - - QXmppDataForm form; - parsePacket(form, xml); - QCOMPARE(form.isNull(), false); - serializePacket(form, xml); -} - -void tst_QXmppDataForm::testMedia() -{ - const QByteArray xml( - "" - "" - "" - "" - "" - "http://www.victim.com/challenges/ocr.jpeg?F3A6292C" - "" - "" - "cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org" - "" - "" - "" - ""); - - 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/all/dataform.h b/tests/all/dataform.h deleted file mode 100644 index d5461237..00000000 --- a/tests/all/dataform.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - -class tst_QXmppDataForm : public QObject -{ - Q_OBJECT - -private slots: - void testSimple(); - void testSubmit(); - void testMedia(); -}; - diff --git a/tests/all/tests.cpp b/tests/all/tests.cpp index 3375e15c..36073a83 100644 --- a/tests/all/tests.cpp +++ b/tests/all/tests.cpp @@ -45,7 +45,6 @@ #include "QXmppEntityTimeIq.h" #include "codec.h" -#include "dataform.h" #include "jingle.h" #include "register.h" #include "roster.h" @@ -57,7 +56,6 @@ #include "stun.h" #include "tests.h" #include "util.h" -#include "vcard.h" void TestUtils::testCrc32() { @@ -892,9 +890,6 @@ int main(int argc, char *argv[]) errors += QTest::qExec(&testCodec); #endif - tst_QXmppDataForm testDataForm; - errors += QTest::qExec(&testDataForm); - TestJingle testJingle; errors += QTest::qExec(&testJingle); @@ -930,17 +925,9 @@ int main(int argc, char *argv[]) tst_QXmppStanza testStanza; errors += QTest::qExec(&testStanza); -#ifdef QXMPP_AUTOTEST_INTERNAL - tst_QXmppStreamInitiationIq testSI; - errors += QTest::qExec(&testSI); -#endif - TestStun testStun; errors += QTest::qExec(&testStun); - tst_QXmppVCardIq testVCard; - errors += QTest::qExec(&testVCard); - TestXmlRpc testXmlRpc; errors += QTest::qExec(&testXmlRpc); diff --git a/tests/all/vcard.h b/tests/all/vcard.h deleted file mode 100644 index 29a1dcad..00000000 --- a/tests/all/vcard.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2008-2012 The QXmpp developers - * - * Author: - * 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 - -class tst_QXmppVCardIq : public QObject -{ - Q_OBJECT - -private slots: - void testAddress_data(); - void testAddress(); - void testEmail_data(); - void testEmail(); - void testPhone_data(); - void testPhone(); - void testVCard(); -}; diff --git a/tests/qxmppdataform/qxmppdataform.pro b/tests/qxmppdataform/qxmppdataform.pro new file mode 100644 index 00000000..ab92935a --- /dev/null +++ b/tests/qxmppdataform/qxmppdataform.pro @@ -0,0 +1,3 @@ +include(../tests.pri) +TARGET = tst_qxmppdataform +SOURCES += tst_qxmppdataform.cpp diff --git a/tests/qxmppdataform/tst_qxmppdataform.cpp b/tests/qxmppdataform/tst_qxmppdataform.cpp new file mode 100644 index 00000000..6ab86ed6 --- /dev/null +++ b/tests/qxmppdataform/tst_qxmppdataform.cpp @@ -0,0 +1,116 @@ +/* + * 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 +#include "QXmppDataForm.h" +#include "util.h" + +class tst_QXmppDataForm : public QObject +{ + Q_OBJECT + +private slots: + void testSimple(); + void testSubmit(); + void testMedia(); +}; + +void tst_QXmppDataForm::testSimple() +{ + const QByteArray xml( + "" + "Joggle Search" + "Fill out this form to search for information!" + "" + "" + "" + ""); + + 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::testSubmit() +{ + const QByteArray xml( + "" + "" + "verona" + "" + ""); + + QXmppDataForm form; + parsePacket(form, xml); + QCOMPARE(form.isNull(), false); + serializePacket(form, xml); +} + +void tst_QXmppDataForm::testMedia() +{ + const QByteArray xml( + "" + "" + "" + "" + "" + "http://www.victim.com/challenges/ocr.jpeg?F3A6292C" + "" + "" + "cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org" + "" + "" + "" + ""); + + 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); +} + +QTEST_MAIN(tst_QXmppDataForm) +#include "tst_qxmppdataform.moc" diff --git a/tests/tests.pro b/tests/tests.pro index a2814ebe..bcfe6825 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,6 +1,7 @@ TEMPLATE = subdirs SUBDIRS = \ all \ + qxmppdataform \ qxmppiq \ qxmppmessage \ qxmpppresence \ -- cgit v1.2.3