aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-08-03 13:10:22 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-08-03 13:10:22 +0200
commitdb39d34c691cf201830fe221ea72982071809247 (patch)
treec17ce58daf0ab153b3b4a2f65ef26649a81138f7 /tests
parentb83586db0d2e260d4730e4bf3e91c4275b82845f (diff)
downloadqxmpp-db39d34c691cf201830fe221ea72982071809247.tar.gz
split vCard tests to their own file
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.cpp43
-rw-r--r--tests/tests.h1
-rw-r--r--tests/tests.pro6
-rw-r--r--tests/vcard.cpp65
-rw-r--r--tests/vcard.h32
5 files changed, 105 insertions, 42 deletions
diff --git a/tests/tests.cpp b/tests/tests.cpp
index 7aa72494..2adaed57 100644
--- a/tests/tests.cpp
+++ b/tests/tests.cpp
@@ -40,7 +40,6 @@
#include "QXmppServer.h"
#include "QXmppStreamFeatures.h"
#include "QXmppUtils.h"
-#include "QXmppVCardIq.h"
#include "QXmppVersionIq.h"
#include "QXmppGlobal.h"
#include "QXmppEntityTimeIq.h"
@@ -59,6 +58,7 @@
#include "sasl.h"
#include "stun.h"
#include "tests.h"
+#include "vcard.h"
void TestUtils::testCrc32()
{
@@ -519,44 +519,6 @@ void TestPackets::testStreamFeatures()
serializePacket(features2, xml2);
}
-void TestPackets::testVCard()
-{
- const QByteArray xml(
- "<iq id=\"vcard1\" type=\"set\">"
- "<vCard xmlns=\"vcard-temp\">"
- "<BDAY>1983-09-14</BDAY>"
- "<EMAIL><INTERNET/><USERID>foo.bar@example.com</USERID></EMAIL>"
- "<FN>Foo Bar!</FN>"
- "<NICKNAME>FooBar</NICKNAME>"
- "<N><GIVEN>Foo</GIVEN><FAMILY>Wiz</FAMILY><MIDDLE>Baz</MIDDLE></N>"
- "<PHOTO>"
- "<TYPE>image/png</TYPE>"
- "<BINVAL>"
- "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA"
- "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP"
- "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC"
- "</BINVAL>"
- "</PHOTO>"
- "</vCard>"
- "</iq>");
-
- QXmppVCardIq vcard;
- parsePacket(vcard, xml);
- QCOMPARE(vcard.birthday(), QDate(1983, 9, 14));
- QCOMPARE(vcard.email(), QLatin1String("foo.bar@example.com"));
- QCOMPARE(vcard.nickName(), QLatin1String("FooBar"));
- QCOMPARE(vcard.fullName(), QLatin1String("Foo Bar!"));
- QCOMPARE(vcard.firstName(), QLatin1String("Foo"));
- QCOMPARE(vcard.middleName(), QLatin1String("Baz"));
- QCOMPARE(vcard.lastName(), QLatin1String("Wiz"));
- QCOMPARE(vcard.photo(), QByteArray::fromBase64(
- "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA"
- "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP"
- "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC"));
- QCOMPARE(vcard.photoType(), QLatin1String("image/png"));
- serializePacket(vcard, xml);
-}
-
void TestPackets::testVersionGet()
{
const QByteArray xmlGet(
@@ -978,6 +940,9 @@ int main(int argc, char *argv[])
TestStun testStun;
errors += QTest::qExec(&testStun);
+ tst_QXmppVCardIq testVCard;
+ errors += QTest::qExec(&testVCard);
+
TestXmlRpc testXmlRpc;
errors += QTest::qExec(&testXmlRpc);
diff --git a/tests/tests.h b/tests/tests.h
index 5ecadccd..67e3f6cf 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -81,7 +81,6 @@ private slots:
void testNonSaslAuth();
void testSession();
void testStreamFeatures();
- void testVCard();
void testVersionGet();
void testVersionResult();
void testEntityTimeGet();
diff --git a/tests/tests.pro b/tests/tests.pro
index 66e66a9e..068a672e 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -18,7 +18,8 @@ SOURCES += \
rsm.cpp \
rtp.cpp \
stun.cpp \
- tests.cpp
+ tests.cpp \
+ vcard.cpp
HEADERS += \
dataform.h \
iq.h \
@@ -31,7 +32,8 @@ HEADERS += \
rsm.h \
rtp.h \
stun.h \
- tests.h
+ tests.h \
+ vcard.h
!isEmpty(QXMPP_AUTOTEST_INTERNAL) {
HEADERS += codec.h sasl.h
diff --git a/tests/vcard.cpp b/tests/vcard.cpp
new file mode 100644
index 00000000..f7145ae9
--- /dev/null
+++ b/tests/vcard.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 "QXmppVCardIq.h"
+
+#include "tests.h"
+#include "vcard.h"
+
+void tst_QXmppVCardIq::testVCard()
+{
+ const QByteArray xml(
+ "<iq id=\"vcard1\" type=\"set\">"
+ "<vCard xmlns=\"vcard-temp\">"
+ "<BDAY>1983-09-14</BDAY>"
+ "<EMAIL><INTERNET/><USERID>foo.bar@example.com</USERID></EMAIL>"
+ "<FN>Foo Bar!</FN>"
+ "<NICKNAME>FooBar</NICKNAME>"
+ "<N><GIVEN>Foo</GIVEN><FAMILY>Wiz</FAMILY><MIDDLE>Baz</MIDDLE></N>"
+ "<PHOTO>"
+ "<TYPE>image/png</TYPE>"
+ "<BINVAL>"
+ "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA"
+ "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP"
+ "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC"
+ "</BINVAL>"
+ "</PHOTO>"
+ "</vCard>"
+ "</iq>");
+
+ QXmppVCardIq vcard;
+ parsePacket(vcard, xml);
+ QCOMPARE(vcard.birthday(), QDate(1983, 9, 14));
+ QCOMPARE(vcard.email(), QLatin1String("foo.bar@example.com"));
+ QCOMPARE(vcard.nickName(), QLatin1String("FooBar"));
+ QCOMPARE(vcard.fullName(), QLatin1String("Foo Bar!"));
+ QCOMPARE(vcard.firstName(), QLatin1String("Foo"));
+ QCOMPARE(vcard.middleName(), QLatin1String("Baz"));
+ QCOMPARE(vcard.lastName(), QLatin1String("Wiz"));
+ QCOMPARE(vcard.photo(), QByteArray::fromBase64(
+ "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA"
+ "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP"
+ "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC"));
+ QCOMPARE(vcard.photoType(), QLatin1String("image/png"));
+ serializePacket(vcard, xml);
+}
diff --git a/tests/vcard.h b/tests/vcard.h
new file mode 100644
index 00000000..796a0857
--- /dev/null
+++ b/tests/vcard.h
@@ -0,0 +1,32 @@
+/*
+ * 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_QXmppVCardIq : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void testVCard();
+};