Warning, file /frameworks/kio/autotests/kdirlistertest.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 #ifndef KDIRLISTERTEST_H 0008 #define KDIRLISTERTEST_H 0009 0010 #include <QDate> 0011 #include <QEventLoop> 0012 #include <QObject> 0013 #include <QSignalSpy> 0014 #include <QTemporaryDir> 0015 #include <kdirlister.h> 0016 0017 #include <memory> 0018 0019 Q_DECLARE_METATYPE(KFileItemList) 0020 0021 class GlobalInits 0022 { 0023 public: 0024 GlobalInits(); 0025 }; 0026 0027 class MyDirLister : public KDirLister, GlobalInits 0028 { 0029 public: 0030 MyDirLister() 0031 : spyStarted(this, &KCoreDirLister::started) 0032 , spyItemsDeleted(this, &KCoreDirLister::itemsDeleted) 0033 , spyClear(this, qOverload<>(&KCoreDirLister::clear)) 0034 , spyClearDir(this, &KCoreDirLister::clearDir) 0035 , spyCompleted(this, qOverload<>(&KCoreDirLister::completed)) 0036 , spyCanceled(this, qOverload<>(&KCoreDirLister::canceled)) 0037 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 79) 0038 , spyClearQUrl(this, qOverload<const QUrl &>(&KCoreDirLister::clear)) 0039 , spyCompletedQUrl(this, qOverload<const QUrl &>(&KCoreDirLister::completed)) 0040 , spyCanceledQUrl(this, qOverload<const QUrl &>(&KCoreDirLister::canceled)) 0041 #else 0042 , spyCompletedQUrl(this, &KCoreDirLister::listingDirCompleted) 0043 , spyCanceledQUrl(this, &KCoreDirLister::listingDirCanceled) 0044 #endif 0045 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 80) 0046 , spyRedirection(this, qOverload<const QUrl &>(&KCoreDirLister::redirection)) 0047 #else 0048 , spyRedirection(this, qOverload<const QUrl &, const QUrl &>(&KCoreDirLister::redirection)) 0049 #endif 0050 , spyJobError(this, &KCoreDirLister::jobError) 0051 { 0052 } 0053 0054 void clearSpies() 0055 { 0056 spyStarted.clear(); 0057 spyClear.clear(); 0058 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 79) 0059 spyClearQUrl.clear(); 0060 #endif 0061 spyCompleted.clear(); 0062 spyCompletedQUrl.clear(); 0063 spyCanceled.clear(); 0064 spyCanceledQUrl.clear(); 0065 spyRedirection.clear(); 0066 spyItemsDeleted.clear(); 0067 spyJobError.clear(); 0068 } 0069 0070 QSignalSpy spyStarted; 0071 QSignalSpy spyItemsDeleted; 0072 QSignalSpy spyClear; 0073 QSignalSpy spyClearDir; 0074 QSignalSpy spyCompleted; 0075 QSignalSpy spyCanceled; 0076 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 79) 0077 QSignalSpy spyClearQUrl; 0078 #endif 0079 QSignalSpy spyCompletedQUrl; 0080 QSignalSpy spyCanceledQUrl; 0081 QSignalSpy spyRedirection; 0082 QSignalSpy spyJobError; 0083 }; 0084 0085 class KDirListerTest : public QObject 0086 { 0087 Q_OBJECT 0088 private Q_SLOTS: 0089 void initTestCase(); 0090 void cleanup(); 0091 void testInvalidUrl(); 0092 void testNonListableUrl(); 0093 void testOpenUrl(); 0094 void testOpenUrlFromCache(); 0095 void testNewItem(); 0096 void testNewItems(); 0097 void benchFindByUrl(); 0098 void testNewItemByCopy(); 0099 void testNewItemsInSymlink(); 0100 void testRefreshItems(); 0101 void testRefreshRootItem(); 0102 void testDeleteItem(); 0103 void testDeleteItems(); 0104 void testRenameItem(); 0105 void testRenameAndOverwrite(); 0106 void testConcurrentListing(); 0107 void testConcurrentHoldingListing(); 0108 void testConcurrentListingAndStop(); 0109 void testDeleteListerEarly(); 0110 void testOpenUrlTwice(); 0111 void testOpenUrlTwiceWithKeep(); 0112 void testOpenAndStop(); 0113 void testBug211472(); 0114 void testRenameCurrentDir(); 0115 void testRenameCurrentDirOpenUrl(); 0116 void testRedirection(); 0117 void testListEmptyDirFromCache(); 0118 void testWatchingAfterCopyJob(); 0119 void testRemoveWatchedDirectory(); 0120 void testDirPermissionChange(); 0121 void testCopyAfterListingAndMove(); // #353195 0122 void testRenameDirectory(); // #401552 0123 void testRequestMimeType(); 0124 void testMimeFilter_data(); 0125 void testMimeFilter(); 0126 void testBug386763(); 0127 void testCacheEviction(); 0128 void testDeleteCurrentDir(); // must be just before last! 0129 void testForgetDir(); // must be last! 0130 0131 protected Q_SLOTS: // 'more private than private slots' - i.e. not seen by qtestlib 0132 void slotNewItems(const KFileItemList &); 0133 void slotNewItems2(const KFileItemList &); 0134 void slotRefreshItems(const QList<QPair<KFileItem, KFileItem>> &); 0135 void slotRefreshItems2(const QList<QPair<KFileItem, KFileItem>> &); 0136 void slotOpenUrlOnRename(const QUrl &); 0137 0138 Q_SIGNALS: 0139 void refreshItemsReceived(); 0140 0141 private: 0142 int fileCount() const; 0143 QString tempPath() const; 0144 void createSimpleFile(const QString &fileName); 0145 void fillDirLister2(MyDirLister &lister, const QString &path); 0146 void waitUntilMTimeChange(const QString &path); 0147 void waitUntilAfter(const QDateTime &ctime); 0148 0149 private: 0150 int m_exitCount; 0151 QEventLoop m_eventLoop; 0152 std::unique_ptr<QTemporaryDir> m_tempDir; 0153 MyDirLister m_dirLister; 0154 KFileItemList m_items; 0155 KFileItemList m_items2; 0156 QList<QPair<KFileItem, KFileItem>> m_refreshedItems, m_refreshedItems2; 0157 }; 0158 0159 #endif