File indexing completed on 2024-12-01 04:35:22

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "channelcounterinfotest.h"
0008 #include "channelcounterinfo.h"
0009 #include "ruqola_autotest_helper.h"
0010 
0011 QTEST_GUILESS_MAIN(ChannelCounterInfoTest)
0012 ChannelCounterInfoTest::ChannelCounterInfoTest(QObject *parent)
0013     : QObject(parent)
0014 {
0015 }
0016 
0017 void ChannelCounterInfoTest::shouldHaveDefaultValues()
0018 {
0019     ChannelCounterInfo info;
0020     QCOMPARE(info.unreadMessages(), 0);
0021     QCOMPARE(info.messageCount(), 0);
0022     QVERIFY(!info.joined());
0023     QVERIFY(!info.isValid());
0024 }
0025 
0026 void ChannelCounterInfoTest::shouldLoadChannelCounter_data()
0027 {
0028     QTest::addColumn<QString>("name");
0029     QTest::addColumn<ChannelCounterInfo>("channelcounter");
0030     ChannelCounterInfo result;
0031     result.setMessageCount(48013);
0032     result.setUnreadMessages(0);
0033     result.setJoined(true);
0034     QDateTime t;
0035     t.setTimeSpec(Qt::LocalTime);
0036     t.setDate(QDate(2020, 9, 25));
0037     t.setTime(QTime(13, 36, 30, 262));
0038     result.setUnreadFrom(t);
0039 
0040     // TODO
0041     QTest::addRow("test1") << QStringLiteral("test1") << result;
0042 }
0043 
0044 void ChannelCounterInfoTest::shouldLoadChannelCounter()
0045 {
0046     QFETCH(QString, name);
0047     QFETCH(ChannelCounterInfo, channelcounter);
0048     const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QLatin1String("/channelcounter/") + name + QLatin1String(".json");
0049     const QJsonObject obj = AutoTestHelper::loadJsonObject(originalJsonFile);
0050 
0051     ChannelCounterInfo r;
0052     r.parseCounterInfo(obj);
0053     const bool equalOwner = (r == channelcounter);
0054     if (!equalOwner) {
0055         qDebug() << "ACTUAL " << r;
0056         qDebug() << "EXPECTED " << channelcounter;
0057     }
0058     QVERIFY(equalOwner);
0059 }
0060 
0061 #include "moc_channelcounterinfotest.cpp"