Handle colors file in fake plasma theme installer
This commit is contained in:
parent
08a6a4a7cd
commit
17d49c0bce
@ -49,7 +49,10 @@ static bool imageIsEmpty(const QImage &img)
|
|||||||
|
|
||||||
void IconItemTest::initTestCase()
|
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());
|
qputenv("XDG_DATA_DIRS", qgetenv("XDG_DATA_DIRS") + ":" + QFINDTESTDATA("data").toLocal8Bit());
|
||||||
|
|
||||||
QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
|
QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
namespace TestUtils {
|
namespace TestUtils {
|
||||||
|
|
||||||
static void copyPath(const QString &src, const QString &dst) {
|
static void copyPath(const QString &src, const QString &dst)
|
||||||
|
{
|
||||||
QDir dir(src);
|
QDir dir(src);
|
||||||
Q_ASSERT(dir.exists());
|
|
||||||
|
|
||||||
foreach (const auto &d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
foreach (const auto &d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
QString dst_path = dst + QLatin1Char('/') + d;
|
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);
|
QStandardPaths::setTestModeEnabled(true);
|
||||||
const auto qttestPath = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constFirst();
|
const auto qttestPath = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constFirst();
|
||||||
Q_ASSERT(!qttestPath.isEmpty());
|
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);
|
QFileInfo f(data);
|
||||||
QVERIFY(f.dir().mkpath(themePath.path()));
|
QVERIFY(f.dir().mkpath(themePath.path()));
|
||||||
|
|
||||||
copyPath(f.dir().filePath("default.gzipped"), themePath.path());
|
copyPath(f.dir().filePath("default.gzipped"), themePath.path());
|
||||||
QFile::copy(f.dir().filePath("metadata.desktop"), themePath.filePath("metadata.desktop"));
|
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
|
} //TestUtils
|
||||||
|
Loading…
Reference in New Issue
Block a user