File indexing completed on 2024-04-14 03:51:17

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2007 Tobias Koenig <tokoe@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 // krazy:excludeall=contractions
0008 
0009 #include "addresseetest.h"
0010 #include "kcontacts/addressee.h"
0011 #include <QTest>
0012 
0013 QTEST_MAIN(AddresseeTest)
0014 
0015 void AddresseeTest::emptyTest()
0016 {
0017     KContacts::Addressee addressee;
0018     QVERIFY(addressee.isEmpty());
0019 
0020     KContacts::Addressee addresseeWithMail;
0021     addresseeWithMail.addEmail(QStringLiteral("foo@bar.org"));
0022     QVERIFY(!addresseeWithMail.isEmpty());
0023 }
0024 
0025 void AddresseeTest::storeTest()
0026 {
0027     KContacts::Addressee addressee;
0028 
0029     KContacts::Picture logo(QStringLiteral("http://scottlandyard.info/pics/logo.png"));
0030     KContacts::Picture photo(QStringLiteral("http://scottlandyard.info/~sinclair/photo.png"));
0031     KContacts::Sound sound(QStringLiteral("http://scottlandyard.info/~sinclair/sound.wav"));
0032 
0033     QStringList emails;
0034     emails << QStringLiteral("john@sinclair.com") << QStringLiteral("ghosthunter@sinclair.com");
0035 
0036     KContacts::Key::List keys;
0037     keys << KContacts::Key(QStringLiteral("SecretKey"));
0038 
0039     QStringList categories;
0040     categories << QStringLiteral("Helper") << QStringLiteral("Friend");
0041 
0042     QStringList customs;
0043     customs << QStringLiteral("X-Danger: high");
0044 
0045     KContacts::Gender gender(QStringLiteral("H"));
0046     addressee.setGender(gender);
0047     KContacts::Lang lang(QLatin1String("lang"));
0048     addressee.setLangs(KContacts::Lang::List() << lang);
0049 
0050     addressee.setUid(QStringLiteral("My uid"));
0051     addressee.setName(QStringLiteral("John Sinclair"));
0052     addressee.setFormattedName(QStringLiteral("Sinclair, John"));
0053     addressee.setFamilyName(QStringLiteral("Sinclair"));
0054     addressee.setGivenName(QStringLiteral("John"));
0055     addressee.setAdditionalName(QStringLiteral("Bob"));
0056     addressee.setPrefix(QStringLiteral("Sir"));
0057     addressee.setSuffix(QStringLiteral("II"));
0058     addressee.setNickName(QStringLiteral("ghosthunter"));
0059     addressee.setBirthday(QDate(1982, 7, 19));
0060     addressee.setMailer(QStringLiteral("mutt"));
0061     addressee.setTimeZone(KContacts::TimeZone(2));
0062     addressee.setGeo(KContacts::Geo(42, 23));
0063     addressee.setTitle(QStringLiteral("Ghost Hunter"));
0064     addressee.setRole(QStringLiteral("Leader"));
0065     addressee.setOrganization(QStringLiteral("Scottland Yard"));
0066     addressee.setNote(QStringLiteral("Don't cross black deads way..."));
0067     addressee.setProductId(QStringLiteral("ProductId45"));
0068     addressee.setRevision(QDateTime(QDate(1982, 9, 15).startOfDay()));
0069     addressee.setSortString(QStringLiteral("Name"));
0070     KContacts::ResourceLocatorUrl url;
0071     url.setUrl(QUrl(QStringLiteral("www.scottlandyard.info")));
0072     addressee.setUrl(url);
0073     addressee.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public));
0074     addressee.setLogo(logo);
0075     addressee.setPhoto(photo);
0076     addressee.setSound(sound);
0077     addressee.setEmails(emails);
0078     addressee.setKeys(keys);
0079     addressee.setCategories(categories);
0080     addressee.setCustoms(customs);
0081     addressee.setKind(QStringLiteral("foo"));
0082     addressee.setChanged(false);
0083     KContacts::Impp imp;
0084     imp.setAddress(QUrl(QStringLiteral("gg:foo@kde.org")));
0085     KContacts::Impp::List listImp;
0086     listImp << imp;
0087     addressee.setImppList(listImp);
0088 
0089     QVERIFY(addressee.imppList() == listImp);
0090     QVERIFY(addressee.langs() == (KContacts::Lang::List() << lang));
0091     QVERIFY(addressee.gender() == gender);
0092     QVERIFY(addressee.uid() == QLatin1String("My uid"));
0093     QVERIFY(addressee.name() == QLatin1String("John Sinclair"));
0094     QVERIFY(addressee.formattedName() == QLatin1String("Sinclair, John"));
0095     QVERIFY(addressee.familyName() == QLatin1String("Sinclair"));
0096     QVERIFY(addressee.givenName() == QLatin1String("John"));
0097     QVERIFY(addressee.additionalName() == QLatin1String("Bob"));
0098     QVERIFY(addressee.prefix() == QLatin1String("Sir"));
0099     QVERIFY(addressee.suffix() == QLatin1String("II"));
0100     QVERIFY(addressee.nickName() == QLatin1String("ghosthunter"));
0101     QVERIFY(addressee.birthday().date() == QDate(1982, 7, 19));
0102     QVERIFY(addressee.birthday().time() == QTime(0, 0));
0103     QVERIFY(!addressee.birthdayHasTime());
0104     QVERIFY(addressee.mailer() == QLatin1String("mutt"));
0105     QVERIFY(addressee.timeZone() == KContacts::TimeZone(2));
0106     QVERIFY(addressee.geo() == KContacts::Geo(42, 23));
0107     QVERIFY(addressee.title() == QLatin1String("Ghost Hunter"));
0108     QVERIFY(addressee.role() == QLatin1String("Leader"));
0109     QVERIFY(addressee.organization() == QLatin1String("Scottland Yard"));
0110     QVERIFY(addressee.note() == QLatin1String("Don't cross black deads way..."));
0111     QVERIFY(addressee.productId() == QLatin1String("ProductId45"));
0112     QVERIFY(addressee.revision() == QDateTime(QDate(1982, 9, 15).startOfDay()));
0113     QVERIFY(addressee.sortString() == QLatin1String("Name"));
0114     QVERIFY(addressee.url() == url);
0115     QVERIFY(addressee.secrecy() == KContacts::Secrecy(KContacts::Secrecy::Public));
0116     QVERIFY(addressee.logo() == logo);
0117     QVERIFY(addressee.photo() == photo);
0118     QVERIFY(addressee.sound() == sound);
0119     QVERIFY(addressee.emails() == emails);
0120     QVERIFY(addressee.keys() == keys);
0121     QVERIFY(addressee.categories() == categories);
0122     QVERIFY(addressee.customs() == customs);
0123     QVERIFY(addressee.changed() == false);
0124     QCOMPARE(addressee.kind(), QStringLiteral("foo"));
0125 }
0126 
0127 void AddresseeTest::equalsTest()
0128 {
0129     KContacts::Addressee addressee1;
0130     KContacts::Addressee addressee2;
0131 
0132     KContacts::Picture logo(QStringLiteral("http://scottlandyard.info/pics/logo.png"));
0133     KContacts::Picture photo(QStringLiteral("http://scottlandyard.info/~sinclair/photo.png"));
0134     KContacts::Sound sound(QStringLiteral("http://scottlandyard.info/~sinclair/sound.wav"));
0135 
0136     QStringList emails;
0137     emails << QStringLiteral("john@sinclair.com") << QStringLiteral("ghosthunter@sinclair.com");
0138 
0139     KContacts::Key::List keys;
0140     keys << KContacts::Key(QStringLiteral("SecretKey"));
0141 
0142     QStringList categories;
0143     categories << QStringLiteral("Helper") << QStringLiteral("Friend");
0144 
0145     QStringList customs;
0146     customs << QStringLiteral("X-Danger: high");
0147 
0148     addressee1.setUid(QStringLiteral("My uid"));
0149     addressee1.setName(QStringLiteral("John Sinclair"));
0150     addressee1.setFormattedName(QStringLiteral("Sinclair, John"));
0151     addressee1.setFamilyName(QStringLiteral("Sinclair"));
0152     addressee1.setGivenName(QStringLiteral("John"));
0153     addressee1.setAdditionalName(QStringLiteral("Bob"));
0154     addressee1.setPrefix(QStringLiteral("Sir"));
0155     addressee1.setSuffix(QStringLiteral("II"));
0156     addressee1.setNickName(QStringLiteral("ghosthunter"));
0157     addressee1.setBirthday(QDateTime(QDate(1982, 7, 19).startOfDay()));
0158     addressee1.setMailer(QStringLiteral("mutt"));
0159     addressee1.setTimeZone(KContacts::TimeZone(2));
0160     addressee1.setGeo(KContacts::Geo(42, 23));
0161     addressee1.setTitle(QStringLiteral("Ghost Hunter"));
0162     addressee1.setRole(QStringLiteral("Leader"));
0163     addressee1.setOrganization(QStringLiteral("Scottland Yard"));
0164     addressee1.setNote(QStringLiteral("Don't cross black deads way..."));
0165     addressee1.setProductId(QStringLiteral("ProductId45"));
0166     addressee1.setRevision(QDateTime(QDate(1982, 9, 15).startOfDay()));
0167     addressee1.setSortString(QStringLiteral("Name"));
0168     KContacts::ResourceLocatorUrl url;
0169     url.setUrl(QUrl(QStringLiteral("www.scottlandyard.info")));
0170     addressee1.setUrl(url);
0171     addressee1.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public));
0172     addressee1.setLogo(logo);
0173     addressee1.setPhoto(photo);
0174     addressee1.setSound(sound);
0175     addressee1.setEmails(emails);
0176     addressee1.setKeys(keys);
0177     addressee1.setCategories(categories);
0178     addressee1.setCustoms(customs);
0179     addressee1.setChanged(false);
0180 
0181     addressee2.setUid(QStringLiteral("My uid"));
0182     addressee2.setName(QStringLiteral("John Sinclair"));
0183     addressee2.setFormattedName(QStringLiteral("Sinclair, John"));
0184     addressee2.setFamilyName(QStringLiteral("Sinclair"));
0185     addressee2.setGivenName(QStringLiteral("John"));
0186     addressee2.setAdditionalName(QStringLiteral("Bob"));
0187     addressee2.setPrefix(QStringLiteral("Sir"));
0188     addressee2.setSuffix(QStringLiteral("II"));
0189     addressee2.setNickName(QStringLiteral("ghosthunter"));
0190     addressee2.setBirthday(QDateTime(QDate(1982, 7, 19).startOfDay()));
0191     addressee2.setMailer(QStringLiteral("mutt"));
0192     addressee2.setTimeZone(KContacts::TimeZone(2));
0193     addressee2.setGeo(KContacts::Geo(42, 23));
0194     addressee2.setTitle(QStringLiteral("Ghost Hunter"));
0195     addressee2.setRole(QStringLiteral("Leader"));
0196     addressee2.setOrganization(QStringLiteral("Scottland Yard"));
0197     addressee2.setNote(QStringLiteral("Don't cross black deads way..."));
0198     addressee2.setProductId(QStringLiteral("ProductId45"));
0199     addressee2.setRevision(QDateTime(QDate(1982, 9, 15).startOfDay()));
0200     addressee2.setSortString(QStringLiteral("Name"));
0201     addressee2.setUrl(url);
0202     addressee2.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public));
0203     addressee2.setLogo(logo);
0204     addressee2.setPhoto(photo);
0205     addressee2.setSound(sound);
0206     addressee2.setEmails(emails);
0207     addressee2.setKeys(keys);
0208     addressee2.setCategories(categories);
0209     addressee2.setCustoms(customs);
0210     addressee2.setChanged(false);
0211 
0212     QVERIFY(addressee1 == addressee2);
0213 }
0214 
0215 void AddresseeTest::differsTest()
0216 {
0217     KContacts::Addressee addressee1;
0218     KContacts::Addressee addressee2;
0219 
0220     addressee1.setNameFromString(QStringLiteral("John Sinclair"));
0221     addressee2.setNameFromString(QStringLiteral("Suko"));
0222 
0223     QVERIFY(addressee1 != addressee2);
0224 }
0225 
0226 void AddresseeTest::assignmentTest()
0227 {
0228     KContacts::Addressee addressee1;
0229     KContacts::Addressee addressee2;
0230 
0231     KContacts::Picture logo(QStringLiteral("http://scottlandyard.info/pics/logo.png"));
0232     KContacts::Picture photo(QStringLiteral("http://scottlandyard.info/~sinclair/photo.png"));
0233     KContacts::Sound sound(QStringLiteral("http://scottlandyard.info/~sinclair/sound.wav"));
0234 
0235     QStringList emails;
0236     emails << QStringLiteral("john@sinclair.com") << QStringLiteral("ghosthunter@sinclair.com");
0237 
0238     KContacts::Key::List keys;
0239     keys << KContacts::Key(QStringLiteral("SecretKey"));
0240 
0241     QStringList categories;
0242     categories << QStringLiteral("Helper") << QStringLiteral("Friend");
0243 
0244     QStringList customs;
0245     customs << QStringLiteral("X-Danger: high");
0246 
0247     addressee1.setUid(QStringLiteral("My uid"));
0248     addressee1.setName(QStringLiteral("John Sinclair"));
0249     addressee1.setFormattedName(QStringLiteral("Sinclair, John"));
0250     addressee1.setFamilyName(QStringLiteral("Sinclair"));
0251     addressee1.setGivenName(QStringLiteral("John"));
0252     addressee1.setAdditionalName(QStringLiteral("Bob"));
0253     addressee1.setPrefix(QStringLiteral("Sir"));
0254     addressee1.setSuffix(QStringLiteral("II"));
0255     addressee1.setNickName(QStringLiteral("ghosthunter"));
0256     addressee1.setBirthday(QDateTime(QDate(1982, 7, 19).startOfDay()));
0257     addressee1.setMailer(QStringLiteral("mutt"));
0258     addressee1.setTimeZone(KContacts::TimeZone(2));
0259     addressee1.setGeo(KContacts::Geo(42, 23));
0260     addressee1.setTitle(QStringLiteral("Ghost Hunter"));
0261     addressee1.setRole(QStringLiteral("Leader"));
0262     addressee1.setOrganization(QStringLiteral("Scottland Yard"));
0263     addressee1.setNote(QStringLiteral("Don't cross black deads way..."));
0264     addressee1.setProductId(QStringLiteral("ProductId45"));
0265     addressee1.setRevision(QDateTime(QDate(1982, 9, 15).startOfDay()));
0266     addressee1.setSortString(QStringLiteral("Name"));
0267     KContacts::ResourceLocatorUrl url;
0268     url.setUrl(QUrl(QStringLiteral("www.scottlandyard.info")));
0269     addressee1.setUrl(url);
0270     addressee1.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public));
0271     addressee1.setLogo(logo);
0272     addressee1.setPhoto(photo);
0273     addressee1.setSound(sound);
0274     addressee1.setEmails(emails);
0275     addressee1.setKeys(keys);
0276     addressee1.setCategories(categories);
0277     addressee1.setCustoms(customs);
0278     addressee1.setChanged(false);
0279 
0280     addressee2 = addressee1;
0281 
0282     QVERIFY(addressee1 == addressee2);
0283 }
0284 
0285 void AddresseeTest::serializeTest()
0286 {
0287     KContacts::Addressee addressee1;
0288     KContacts::Addressee addressee2;
0289 
0290     KContacts::Picture logo(QStringLiteral("http://scottlandyard.info/pics/logo.png"));
0291     KContacts::Picture photo(QStringLiteral("http://scottlandyard.info/~sinclair/photo.png"));
0292     KContacts::Sound sound(QStringLiteral("http://scottlandyard.info/~sinclair/sound.wav"));
0293 
0294     QStringList emails;
0295     emails << QStringLiteral("john@sinclair.com") << QStringLiteral("ghosthunter@sinclair.com");
0296 
0297     KContacts::Key::List keys;
0298     keys << KContacts::Key(QStringLiteral("SecretKey"));
0299 
0300     QStringList categories;
0301     categories << QStringLiteral("Helper") << QStringLiteral("Friend");
0302 
0303     QStringList customs;
0304     customs << QStringLiteral("FirstApp-FirstKey:FirstValue") << QStringLiteral("SecondApp-SecondKey:SecondValue")
0305             << QStringLiteral("ThirdApp-ThirdKey:ThirdValue");
0306 
0307     addressee1.setUid(QStringLiteral("My uid"));
0308     addressee1.setName(QStringLiteral("John Sinclair"));
0309     addressee1.setFormattedName(QStringLiteral("Sinclair, John"));
0310     addressee1.setFamilyName(QStringLiteral("Sinclair"));
0311     addressee1.setGivenName(QStringLiteral("John"));
0312     addressee1.setAdditionalName(QStringLiteral("Bob"));
0313     addressee1.setPrefix(QStringLiteral("Sir"));
0314     addressee1.setSuffix(QStringLiteral("II"));
0315     addressee1.setNickName(QStringLiteral("ghosthunter"));
0316     addressee1.setBirthday(QDateTime(QDate(1982, 7, 19).startOfDay()));
0317     addressee1.setMailer(QStringLiteral("mutt"));
0318     addressee1.setTimeZone(KContacts::TimeZone(2));
0319     addressee1.setGeo(KContacts::Geo(42, 23));
0320     addressee1.setTitle(QStringLiteral("Ghost Hunter"));
0321     addressee1.setRole(QStringLiteral("Leader"));
0322     addressee1.setOrganization(QStringLiteral("Scottland Yard"));
0323     addressee1.setNote(QStringLiteral("Don't cross black deads way..."));
0324     addressee1.setProductId(QStringLiteral("ProductId45"));
0325     addressee1.setRevision(QDateTime(QDate(1982, 9, 15).startOfDay()));
0326     addressee1.setSortString(QStringLiteral("Name"));
0327     KContacts::ResourceLocatorUrl url;
0328     url.setUrl(QUrl(QStringLiteral("www.scottlandyard.info")));
0329 
0330     addressee1.setUrl(url);
0331     addressee1.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public));
0332     addressee1.setLogo(logo);
0333     addressee1.setPhoto(photo);
0334     addressee1.setSound(sound);
0335     addressee1.setEmails(emails);
0336     addressee1.setKeys(keys);
0337     addressee1.setCategories(categories);
0338     addressee1.setCustoms(customs);
0339     addressee1.setChanged(false);
0340 
0341     QByteArray data;
0342     QDataStream s(&data, QIODevice::WriteOnly);
0343     s << addressee1;
0344 
0345     QDataStream t(&data, QIODevice::ReadOnly);
0346     t >> addressee2;
0347 
0348     QVERIFY(addressee1 == addressee2);
0349 }
0350 
0351 void AddresseeTest::fullEmailTest()
0352 {
0353     KContacts::Addressee a;
0354     QStringList emails;
0355     emails << QStringLiteral("foo@bar.com");
0356     a.setEmails(emails);
0357     a.setFormattedName(QStringLiteral("firstname \"nickname\" lastname"));
0358     QCOMPARE(a.fullEmail(), QStringLiteral("\"firstname \\\"nickname\\\" lastname\" <foo@bar.com>"));
0359 }
0360 
0361 void AddresseeTest::nameFromStringTest()
0362 {
0363     KContacts::Addressee a;
0364     a.setNameFromString(QStringLiteral("Firstname Lastname"));
0365     QCOMPARE(a.givenName(), QStringLiteral("Firstname"));
0366     QCOMPARE(a.familyName(), QStringLiteral("Lastname"));
0367     QCOMPARE(a.formattedName(), QStringLiteral("Firstname Lastname"));
0368 }
0369 
0370 void AddresseeTest::customFieldsTest()
0371 {
0372     KContacts::Addressee a;
0373 
0374     // test for empty
0375     QVERIFY(a.customs().isEmpty());
0376 
0377     // test insert
0378     a.insertCustom(QStringLiteral("MyApp"), QStringLiteral("MyKey"), QStringLiteral("MyValue"));
0379     QCOMPARE(a.customs().count(), 1);
0380     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("MyValue"));
0381 
0382     a.insertCustom(QStringLiteral("MyApp"), QStringLiteral("MyKey"), QStringLiteral("YourValue"));
0383     QCOMPARE(a.customs().count(), 1); // still one, we overwrite...
0384     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("YourValue"));
0385 
0386     // test query non-existing app/key
0387     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("UnknownKey")), QString());
0388     QCOMPARE(a.custom(QStringLiteral("UnknownApp"), QStringLiteral("MyKey")), QString());
0389 
0390     // test insert with different key
0391     a.insertCustom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey"), QStringLiteral("OtherValue"));
0392     QCOMPARE(a.customs().count(), 2);
0393     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey")), QStringLiteral("OtherValue"));
0394     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("YourValue"));
0395 
0396     // test insert with different app
0397     a.insertCustom(QStringLiteral("OtherApp"), QStringLiteral("OtherKey"), QStringLiteral("OurValue"));
0398     QCOMPARE(a.customs().count(), 3);
0399     QCOMPARE(a.custom(QStringLiteral("OtherApp"), QStringLiteral("OtherKey")), QStringLiteral("OurValue"));
0400     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey")), QStringLiteral("OtherValue"));
0401     QCOMPARE(a.custom(QStringLiteral("MyApp"), QStringLiteral("MyKey")), QStringLiteral("YourValue"));
0402 
0403 #if 0 // Order is not defined now as we use a QHash
0404     // test customs
0405     QCOMPARE(a.customs().at(0), QStringLiteral("MyApp-MyKey:YourValue"));
0406     QCOMPARE(a.customs().at(1), QStringLiteral("MyApp-AnotherKey:OtherValue"));
0407     QCOMPARE(a.customs().at(2), QStringLiteral("OtherApp-OtherKey:OurValue"));
0408 #endif
0409     // test equal operator
0410     KContacts::Addressee b;
0411     b.setUid(a.uid());
0412     b.insertCustom(QStringLiteral("OtherApp"), QStringLiteral("OtherKey"), QStringLiteral("OurValue"));
0413     b.insertCustom(QStringLiteral("MyApp"), QStringLiteral("MyKey"), QStringLiteral("YourValue"));
0414     b.insertCustom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey"), QStringLiteral("OtherValue"));
0415 
0416     QCOMPARE(a, b);
0417 
0418     b.insertCustom(QStringLiteral("MyApp"), QStringLiteral("AnotherKey"), QStringLiteral("WrongValue"));
0419     QVERIFY(a != b);
0420 
0421     // test setCustoms
0422     KContacts::Addressee c;
0423     c.insertCustom(QStringLiteral("ThisApp"), QStringLiteral("ShouldNotBe"), QStringLiteral("There"));
0424     QCOMPARE(c.customs().count(), 1);
0425 
0426     const QStringList testData = QStringList() << QStringLiteral("FirstApp-FirstKey:FirstValue") //
0427                                                << QStringLiteral("SecondApp-SecondKey:SecondValue") //
0428                                                << QStringLiteral("ThirdApp-ThirdKey:ThirdValue");
0429 
0430     c.setCustoms(testData);
0431     QCOMPARE(c.customs().count(), 3);
0432 
0433     QCOMPARE(c.custom(QStringLiteral("FirstApp"), QStringLiteral("FirstKey")), QStringLiteral("FirstValue"));
0434     QCOMPARE(c.custom(QStringLiteral("SecondApp"), QStringLiteral("SecondKey")), QStringLiteral("SecondValue"));
0435     QCOMPARE(c.custom(QStringLiteral("ThirdApp"), QStringLiteral("ThirdKey")), QStringLiteral("ThirdValue"));
0436 
0437     // test remove
0438     QCOMPARE(c.customs().count(), 3);
0439     c.removeCustom(QStringLiteral("UnknownApp"), QStringLiteral("FirstKey"));
0440     QCOMPARE(c.customs().count(), 3);
0441     c.removeCustom(QStringLiteral("FirstApp"), QStringLiteral("UnknownKey"));
0442     QCOMPARE(c.customs().count(), 3);
0443     c.removeCustom(QStringLiteral("FirstApp"), QStringLiteral("FirstKey"));
0444     QCOMPARE(c.customs().count(), 2);
0445 }
0446 
0447 void AddresseeTest::parseEmailAddress_data()
0448 {
0449     QTest::addColumn<QString>("inputEmail");
0450     QTest::addColumn<QString>("email");
0451     QTest::addColumn<QString>("name");
0452     QTest::newRow("simpleemail") << QStringLiteral("foo@kde.org") << QStringLiteral("foo@kde.org") << QString();
0453     QTest::newRow("email") << QStringLiteral("foo <foo@kde.org>") << QStringLiteral("foo@kde.org") << QStringLiteral("foo");
0454     QTest::newRow("namewithdoublequote") << QStringLiteral("\"foo\" <foo@kde.org>") << QStringLiteral("foo@kde.org") << QStringLiteral("foo");
0455 }
0456 
0457 void AddresseeTest::parseEmailAddress()
0458 {
0459     QFETCH(QString, inputEmail);
0460     QFETCH(QString, email);
0461     QFETCH(QString, name);
0462 
0463     QString parsedName;
0464     QString parsedEmail;
0465     KContacts::Addressee::parseEmailAddress(inputEmail, parsedName, parsedEmail);
0466     QCOMPARE(parsedEmail, email);
0467     QCOMPARE(parsedName, name);
0468 }
0469 
0470 #include "moc_addresseetest.cpp"