Commit ad8892fd authored by Laurent Montel's avatar Laurent Montel 😁

Add autotests for vcardline support. Test group support

CCBUG: 365192
parent 91751093
......@@ -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)
/*
This file is part of the KContacts framework.
Copyright (c) 2016 Laurent Montel <montel@kde.org>
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)
/*
This file is part of the KContacts framework.
Copyright (c) 2016 Laurent Montel <montel@kde.org>
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
......@@ -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;
......
......@@ -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 ]));
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment