Warning, file /frameworks/kcontacts/autotests/vcardtool_benchmark.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KContacts framework. 0003 SPDX-FileCopyrightText: 2016 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "vcardtool_benchmark.h" 0009 #include "title.h" 0010 #include "vcardtool_p.h" 0011 #include <QTest> 0012 0013 PerformanceTest::PerformanceTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 PerformanceTest::~PerformanceTest() 0019 { 0020 } 0021 0022 void PerformanceTest::testParserPerformance() 0023 { 0024 QByteArray vcarddata( 0025 "BEGIN:VCARD\n" 0026 "VERSION:3.0\n" 0027 "N:LastName;FirstName;;;\n" 0028 "UID:c80cf296-0825-4eb0-ab16-1fac1d522a33@xxxxxx.xx\n" 0029 "Title:boo\n" 0030 "REV:2015-03-14T09:24:45+00:00\n" 0031 "FN:FirstName LastName\n" 0032 "END:VCARD\n"); 0033 0034 QBENCHMARK { 0035 KContacts::VCardTool vcard; 0036 const KContacts::AddresseeList lst = vcard.parseVCards(vcarddata); 0037 QCOMPARE(lst.count(), 1); 0038 } 0039 } 0040 0041 void PerformanceTest::testExportPerformance() 0042 { 0043 KContacts::AddresseeList lst; 0044 KContacts::Addressee addr; 0045 addr.setEmails(QStringList() << QStringLiteral("foo@kde.org")); 0046 addr.setUid(QStringLiteral("testuid")); 0047 KContacts::Title::List lstTitle; 0048 KContacts::Title title(QStringLiteral("fr")); 0049 lstTitle << title; 0050 addr.setExtraTitleList(lstTitle); 0051 lst << addr; 0052 QByteArray expected( 0053 "BEGIN:VCARD\r\n" 0054 "VERSION:4.0\r\n" 0055 "EMAIL:foo@kde.org\r\n" 0056 "N:;;;;\r\n" 0057 "TITLE:fr\r\n" 0058 "UID:testuid\r\n" 0059 "END:VCARD\r\n\r\n"); 0060 QBENCHMARK { 0061 KContacts::VCardTool vcard; 0062 const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0); 0063 QCOMPARE(ba, expected); 0064 } 0065 } 0066 0067 QTEST_GUILESS_MAIN(PerformanceTest)