Commit 6ce509df authored by David Faure's avatar David Faure
Browse files

Code cleanups and modernization

Fix update-mime-database warning due to XDG_DATA_HOME not set.

Test still fails though.
parent b8a7feae
......@@ -512,7 +512,8 @@ void MimeTypeData::saveDefaultApplication(KConfigGroup &config, const QStringLis
if (services.isEmpty()) {
config.deleteEntry(name());
} else {
config.writeXdgListEntry(name(), QStringList(collectStorageIds(services).first()));
const QString firstStorageId = collectStorageIds(services).first();
config.writeXdgListEntry(name(), {firstStorageId});
}
}
......
......@@ -34,11 +34,11 @@ class MimeTypeData
{
public:
// Constructor used for groups
MimeTypeData(const QString &major);
explicit MimeTypeData(const QString &major);
// Real constructor, used for an existing mimetype.
MimeTypeData(const QMimeType &mime);
explicit MimeTypeData(const QMimeType &mime);
// Real constructor, used for a new mimetype.
MimeTypeData(const QString &mimeName,
explicit MimeTypeData(const QString &mimeName,
bool /*unused, just to distinguish from the other QString ctor*/);
QString name() const
......
......@@ -42,9 +42,6 @@ class FileTypesTest : public QObject
private Q_SLOTS:
void initTestCase()
{
extern KSERVICE_EXPORT bool kservice_require_kded;
kservice_require_kded = false;
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 73, 0)
QLoggingCategory::setFilterRules(QStringLiteral("kf.coreaddons.kdirwatch.debug=true"));
#else
......@@ -53,6 +50,9 @@ private Q_SLOTS:
QStandardPaths::setTestModeEnabled(true);
// update-mime-database needs to know about that test directory for the mimetype pattern change in testMimeTypePatterns to have an effect
qputenv("XDG_DATA_HOME", QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)));
m_mimeTypeCreatedSuccessfully = false;
QStringList appsDirs = QStandardPaths::standardLocations(
QStandardPaths::ApplicationsLocation);
......@@ -91,7 +91,7 @@ private Q_SLOTS:
"filetypesrc"));
if (mustUpdateKSycoca) {
// Update ksycoca in ~/.kde-unit-test after creating the above
// Update ksycoca in ~/.qttest after creating the above [might not be needed anymore]
runKBuildSycoca();
}
KService::Ptr fakeApplicationService = KService::serviceByStorageId(fakeApplication);
......@@ -169,7 +169,7 @@ private Q_SLOTS:
QVERIFY(!data.isDirty());
data.setPatterns(patterns);
QVERIFY(data.isDirty());
bool needUpdateMimeDb = data.sync();
const bool needUpdateMimeDb = data.sync();
QVERIFY(needUpdateMimeDb);
MimeTypeWriter::runUpdateMimeDatabase();
......@@ -180,6 +180,7 @@ private Q_SLOTS:
// Check what's in QMimeDatabase
QStringList newPatterns = db.mimeTypeForName(QStringLiteral("text/plain")).globPatterns();
newPatterns.sort();
qDebug() << "QMimeDatabase says" << newPatterns << "we just saved" << patterns;
QCOMPARE(newPatterns, patterns);
QVERIFY(!data.isDirty());
......@@ -204,7 +205,6 @@ private Q_SLOTS:
QStringList appServices = data.appServices();
//qDebug() << appServices;
QVERIFY(!appServices.isEmpty());
const QString oldPreferredApp = appServices.first();
QVERIFY(!appServices.contains(fakeApplication)); // already there? hmm can't really test then
QVERIFY(!data.isDirty());
appServices.prepend(fakeApplication);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment