Warning, file /frameworks/plasma-framework/autotests/utils.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2019 Aleix Pol <apol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef UTILS_H 0007 #define UTILS_H 0008 0009 #include <QDir> 0010 #include <QStandardPaths> 0011 #include <QString> 0012 #include <QTest> 0013 0014 namespace Plasma 0015 { 0016 namespace TestUtils 0017 { 0018 static void copyPath(const QString &src, const QString &dst) 0019 { 0020 QDir dir(src); 0021 0022 const auto dirList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); 0023 for (const auto &d : dirList) { 0024 QString dst_path = dst + QLatin1Char('/') + d; 0025 dir.mkpath(dst_path); 0026 copyPath(src + QLatin1Char('/') + d, dst_path); 0027 } 0028 0029 const auto entryList = dir.entryList(QDir::Files); 0030 for (const auto &f : entryList) { 0031 QFile::copy(src + QLatin1Char('/') + f, dst + QLatin1Char('/') + f); 0032 } 0033 } 0034 0035 static void installPlasmaTheme(const QString &theme = QStringLiteral("breeze")) 0036 { 0037 QString destinationTheme = (theme == QLatin1String("breeze") ? QStringLiteral("default") : theme); 0038 0039 QStandardPaths::setTestModeEnabled(true); 0040 const auto qttestPath = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).constFirst(); 0041 Q_ASSERT(!qttestPath.isEmpty()); 0042 QDir themePath(qttestPath + QLatin1String("/plasma/desktoptheme/") + destinationTheme); 0043 0044 auto data = QFINDTESTDATA("../src/desktoptheme/" + theme + "/metadata.json"); 0045 QFileInfo f(data); 0046 QVERIFY(f.dir().mkpath(themePath.path())); 0047 0048 copyPath(f.dir().filePath("default.gzipped"), themePath.path()); 0049 QFile::copy(f.dir().filePath("metadata.json"), themePath.filePath("metadata.json")); 0050 0051 const QString colorsFile = QFINDTESTDATA("../src/desktoptheme/" + theme + "/colors"); 0052 if (!colorsFile.isEmpty()) { 0053 QFile::copy(colorsFile, themePath.filePath("colors")); 0054 } 0055 } 0056 0057 } // TestUtils 0058 } // Plasma 0059 0060 #endif