diff options
| author | Sandro Knauß <sknauss@kde.org> | 2016-03-22 16:18:21 +0100 | 
|---|---|---|
| committer | Sandro Knauß <sknauss@kde.org> | 2016-03-28 17:44:48 +0200 | 
| commit | 50f191eaba9b076675a52252dd8f2a5aaf5b1bb0 (patch) | |
| tree | b1913743e1ac75b76e6fb5632d3b899de5611a74 /autotests/kconfigtest.cpp | |
| parent | 43f8c1169524103eea0cbe624572c582b4d14494 (diff) | |
| download | kconfig-50f191eaba9b076675a52252dd8f2a5aaf5b1bb0.tar.gz kconfig-50f191eaba9b076675a52252dd8f2a5aaf5b1bb0.tar.bz2 | |
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.
Diffstat (limited to 'autotests/kconfigtest.cpp')
| -rw-r--r-- | autotests/kconfigtest.cpp | 34 | 
1 files changed, 34 insertions, 0 deletions
| 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"); | 
