kde4_add_unit_test(dolphintreeviewtest TEST dolphintreeviewtest.cpp)
target_link_libraries(dolphintreeviewtest dolphinprivate ${KDE4_KDEUI_LIBS} ${QT_QTTEST_LIBRARY})
-kde4_add_unit_test(dolphindetailsviewtest TEST dolphindetailsviewtest.cpp testhelper.cpp ../views/zoomlevelinfo.cpp)
+kde4_add_unit_test(dolphindetailsviewtest TEST dolphindetailsviewtest.cpp testbase.cpp ../views/zoomlevelinfo.cpp)
target_link_libraries(dolphindetailsviewtest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
#include <qtest_kde.h>
-#include "testhelper.h"
+#include "testbase.h"
#include "views/dolphindetailsview.h"
#include "views/dolphinview.h"
#include "kdebug.h"
-class DolphinDetailsViewTest : public QObject
+class DolphinDetailsViewTest : public TestBase
{
Q_OBJECT
private slots:
void initTestCase();
- void cleanupTestCase();
void bug234600_overlappingIconsWhenZooming();
-private:
-
- TestHelper* m_helper;
- DolphinView* m_view;
};
void DolphinDetailsViewTest::initTestCase()
// add time stamps to find origin of test failures due to timeout at
// http://my.cdash.org/index.php?project=kdebase&date=
qputenv("KDE_DEBUG_TIMESTAMP", QByteArray("1"));
-
- m_helper = new TestHelper;
- m_view = m_helper->view();
-}
-
-void DolphinDetailsViewTest::cleanupTestCase()
-{
- delete m_helper;
}
/**
{
QStringList files;
files << "a" << "b" << "c" << "d";
- m_helper->createFiles(files);
+ createFiles(files);
m_view->setMode(DolphinView::DetailsView);
- DolphinDetailsView* detailsView = qobject_cast<DolphinDetailsView*>(m_helper->itemView());
+ DolphinDetailsView* detailsView = qobject_cast<DolphinDetailsView*>(itemView());
QVERIFY(detailsView);
m_view->resize(400, 400);
m_view->show();
m_view->hide();
kDebug() << "Cleaning up test directory...";
- m_helper->cleanupTestDir();
+ cleanupTestDir();
kDebug() << "Done.";
}
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
-#include "testhelper.h"
+#include "testbase.h"
#include "views/dolphinview.h"
#include "views/dolphinmodel.h"
#include <QtCore/QDir>
#include <QtGui/QAbstractItemView>
-TestHelper::TestHelper()
+TestBase::TestBase()
{
m_tempDir = new KTempDir;
Q_ASSERT(m_tempDir->exists());
m_view = new DolphinView(0, KUrl(m_path), m_proxyModel);
}
-TestHelper::~TestHelper()
+TestBase::~TestBase()
{
delete m_view;
delete m_proxyModel;
delete m_tempDir;
}
-QAbstractItemView* TestHelper::itemView () const
+QAbstractItemView* TestBase::itemView () const
{
return m_view->m_viewAccessor.itemView();
}
-KUrl TestHelper::testDirUrl() const
+KUrl TestBase::testDirUrl() const
{
return KUrl(m_path);
}
-void TestHelper::createFile(const QString& path, const QByteArray& data)
+void TestBase::createFile(const QString& path, const QByteArray& data)
{
QString absolutePath = path;
makePathAbsoluteAndCreateParents(absolutePath);
Q_ASSERT(QFile::exists(absolutePath));
}
-void TestHelper::createFiles(const QStringList& files)
+void TestBase::createFiles(const QStringList& files)
{
foreach(const QString& path, files) {
createFile(path);
}
}
-void TestHelper::createDir(const QString& path)
+void TestBase::createDir(const QString& path)
{
QString absolutePath = path;
makePathAbsoluteAndCreateParents(absolutePath);
Q_ASSERT(QFile::exists(absolutePath));
}
-void TestHelper::makePathAbsoluteAndCreateParents(QString& path)
+void TestBase::makePathAbsoluteAndCreateParents(QString& path)
{
QFileInfo fileInfo(path);
if (!fileInfo.isAbsolute()) {
Q_ASSERT(dir.exists());
}
-void TestHelper::cleanupTestDir()
+void TestBase::cleanupTestDir()
{
delete m_tempDir;
m_tempDir = new KTempDir;
class DolphinView;
/*
- * The class TestHelper aims to make writing Dolphin unit tests easier.
+ * 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 TestHelper destructor.
+ * the TestBase destructor.
*
- * TODO: TestHelper should also backup the DolphinSettings and restore them later!
+ * TODO: TestBase should also backup the DolphinSettings and restore them later!
*/
-class TestHelper
+class TestBase : public QObject
{
+ Q_OBJECT
public:
- TestHelper();
- ~TestHelper();
-
- DolphinView* view() const { return m_view; }
- DolphinSortFilterProxyModel* proxyModel() const { return m_proxyModel; }
+ TestBase();
+ ~TestBase();
// Returns the item view (icons, details, or columns)
QAbstractItemView* itemView () const;
void cleanupTestDir();
-private:
-
- void makePathAbsoluteAndCreateParents(QString& path);
+ // Make members that are accessed frequently by the derived test classes public
- KTempDir* m_tempDir;
- QString m_path;
- QDir* m_dir;
DolphinDirLister* m_dirLister;
DolphinModel* m_dolphinModel;
DolphinSortFilterProxyModel* m_proxyModel;
DolphinView* m_view;
+private:
+
+ KTempDir* m_tempDir;
+ QString m_path;
+ QDir* m_dir;
+
+ void makePathAbsoluteAndCreateParents(QString& path);
+
};
#endif
\ No newline at end of file
QSet<QString> m_newFileNames;
// For unit tests
- friend class TestHelper;
+ friend class TestBase;
};
/// Allow using DolphinView::Mode in QVariant