From 50f191eaba9b076675a52252dd8f2a5aaf5b1bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Tue, 22 Mar 2016 16:18:21 +0100 Subject: Add support for get QStandardPaths locations. Inside desktop files we want to reach also data, cache and config home to create files inside these directories. REVIEW: 127462 CHANGELOG: Add support for get QStandardPaths locations inside desktop files. --- autotests/kconfigtest.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'autotests/kconfigtest.cpp') diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index e92197f3..2b905b57 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -552,6 +552,40 @@ void KConfigTest::testPersistenceOfExpandFlagForPath() testPath(); } +void KConfigTest::testPathQtHome() +{ + { + QFile file(testConfigDir() + "/pathtest"); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream out(&file); + out.setCodec("UTF-8"); + out << "[Test Group]" << endl + << "dataDir[$e]=$QT_DATA_HOME/kconfigtest" << endl + << "cacheDir[$e]=$QT_CACHE_HOME/kconfigtest" << endl + << "configDir[$e]=$QT_CONFIG_HOME/kconfigtest" << endl; + } + KConfig cf2(TEST_SUBDIR "pathtest"); + KConfigGroup group = cf2.group("Test Group"); + qunsetenv("QT_DATA_HOME"); + qunsetenv("QT_CACHE_HOME"); + qunsetenv("QT_CONFIG_HOME"); + QVERIFY(group.hasKey("dataDir")); + QCOMPARE(group.readEntry("dataDir", QString()), QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest"))); + QVERIFY(group.hasKey("cacheDir")); + QCOMPARE(group.readEntry("cacheDir", QString()), QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest"))); + QVERIFY(group.hasKey("configDir")); + QCOMPARE(group.readEntry("configDir", QString()), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest"))); + qputenv("QT_DATA_HOME","/1"); + qputenv("QT_CACHE_HOME","/2"); + qputenv("QT_CONFIG_HOME","/3"); + QVERIFY(group.hasKey("dataDir")); + QCOMPARE(group.readEntry("dataDir", QString()), QStringLiteral("/1/kconfigtest")); + QVERIFY(group.hasKey("cacheDir")); + QCOMPARE(group.readEntry("cacheDir", QString()), QStringLiteral("/2/kconfigtest")); + QVERIFY(group.hasKey("configDir")); + QCOMPARE(group.readEntry("configDir", QString()), QStringLiteral("/3/kconfigtest")); +} + void KConfigTest::testComplex() { KConfig sc2(TEST_SUBDIR "kconfigtest"); -- cgit v1.2.1