aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-07-27 13:24:37 +0200
committerMontel Laurent <[email protected]>2015-07-27 13:24:37 +0200
commit404c56fad54dc3454f6065bc58f2dd632c5d331a (patch)
treef59a81a55f65c6b9f637dbc6d1def802e14fdd6a
parent1bb5f75e4a72aae30c44cb2d8a877cf315b8139e (diff)
Add more autotests
-rw-r--r--autotests/addresseetest.cpp9
-rw-r--r--autotests/geotest.cpp70
-rw-r--r--autotests/geotest.h3
3 files changed, 81 insertions, 1 deletions
diff --git a/autotests/addresseetest.cpp b/autotests/addresseetest.cpp
index f36ba4b..156d642 100644
--- a/autotests/addresseetest.cpp
+++ b/autotests/addresseetest.cpp
@@ -93,7 +93,14 @@ void AddresseeTest::storeTest()
addressee.setCustoms(customs);
addressee.setKind(QStringLiteral("foo"));
addressee.setChanged(false);
-
+ KContacts::Impp imp;
+ imp.setType(KContacts::Impp::GaduGadu);
+ imp.setAddress(QStringLiteral("[email protected]"));
+ KContacts::Impp::List listImp;
+ listImp << imp;
+ addressee.setImppList(listImp);
+
+ QVERIFY(addressee.imppList() == listImp);
QVERIFY(addressee.langs() == (KContacts::Lang::List() << lang));
QVERIFY(addressee.gender() == gender);
QVERIFY(addressee.uid() == QStringLiteral("My uid"));
diff --git a/autotests/geotest.cpp b/autotests/geotest.cpp
index aa4f02f..c79d868 100644
--- a/autotests/geotest.cpp
+++ b/autotests/geotest.cpp
@@ -134,3 +134,73 @@ void GeoTest::shouldParseGeoVCard4()
QCOMPARE(geo.latitude(), 22.5);
QCOMPARE(geo.longitude(), 180.0);
}
+
+void GeoTest::shouldGenerateVCard3()
+{
+ KContacts::AddresseeList lst;
+ KContacts::Addressee addr;
+ addr.setEmails(QStringList() << QStringLiteral("[email protected]"));
+ addr.setUid(QStringLiteral("testuid"));
+
+ KContacts::Geo geo;
+ geo.setLongitude(180.0);
+ geo.setLatitude(22.5);
+ addr.setGeo(geo);
+
+ lst << addr;
+ KContacts::VCardTool vcard;
+ const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v3_0);
+ QByteArray expected("BEGIN:VCARD\r\n"
+ "VERSION:3.0\r\n"
+ "EMAIL:[email protected]\r\n"
+ "GEO:22.500000;180.000000\r\n"
+ "N:;;;;\r\n"
+ "UID:testuid\r\n"
+ "END:VCARD\r\n\r\n");
+ QCOMPARE(ba, expected);
+
+}
+
+void GeoTest::shouldGenerateVCard4()
+{
+ KContacts::AddresseeList lst;
+ KContacts::Addressee addr;
+ addr.setEmails(QStringList() << QStringLiteral("[email protected]"));
+ addr.setUid(QStringLiteral("testuid"));
+
+ KContacts::Geo geo;
+ geo.setLongitude(180.0);
+ geo.setLatitude(22.5);
+ addr.setGeo(geo);
+
+ lst << addr;
+ KContacts::VCardTool vcard;
+ const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0);
+ QByteArray expected("BEGIN:VCARD\r\n"
+ "VERSION:4.0\r\n"
+ "EMAIL:[email protected]\r\n"
+ "GEO:geo:22.500000,180.000000\r\n"
+ "N:;;;;\r\n"
+ "UID:testuid\r\n"
+ "END:VCARD\r\n\r\n");
+ QCOMPARE(ba, expected);
+}
+
+void GeoTest::shouldGenerateWithoutGeo()
+{
+ KContacts::AddresseeList lst;
+ KContacts::Addressee addr;
+ addr.setEmails(QStringList() << QStringLiteral("[email protected]"));
+ addr.setUid(QStringLiteral("testuid"));
+
+ lst << addr;
+ KContacts::VCardTool vcard;
+ const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0);
+ QByteArray expected("BEGIN:VCARD\r\n"
+ "VERSION:4.0\r\n"
+ "EMAIL:[email protected]\r\n"
+ "N:;;;;\r\n"
+ "UID:testuid\r\n"
+ "END:VCARD\r\n\r\n");
+ QCOMPARE(ba, expected);
+}
diff --git a/autotests/geotest.h b/autotests/geotest.h
index 646ddf0..25a4e47 100644
--- a/autotests/geotest.h
+++ b/autotests/geotest.h
@@ -36,6 +36,9 @@ private Q_SLOTS:
void serialization();
void shouldParseGeoVCard3();
void shouldParseGeoVCard4();
+ void shouldGenerateVCard3();
+ void shouldGenerateVCard4();
+ void shouldGenerateWithoutGeo();
};
#endif