┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/tests/testbase.h
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2011-04-03 15:31:27 +0200
committerFrank Reininghaus <[email protected]>2011-04-03 15:32:12 +0200
commit95cb8ffe01e0252d3a26f244e8607254200d067f (patch)
treed76499d9b454b8730e48a2f24a55c914f7f0230c /src/tests/testbase.h
parent5ff682d852a07b5121e49d8ed2a239b0a1762b6b (diff)
Dolphin unit test refactoring
This commit changes mainly two things: 1. The functionality related to the handling of temporary files and folders is moved to a new class TestDir. 2. The setup of a temporary folder and of DolphinView instances is now done in each unit test function. A benefit of this change is that there are no unwanted interactions between different unit test functions any more. Moreover, different test functions could now share a test folder more easily. Additionally, the reference arguments of all functions are changed to pointers for consistency.
Diffstat (limited to 'src/tests/testbase.h')
-rw-r--r--src/tests/testbase.h66
1 files changed, 13 insertions, 53 deletions
diff --git a/src/tests/testbase.h b/src/tests/testbase.h
index 7e6ff4bb5..7034cbe41 100644
--- a/src/tests/testbase.h
+++ b/src/tests/testbase.h
@@ -17,26 +17,20 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
*****************************************************************************/
-#ifndef TESTHELPER_H
-#define TESTHELPER_H
+#ifndef TESTBASE_H
+#define TESTBASE_H
-#include <KUrl>
+#include <QtCore/QObject>
-#include <QDateTime>
-
-class KTempDir;
class QAbstractItemView;
-class QDir;
class DolphinDirLister;
class DolphinModel;
class DolphinSortFilterProxyModel;
class DolphinView;
/**
- * The class TestBase aims to make writing Dolphin unit tests easier.
- * It provides functionality that almost every unit test needs: setup of the DolphinView and
- * easy creation of test files and subfolders in a temporary directory which is removed in
- * the TestBase destructor.
+ * The class TestBase (which is a friend of DolphinView's) provides access to some
+ * parts of DolphinView to the unit tests.
*
* TODO: TestBase should also backup the DolphinSettings and restore them later!
*/
@@ -47,51 +41,17 @@ class TestBase : public QObject
public:
- TestBase();
- ~TestBase();
-
- // Returns the item view (icons, details, or columns)
- QAbstractItemView* itemView() const;
-
- // Reloads the view and waits for the finishedPathLoading(const KUrl&) signal.
- void reloadViewAndWait();
-
- KUrl testDirUrl() const;
-
- /**
- * The following functions create either a file, a list of files, or a directory.
- * The paths may be absolute or relative to the test directory. Any missing parent
- * directories will be created automatically.
- */
-
- void createFile(const QString& path, const QByteArray& data = QByteArray("test"), const QDateTime& time = QDateTime());
- void createFiles(const QStringList& files);
- void createDir(const QString& path, const QDateTime& time = QDateTime());
-
- /**
- * Returns the items shown in the view. The order corresponds to the sort order of the view.
- */
-
- QStringList viewItems() const;
-
- /**
- * Remove the test directory and create an empty one.
- */
-
- void cleanupTestDir();
-
- // Make members that are accessed frequently by the derived test classes public
-
- DolphinView* m_view;
-
- QString m_path;
+ TestBase() {};
+ ~TestBase() {};
-private:
+ /** Returns the item view (icons, details, or columns) */
+ static QAbstractItemView* itemView(const DolphinView* view);
- KTempDir* m_tempDir;
- QDir* m_dir;
+ /** Reloads the view and waits for the finishedPathLoading(const KUrl&) signal. */
+ static void reloadViewAndWait(DolphinView* view);
- void makePathAbsoluteAndCreateParents(QString& path);
+ /** Returns the items shown in the view. The order corresponds to the sort order of the view. */
+ static QStringList viewItems(const DolphinView* view);
};