diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-09 08:56:27 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-09 10:59:42 +0200 |
commit | cdf9aed6302df57a8a1c56f03e6f82254ea87043 (patch) | |
tree | 7befd1b8dec14654423247a965eeb273f1f7126b /tests/auto | |
parent | 71e1976bccbe3809eed1b8d4a69b45963e29cb69 (diff) |
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 <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/io/qdir/tst_qdir.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
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(); |