aboutsummaryrefslogtreecommitdiff
path: root/tests/vcard.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-08-03 16:28:53 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-08-03 16:28:53 +0200
commita8e6bd3e1d435038591b3a16fb31136539c5efec (patch)
treef1e1ac1be12a07f9faa21f59c4e2f7e45ada31f3 /tests/vcard.cpp
parent1268a64bdd1320639cad0d9c8331fb6fd682b30c (diff)
downloadqxmpp-a8e6bd3e1d435038591b3a16fb31136539c5efec.tar.gz
Make it possible to have several addresses in vCards.
Diffstat (limited to 'tests/vcard.cpp')
-rw-r--r--tests/vcard.cpp34
1 files changed, 31 insertions, 3 deletions
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<QByteArray>("xml");
QTest::addColumn<int>("type");
-
- QTest::newRow("none") << QByteArray("<ADR/>") << int(QXmppVCardAddress::None);
- QTest::newRow("HOME") << QByteArray("<ADR><HOME/></ADR>") << int(QXmppVCardAddress::Home);
+ QTest::addColumn<QString>("country");
+ QTest::addColumn<QString>("locality");
+ QTest::addColumn<QString>("postcode");
+ QTest::addColumn<QString>("region");
+ QTest::addColumn<QString>("street");
+
+ QTest::newRow("none") << QByteArray("<ADR/>") << int(QXmppVCardAddress::None) << "" << "" << "" << "" << "";
+ QTest::newRow("HOME") << QByteArray("<ADR><HOME/></ADR>") << int(QXmppVCardAddress::Home) << "" << "" << "" << "" << "";
+ QTest::newRow("WORK") << QByteArray("<ADR><WORK/></ADR>") << int(QXmppVCardAddress::Work) << "" << "" << "" << "" << "";
+ QTest::newRow("POSTAL") << QByteArray("<ADR><POSTAL/></ADR>") << int(QXmppVCardAddress::Postal) << "" << "" << "" << "" << "";
+ QTest::newRow("PREF") << QByteArray("<ADR><PREF/></ADR>") << int(QXmppVCardAddress::Preferred) << "" << "" << "" << "" << "";
+
+ QTest::newRow("country") << QByteArray("<ADR><CTRY>France</CTRY></ADR>") << int(QXmppVCardAddress::None) << "France" << "" << "" << "" << "";
+ QTest::newRow("locality") << QByteArray("<ADR><LOCALITY>Paris</LOCALITY></ADR>") << int(QXmppVCardAddress::None) << "" << "Paris" << "" << "" << "";
+ QTest::newRow("postcode") << QByteArray("<ADR><PCODE>75008</PCODE></ADR>") << int(QXmppVCardAddress::None) << "" << "" << "75008" << "" << "";
+ QTest::newRow("region") << QByteArray("<ADR><REGION>Ile de France</REGION></ADR>") << int(QXmppVCardAddress::None) << "" << "" << "" << "Ile de France" << "";
+ QTest::newRow("street") << QByteArray("<ADR><STREET>55 rue du faubourg Saint-Honoré</STREET></ADR>") << 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(
"<iq id=\"vcard1\" type=\"set\">"
"<vCard xmlns=\"vcard-temp\">"
+ "<ADR><CTRY>France</CTRY></ADR>"
"<BDAY>1983-09-14</BDAY>"
"<EMAIL><INTERNET/><USERID>foo.bar@example.com</USERID></EMAIL>"
"<FN>Foo Bar!</FN>"
@@ -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);