File indexing completed on 2025-01-05 04:47:12

0001 /*
0002     SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "xmldocument.h"
0008 
0009 #include <QObject>
0010 
0011 #include <QTest>
0012 
0013 using namespace Akonadi;
0014 
0015 class XmlDocumentTest : public QObject
0016 {
0017     Q_OBJECT
0018 private Q_SLOTS:
0019     void testDocumentLoad()
0020     {
0021         XmlDocument doc(QFINDTESTDATA("knutdemo.xml"), QFINDTESTDATA("../akonadi-xml.xsd"));
0022         QVERIFY(doc.isValid());
0023         QVERIFY(doc.lastError().isEmpty());
0024         QCOMPARE(doc.collections().count(), 9);
0025 
0026         Collection col = doc.collectionByRemoteId(QStringLiteral("c11"));
0027         QCOMPARE(col.name(), QStringLiteral("Inbox"));
0028         QCOMPARE(col.attributes().count(), 1);
0029         QCOMPARE(col.parentCollection().remoteId(), QStringLiteral("c1"));
0030 
0031         QCOMPARE(doc.childCollections(col).count(), 2);
0032 
0033         Item item = doc.itemByRemoteId(QStringLiteral("contact1"));
0034         QCOMPARE(item.mimeType(), QStringLiteral("text/directory"));
0035         QVERIFY(item.hasPayload());
0036 
0037         Item::List items = doc.items(col);
0038         QCOMPARE(items.count(), 1);
0039         item = items.first();
0040         QVERIFY(item.hasPayload());
0041         QCOMPARE(item.flags().count(), 1);
0042         QVERIFY(item.hasFlag("\\SEEN"));
0043     }
0044 };
0045 
0046 QTEST_MAIN(XmlDocumentTest)
0047 
0048 #include "xmldocumenttest.moc"