File indexing completed on 2024-12-22 04:57:38
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 0003 SPDX-FileContributor: Kevin Krammer <krake@kdab.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include "testdatautil.h" 0009 0010 #include <QTemporaryDir> 0011 0012 #include <QDir> 0013 #include <QTest> 0014 0015 class TestDataTest : public QObject 0016 { 0017 Q_OBJECT 0018 public: 0019 TestDataTest() = default; 0020 0021 private Q_SLOTS: 0022 void testResources(); 0023 void testInstall(); 0024 }; 0025 0026 void TestDataTest::testResources() 0027 { 0028 const QStringList testDataNames = TestDataUtil::testDataNames(); 0029 QCOMPARE(testDataNames, 0030 QStringList() << QStringLiteral("dimap") << QStringLiteral("maildir") << QStringLiteral("maildir-tagged") << QStringLiteral("mbox") 0031 << QStringLiteral("mbox-tagged") << QStringLiteral("mbox-unpurged")); 0032 0033 for (const QString &testDataName : testDataNames) { 0034 if (testDataName.startsWith(QLatin1StringView("mbox"))) { 0035 QVERIFY(TestDataUtil::folderType(testDataName) == TestDataUtil::MBoxFolder); 0036 } else { 0037 QVERIFY(TestDataUtil::folderType(testDataName) == TestDataUtil::MaildirFolder); 0038 } 0039 } 0040 0041 // TODO check contents? 0042 } 0043 0044 void TestDataTest::testInstall() 0045 { 0046 QTemporaryDir dir; 0047 QDir installDir(dir.path()); 0048 QDir curDir; 0049 0050 const QString indexFilePattern = QStringLiteral(".%1.index"); 0051 0052 QVERIFY(TestDataUtil::installFolder(QLatin1StringView("mbox"), dir.path(), QStringLiteral("mbox1"))); 0053 QVERIFY(installDir.exists(QLatin1StringView("mbox1"))); 0054 QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1StringView("mbox1")))); 0055 0056 QVERIFY(TestDataUtil::installFolder(QLatin1StringView("mbox-tagged"), dir.path(), QStringLiteral("mbox2"))); 0057 QVERIFY(installDir.exists(QLatin1StringView("mbox2"))); 0058 QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1StringView("mbox2")))); 0059 0060 QVERIFY(TestDataUtil::installFolder(QLatin1StringView("maildir"), dir.path(), QStringLiteral("md1"))); 0061 QVERIFY(installDir.exists(QLatin1StringView("md1"))); 0062 QVERIFY(installDir.exists(QLatin1StringView("md1/new"))); 0063 QVERIFY(installDir.exists(QLatin1StringView("md1/cur"))); 0064 QVERIFY(installDir.exists(QLatin1StringView("md1/tmp"))); 0065 QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1StringView("md1")))); 0066 0067 curDir = installDir; 0068 curDir.cd(QStringLiteral("md1")); 0069 curDir.cd(QStringLiteral("cur")); 0070 curDir.setFilter(QDir::Files); 0071 QCOMPARE((int)curDir.count(), 4); 0072 0073 QVERIFY(TestDataUtil::installFolder(QLatin1StringView("maildir-tagged"), dir.path(), QStringLiteral("md2"))); 0074 QVERIFY(installDir.exists(QLatin1StringView("md2"))); 0075 QVERIFY(installDir.exists(QLatin1StringView("md2/new"))); 0076 QVERIFY(installDir.exists(QLatin1StringView("md2/cur"))); 0077 QVERIFY(installDir.exists(QLatin1StringView("md2/tmp"))); 0078 QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1StringView("md2")))); 0079 0080 curDir = installDir; 0081 curDir.cd(QStringLiteral("md2")); 0082 curDir.cd(QStringLiteral("cur")); 0083 curDir.setFilter(QDir::Files); 0084 QCOMPARE((int)curDir.count(), 4); 0085 } 0086 0087 #include "testdatatest.moc" 0088 0089 QTEST_MAIN(TestDataTest)