File indexing completed on 2024-12-01 04:35:22
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "bannerinfostest.h" 0008 #include "bannerinfo/bannerinfos.h" 0009 #include "ruqola_autotest_helper.h" 0010 0011 QTEST_GUILESS_MAIN(BannerInfosTest) 0012 BannerInfosTest::BannerInfosTest(QObject *parent) 0013 : QObject{parent} 0014 { 0015 } 0016 0017 void BannerInfosTest::shouldHaveDefaultValues() 0018 { 0019 BannerInfos w; 0020 QVERIFY(w.isEmpty()); 0021 QCOMPARE(w.count(), 0); 0022 QVERIFY(w.bannerUnreadInformations().isEmpty()); 0023 } 0024 0025 void BannerInfosTest::shouldLoadBannerInfos_data() 0026 { 0027 QTest::addColumn<QString>("name"); 0028 QTest::addColumn<int>("bannersCount"); 0029 QTest::addColumn<bool>("hasUnreadBanner"); 0030 0031 QTest::addRow("bannerinfos-empty") << QStringLiteral("bannerinfos-empty") << 0 << false; 0032 QTest::addRow("bannerinfos1") << QStringLiteral("bannerinfos1") << 3 << false; 0033 QTest::addRow("bannerinfos2") << QStringLiteral("bannerinfos2") << 3 << true; 0034 QTest::addRow("bannerinfos3") << QStringLiteral("bannerinfos3") << 3 << true; 0035 } 0036 0037 void BannerInfosTest::shouldLoadBannerInfos() 0038 { 0039 QFETCH(QString, name); 0040 QFETCH(int, bannersCount); 0041 QFETCH(bool, hasUnreadBanner); 0042 const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QLatin1String("/bannerinfos/") + name + QLatin1String(".json"); 0043 const QJsonObject obj = AutoTestHelper::loadJsonObject(originalJsonFile); 0044 0045 BannerInfos r; 0046 r.parseBannerInfos(obj); 0047 QCOMPARE(r.count(), bannersCount); 0048 QCOMPARE(r.bannerUnreadInformations().isEmpty(), !hasUnreadBanner); 0049 } 0050 0051 #include "moc_bannerinfostest.cpp"