From 853e9ac787f2eaf603c7756726b2d90a143aa183 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Mon, 20 Feb 2012 13:29:13 +1000 Subject: Modify helper functions to remove embedded QSKIP call and return status. The helper functions contained QSKIP macros which do not also skip their parent function. These QSKIP function were removed and replaced with a return success value. Change-Id: I533f57842fc95beaeb1fcde5235678e9807db056 Reviewed-by: Rohan McGovern --- .../mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'tests/auto/corelib/mimetypes/qmimedatabase') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 12d6587dfb..fc86fa5431 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -714,20 +714,21 @@ void tst_QMimeDatabase::fromThreads() f.waitForFinished(); } -static void runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDatabase method? +static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDatabase method? { const QString umd = QStandardPaths::findExecutable(QString::fromLatin1("update-mime-database")); if (umd.isEmpty()) - QSKIP("shared-mime-info not found, skipping mime.cache test"); + return false; QProcess proc; proc.setProcessChannelMode(QProcess::MergedChannels); // silence output proc.start(umd, QStringList() << path); proc.waitForFinished(); //qDebug() << "runUpdateMimeDatabase" << path; + return true; } -static void waitAndRunUpdateMimeDatabase(const QString &path) +static bool waitAndRunUpdateMimeDatabase(const QString &path) { QFileInfo mimeCacheInfo(path + QString::fromLatin1("/mime.cache")); if (mimeCacheInfo.exists()) { @@ -736,7 +737,7 @@ static void waitAndRunUpdateMimeDatabase(const QString &path) QTest::qSleep(200); } } - runUpdateMimeDatabase(path); + return runUpdateMimeDatabase(path); } static void checkHasMimeType(const QString &mimeType) @@ -775,7 +776,8 @@ void tst_QMimeDatabase::installNewGlobalMimeType() QFile::remove(destFile); //qDebug() << destFile; QVERIFY(QFile::copy(srcFile, destFile)); - waitAndRunUpdateMimeDatabase(mimeDir); + if (!waitAndRunUpdateMimeDatabase(mimeDir)) + QSKIP("shared-mime-info not found, skipping mime.cache test"); QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("text/x-suse-ymu")); @@ -784,7 +786,8 @@ void tst_QMimeDatabase::installNewGlobalMimeType() // Now test removing it again QFile::remove(destFile); - waitAndRunUpdateMimeDatabase(mimeDir); + if (!waitAndRunUpdateMimeDatabase(mimeDir)) + QSKIP("shared-mime-info not found, skipping mime.cache test"); QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("application/octet-stream")); QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); @@ -805,7 +808,8 @@ void tst_QMimeDatabase::installNewLocalMimeType() const QString destFile = destDir + fileName; QFile::remove(destFile); QVERIFY(QFile::copy(srcFile, destFile)); - runUpdateMimeDatabase(mimeDir); + if (!runUpdateMimeDatabase(mimeDir)) + QSKIP("shared-mime-info not found, skipping mime.cache test");; QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("text/x-suse-ymu")); @@ -814,7 +818,8 @@ void tst_QMimeDatabase::installNewLocalMimeType() // Now test removing it again (note, this leaves a mostly-empty mime.cache file) QFile::remove(destFile); - waitAndRunUpdateMimeDatabase(mimeDir); + if (!waitAndRunUpdateMimeDatabase(mimeDir)) + QSKIP("shared-mime-info not found, skipping mime.cache test"); QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(), QString::fromLatin1("application/octet-stream")); QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid()); -- cgit v1.2.3