From 61ca116a2eaf8a275803524ade494ace6b9cb812 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 8 Jun 2015 21:49:48 +0200 Subject: QTest: Make qExtractTestData() return the created QTemporaryDir ... and enable auto-deletion on it. This allows users of the function to get rid of their own cleanup code. They just need to keep the shared pointer alive for as long as they need it. Drive-by changes: - replaced QStringLiterals that were only used as the rhs of op+ - replaced an instance of mid() used as the rhs of op+ with midRef() - enabled NRVO Change-Id: I161d39461e020c9e8d473c0810dea2109fe0d62d Reviewed-by: Lars Knoll --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 62e183f619..1e51f2c5f4 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -263,21 +263,23 @@ private slots: private: const QString m_currentDir; - QString m_dataPath; QString m_sourceFile; QString m_proFile; QString m_resourcesDir; QTemporaryDir m_dir; + QSharedPointer m_dataDir; }; void tst_QFileInfo::initTestCase() { - m_dataPath = QEXTRACTTESTDATA("/testdata"); - QVERIFY(!m_dataPath.isEmpty()); + m_dataDir = QEXTRACTTESTDATA("/testdata"); + QVERIFY(m_dataDir); + const QString dataPath = m_dataDir->path(); + QVERIFY(!dataPath.isEmpty()); - m_sourceFile = m_dataPath + QStringLiteral("/tst_qfileinfo.cpp"); - m_resourcesDir = m_dataPath + QStringLiteral("/resources"); - m_proFile = m_dataPath + QStringLiteral("/tst_qfileinfo.pro"); + m_sourceFile = dataPath + QLatin1String("/tst_qfileinfo.cpp"); + m_resourcesDir = dataPath + QLatin1String("/resources"); + m_proFile = dataPath + QLatin1String("/tst_qfileinfo.pro"); QVERIFY(m_dir.isValid()); QVERIFY(QDir::setCurrent(m_dir.path())); @@ -286,7 +288,6 @@ void tst_QFileInfo::initTestCase() void tst_QFileInfo::cleanupTestCase() { QDir::setCurrent(m_currentDir); // Release temporary directory so that it can be deleted on Windows - QDir(m_dataPath).removeRecursively(); } // Testing get/set functions -- cgit v1.2.3