1 /*****************************************************************************
2 * Copyright (C) 2010-2011 by Frank Reininghaus (frank78ac@googlemail.com) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 *****************************************************************************/
28 class QAbstractItemView
;
30 class DolphinDirLister
;
32 class DolphinSortFilterProxyModel
;
36 * The class TestBase aims to make writing Dolphin unit tests easier.
37 * It provides functionality that almost every unit test needs: setup of the DolphinView and
38 * easy creation of test files and subfolders in a temporary directory which is removed in
39 * the TestBase destructor.
41 * TODO: TestBase should also backup the DolphinSettings and restore them later!
44 class TestBase
: public QObject
53 // Returns the item view (icons, details, or columns)
54 QAbstractItemView
* itemView() const;
56 // Reloads the view and waits for the finishedPathLoading(const KUrl&) signal.
57 void reloadViewAndWait();
59 KUrl
testDirUrl() const;
62 * The following functions create either a file, a list of files, or a directory.
63 * The paths may be absolute or relative to the test directory. Any missing parent
64 * directories will be created automatically.
67 void createFile(const QString
& path
, const QByteArray
& data
= QByteArray("test"), const QDateTime
& time
= QDateTime());
68 void createFiles(const QStringList
& files
);
69 void createDir(const QString
& path
, const QDateTime
& time
= QDateTime());
72 * Returns the items shown in the view. The order corresponds to the sort order of the view.
75 QStringList
viewItems() const;
78 * Remove the test directory and create an empty one.
81 void cleanupTestDir();
83 // Make members that are accessed frequently by the derived test classes public
94 void makePathAbsoluteAndCreateParents(QString
& path
);