From a8e6bd3e1d435038591b3a16fb31136539c5efec Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Fri, 3 Aug 2012 16:28:53 +0200 Subject: Make it possible to have several addresses in vCards. --- tests/vcard.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'tests/vcard.cpp') diff --git a/tests/vcard.cpp b/tests/vcard.cpp index ccc65199..eacaf938 100644 --- a/tests/vcard.cpp +++ b/tests/vcard.cpp @@ -30,19 +30,43 @@ void tst_QXmppVCardIq::testAddress_data() { QTest::addColumn("xml"); QTest::addColumn("type"); - - QTest::newRow("none") << QByteArray("") << int(QXmppVCardAddress::None); - QTest::newRow("HOME") << QByteArray("") << int(QXmppVCardAddress::Home); + 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); } @@ -111,6 +135,7 @@ void tst_QXmppVCardIq::testVCard() const QByteArray xml( "" "" + "France" "1983-09-14" "foo.bar@example.com" "Foo Bar!" @@ -132,6 +157,9 @@ void tst_QXmppVCardIq::testVCard() 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.email(), QLatin1String("foo.bar@example.com")); QCOMPARE(vcard.emails().size(), 1); -- cgit v1.2.3