aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-07-08 08:56:04 +0200
committerMontel Laurent <[email protected]>2016-07-08 08:56:04 +0200
commitad8892fd98a401ffe9a6aafc3bc0a109da22c7b8 (patch)
tree741a84886eff6f339acce150aebaa77f5793af6b
parent91751093eb6bf584a17f0be5873d60a7813dd80d (diff)
Add autotests for vcardline support. Test group support
-rw-r--r--autotests/CMakeLists.txt1
-rw-r--r--autotests/vcardlinetest.cpp36
-rw-r--r--autotests/vcardlinetest.h35
-rw-r--r--src/vcardparser/vcardline.h4
-rw-r--r--src/vcardparser/vcardparser.cpp1
-rw-r--r--src/vcardtool.cpp5
6 files changed, 81 insertions, 1 deletions
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index 363ba5a..c0c3775 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -31,5 +31,6 @@ ecm_add_tests(birthdaytest.cpp
relatedtest.cpp
resourcelocatorurltest.cpp
customidentifiertest.cpp
+ vcardlinetest.cpp
NAME_PREFIX "kcontacts-" LINK_LIBRARIES KF5Contacts Qt5::Test KF5::ConfigCore Qt5::Gui)
diff --git a/autotests/vcardlinetest.cpp b/autotests/vcardlinetest.cpp
new file mode 100644
index 0000000..7303610
--- /dev/null
+++ b/autotests/vcardlinetest.cpp
@@ -0,0 +1,36 @@
+/*
+ This file is part of the KContacts framework.
+ Copyright (c) 2016 Laurent Montel <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "vcardlinetest.h"
+
+#include <QTest>
+
+VCardLineTest::VCardLineTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+VCardLineTest::~VCardLineTest()
+{
+
+}
+
+QTEST_MAIN(VCardLineTest)
diff --git a/autotests/vcardlinetest.h b/autotests/vcardlinetest.h
new file mode 100644
index 0000000..0d10f0e
--- /dev/null
+++ b/autotests/vcardlinetest.h
@@ -0,0 +1,35 @@
+/*
+ This file is part of the KContacts framework.
+ Copyright (c) 2016 Laurent Montel <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#ifndef VCARDLINETEST_H
+#define VCARDLINETEST_H
+
+#include <QObject>
+
+class VCardLineTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit VCardLineTest(QObject *parent = Q_NULLPTR);
+ ~VCardLineTest();
+};
+
+#endif // VCARDLINETEST_H
diff --git a/src/vcardparser/vcardline.h b/src/vcardparser/vcardline.h
index a50287d..79403f7 100644
--- a/src/vcardparser/vcardline.h
+++ b/src/vcardparser/vcardline.h
@@ -26,10 +26,12 @@
#include <QtCore/QStringList>
#include <QtCore/QVariant>
+#include "kcontacts_export.h"
+
namespace KContacts
{
-class VCardLine
+class KCONTACTS_EXPORT VCardLine
{
public:
typedef QVector<VCardLine> List;
diff --git a/src/vcardparser/vcardparser.cpp b/src/vcardparser/vcardparser.cpp
index 894d713..a263813 100644
--- a/src/vcardparser/vcardparser.cpp
+++ b/src/vcardparser/vcardparser.cpp
@@ -124,6 +124,7 @@ VCard::List VCardParser::parseVCards(const QByteArray &text)
if (groupPos != -1) {
vCardLine.setGroup(cache.fromLatin1(params[ 0 ].left(groupPos)));
vCardLine.setIdentifier(cache.fromLatin1(params[ 0 ].mid(groupPos + 1)));
+ qDebug()<<" group !!!!!!!!!!" << vCardLine.group();
} else {
vCardLine.setIdentifier(cache.fromLatin1(params[ 0 ]));
}
diff --git a/src/vcardtool.cpp b/src/vcardtool.cpp
index fd254f1..7ce8ae9 100644
--- a/src/vcardtool.cpp
+++ b/src/vcardtool.cpp
@@ -632,6 +632,7 @@ Addressee::List VCardTool::parseVCards(const QByteArray &vcard) const
static const QLatin1Char semicolonSep(';');
static const QLatin1Char commaSep(',');
QString identifier;
+ QString group;
Addressee::List addrList;
const VCard::List vCardList = VCardParser::parseVCards(vcard);
@@ -651,6 +652,10 @@ Addressee::List VCardTool::parseVCards(const QByteArray &vcard) const
// iterate over the lines
for (lineIt = lines.begin(); lineIt != lines.end(); ++lineIt) {
identifier = (*lineIt).identifier().toLower();
+ group = (*lineIt).group();
+ if (!group.isEmpty()) {
+ qDebug() << "group not empty "<< (*lineIt).value().toString();
+ }
// ADR
if (identifier == QLatin1String("adr")) {
Address address;