File indexing completed on 2024-12-01 04:35:24
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "manageloadhistoryparsesyncmessagesutilstest.h" 0008 #include "manageloadhistoryparsesyncmessagesutils.h" 0009 #include "ruqola_autotest_helper.h" 0010 0011 QTEST_MAIN(ManageLoadHistoryParseSyncMessagesUtilsTest) 0012 ManageLoadHistoryParseSyncMessagesUtilsTest::ManageLoadHistoryParseSyncMessagesUtilsTest(QObject *parent) 0013 : QObject{parent} 0014 { 0015 } 0016 0017 void ManageLoadHistoryParseSyncMessagesUtilsTest::shouldHaveDefaultValues() 0018 { 0019 ManageLoadHistoryParseSyncMessagesUtils w(nullptr); 0020 QVERIFY(w.deletedMessages().isEmpty()); 0021 QVERIFY(w.updatesMessages().isEmpty()); 0022 } 0023 0024 void ManageLoadHistoryParseSyncMessagesUtilsTest::shouldParseSyncMessages_data() 0025 { 0026 QTest::addColumn<QString>("name"); 0027 QTest::addColumn<int>("deleted"); 0028 QTest::addColumn<int>("update"); 0029 0030 QTest::addRow("empty") << QStringLiteral("empty.json") << 0 << 0; 0031 QTest::addRow("test1") << QStringLiteral("test1.json") << 1 << 0; 0032 QTest::addRow("test2") << QStringLiteral("test2.json") << 1 << 2; 0033 } 0034 0035 void ManageLoadHistoryParseSyncMessagesUtilsTest::shouldParseSyncMessages() 0036 { 0037 QFETCH(QString, name); 0038 QFETCH(int, deleted); 0039 QFETCH(int, update); 0040 0041 const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QLatin1String("/syncmessages/%1").arg(name); 0042 const QJsonObject obj = AutoTestHelper::loadJsonObject(originalJsonFile); 0043 0044 ManageLoadHistoryParseSyncMessagesUtils w(nullptr); 0045 w.parse(obj); 0046 QCOMPARE(w.deletedMessages().count(), deleted); 0047 QCOMPARE(w.updatesMessages().count(), update); 0048 } 0049 0050 #include "moc_manageloadhistoryparsesyncmessagesutilstest.cpp"