diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-03-01 13:47:04 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-03-02 07:14:47 +0000 |
commit | 235c1c776a51717377d18d8b537ebffeee65560a (patch) | |
tree | 64a826044330d2f1560253e0afa862e9effd9440 | |
parent | 6cc050c969b6dde1566f2b71f32829e680557350 (diff) | |
download | qtbase-235c1c776a51717377d18d8b537ebffeee65560a.tar.gz |
Fix test tst_QIcon::fromThemeCache().
Verify that the temporary directory could be created. Check whether
the gtk-update-icon-cache binary exists before running and skip cleanly.
Check successful execution. Fixes Windows warnings:
SKIP : tst_QIcon::fromThemeCache() gtk-update-icon-cache not run
.\tst_qicon.cpp(707) : failure location
QWARN : tst_QIcon::fromThemeCache() QTemporaryDir: Unable to remove "D:\\temp\\tst_qicon-DSSn9G" most likely due to the presence of read-only
files.
Change-Id: Ibc8f883121e62b30d71586bc64b42eb6c480925f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
-rw-r--r-- | tests/auto/gui/image/qicon/tst_qicon.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp index 079b14a64e..3c4610a892 100644 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ b/tests/auto/gui/image/qicon/tst_qicon.cpp @@ -31,6 +31,7 @@ #include <QImageReader> #include <qicon.h> #include <qiconengine.h> +#include <QtCore/QStandardPaths> #include <algorithm> @@ -648,9 +649,20 @@ void tst_QIcon::fromTheme() QVERIFY(!fullPathIcon.isNull()); } +static inline QString findGtkUpdateIconCache() +{ + QString binary = QLatin1String("gtk-update-icon-cache"); +#ifdef Q_OS_WIN + binary += QLatin1String(".exe"); +#endif + return QStandardPaths::findExecutable(binary); +} + void tst_QIcon::fromThemeCache() { QTemporaryDir dir; + QVERIFY2(dir.isValid(), qPrintable(dir.errorString())); + QVERIFY(QDir().mkpath(dir.path() + QLatin1String("/testcache/16x16/actions"))); QVERIFY(QFile(QStringLiteral(":/styles/commonstyle/images/standardbutton-open-16.png")) .copy( dir.path() + QLatin1String("/testcache/16x16/actions/button-open.png"))); @@ -700,11 +712,20 @@ void tst_QIcon::fromThemeCache() QVERIFY(!QIcon::fromTheme("button-open").isNull()); // Try to run the actual gtk-update-icon-cache and make sure that icons are still found + const QString gtkUpdateIconCache = findGtkUpdateIconCache(); + if (gtkUpdateIconCache.isEmpty()) { + QIcon::setThemeSearchPaths(QStringList()); + QSKIP("gtk-update-icon-cache not run (binary not found)"); + } QProcess process; - process.start(QStringLiteral("gtk-update-icon-cache"), + process.start(gtkUpdateIconCache, QStringList() << QStringLiteral("-f") << QStringLiteral("-t") << (dir.path() + QLatin1String("/testcache"))); - if (!process.waitForFinished()) - QSKIP("gtk-update-icon-cache not run"); + QVERIFY2(process.waitForStarted(), qPrintable(QLatin1String("Unable to start: ") + + gtkUpdateIconCache + QLatin1String(": ") + + process.errorString())); + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QCOMPARE(process.exitCode(), 0); QVERIFY(QFileInfo(cacheName).lastModified() >= QFileInfo(dir.path() + QLatin1String("/testcache/16x16/actions")).lastModified()); QIcon::setThemeSearchPaths(QStringList() << dir.path()); // reload themes QVERIFY(!QIcon::fromTheme("button-open").isNull()); |