File indexing completed on 2024-11-10 04:40:10
0001 /* 0002 SPDX-FileCopyrightText: 2009 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "entitydisplayattribute.h" 0008 0009 #include <QObject> 0010 0011 #include <QTest> 0012 0013 using namespace Akonadi; 0014 0015 class EntityDisplayAttributeTest : public QObject 0016 { 0017 Q_OBJECT 0018 private Q_SLOTS: 0019 void testDeserialize_data() 0020 { 0021 QTest::addColumn<QByteArray>("input"); 0022 QTest::addColumn<QString>("name"); 0023 QTest::addColumn<QString>("icon"); 0024 QTest::addColumn<QString>("activeIcon"); 0025 QTest::addColumn<QByteArray>("output"); 0026 0027 QTest::newRow("empty") << QByteArray(R"(("" ""))") << QString() << QString() << QString() << QByteArray(R"(("" "" "" ()))"); 0028 QTest::newRow("name+icon") << QByteArray(R"(("name" "icon"))") << QStringLiteral("name") << QStringLiteral("icon") << QString() 0029 << QByteArray(R"(("name" "icon" "" ()))"); 0030 QTest::newRow("name+icon+activeIcon") << QByteArray(R"(("name" "icon" "activeIcon"))") << QStringLiteral("name") << QStringLiteral("icon") 0031 << QStringLiteral("activeIcon") << QByteArray(R"(("name" "icon" "activeIcon" ()))"); 0032 } 0033 0034 void testDeserialize() 0035 { 0036 QFETCH(QByteArray, input); 0037 QFETCH(QString, name); 0038 QFETCH(QString, icon); 0039 QFETCH(QString, activeIcon); 0040 QFETCH(QByteArray, output); 0041 0042 auto attr = new EntityDisplayAttribute(); 0043 attr->deserialize(input); 0044 QCOMPARE(attr->displayName(), name); 0045 QCOMPARE(attr->iconName(), icon); 0046 QCOMPARE(attr->activeIconName(), activeIcon); 0047 0048 QCOMPARE(attr->serialized(), output); 0049 0050 EntityDisplayAttribute *copy = attr->clone(); 0051 QCOMPARE(copy->serialized(), output); 0052 0053 delete attr; 0054 delete copy; 0055 } 0056 }; 0057 0058 QTEST_MAIN(EntityDisplayAttributeTest) 0059 0060 #include "entitydisplayattributetest.moc"