File indexing completed on 2024-11-10 04:40:09
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Daniel Vrátil <dvratil@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 * 0006 */ 0007 0008 #include "collectioncreatejob.h" 0009 #include "collectiondeletejob.h" 0010 #include "collectionfetchjob.h" 0011 #include "entitydisplayattribute.h" 0012 #include "qtest_akonadi.h" 0013 0014 using namespace Akonadi; 0015 0016 class CollectionCreateTest : public QObject 0017 { 0018 Q_OBJECT 0019 0020 private Q_SLOTS: 0021 void initTestCase() 0022 { 0023 AkonadiTest::checkTestIsIsolated(); 0024 } 0025 0026 void testCreateCollection() 0027 { 0028 auto monitor = AkonadiTest::getTestMonitor(); 0029 QSignalSpy spy(monitor.get(), &Monitor::collectionAdded); 0030 0031 Collection col; 0032 col.setName(QLatin1StringView("test_collection")); 0033 col.setContentMimeTypes({Collection::mimeType()}); 0034 col.setParentCollection(Collection(AkonadiTest::collectionIdFromPath(QLatin1StringView("res1")))); 0035 col.setRights(Collection::AllRights); 0036 0037 auto cj = new CollectionCreateJob(col, this); 0038 AKVERIFYEXEC(cj); 0039 col = cj->collection(); 0040 QVERIFY(col.isValid()); 0041 0042 QTRY_COMPARE(spy.count(), 1); 0043 auto ntfCol = spy.at(0).at(0).value<Collection>(); 0044 QCOMPARE(col, ntfCol); 0045 0046 auto dj = new CollectionDeleteJob(col, this); 0047 AKVERIFYEXEC(dj); 0048 } 0049 }; 0050 0051 QTEST_AKONADIMAIN(CollectionCreateTest) 0052 0053 #include "collectioncreatetest.moc"