From db2f84e966682c1072cd579baa9511906a276ab0 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Thu, 27 Sep 2012 15:06:55 +0200 Subject: start splitting tests --- tests/vcard.cpp | 187 -------------------------------------------------------- 1 file changed, 187 deletions(-) delete mode 100644 tests/vcard.cpp (limited to 'tests/vcard.cpp') diff --git a/tests/vcard.cpp b/tests/vcard.cpp deleted file mode 100644 index 92c1c5ee..00000000 --- a/tests/vcard.cpp +++ /dev/null @@ -1,187 +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 "QXmppVCardIq.h" - -#include "tests.h" -#include "vcard.h" - -void tst_QXmppVCardIq::testAddress_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("type"); - QTest::addColumn("country"); - QTest::addColumn("locality"); - QTest::addColumn("postcode"); - QTest::addColumn("region"); - QTest::addColumn("street"); - - QTest::newRow("none") << QByteArray("") << int(QXmppVCardAddress::None) << "" << "" << "" << "" << ""; - QTest::newRow("HOME") << QByteArray("") << int(QXmppVCardAddress::Home) << "" << "" << "" << "" << ""; - QTest::newRow("WORK") << QByteArray("") << int(QXmppVCardAddress::Work) << "" << "" << "" << "" << ""; - QTest::newRow("POSTAL") << QByteArray("") << int(QXmppVCardAddress::Postal) << "" << "" << "" << "" << ""; - QTest::newRow("PREF") << QByteArray("") << int(QXmppVCardAddress::Preferred) << "" << "" << "" << "" << ""; - - QTest::newRow("country") << QByteArray("France") << int(QXmppVCardAddress::None) << "France" << "" << "" << "" << ""; - QTest::newRow("locality") << QByteArray("Paris") << int(QXmppVCardAddress::None) << "" << "Paris" << "" << "" << ""; - QTest::newRow("postcode") << QByteArray("75008") << int(QXmppVCardAddress::None) << "" << "" << "75008" << "" << ""; - QTest::newRow("region") << QByteArray("Ile de France") << int(QXmppVCardAddress::None) << "" << "" << "" << "Ile de France" << ""; - QTest::newRow("street") << QByteArray("55 rue du faubourg Saint-Honoré") << int(QXmppVCardAddress::None) << "" << "" << "" << "" << QString::fromUtf8("55 rue du faubourg Saint-Honoré"); -} - -void tst_QXmppVCardIq::testAddress() -{ - QFETCH(QByteArray, xml); - QFETCH(int, type); - QFETCH(QString, country); - QFETCH(QString, locality); - QFETCH(QString, postcode); - QFETCH(QString, region); - QFETCH(QString, street); - - QXmppVCardAddress address; - parsePacket(address, xml); - QCOMPARE(int(address.type()), type); - QCOMPARE(address.country(), country); - QCOMPARE(address.locality(), locality); - QCOMPARE(address.postcode(), postcode); - QCOMPARE(address.region(), region); - QCOMPARE(address.street(), street); - serializePacket(address, xml); -} - -void tst_QXmppVCardIq::testEmail_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("type"); - - QTest::newRow("none") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::None); - QTest::newRow("HOME") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::Home); - QTest::newRow("WORK") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::Work); - QTest::newRow("INTERNET") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::Internet); - QTest::newRow("X400") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::X400); - QTest::newRow("PREF") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::Preferred); - QTest::newRow("all") << QByteArray("foo.bar@example.com") << int(QXmppVCardEmail::Home | QXmppVCardEmail::Work | QXmppVCardEmail::Internet | QXmppVCardEmail::Preferred | QXmppVCardEmail::X400); -} - -void tst_QXmppVCardIq::testEmail() -{ - QFETCH(QByteArray, xml); - QFETCH(int, type); - - QXmppVCardEmail email; - parsePacket(email, xml); - QCOMPARE(email.address(), QLatin1String("foo.bar@example.com")); - QCOMPARE(int(email.type()), type); - serializePacket(email, xml); -} - -void tst_QXmppVCardIq::testPhone_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("type"); - - QTest::newRow("none") << QByteArray("12345") << int(QXmppVCardPhone::None); - QTest::newRow("HOME") << QByteArray("12345") << int(QXmppVCardPhone::Home); - QTest::newRow("WORK") << QByteArray("12345") << int(QXmppVCardPhone::Work); - QTest::newRow("VOICE") << QByteArray("12345") << int(QXmppVCardPhone::Voice); - QTest::newRow("FAX") << QByteArray("12345") << int(QXmppVCardPhone::Fax); - QTest::newRow("PAGER") << QByteArray("12345") << int(QXmppVCardPhone::Pager); - QTest::newRow("MSG") << QByteArray("12345") << int(QXmppVCardPhone::Messaging); - QTest::newRow("CELL") << QByteArray("12345") << int(QXmppVCardPhone::Cell); - QTest::newRow("VIDEO") << QByteArray("") << int(QXmppVCardPhone::Video); - QTest::newRow("BBS") << QByteArray("12345") << int(QXmppVCardPhone::BBS); - QTest::newRow("MODEM") << QByteArray("12345") << int(QXmppVCardPhone::Modem); - QTest::newRow("IDSN") << QByteArray("12345") << int(QXmppVCardPhone::ISDN); - QTest::newRow("PCS") << QByteArray("12345") << int(QXmppVCardPhone::PCS); - QTest::newRow("PREF") << QByteArray("12345") << int(QXmppVCardPhone::Preferred); -} - -void tst_QXmppVCardIq::testPhone() -{ - QFETCH(QByteArray, xml); - QFETCH(int, type); - - QXmppVCardPhone phone; - parsePacket(phone, xml); - QCOMPARE(phone.number(), QLatin1String("12345")); - QCOMPARE(int(phone.type()), type); - serializePacket(phone, xml); -} - - -void tst_QXmppVCardIq::testVCard() -{ - const QByteArray xml( - "" - "" - "France" - "1983-09-14" - "I like XMPP." - "foo.bar@example.com" - "Foo Bar!" - "FooBar" - "FooWizBaz" - "12345" - "67890" - "" - "image/png" - "" - "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA" - "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP" - "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC" - "" - "" - "http://code.google.com/p/qxmpp/" - "" - ""); - - QXmppVCardIq vcard; - parsePacket(vcard, xml); - QCOMPARE(vcard.addresses().size(), 1); - QCOMPARE(vcard.addresses()[0].country(), QLatin1String("France")); - QCOMPARE(int(vcard.addresses()[0].type()), int(QXmppVCardEmail::None)); - QCOMPARE(vcard.birthday(), QDate(1983, 9, 14)); - QCOMPARE(vcard.description(), QLatin1String("I like XMPP.")); - QCOMPARE(vcard.email(), QLatin1String("foo.bar@example.com")); - QCOMPARE(vcard.emails().size(), 1); - QCOMPARE(vcard.emails()[0].address(), QLatin1String("foo.bar@example.com")); - QCOMPARE(int(vcard.emails()[0].type()), int(QXmppVCardEmail::Internet)); - 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.phones().size(), 2); - QCOMPARE(vcard.phones()[0].number(), QLatin1String("12345")); - QCOMPARE(int(vcard.phones()[0].type()), int(QXmppVCardEmail::Home)); - QCOMPARE(vcard.phones()[1].number(), QLatin1String("67890")); - QCOMPARE(int(vcard.phones()[1].type()), int(QXmppVCardEmail::Work)); - QCOMPARE(vcard.photo(), QByteArray::fromBase64( - "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAAXNSR0IArs4c6QAAAAlwSFlzAAA" - "UIgAAFCIBjw1HyAAAAAd0SU1FB9oIHQInNvuJovgAAAAiSURBVAjXY2TQ+s/AwMDAwPD/GiMDlP" - "WfgYGBiQEHGJwSAK2BBQ1f3uvpAAAAAElFTkSuQmCC")); - QCOMPARE(vcard.photoType(), QLatin1String("image/png")); - QCOMPARE(vcard.url(), QLatin1String("http://code.google.com/p/qxmpp/")); - serializePacket(vcard, xml); -} -- cgit v1.2.3