[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kcontacts] /: Backport unit test + export multi emails
From: Montel Laurent <montel () kde ! org>
Date: 2015-03-31 21:00:18
Message-ID: E1Yd3Gk-00045W-Gu () scm ! kde ! org
[Download RAW message or body]
Git commit fcb434de7c855731ee9a9ec8091e9687d64a80a4 by Montel Laurent.
Committed on 31/03/2015 at 20:59.
Pushed by mlaurent into branch 'master'.
Backport unit test + export multi emails
M +50 -0 autotests/ldifconvertertest.cpp
M +2 -0 autotests/ldifconvertertest.h
M +10 -3 src/converter/ldifconverter.cpp
http://commits.kde.org/kcontacts/fcb434de7c855731ee9a9ec8091e9687d64a80a4
diff --git a/autotests/ldifconvertertest.cpp b/autotests/ldifconvertertest.cpp
index ceb420b..6fb135e 100644
--- a/autotests/ldifconvertertest.cpp
+++ b/autotests/ldifconvertertest.cpp
@@ -120,6 +120,31 @@ void LDifConverterTest::shouldImportTheBatsBirthday()
QCOMPARE(contactGroup.count(), 0);
}
+void LDifConverterTest::shouldImportTheBatsEmails()
+{
+ QString str = QLatin1String("dn: cn=laurent,mail=foo@kde.org\n"
+ "sn: laurent\n"
+ "cn: laurent\n"
+ "uid: d1d5cdd4-7d5d-484b-828d-58864d8efe74\n"
+ "mail: foo@kde.org\n"
+ "othermailbox: foo2@kde.org\n"
+ "othermailbox: foo3@kde.org\n"
+ "objectclass: top_n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson");
+ AddresseeList lst;
+ ContactGroup::List contactGroup;
+ bool result = LDIFConverter::LDIFToAddressee(str, lst, contactGroup);
+ QVERIFY(result);
+ QCOMPARE(lst.count(), 1);
+ QCOMPARE(lst.at(0).emails().count(), 3);
+ QCOMPARE(lst.at(0).emails().at(0), QLatin1String("foo@kde.org"));
+ QCOMPARE(lst.at(0).emails().at(1), QLatin1String("foo2@kde.org"));
+ QCOMPARE(lst.at(0).emails().at(2), QLatin1String("foo3@kde.org"));
+ QCOMPARE(contactGroup.count(), 0);
+}
+
+
void LDifConverterTest::shouldImportTitle()
{
QString str = QLatin1String("dn: cn=laurent,mail=foo@kde.org\n"
@@ -267,6 +292,31 @@ void LDifConverterTest::shouldExportEmail()
QCOMPARE(str, expected);
}
+void LDifConverterTest::shouldExportMultiEmails()
+{
+ AddresseeList lst;
+ ContactGroup::List contactGroup;
+ Addressee addr;
+ addr.setEmails(QStringList() << QLatin1String("foo@kde.org") << \
QLatin1String("foo2@kde.org") << QLatin1String("foo3@kde.org")); + \
addr.setUid(QLatin1String("testuid")); + lst << addr;
+ QString str;
+ bool result = LDIFConverter::addresseeAndContactGroupToLDIF(lst, contactGroup, \
str); + QVERIFY(result);
+ QString expected = QLatin1String("dn: cn=,mail=foo@kde.org\n"
+ "objectclass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "uid: testuid\n"
+ "mail: foo@kde.org\n"
+ "mozillasecondemail: foo2@kde.org\n"
+ "othermailbox: foo3@kde.org\n"
+ "\n");
+
+ QCOMPARE(str, expected);
+
+}
+
void LDifConverterTest::shouldExportBirthday()
{
AddresseeList lst;
diff --git a/autotests/ldifconvertertest.h b/autotests/ldifconvertertest.h
index 10c3422..5739b03 100644
--- a/autotests/ldifconvertertest.h
+++ b/autotests/ldifconvertertest.h
@@ -36,6 +36,7 @@ private Q_SLOTS:
void shouldImportMultiEmails();
void shouldImportStandardBirthday();
void shouldImportTheBatsBirthday();
+ void shouldImportTheBatsEmails();
void shouldImportTitle();
void shouldImportWorkStreet();
void shouldImportContactGroup();
@@ -49,6 +50,7 @@ private Q_SLOTS:
void shouldExportMultiEntries();
void shouldExportGroup();
void shouldExportWorkStreet();
+ void shouldExportMultiEmails();
};
#endif // LDIFCONVERTERTEST_H
diff --git a/src/converter/ldifconverter.cpp b/src/converter/ldifconverter.cpp
index 5fa6734..d5565f3 100644
--- a/src/converter/ldifconverter.cpp
+++ b/src/converter/ldifconverter.cpp
@@ -162,11 +162,18 @@ bool LDIFConverter::addresseeToLDIF(const Addressee &addr, \
QString &str) ldif_out(t, QLatin1String("xmozillanickname"), addr.nickName());
ldif_out(t, QLatin1String("mozillanickname"), addr.nickName());
+
ldif_out(t, QLatin1String("mail"), addr.preferredEmail());
- if (addr.emails().count() > 1) {
- ldif_out(t, QLatin1String("mozillasecondemail"), addr.emails().at(1));
+ for (int i = 1; i < addr.emails().count(); ++i) {
+ if (i == 0) {
+ //nothing
+ } else if (i == 1) {
+ ldif_out( t, QLatin1String( "mozillasecondemail" ), addr.emails()[ 1 ] \
); + } else {
+ ldif_out( t, QLatin1String( "othermailbox" ), addr.emails()[ i ] );
+ }
}
-//ldif_out( t, "mozilla_AIMScreenName: %1\n", "screen_name" );
+ //ldif_out( t, "mozilla_AIMScreenName: %1\n", "screen_name" );
ldif_out(t, QLatin1String("telephonenumber"),
addr.phoneNumber(PhoneNumber::Work).number());
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic