From cdf9aed6302df57a8a1c56f03e6f82254ea87043 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 9 Jul 2014 08:56:27 +0200 Subject: tst_qdir: Move QFINDTESTDATA() from init() to constructor. Check result in initTestData(). Previously, QFINDTESTDATA() was repeatedly invoked in init(). The data-driven cd() test then failed when invoked stand-alone since cd_data(), which relies on the data path, is executed before init(). Task-number: QTBUG-40067 Change-Id: I91039247e8dcaedd92fa990f1b5f82bc54b17c60 Reviewed-by: Joerg Bornemann --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 2bac6f5834..cf7cdc874c 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -72,8 +72,12 @@ class tst_QDir : public QObject { Q_OBJECT +public: + tst_QDir(); + private slots: void init(); + void initTestCase(); void cleanupTestCase(); void getSetCheck(); @@ -198,19 +202,25 @@ private slots: void cdBelowRoot(); private: - QString m_dataPath; + const QString m_dataPath; }; -void tst_QDir::init() +tst_QDir::tst_QDir() + : m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath()) { - // Directory under which testdata can be found. - m_dataPath = QFileInfo(QFINDTESTDATA("testData")).absolutePath(); - QVERIFY2(!m_dataPath.isEmpty(), "test data not found"); +} +void tst_QDir::init() +{ // Some tests want to use "." as relative path to data. QVERIFY2(QDir::setCurrent(m_dataPath), qPrintable("Could not chdir to " + m_dataPath)); } +void tst_QDir::initTestCase() +{ + QVERIFY2(!m_dataPath.isEmpty(), "test data not found"); +} + void tst_QDir::cleanupTestCase() { QDir(QDir::currentPath() + "/tmpdir").removeRecursively(); -- cgit v1.2.3