File indexing completed on 2024-12-01 04:35:24
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "fileattachmentstest.h" 0008 #include "attachments/fileattachments.h" 0009 #include <QTest> 0010 QTEST_GUILESS_MAIN(FileAttachmentsTest) 0011 FileAttachmentsTest::FileAttachmentsTest(QObject *parent) 0012 : QObject(parent) 0013 { 0014 } 0015 0016 void FileAttachmentsTest::shouldHaveDefaultValues() 0017 { 0018 FileAttachments w; 0019 QVERIFY(w.isEmpty()); 0020 QCOMPARE(w.offset(), 0); 0021 QCOMPARE(w.total(), 0); 0022 QCOMPARE(w.filesCount(), 0); 0023 } 0024 0025 // TODO implement it 0026 #if 0 0027 void FileAttachmentsTest::shouldLoadThreads_data() 0028 { 0029 QTest::addColumn<QString>("name"); 0030 QTest::addColumn<int>("threadsCount"); 0031 QTest::addColumn<int>("total"); 0032 QTest::addColumn<int>("offset"); 0033 0034 QTest::addRow("empty") << QStringLiteral("threads-empty") << 0 << 0 << 0; 0035 } 0036 0037 void FileAttachmentsTest::shouldLoadThreads() 0038 { 0039 QFETCH(QString, name); 0040 QFETCH(int, threadsCount); 0041 QFETCH(int, total); 0042 QFETCH(int, offset); 0043 const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QLatin1String("/threads/") + name + QLatin1String(".json"); 0044 QFile f(originalJsonFile); 0045 QVERIFY(f.open(QIODevice::ReadOnly)); 0046 const QByteArray content = f.readAll(); 0047 f.close(); 0048 const QJsonDocument doc = QJsonDocument::fromJson(content); 0049 const QJsonObject obj = doc.object(); 0050 0051 Threads m; 0052 m.parseThreads(obj); 0053 QCOMPARE(m.threadsCount(), threadsCount); 0054 QCOMPARE(m.total(), total); 0055 QCOMPARE(m.offset(), offset); 0056 } 0057 0058 #endif 0059 0060 #include "moc_fileattachmentstest.cpp"