File indexing completed on 2024-05-19 15:15:35

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2004 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef TESTTRASH_H
0009 #define TESTTRASH_H
0010 
0011 #include <QObject>
0012 #include <QTemporaryDir>
0013 
0014 #include <KIO/Job>
0015 
0016 class TestTrash : public QObject
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     TestTrash()
0022     {
0023     }
0024 
0025 private Q_SLOTS:
0026     void initTestCase();
0027     void cleanupTestCase();
0028 
0029     void testIcons();
0030 
0031     void urlTestFile();
0032     void urlTestDirectory();
0033     void urlTestSubDirectory();
0034 
0035     void trashFileFromHome();
0036     void trashPercentFileFromHome();
0037     void trashUtf8FileFromHome();
0038     void trashUmlautFileFromHome();
0039     void testTrashNotEmpty();
0040     void trashFileFromOther();
0041     void trashFileIntoOtherPartition();
0042     void trashFileOwnedByRoot();
0043     void trashSymlinkFromHome();
0044     void trashSymlinkFromOther();
0045     void trashBrokenSymlinkFromHome();
0046     void trashDirectoryFromHome();
0047     void trashDotDirectory();
0048     void trashReadOnlyDirFromHome();
0049     void trashDirectoryFromOther();
0050     void trashDirectoryOwnedByRoot();
0051     void trashDirectoryWithTrailingSlash();
0052     void trashBrokenSymlinkIntoSubdir();
0053 
0054     void statRoot();
0055     void statFileInRoot();
0056     void statDirectoryInRoot();
0057     void statSymlinkInRoot();
0058     void statFileInDirectory();
0059     void statBrokenSymlinkInSubdir();
0060     void testRemoveStaleInfofile();
0061 
0062     void copyFileFromTrash();
0063     void copyFileInDirectoryFromTrash();
0064     void copyDirectoryFromTrash();
0065     void copySymlinkFromTrash();
0066 
0067     void renameFileInTrash();
0068     void renameDirInTrash();
0069     void moveFileFromTrash();
0070     void moveFileFromTrashToDir_data();
0071     void moveFileFromTrashToDir();
0072     void moveFileInDirectoryFromTrash();
0073     void moveDirectoryFromTrash();
0074     void moveSymlinkFromTrash();
0075     void testMoveNonExistingFile();
0076 
0077     void listRootDir();
0078     void listRecursiveRootDir();
0079     void mostLocalUrlTest();
0080     void listSubDir();
0081 
0082     void delRootFile();
0083     void delFileInDirectory();
0084     void delDirectory();
0085 
0086     void getFile();
0087     void restoreFile();
0088     void restoreFileFromSubDir();
0089     void restoreFileToDeletedDirectory();
0090 
0091     void emptyTrash();
0092     void testEmptyTrashSize();
0093 
0094 protected Q_SLOTS:
0095     void slotEntries(KIO::Job *, const KIO::UDSEntryList &);
0096 
0097 private:
0098     void trashFile(const QString &origFilePath, const QString &fileId);
0099     void trashSymlink(const QString &origFilePath, const QString &fileName, bool broken);
0100     void trashDirectory(const QString &origPath, const QString &fileName);
0101     void copyFromTrash(const QString &fileId, const QString &destPath, const QString &relativePath = QString());
0102     void moveInTrash(const QString &fileId, const QString &destFileId);
0103     void moveFromTrash(const QString &fileId, const QString &destPath, const QString &relativePath = QString());
0104     void checkDirCacheValidity();
0105 
0106     QString homeTmpDir() const;
0107     QString otherTmpDir() const;
0108     QString utf8FileName() const;
0109     QString umlautFileName() const;
0110     QString readOnlyDirPath() const;
0111 
0112     QString m_trashDir;
0113 
0114     QString m_otherPartitionTopDir;
0115     QString m_otherPartitionTrashDir;
0116     bool m_tmpIsWritablePartition;
0117     int m_tmpTrashId;
0118     int m_otherPartitionId;
0119 
0120     int m_entryCount;
0121     QStringList m_listResult;
0122     QStringList m_displayNameListResult;
0123 
0124     QTemporaryDir m_tempDir;
0125 };
0126 
0127 #endif