File indexing completed on 2024-11-10 04:40:16
0001 /* 0002 SPDX-FileCopyrightText: 2011 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "aktest.h" 0008 #include "private/standarddirs_p.h" 0009 0010 #include <QObject> 0011 #include <QTest> 0012 0013 using namespace Akonadi; 0014 0015 class AkStandardDirsTest : public QObject 0016 { 0017 Q_OBJECT 0018 private Q_SLOTS: 0019 void testCondigFile() 0020 { 0021 akTestSetInstanceIdentifier(QString()); 0022 QVERIFY(StandardDirs::agentsConfigFile(StandardDirs::ReadOnly).endsWith(QStringLiteral("agentsrc"))); 0023 QVERIFY(StandardDirs::agentsConfigFile(StandardDirs::ReadWrite).endsWith(QStringLiteral("agentsrc"))); 0024 QVERIFY(!StandardDirs::agentsConfigFile(StandardDirs::ReadWrite).endsWith(QStringLiteral("foo/agentsrc"))); 0025 0026 akTestSetInstanceIdentifier(QStringLiteral("foo")); 0027 QVERIFY(StandardDirs::agentsConfigFile(StandardDirs::ReadOnly).endsWith(QStringLiteral("agentsrc"))); 0028 QVERIFY(StandardDirs::agentsConfigFile(StandardDirs::ReadWrite).endsWith(QStringLiteral("instance/foo/agentsrc"))); 0029 } 0030 0031 void testSaveDir() 0032 { 0033 akTestSetInstanceIdentifier(QString()); 0034 #ifdef Q_OS_WIN // See buildFullRelPath() in standarddirs.cpp 0035 QVERIFY(StandardDirs::saveDir("data").endsWith(QStringLiteral("/akonadi/data"))); 0036 #else 0037 QVERIFY(StandardDirs::saveDir("data").endsWith(QStringLiteral("/akonadi"))); 0038 #endif 0039 QVERIFY(!StandardDirs::saveDir("data").endsWith(QStringLiteral("foo/akonadi"))); 0040 0041 akTestSetInstanceIdentifier(QStringLiteral("foo")); 0042 #ifdef Q_OS_WIN // See buildFullRelPath() in standarddirs.cpp 0043 QVERIFY(StandardDirs::saveDir("data").endsWith(QStringLiteral("/akonadi/data/instance/foo"))); 0044 #else 0045 QVERIFY(StandardDirs::saveDir("data").endsWith(QStringLiteral("/akonadi/instance/foo"))); 0046 #endif 0047 } 0048 }; 0049 0050 AKTEST_MAIN(AkStandardDirsTest) 0051 0052 #include "akstandarddirstest.moc"