diff --git a/autotests/iconitemtest.cpp b/autotests/iconitemtest.cpp index 8373a24d1..57e0b1d64 100644 --- a/autotests/iconitemtest.cpp +++ b/autotests/iconitemtest.cpp @@ -49,7 +49,10 @@ static bool imageIsEmpty(const QImage &img) void IconItemTest::initTestCase() { - Plasma::TestUtils::installPlasmaTheme(); + Plasma::TestUtils::installPlasmaTheme("breeze"); + Plasma::TestUtils::installPlasmaTheme("breeze-light"); + Plasma::TestUtils::installPlasmaTheme("breeze-dark"); + qputenv("XDG_DATA_DIRS", qgetenv("XDG_DATA_DIRS") + ":" + QFINDTESTDATA("data").toLocal8Bit()); QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); diff --git a/autotests/utils.h b/autotests/utils.h index 0ccee7fed..47aaf6e1b 100644 --- a/autotests/utils.h +++ b/autotests/utils.h @@ -25,9 +25,9 @@ namespace Plasma { namespace TestUtils { -static void copyPath(const QString &src, const QString &dst) { +static void copyPath(const QString &src, const QString &dst) +{ QDir dir(src); - Q_ASSERT(dir.exists()); foreach (const auto &d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { QString dst_path = dst + QLatin1Char('/') + d; @@ -40,18 +40,27 @@ static void copyPath(const QString &src, const QString &dst) { } } -static void installPlasmaTheme() { +static void installPlasmaTheme(const QString &theme = QStringLiteral("breeze")) +{ + QString destinationTheme = (theme == QLatin1String("breeze") ? QStringLiteral("default") : theme); + QStandardPaths::setTestModeEnabled(true); const auto qttestPath = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constFirst(); Q_ASSERT(!qttestPath.isEmpty()); - QDir themePath(qttestPath + QLatin1String("/plasma/desktoptheme/default")); + QDir themePath(qttestPath + QLatin1String("/plasma/desktoptheme/") + destinationTheme); - auto data = QFINDTESTDATA("../src/desktoptheme/breeze/metadata.desktop"); + auto data = QFINDTESTDATA("../src/desktoptheme/" + theme + "/metadata.desktop"); QFileInfo f(data); QVERIFY(f.dir().mkpath(themePath.path())); copyPath(f.dir().filePath("default.gzipped"), themePath.path()); QFile::copy(f.dir().filePath("metadata.desktop"), themePath.filePath("metadata.desktop")); + + const QString colorsFile = QFINDTESTDATA("../src/desktoptheme/" + theme + "/colors"); + if (!colorsFile.isEmpty()) { + QFile::copy(colorsFile, themePath.filePath("colors")); + } + } } //TestUtils