File indexing completed on 2024-05-05 05:53:33

0001 /***************************************************************************
0002  *   Copyright (C) 2016 by Arnav Dhamija <arnav.dhamija@gmail.com>         *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
0018  ***************************************************************************/
0019 
0020 #ifndef WORKERTEST_H
0021 #define WORKERTEST_H
0022 
0023 #include <KIO/Job>
0024 #include <KIO/UDSEntry>
0025 #include <QObject>
0026 #include <QProcess>
0027 #include <QString>
0028 
0029 class WorkerTest : public QObject
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     WorkerTest();
0035     ~WorkerTest()
0036     {
0037     }
0038 
0039     enum NodeType {
0040         DirectoryNode,
0041         SymlinkNode,
0042         FileNode,
0043         InvalidNode,
0044     };
0045 
0046 private:
0047     QString tmpDirPath();
0048     bool statUrl(const QUrl &url, KIO::UDSEntry &entry);
0049     void stashFile(const QString &realPath, const QString &stashPath);
0050     void stashSymlink(const QString &realPath, const QString &stashPath);
0051     void stashDirectory(const QString &path);
0052     void stashCopy(const QUrl &src, const QUrl &dest);
0053     void statItem(const QUrl &url, const int &type);
0054     void createDirectory();
0055     void moveFromStash(const QUrl &src, const QUrl &dest);
0056     void deleteFromStash(const QUrl &url);
0057     void createTestFiles();
0058     void nukeStash(); // deletes every folder and file in stash:/
0059 
0060     QProcess *stashDaemonProcess;
0061 
0062     const QString tmpFolder;
0063     const QString m_fileTestFile;
0064     const QString m_fileTestFolder;
0065     const QString m_stashTestFolder;
0066     const QString m_stashTestSymlink;
0067     const QString m_stashTestFile;
0068     const QString m_stashTestFileInSubDirectory;
0069     const QString m_newStashFileName;
0070     const QString m_stashFileForRename;
0071     const QString m_absolutePath;
0072 
0073 private slots:
0074     void initTestCase();
0075     void init();
0076     void copyFileToStash();
0077     void copyStashToFile();
0078     void copyStashToStash();
0079     void copySymlinkFromStashToFile();
0080 
0081     void moveToFileFromStash();
0082 
0083     void renameFileInStash();
0084     void statRoot();
0085     void statFileInRoot();
0086     void statDirectoryInRoot();
0087     void statSymlinkInRoot();
0088     void statFileInDirectory();
0089 
0090     void listRootDir();
0091     void listSubDir();
0092 
0093     void delRootFile();
0094     void delFileInDirectory();
0095     void delDirectory();
0096 
0097     void cleanup();
0098     void cleanupTestCase();
0099 };
0100 
0101 #endif