aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-07-22 01:20:23 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-07-22 01:20:23 +0200
commit4c8dc9678157cb1c663365f9cbd3b4bc056ba892 (patch)
treeba4f9fcc1f154b17fa0d548f20d8cfc6b4e71d92 /tests
parent92eed51ce3256c59c85529f195fe4cdfbe0a1415 (diff)
downloadqxmpp-4c8dc9678157cb1c663365f9cbd3b4bc056ba892.tar.gz
start testing QXmppRosterIq
Diffstat (limited to 'tests')
-rw-r--r--tests/roster.cpp58
-rw-r--r--tests/roster.h34
-rw-r--r--tests/tests.cpp4
-rw-r--r--tests/tests.pro2
4 files changed, 98 insertions, 0 deletions
diff --git a/tests/roster.cpp b/tests/roster.cpp
new file mode 100644
index 00000000..96f0fe49
--- /dev/null
+++ b/tests/roster.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "QXmppRosterIq.h"
+
+#include "roster.h"
+#include "tests.h"
+
+void tst_QXmppRosterIq::testItem_data()
+{
+ QTest::addColumn<QByteArray>("xml");
+ QTest::addColumn<int>("subscriptionType");
+
+ QTest::newRow("notset")
+ << QByteArray("<item/>")
+ << int(QXmppRosterIq::Item::NotSet);
+ QTest::newRow("from")
+ << QByteArray("<item subscription=\"from\"/>")
+ << int(QXmppRosterIq::Item::From);
+ QTest::newRow("to")
+ << QByteArray("<item subscription=\"to\"/>")
+ << int(QXmppRosterIq::Item::To);
+ QTest::newRow("both")
+ << QByteArray("<item subscription=\"both\"/>")
+ << int(QXmppRosterIq::Item::Both);
+}
+
+void tst_QXmppRosterIq::testItem()
+{
+ QFETCH(QByteArray, xml);
+ QFETCH(int, subscriptionType);
+
+ QXmppRosterIq::Item item;
+ parsePacket(item, xml);
+ QCOMPARE(int(item.subscriptionType()), subscriptionType);
+ serializePacket(item, xml);
+}
+
diff --git a/tests/roster.h b/tests/roster.h
new file mode 100644
index 00000000..83240ec3
--- /dev/null
+++ b/tests/roster.h
@@ -0,0 +1,34 @@
+/*
+ * 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 <QObject>
+
+class tst_QXmppRosterIq : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testItem_data();
+ void testItem();
+};
+
diff --git a/tests/tests.cpp b/tests/tests.cpp
index c48acfbe..9993686a 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -52,6 +52,7 @@
#include "message.h"
#include "presence.h"
#include "register.h"
+#include "roster.h"
#include "rpc.h"
#include "rsm.h"
#include "rtp.h"
@@ -954,6 +955,9 @@ int main(int argc, char *argv[])
tst_QXmppResultSet testRsm;
errors += QTest::qExec(&testRsm);
+ tst_QXmppRosterIq testRoster;
+ errors += QTest::qExec(&testRoster);
+
tst_QXmppRtpPacket testRtp;
errors += QTest::qExec(&testRtp);
diff --git a/tests/tests.pro b/tests/tests.pro
index 48df9eaa..66e66a9e 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -13,6 +13,7 @@ SOURCES += \
message.cpp \
presence.cpp \
register.cpp \
+ roster.cpp \
rpc.cpp \
rsm.cpp \
rtp.cpp \
@@ -25,6 +26,7 @@ HEADERS += \
message.h \
presence.h \
register.h \
+ roster.h \
rpc.h \
rsm.h \
rtp.h \