diff options
author | David Faure <faure@kde.org> | 2013-12-18 09:53:59 +0100 |
---|---|---|
committer | David Faure <faure@kde.org> | 2013-12-18 09:53:59 +0100 |
commit | 159963832457e6307282308455330acc7b5bd153 (patch) | |
tree | ce1cc0234d37e9afc75bc86d734beb963ed57d02 /autotests | |
parent | 867e7a50e6396338ab4fe9aa22ad141e4cd344d2 (diff) | |
download | kconfig-159963832457e6307282308455330acc7b5bd153.tar.gz kconfig-159963832457e6307282308455330acc7b5bd153.tar.bz2 |
Code reformatted using kde-dev-scripts/astyle-kdelibs.
Use git blame -w 867e7a5 to show authorship as it was before this commit.
Diffstat (limited to 'autotests')
33 files changed, 1217 insertions, 1229 deletions
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index a9bf52c8..48192f5e 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -25,32 +25,30 @@ // QT5 TODO QTEST_GUILESS_MAIN(KConfigCompiler_Test) QTEST_MAIN(KConfigCompiler_Test) -typedef const char * CompilerTestSet[]; - -static CompilerTestSet testCases = -{ - "test1.cpp", "test1.h", - "test2.cpp", "test2.h", - "test3.cpp", "test3.h", - "test3a.cpp", "test3a.h", - "test4.cpp", "test4.h", - "test5.cpp", "test5.h", - "test6.cpp", "test6.h", - "test7.cpp", "test7.h", - "test8a.cpp", "test8a.h", - "test8b.cpp", "test8b.h", - "test9.h", "test9.cpp", - "test10.h", "test10.cpp", - "test11.h", "test11.cpp", - "test11a.h", "test11a.cpp", - "test12.h", "test12.cpp", - "test_dpointer.cpp", "test_dpointer.h", - "test_signal.cpp", "test_signal.h", - NULL +typedef const char *CompilerTestSet[]; + +static CompilerTestSet testCases = { + "test1.cpp", "test1.h", + "test2.cpp", "test2.h", + "test3.cpp", "test3.h", + "test3a.cpp", "test3a.h", + "test4.cpp", "test4.h", + "test5.cpp", "test5.h", + "test6.cpp", "test6.h", + "test7.cpp", "test7.h", + "test8a.cpp", "test8a.h", + "test8b.cpp", "test8b.h", + "test9.h", "test9.cpp", + "test10.h", "test10.cpp", + "test11.h", "test11.cpp", + "test11a.h", "test11a.cpp", + "test12.h", "test12.cpp", + "test_dpointer.cpp", "test_dpointer.h", + "test_signal.cpp", "test_signal.h", + NULL }; -static CompilerTestSet testCasesToRun = -{ +static CompilerTestSet testCasesToRun = { "test1", "test2", "test3", @@ -70,11 +68,10 @@ static CompilerTestSet testCasesToRun = }; #if 0 -static CompilerTestSet willFailCases = -{ - // where is that QDir coming from? - //"test9.cpp", NULL - NULL +static CompilerTestSet willFailCases = { + // where is that QDir coming from? + //"test9.cpp", NULL + NULL }; #endif @@ -153,7 +150,6 @@ void KConfigCompiler_Test::testRunning() QCOMPARE(process.exitCode(), 0); } - void KConfigCompiler_Test::appendFileDiff(const QString &oldFile, const QString &newFile) { if (m_diffExe.isEmpty()) { diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.h b/autotests/kconfig_compiler/kconfigcompiler_test.h index 53ad18a0..940044a8 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.h +++ b/autotests/kconfig_compiler/kconfigcompiler_test.h @@ -24,7 +24,7 @@ class QString; class KConfigCompiler_Test : public QObject { - Q_OBJECT + Q_OBJECT private Q_SLOTS: void initTestCase(); void testBaselineComparison_data(); diff --git a/autotests/kconfig_compiler/myprefs.h b/autotests/kconfig_compiler/myprefs.h index 4d12eeb7..609fc546 100644 --- a/autotests/kconfig_compiler/myprefs.h +++ b/autotests/kconfig_compiler/myprefs.h @@ -5,8 +5,8 @@ class MyPrefs : public KConfigSkeleton { - public: - MyPrefs( const QString &a ) : KConfigSkeleton( a ) {} +public: + MyPrefs(const QString &a) : KConfigSkeleton(a) {} }; #endif diff --git a/autotests/kconfig_compiler/test10main.cpp b/autotests/kconfig_compiler/test10main.cpp index 9e9a7db8..6dccda1b 100644 --- a/autotests/kconfig_compiler/test10main.cpp +++ b/autotests/kconfig_compiler/test10main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test10.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test10 *t = Test10::self(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test10 *t = Test10::self(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test11main.cpp b/autotests/kconfig_compiler/test11main.cpp index 4f5fc80c..339ecc71 100644 --- a/autotests/kconfig_compiler/test11main.cpp +++ b/autotests/kconfig_compiler/test11main.cpp @@ -22,13 +22,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test11a.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test11 *t = new Test11(); - Test11a *t2 = new Test11a(); - delete t; - delete t2; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test11 *t = new Test11(); + Test11a *t2 = new Test11a(); + delete t; + delete t2; + return 0; } diff --git a/autotests/kconfig_compiler/test12main.cpp b/autotests/kconfig_compiler/test12main.cpp index b8a05294..9c049f1b 100644 --- a/autotests/kconfig_compiler/test12main.cpp +++ b/autotests/kconfig_compiler/test12main.cpp @@ -20,9 +20,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "test12.h" -int main( int, char** ) +int main(int, char **) { - Test12 *t = new Test12(); - delete t; - return 0; + Test12 *t = new Test12(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test1main.cpp b/autotests/kconfig_compiler/test1main.cpp index f1f61c0a..d7dc038d 100644 --- a/autotests/kconfig_compiler/test1main.cpp +++ b/autotests/kconfig_compiler/test1main.cpp @@ -21,11 +21,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test1.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test1 *t = new Test1( QString(), QString() ); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test1 *t = new Test1(QString(), QString()); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test2main.cpp b/autotests/kconfig_compiler/test2main.cpp index 80203c65..a70241f7 100644 --- a/autotests/kconfig_compiler/test2main.cpp +++ b/autotests/kconfig_compiler/test2main.cpp @@ -21,11 +21,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test2.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test2 *t = new Test2(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test2 *t = new Test2(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test3amain.cpp b/autotests/kconfig_compiler/test3amain.cpp index fa33f1cb..e08bf7ac 100644 --- a/autotests/kconfig_compiler/test3amain.cpp +++ b/autotests/kconfig_compiler/test3amain.cpp @@ -21,11 +21,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test3a.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - TestNameSpace::InnerNameSpace::Test3a *t = new TestNameSpace::InnerNameSpace::Test3a(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + TestNameSpace::InnerNameSpace::Test3a *t = new TestNameSpace::InnerNameSpace::Test3a(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test3main.cpp b/autotests/kconfig_compiler/test3main.cpp index bf2846c1..82680bf8 100644 --- a/autotests/kconfig_compiler/test3main.cpp +++ b/autotests/kconfig_compiler/test3main.cpp @@ -21,11 +21,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test3.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - TestNameSpace::Test3 *t = new TestNameSpace::Test3(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + TestNameSpace::Test3 *t = new TestNameSpace::Test3(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp index 3ef924c8..8f1c1ec8 100644 --- a/autotests/kconfig_compiler/test4main.cpp +++ b/autotests/kconfig_compiler/test4main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test4.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test4 *t = Test4::self(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test4 *t = Test4::self(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test5main.cpp b/autotests/kconfig_compiler/test5main.cpp index 55e30d07..95ed498b 100644 --- a/autotests/kconfig_compiler/test5main.cpp +++ b/autotests/kconfig_compiler/test5main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test5.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test5 *t = Test5::self(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test5 *t = Test5::self(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test6main.cpp b/autotests/kconfig_compiler/test6main.cpp index a60d8378..48932475 100644 --- a/autotests/kconfig_compiler/test6main.cpp +++ b/autotests/kconfig_compiler/test6main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test6.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test6 *t = new Test6(QString()); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test6 *t = new Test6(QString()); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test7main.cpp b/autotests/kconfig_compiler/test7main.cpp index bf55be20..16fee863 100644 --- a/autotests/kconfig_compiler/test7main.cpp +++ b/autotests/kconfig_compiler/test7main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test7.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test7 *t = new Test7(42); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test7 *t = new Test7(42); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test8main.cpp b/autotests/kconfig_compiler/test8main.cpp index c4576911..b8fcc492 100644 --- a/autotests/kconfig_compiler/test8main.cpp +++ b/autotests/kconfig_compiler/test8main.cpp @@ -23,14 +23,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test8b.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test8a *config1 = new Test8a( KSharedConfig::openConfig( QString() ) ); - Test8a *config2 = new Test8a(); - Test8b::self(); - delete config1; - delete config2; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test8a *config1 = new Test8a(KSharedConfig::openConfig(QString())); + Test8a *config2 = new Test8a(); + Test8b::self(); + delete config1; + delete config2; + return 0; } diff --git a/autotests/kconfig_compiler/test9main.cpp b/autotests/kconfig_compiler/test9main.cpp index 352613aa..28205ee5 100644 --- a/autotests/kconfig_compiler/test9main.cpp +++ b/autotests/kconfig_compiler/test9main.cpp @@ -23,23 +23,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <QGuiApplication> #include <QDebug> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - Test9 *t = new Test9( QString(), QString() ); + QGuiApplication app(argc, argv); + Q_UNUSED(app); + Test9 *t = new Test9(QString(), QString()); - QStringList myPathsList2 = t->myPathsList2(); - qWarning() << myPathsList2; + QStringList myPathsList2 = t->myPathsList2(); + qWarning() << myPathsList2; - // add another path - QStringList newlist; - myPathsList2 << QDir::homePath() + QString::fromLatin1("/.kde"); - qWarning() << myPathsList2; + // add another path + QStringList newlist; + myPathsList2 << QDir::homePath() + QString::fromLatin1("/.kde"); + qWarning() << myPathsList2; - t->setMyPathsList2(myPathsList2); - qWarning() << t->myPathsList2(); + t->setMyPathsList2(myPathsList2); + qWarning() << t->myPathsList2(); - delete t; - return 0; + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test_dpointer_main.cpp b/autotests/kconfig_compiler/test_dpointer_main.cpp index 6e4cb806..884b1e1b 100644 --- a/autotests/kconfig_compiler/test_dpointer_main.cpp +++ b/autotests/kconfig_compiler/test_dpointer_main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test_dpointer.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - TestDPointer *t = TestDPointer::self(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + TestDPointer *t = TestDPointer::self(); + delete t; + return 0; } diff --git a/autotests/kconfig_compiler/test_signal_main.cpp b/autotests/kconfig_compiler/test_signal_main.cpp index 3189e79a..09e23ed5 100644 --- a/autotests/kconfig_compiler/test_signal_main.cpp +++ b/autotests/kconfig_compiler/test_signal_main.cpp @@ -22,11 +22,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "test_signal.h" #include <QGuiApplication> -int main( int argc, char **argv ) +int main(int argc, char **argv) { - QGuiApplication app(argc, argv); - Q_UNUSED(app); - TestSignal *t = TestSignal::self(); - delete t; - return 0; + QGuiApplication app(argc, argv); + Q_UNUSED(app); + TestSignal *t = TestSignal::self(); + delete t; + return 0; } diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp index 225f1719..5d715d98 100644 --- a/autotests/kconfigguitest.cpp +++ b/autotests/kconfigguitest.cpp @@ -26,7 +26,7 @@ #include <kconfiggroup.h> #include <kconfigskeleton.h> -QTEST_MAIN( KConfigTest ) +QTEST_MAIN(KConfigTest) #define COLORENTRY1 QColor("steelblue") #define COLORENTRY2 QColor(235, 235, 100, 125) @@ -35,111 +35,112 @@ QTEST_MAIN( KConfigTest ) void KConfigTest::initTestCase() { - // cheat the linker on windows to link against kconfiggui - KConfigSkeleton foo; - Q_UNUSED(foo); - - KConfig sc( "kconfigtest" ); - - KConfigGroup cg(&sc, "ComplexTypes"); - cg.writeEntry( "colorEntry1", COLORENTRY1 ); - cg.writeEntry( "colorEntry2", COLORENTRY2 ); - cg.writeEntry( "colorEntry3", (QList<int>() << 234 << 234 << 127)); - cg.writeEntry( "colorEntry4", (QList<int>() << 235 << 235 << 100 << 125)); - cg.writeEntry( "fontEntry", FONTENTRY ); - QVERIFY(sc.sync()); - - KConfig sc1("kdebugrc"); - KConfigGroup sg0(&sc1, "0"); - sg0.writeEntry("AbortFatal", false); - sg0.writeEntry("WarnOutput", 0); - sg0.writeEntry("FatalOutput", 0); - QVERIFY(sc1.sync()); + // cheat the linker on windows to link against kconfiggui + KConfigSkeleton foo; + Q_UNUSED(foo); + + KConfig sc("kconfigtest"); + + KConfigGroup cg(&sc, "ComplexTypes"); + cg.writeEntry("colorEntry1", COLORENTRY1); + cg.writeEntry("colorEntry2", COLORENTRY2); + cg.writeEntry("colorEntry3", (QList<int>() << 234 << 234 << 127)); + cg.writeEntry("colorEntry4", (QList<int>() << 235 << 235 << 100 << 125)); + cg.writeEntry("fontEntry", FONTENTRY); + QVERIFY(sc.sync()); + + KConfig sc1("kdebugrc"); + KConfigGroup sg0(&sc1, "0"); + sg0.writeEntry("AbortFatal", false); + sg0.writeEntry("WarnOutput", 0); + sg0.writeEntry("FatalOutput", 0); + QVERIFY(sc1.sync()); } void KConfigTest::cleanupTestCase() { - QDir local(QDir::homePath() + "/.kde-unit-test/share/config"); + QDir local(QDir::homePath() + "/.kde-unit-test/share/config"); - Q_FOREACH(const QString &file, local.entryList(QDir::Files)) - if(!local.remove(file)) - qWarning("%s: removing failed", qPrintable( file )); + Q_FOREACH (const QString &file, local.entryList(QDir::Files)) + if (!local.remove(file)) { + qWarning("%s: removing failed", qPrintable(file)); + } - QCOMPARE((int)local.entryList(QDir::Files).count(), 0); + QCOMPARE((int)local.entryList(QDir::Files).count(), 0); - local.cdUp(); - local.rmpath("config"); + local.cdUp(); + local.rmpath("config"); } void KConfigTest::testComplex() { - KConfig sc2( "kconfigtest" ); - KConfigGroup sc3(&sc2, "ComplexTypes"); - - QCOMPARE( QVariant(sc3.readEntry( "colorEntry1", QColor(Qt::black) )).toString(), - QVariant(COLORENTRY1).toString() ); - QCOMPARE( sc3.readEntry( "colorEntry1", QColor() ), COLORENTRY1 ); - QCOMPARE( sc3.readEntry( "colorEntry2", QColor() ), COLORENTRY2 ); - QCOMPARE( sc3.readEntry( "colorEntry3", QColor() ), COLORENTRY3 ); - QCOMPARE( sc3.readEntry( "colorEntry4", QColor() ), COLORENTRY2 ); - QCOMPARE( sc3.readEntry( "defaultColorTest", QColor("black") ), QColor("black") ); - QCOMPARE( sc3.readEntry( "fontEntry", QFont() ), FONTENTRY ); + KConfig sc2("kconfigtest"); + KConfigGroup sc3(&sc2, "ComplexTypes"); + + QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(), + QVariant(COLORENTRY1).toString()); + QCOMPARE(sc3.readEntry("colorEntry1", QColor()), COLORENTRY1); + QCOMPARE(sc3.readEntry("colorEntry2", QColor()), COLORENTRY2); + QCOMPARE(sc3.readEntry("colorEntry3", QColor()), COLORENTRY3); + QCOMPARE(sc3.readEntry("colorEntry4", QColor()), COLORENTRY2); + QCOMPARE(sc3.readEntry("defaultColorTest", QColor("black")), QColor("black")); + QCOMPARE(sc3.readEntry("fontEntry", QFont()), FONTENTRY); } void KConfigTest::testInvalid() { - KConfig sc( "kconfigtest" ); + KConfig sc("kconfigtest"); - // all of these should print a message to the kdebug.dbg file - KConfigGroup sc3(&sc, "InvalidTypes" ); + // all of these should print a message to the kdebug.dbg file + KConfigGroup sc3(&sc, "InvalidTypes"); - QList<int> list; + QList<int> list; - // 1 element list - list << 1; - sc3.writeEntry( QString("badList"), list); - QVERIFY(sc.sync()); + // 1 element list + list << 1; + sc3.writeEntry(QString("badList"), list); + QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); - // 2 element list - list << 2; - sc3.writeEntry( "badList", list); - QVERIFY(sc.sync()); + // 2 element list + list << 2; + sc3.writeEntry("badList", list); + QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); - // 3 element list - list << 303; - sc3.writeEntry( "badList", list); - QVERIFY(sc.sync()); + // 3 element list + list << 303; + sc3.writeEntry("badList", list); + QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); // out of bounds + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds - // 4 element list - list << 4; - sc3.writeEntry( "badList", list ); - QVERIFY(sc.sync()); + // 4 element list + list << 4; + sc3.writeEntry("badList", list); + QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); // out of bounds + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds - list[2] = -3; - sc3.writeEntry( "badList", list ); - QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); // out of bounds + list[2] = -3; + sc3.writeEntry("badList", list); + QVERIFY(sc.sync()); + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds - // 5 element list - list[2] = 3; - list << 5; - sc3.writeEntry( "badList", list); - QVERIFY(sc.sync()); + // 5 element list + list[2] = 3; + list << 5; + sc3.writeEntry("badList", list); + QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); - // 6 element list - list << 6; - sc3.writeEntry( "badList", list); - QVERIFY(sc.sync()); + // 6 element list + list << 6; + sc3.writeEntry("badList", list); + QVERIFY(sc.sync()); - QVERIFY( sc3.readEntry( "badList", QColor() ) == QColor() ); + QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); } diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp index a4403da9..451d636e 100644 --- a/autotests/kconfigloadertest.cpp +++ b/autotests/kconfigloadertest.cpp @@ -51,70 +51,70 @@ void ConfigLoaderTest::cleanup() void ConfigLoaderTest::boolDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool*, "DefaultBoolItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemBool *, "DefaultBoolItem"); QVERIFY(typeItem->isEqual(true)); } void ConfigLoaderTest::colorDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor*, "DefaultColorItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemColor *, "DefaultColorItem"); QVERIFY(typeItem->isEqual(QColor("#00FF00"))); } void ConfigLoaderTest::dateTimeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime*, "DefaultDateTimeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDateTime *, "DefaultDateTimeItem"); QVERIFY(typeItem->isEqual(QDateTime::fromString("Thu Sep 09 2010"))); } void ConfigLoaderTest::enumDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum*, "DefaultEnumItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemEnum *, "DefaultEnumItem"); QVERIFY(typeItem->isEqual(3)); } void ConfigLoaderTest::fontDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont*, "DefaultFontItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemFont *, "DefaultFontItem"); QVERIFY(typeItem->isEqual(QFont("DejaVu Sans"))); } void ConfigLoaderTest::intDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt*, "DefaultIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemInt *, "DefaultIntItem"); QVERIFY(typeItem->isEqual(27)); } void ConfigLoaderTest::passwordDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword*, "DefaultPasswordItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPassword *, "DefaultPasswordItem"); QVERIFY(typeItem->isEqual(QString::fromLatin1("h4x."))); } void ConfigLoaderTest::pathDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath*, "DefaultPathItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemPath *, "DefaultPathItem"); QVERIFY(typeItem->isEqual(QString::fromLatin1("/dev/null"))); } void ConfigLoaderTest::stringDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString*, "DefaultStringItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemString *, "DefaultStringItem"); QVERIFY(typeItem->isEqual(QString::fromLatin1("TestString"))); } void ConfigLoaderTest::stringListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList*, "DefaultStringListItem"); + GET_CONFIG_ITEM_VALUE(KConfigSkeleton::ItemStringList *, "DefaultStringListItem"); // Create a string list with the expected values. QStringList expected; @@ -129,28 +129,28 @@ void ConfigLoaderTest::stringListDefaultValue() void ConfigLoaderTest::uintDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt*, "DefaultUIntItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUInt *, "DefaultUIntItem"); QVERIFY(typeItem->isEqual(7U)); } void ConfigLoaderTest::urlDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl*, "DefaultUrlItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemUrl *, "DefaultUrlItem"); QVERIFY(typeItem->isEqual(QUrl("http://kde.org"))); } void ConfigLoaderTest::doubleDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble*, "DefaultDoubleItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemDouble *, "DefaultDoubleItem"); QVERIFY(typeItem->isEqual(13.37)); } void ConfigLoaderTest::intListDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList*, "DefaultIntListItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemIntList *, "DefaultIntListItem"); // Create a int list with the expected values. QList<int> expected; @@ -166,21 +166,21 @@ void ConfigLoaderTest::intListDefaultValue() void ConfigLoaderTest::longLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong*, "DefaultLongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemLongLong *, "DefaultLongLongItem"); QVERIFY(typeItem->isEqual(Q_INT64_C(-9211372036854775808))); } void ConfigLoaderTest::pointDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint*, "DefaultPointItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemPoint *, "DefaultPointItem"); QVERIFY(typeItem->isEqual(QPoint(185, 857))); } void ConfigLoaderTest::rectDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect*, "DefaultRectItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemRect *, "DefaultRectItem"); // Create a new QRect with the expected value. QRect expected; @@ -191,18 +191,17 @@ void ConfigLoaderTest::rectDefaultValue() void ConfigLoaderTest::sizeDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize*, "DefaultSizeItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemSize *, "DefaultSizeItem"); QVERIFY(typeItem->isEqual(QSize(640, 480))); } void ConfigLoaderTest::ulongLongDefaultValue() { - GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong*, "DefaultULongLongItem"); + GET_CONFIG_ITEM_VALUE(KCoreConfigSkeleton::ItemULongLong *, "DefaultULongLongItem"); QVERIFY(typeItem->isEqual(Q_UINT64_C(9223372036854775806))); } - QTEST_MAIN(ConfigLoaderTest) diff --git a/autotests/kconfigloadertest.h b/autotests/kconfigloadertest.h index be8c7629..b7e7edf6 100644 --- a/autotests/kconfigloadertest.h +++ b/autotests/kconfigloadertest.h @@ -56,8 +56,8 @@ private Q_SLOTS: void ulongLongDefaultValue(); private: - KConfigLoader* cl; - QFile* configFile; + KConfigLoader *cl; + QFile *configFile; }; #endif diff --git a/autotests/kconfignokdehometest.cpp b/autotests/kconfignokdehometest.cpp index 0c7d8265..4ee17635 100644 --- a/autotests/kconfignokdehometest.cpp +++ b/autotests/kconfignokdehometest.cpp @@ -34,7 +34,6 @@ private Q_SLOTS: void testNoKdeHome(); }; - void KConfigNoKdeHomeTest::testNoKdeHome() { QStandardPaths::setTestModeEnabled(true); diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp index d3b30e84..31278e76 100644 --- a/autotests/kconfigskeletontest.cpp +++ b/autotests/kconfigskeletontest.cpp @@ -23,9 +23,7 @@ #include <QFont> #include <QtTest/QtTestGui> - -QTEST_MAIN( KConfigSkeletonTest) - +QTEST_MAIN(KConfigSkeletonTest) #define DEFAULT_SETTING1 false #define DEFAULT_SETTING2 QColor(1,2,3) @@ -60,14 +58,14 @@ void KConfigSkeletonTest::testSimple() mMyFont = WRITE_SETTING3; mMyString = WRITE_SETTING4; - writeConfig (); + writeConfig(); mMyBool = false; mMyColor = QColor(); mMyString.clear(); mMyFont = QFont(); - readConfig (); + readConfig(); QCOMPARE(mMyBool, WRITE_SETTING1); QCOMPARE(mMyColor, WRITE_SETTING2); @@ -98,7 +96,7 @@ void KConfigSkeletonTest::testClear() void KConfigSkeletonTest::testDefaults() { - setDefaults (); + setDefaults(); QCOMPARE(mMyBool, DEFAULT_SETTING1); QCOMPARE(mMyColor, DEFAULT_SETTING2); @@ -108,4 +106,3 @@ void KConfigSkeletonTest::testDefaults() writeConfig(); } - diff --git a/autotests/kconfigskeletontest.h b/autotests/kconfigskeletontest.h index f65739dc..c54c7b07 100644 --- a/autotests/kconfigskeletontest.h +++ b/autotests/kconfigskeletontest.h @@ -24,7 +24,7 @@ class KConfigSkeletonTest : public KConfigSkeleton { Q_OBJECT - public: +public: private Q_SLOTS: void initTestCase(); @@ -34,10 +34,10 @@ private Q_SLOTS: void testClear(); private: - bool mMyBool; - QColor mMyColor; - QFont mMyFont; - QString mMyString; + bool mMyBool; + QColor mMyColor; + QFont mMyFont; + QString mMyString; }; diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 1aed5151..1c0dc1cf 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -37,10 +37,10 @@ #include <unistd.h> // gethostname #endif -KCONFIGGROUP_DECLARE_ENUM_QOBJECT(KConfigTest,Testing) -KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(KConfigTest,Flags) +KCONFIGGROUP_DECLARE_ENUM_QOBJECT(KConfigTest, Testing) +KCONFIGGROUP_DECLARE_FLAGS_QOBJECT(KConfigTest, Flags) -QTEST_MAIN( KConfigTest ) +QTEST_MAIN(KConfigTest) #define BOOLENTRY1 true #define BOOLENTRY2 false @@ -78,135 +78,133 @@ QTEST_MAIN( KConfigTest ) void KConfigTest::initTestCase() { - // ensure we don't use files in the real config directory - QStandardPaths::setTestModeEnabled(true); - QString testConfigDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); - - // to make sure all files from a previous failed run are deleted - cleanupTestCase(); - - - KConfig sc( "kconfigtest" ); - - KConfigGroup cg(&sc, "AAA"); - cg.writeEntry("stringEntry1", STRINGENTRY1, - KConfig::Persistent|KConfig::Global); - cg.deleteEntry("stringEntry2", KConfig::Global); - - cg = KConfigGroup(&sc, "Hello"); - cg.writeEntry( "boolEntry1", BOOLENTRY1 ); - cg.writeEntry( "boolEntry2", BOOLENTRY2 ); - - QByteArray data( UTF8BITENTRY ); - QCOMPARE( data.size(), 12 ); // the source file is in utf8 - QCOMPARE( QString::fromUtf8(data).length(), 9 ); - cg.writeEntry ("Test", data); - cg.writeEntry( "bytearrayEntry", BYTEARRAYENTRY ); - cg.writeEntry( ESCAPEKEY, ESCAPEENTRY ); - cg.writeEntry( "emptyEntry", ""); - cg.writeEntry( "stringEntry1", STRINGENTRY1 ); - cg.writeEntry( "stringEntry2", STRINGENTRY2 ); - cg.writeEntry( "stringEntry3", STRINGENTRY3 ); - cg.writeEntry( "stringEntry4", STRINGENTRY4 ); - cg.writeEntry( "stringEntry5", STRINGENTRY5 ); - cg.writeEntry( "urlEntry1", QUrl("http://qt-project.org") ); - cg.writeEntry( "keywith=equalsign", STRINGENTRY1 ); - cg.deleteEntry( "stringEntry5" ); - cg.deleteEntry( "stringEntry6" ); // deleting a nonexistent entry - cg.writeEntry( "byteArrayEntry1", QByteArray( STRINGENTRY1 ), - KConfig::Global|KConfig::Persistent ); - cg.writeEntry( "doubleEntry1", DOUBLEENTRY ); - cg.writeEntry( "floatEntry1", FLOATENTRY ); - - sc.deleteGroup("deleteMe"); // deleting a nonexistent group - - cg = KConfigGroup(&sc, "Complex Types"); - cg.writeEntry( "rectEntry", RECTENTRY ); - cg.writeEntry( "pointEntry", POINTENTRY ); - cg.writeEntry( "sizeEntry", SIZEENTRY ); - cg.writeEntry( "dateTimeEntry", DATETIMEENTRY ); - cg.writeEntry( "dateEntry", DATETIMEENTRY.date() ); - - KConfigGroup ct = cg; - cg = KConfigGroup(&ct, "Nested Group 1"); - cg.writeEntry("stringentry1", STRINGENTRY1); - - cg = KConfigGroup(&ct, "Nested Group 2"); - cg.writeEntry( "stringEntry2", STRINGENTRY2 ); - - cg = KConfigGroup(&cg, "Nested Group 2.1"); - cg.writeEntry( "stringEntry3", STRINGENTRY3 ); - - cg = KConfigGroup(&ct, "Nested Group 3"); - cg.writeEntry( "stringEntry3", STRINGENTRY3 ); - - cg = KConfigGroup(&sc, "List Types" ); - cg.writeEntry( "listOfIntsEntry1", INTLISTENTRY1 ); - cg.writeEntry( "listOfByteArraysEntry1", BYTEARRAYLISTENTRY1 ); - cg.writeEntry( "stringListEntry", STRINGLISTENTRY ); - cg.writeEntry( "stringListEmptyEntry", STRINGLISTEMPTYENTRY ); - cg.writeEntry( "stringListJustEmptyElement", STRINGLISTJUSTEMPTYELEMENT ); - cg.writeEntry( "stringListEmptyTrailingElement", STRINGLISTEMPTYTRAINLINGELEMENT ); - cg.writeEntry( "stringListEscapeOddEntry", STRINGLISTESCAPEODDENTRY ); - cg.writeEntry( "stringListEscapeEvenEntry", STRINGLISTESCAPEEVENENTRY ); - cg.writeEntry( "stringListEscapeCommaEntry", STRINGLISTESCAPECOMMAENTRY ); - cg.writeEntry( "variantListEntry", VARIANTLISTENTRY ); - - cg = KConfigGroup(&sc, "Path Type" ); - cg.writePathEntry( "homepath", HOMEPATH ); - cg.writePathEntry( "homepathescape", HOMEPATHESCAPE ); - - cg = KConfigGroup(&sc, "Enum Types" ); - writeEntry( cg, "enum-10", Tens ); - writeEntry( cg, "enum-100", Hundreds ); - writeEntry( cg, "flags-bit0", Flags(bit0)); - writeEntry( cg, "flags-bit0-bit1", Flags(bit0|bit1) ); - - cg = KConfigGroup(&sc, "ParentGroup" ); - KConfigGroup cg1(&cg, "SubGroup1" ); - cg1.writeEntry( "somestring", "somevalue" ); - cg.writeEntry( "parentgrpstring", "somevalue" ); - KConfigGroup cg2(&cg, "SubGroup2" ); - cg2.writeEntry( "substring", "somevalue" ); - KConfigGroup cg3(&cg, "SubGroup/3"); - cg3.writeEntry( "sub3string", "somevalue" ); - - QVERIFY(sc.isDirty()); - QVERIFY(sc.sync()); - QVERIFY(!sc.isDirty()); - - QVERIFY2(QFile::exists(testConfigDir + QStringLiteral("/kconfigtest")), - qPrintable(testConfigDir + QStringLiteral("/kconfigtest must exist"))); - QVERIFY2(QFile::exists(testConfigDir + QStringLiteral("/kdeglobals")), - qPrintable(testConfigDir + QStringLiteral("/kdeglobals must exist"))); - - - KConfig sc1("kdebugrc", KConfig::SimpleConfig); - KConfigGroup sg0(&sc1, "0"); - sg0.writeEntry("AbortFatal", false); - sg0.writeEntry("WarnOutput", 0); - sg0.writeEntry("FatalOutput", 0); - QVERIFY(sc1.sync()); - - //Setup stuff to test KConfig::addConfigSources() - KConfig devcfg("specificrc"); - KConfigGroup devonlygrp(&devcfg, "Specific Only Group"); - devonlygrp.writeEntry("ExistingEntry", "DevValue"); - KConfigGroup devandbasegrp(&devcfg, "Shared Group"); - devandbasegrp.writeEntry("SomeSharedEntry", "DevValue"); - devandbasegrp.writeEntry("SomeSpecificOnlyEntry", "DevValue"); - QVERIFY(devcfg.sync()); - KConfig basecfg("baserc"); - KConfigGroup basegrp(&basecfg, "Base Only Group"); - basegrp.writeEntry("ExistingEntry", "BaseValue"); - KConfigGroup baseanddevgrp(&basecfg, "Shared Group"); - baseanddevgrp.writeEntry("SomeSharedEntry", "BaseValue"); - baseanddevgrp.writeEntry("SomeBaseOnlyEntry", "BaseValue"); - QVERIFY(basecfg.sync()); - - KConfig gecfg("groupescapetest", KConfig::SimpleConfig); - cg = KConfigGroup(&gecfg, DOLLARGROUP); - cg.writeEntry( "entry", "doesntmatter" ); + // ensure we don't use files in the real config directory + QStandardPaths::setTestModeEnabled(true); + QString testConfigDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation); + + // to make sure all files from a previous failed run are deleted + cleanupTestCase(); + + KConfig sc("kconfigtest"); + + KConfigGroup cg(&sc, "AAA"); + cg.writeEntry("stringEntry1", STRINGENTRY1, + KConfig::Persistent | KConfig::Global); + cg.deleteEntry("stringEntry2", KConfig::Global); + + cg = KConfigGroup(&sc, "Hello"); + cg.writeEntry("boolEntry1", BOOLENTRY1); + cg.writeEntry("boolEntry2", BOOLENTRY2); + + QByteArray data(UTF8BITENTRY); + QCOMPARE(data.size(), 12); // the source file is in utf8 + QCOMPARE(QString::fromUtf8(data).length(), 9); + cg.writeEntry("Test", data); + cg.writeEntry("bytearrayEntry", BYTEARRAYENTRY); + cg.writeEntry(ESCAPEKEY, ESCAPEENTRY); + cg.writeEntry("emptyEntry", ""); + cg.writeEntry("stringEntry1", STRINGENTRY1); + cg.writeEntry("stringEntry2", STRINGENTRY2); + cg.writeEntry("stringEntry3", STRINGENTRY3); + cg.writeEntry("stringEntry4", STRINGENTRY4); + cg.writeEntry("stringEntry5", STRINGENTRY5); + cg.writeEntry("urlEntry1", QUrl("http://qt-project.org")); + cg.writeEntry("keywith=equalsign", STRINGENTRY1); + cg.deleteEntry("stringEntry5"); + cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry + cg.writeEntry("byteArrayEntry1", QByteArray(STRINGENTRY1), + KConfig::Global | KConfig::Persistent); + cg.writeEntry("doubleEntry1", DOUBLEENTRY); + cg.writeEntry("floatEntry1", FLOATENTRY); + + sc.deleteGroup("deleteMe"); // deleting a nonexistent group + + cg = KConfigGroup(&sc, "Complex Types"); + cg.writeEntry("rectEntry", RECTENTRY); + cg.writeEntry("pointEntry", POINTENTRY); + cg.writeEntry("sizeEntry", SIZEENTRY); + cg.writeEntry("dateTimeEntry", DATETIMEENTRY); + cg.writeEntry("dateEntry", DATETIMEENTRY.date()); + + KConfigGroup ct = cg; + cg = KConfigGroup(&ct, "Nested Group 1"); + cg.writeEntry("stringentry1", STRINGENTRY1); + + cg = KConfigGroup(&ct, "Nested Group 2"); + cg.writeEntry("stringEntry2", STRINGENTRY2); + + cg = KConfigGroup(&cg, "Nested Group 2.1"); + cg.writeEntry("stringEntry3", STRINGENTRY3); + + cg = KConfigGroup(&ct, "Nested Group 3"); + cg.writeEntry("stringEntry3", STRINGENTRY3); + + cg = KConfigGroup(&sc, "List Types"); + cg.writeEntry("listOfIntsEntry1", INTLISTENTRY1); + cg.writeEntry("listOfByteArraysEntry1", BYTEARRAYLISTENTRY1); + cg.writeEntry("stringListEntry", STRINGLISTENTRY); + cg.writeEntry("stringListEmptyEntry", STRINGLISTEMPTYENTRY); + cg.writeEntry("stringListJustEmptyElement", STRINGLISTJUSTEMPTYELEMENT); + cg.writeEntry("stringListEmptyTrailingElement", STRINGLISTEMPTYTRAINLINGELEMENT); + cg.writeEntry("stringListEscapeOddEntry", STRINGLISTESCAPEODDENTRY); + cg.writeEntry("stringListEscapeEvenEntry", STRINGLISTESCAPEEVENENTRY); + cg.writeEntry("stringListEscapeCommaEntry", STRINGLISTESCAPECOMMAENTRY); + cg.writeEntry("variantListEntry", VARIANTLISTENTRY); + + cg = KConfigGroup(&sc, "Path Type"); + cg.writePathEntry("homepath", HOMEPATH); + cg.writePathEntry("homepathescape", HOMEPATHESCAPE); + + cg = KConfigGroup(&sc, "Enum Types"); + writeEntry(cg, "enum-10", Tens); + writeEntry(cg, "enum-100", Hundreds); + writeEntry(cg, "flags-bit0", Flags(bit0)); + writeEntry(cg, "flags-bit0-bit1", Flags(bit0 | bit1)); + + cg = KConfigGroup(&sc, "ParentGroup"); + KConfigGroup cg1(&cg, "SubGroup1"); + cg1.writeEntry("somestring", "somevalue"); + cg.writeEntry("parentgrpstring", "somevalue"); + KConfigGroup cg2(&cg, "SubGroup2"); + cg2.writeEntry("substring", "somevalue"); + KConfigGroup cg3(&cg, "SubGroup/3"); + cg3.writeEntry("sub3string", "somevalue"); + + QVERIFY(sc.isDirty()); + QVERIFY(sc.sync()); + QVERIFY(!sc.isDirty()); + + QVERIFY2(QFile::exists(testConfigDir + QStringLiteral("/kconfigtest")), + qPrintable(testConfigDir + QStringLiteral("/kconfigtest must exist"))); + QVERIFY2(QFile::exists(testConfigDir + QStringLiteral("/kdeglobals")), + qPrintable(testConfigDir + QStringLiteral("/kdeglobals must exist"))); + + KConfig sc1("kdebugrc", KConfig::SimpleConfig); + KConfigGroup sg0(&sc1, "0"); + sg0.writeEntry("AbortFatal", false); + sg0.writeEntry("WarnOutput", 0); + sg0.writeEntry("FatalOutput", 0); + QVERIFY(sc1.sync()); + + //Setup stuff to test KConfig::addConfigSources() + KConfig devcfg("specificrc"); + KConfigGroup devonlygrp(&devcfg, "Specific Only Group"); + devonlygrp.writeEntry("ExistingEntry", "DevValue"); + KConfigGroup devandbasegrp(&devcfg, "Shared Group"); + devandbasegrp.writeEntry("SomeSharedEntry", "DevValue"); + devandbasegrp.writeEntry("SomeSpecificOnlyEntry", "DevValue"); + QVERIFY(devcfg.sync()); + KConfig basecfg("baserc"); + KConfigGroup basegrp(&basecfg, "Base Only Group"); + basegrp.writeEntry("ExistingEntry", "BaseValue"); + KConfigGroup baseanddevgrp(&basecfg, "Shared Group"); + baseanddevgrp.writeEntry("SomeSharedEntry", "BaseValue"); + baseanddevgrp.writeEntry("SomeBaseOnlyEntry", "BaseValue"); + QVERIFY(basecfg.sync()); + + KConfig gecfg("groupescapetest", KConfig::SimpleConfig); + cg = KConfigGroup(&gecfg, DOLLARGROUP); + cg.writeEntry("entry", "doesntmatter"); } @@ -220,24 +218,24 @@ void KConfigTest::cleanupTestCase() QVERIFY(!localConfig.exists()); } - -static QList<QByteArray> readLinesFrom(const QString& path) +static QList<QByteArray> readLinesFrom(const QString &path) { QFile file(path); - const bool opened = file.open(QIODevice::ReadOnly|QIODevice::Text); + const bool opened = file.open(QIODevice::ReadOnly | QIODevice::Text); Q_ASSERT(opened); Q_UNUSED(opened); QList<QByteArray> lines; QByteArray line; do { line = file.readLine(); - if (!line.isEmpty()) + if (!line.isEmpty()) { lines.append(line); - } while(!line.isEmpty()); + } + } while (!line.isEmpty()); return lines; } -static QList<QByteArray> readLines(const char* fileName = "kconfigtest") +static QList<QByteArray> readLines(const char *fileName = "kconfigtest") { const QString path = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + '/' + fileName; Q_ASSERT(!path.isEmpty()); @@ -247,23 +245,23 @@ static QList<QByteArray> readLines(const char* fileName = "kconfigtest") // see also testDefaults, which tests reverting with a defaults (global) file available void KConfigTest::testDirtyAfterRevert() { - KConfig sc( "kconfigtest_revert" ); - - KConfigGroup cg(&sc, "Hello"); - cg.revertToDefault( "does_not_exist" ); - QVERIFY(!sc.isDirty()); - cg.writeEntry("Test", "Correct"); - QVERIFY(sc.isDirty()); - sc.sync(); - QVERIFY(!sc.isDirty()); - - cg.revertToDefault("Test"); - QVERIFY(sc.isDirty()); - QVERIFY(sc.sync()); - QVERIFY(!sc.isDirty()); - - cg.revertToDefault("Test"); - QVERIFY(!sc.isDirty()); + KConfig sc("kconfigtest_revert"); + + KConfigGroup cg(&sc, "Hello"); + cg.revertToDefault("does_not_exist"); + QVERIFY(!sc.isDirty()); + cg.writeEntry("Test", "Correct"); + QVERIFY(sc.isDirty()); + sc.sync(); + QVERIFY(!sc.isDirty()); + + cg.revertToDefault("Test"); + QVERIFY(sc.isDirty()); + QVERIFY(sc.sync()); + QVERIFY(!sc.isDirty()); + + cg.revertToDefault("Test"); + QVERIFY(!sc.isDirty()); } void KConfigTest::testRevertAllEntries() @@ -271,21 +269,21 @@ void KConfigTest::testRevertAllEntries() // this tests the case were we revert (delete) all entries in a file, // leaving a blank file { - KConfig sc( "konfigtest2", KConfig::SimpleConfig ); - KConfigGroup cg( &sc, "Hello" ); - cg.writeEntry( "Test", "Correct" ); + KConfig sc("konfigtest2", KConfig::SimpleConfig); + KConfigGroup cg(&sc, "Hello"); + cg.writeEntry("Test", "Correct"); } { - KConfig sc( "konfigtest2", KConfig::SimpleConfig ); - KConfigGroup cg( &sc, "Hello" ); - QCOMPARE( cg.readEntry( "Test", "Default" ), QString("Correct") ); - cg.revertToDefault( "Test" ); + KConfig sc("konfigtest2", KConfig::SimpleConfig); + KConfigGroup cg(&sc, "Hello"); + QCOMPARE(cg.readEntry("Test", "Default"), QString("Correct")); + cg.revertToDefault("Test"); } - KConfig sc( "konfigtest2", KConfig::SimpleConfig ); - KConfigGroup cg( &sc, "Hello" ); - QCOMPARE( cg.readEntry( "Test", "Default" ), QString("Default") ); + KConfig sc("konfigtest2", KConfig::SimpleConfig); + KConfigGroup cg(&sc, "Hello"); + QCOMPARE(cg.readEntry("Test", "Default"), QString("Default")); } void KConfigTest::testSimple() @@ -294,49 +292,49 @@ void KConfigTest::testSimple() const QStringList kdeglobals = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QLatin1String("kdeglobals")); QVERIFY(!kdeglobals.isEmpty()); - KConfig sc2( "kconfigtest" ); - QCOMPARE(sc2.name(), QString("kconfigtest")); - - // make sure groupList() isn't returning something it shouldn't - Q_FOREACH(const QString& group, sc2.groupList()) { - QVERIFY(!group.isEmpty() && group != "<default>"); - QVERIFY(!group.contains(QChar(0x1d))); - } - - KConfigGroup sc3( &sc2, "AAA"); - - QVERIFY( sc3.hasKey( "stringEntry1" ) ); // from kdeglobals - QVERIFY( !sc3.isEntryImmutable("stringEntry1") ); - QCOMPARE( sc3.readEntry( "stringEntry1" ), QString( STRINGENTRY1 ) ); - - QVERIFY( !sc3.hasKey( "stringEntry2" ) ); - QCOMPARE( sc3.readEntry( "stringEntry2", QString("bla") ), QString( "bla" ) ); - - QVERIFY( !sc3.hasDefault( "stringEntry1" ) ); - - sc3 = KConfigGroup(&sc2, "Hello"); - QCOMPARE( sc3.readEntry( "Test", QByteArray() ), QByteArray( UTF8BITENTRY ) ); - QCOMPARE( sc3.readEntry( "bytearrayEntry", QByteArray() ), BYTEARRAYENTRY ); - QCOMPARE( sc3.readEntry( ESCAPEKEY ), QString( ESCAPEENTRY ) ); - QCOMPARE( sc3.readEntry( "Test", QString() ), QString::fromUtf8( UTF8BITENTRY ) ); - QCOMPARE( sc3.readEntry( "emptyEntry"/*, QString("Fietsbel")*/), QString("") ); - QCOMPARE( sc3.readEntry("emptyEntry", QString("Fietsbel")).isEmpty(), true ); - QCOMPARE( sc3.readEntry( "stringEntry1" ), QString( STRINGENTRY1 ) ); - QCOMPARE( sc3.readEntry( "stringEntry2" ), QString( STRINGENTRY2 ) ); - QCOMPARE( sc3.readEntry( "stringEntry3" ), QString( STRINGENTRY3 ) ); - QCOMPARE( sc3.readEntry( "stringEntry4" ), QString( STRINGENTRY4 ) ); - QVERIFY( !sc3.hasKey( "stringEntry5" ) ); - QCOMPARE( sc3.readEntry( "stringEntry5", QString("test") ), QString( "test" ) ); - QVERIFY( !sc3.hasKey( "stringEntry6" ) ); - QCOMPARE( sc3.readEntry( "stringEntry6", QString("foo") ), QString( "foo" ) ); - QCOMPARE( sc3.readEntry( "urlEntry1", QUrl() ), QUrl("http://qt-project.org") ); - QCOMPARE( sc3.readEntry( "boolEntry1", BOOLENTRY1 ), BOOLENTRY1 ); - QCOMPARE( sc3.readEntry( "boolEntry2", false ), BOOLENTRY2 ); - QCOMPARE( sc3.readEntry("keywith=equalsign", QString("wrong")), QString(STRINGENTRY1)); - QCOMPARE( sc3.readEntry( "byteArrayEntry1", QByteArray() ), - QByteArray( STRINGENTRY1 ) ); - QCOMPARE( sc3.readEntry( "doubleEntry1", 0.0 ), DOUBLEENTRY ); - QCOMPARE( sc3.readEntry( "floatEntry1", 0.0f ), FLOATENTRY ); + KConfig sc2("kconfigtest"); + QCOMPARE(sc2.name(), QString("kconfigtest")); + + // make sure groupList() isn't returning something it shouldn't + Q_FOREACH (const QString &group, sc2.groupList()) { + QVERIFY(!group.isEmpty() && group != "<default>"); + QVERIFY(!group.contains(QChar(0x1d))); + } + + KConfigGroup sc3(&sc2, "AAA"); + + QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals + QVERIFY(!sc3.isEntryImmutable("stringEntry1")); + QCOMPARE(sc3.readEntry("stringEntry1"), QString(STRINGENTRY1)); + + QVERIFY(!sc3.hasKey("stringEntry2")); + QCOMPARE(sc3.readEntry("stringEntry2", QString("bla")), QString("bla")); + + QVERIFY(!sc3.hasDefault("stringEntry1")); + + sc3 = KConfigGroup(&sc2, "Hello"); + QCOMPARE(sc3.readEntry("Test", QByteArray()), QByteArray(UTF8BITENTRY)); + QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), BYTEARRAYENTRY); + QCOMPARE(sc3.readEntry(ESCAPEKEY), QString(ESCAPEENTRY)); + QCOMPARE(sc3.readEntry("Test", QString()), QString::fromUtf8(UTF8BITENTRY)); + QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QString("")); + QCOMPARE(sc3.readEntry("emptyEntry", QString("Fietsbel")).isEmpty(), true); + QCOMPARE(sc3.readEntry("stringEntry1"), QString(STRINGENTRY1)); + QCOMPARE(sc3.readEntry("stringEntry2"), QString(STRINGENTRY2)); + QCOMPARE(sc3.readEntry("stringEntry3"), QString(STRINGENTRY3)); + QCOMPARE(sc3.readEntry("stringEntry4"), QString(STRINGENTRY4)); + QVERIFY(!sc3.hasKey("stringEntry5")); + QCOMPARE(sc3.readEntry("stringEntry5", QString("test")), QString("test")); + QVERIFY(!sc3.hasKey("stringEntry6")); + QCOMPARE(sc3.readEntry("stringEntry6", QString("foo")), QString("foo")); + QCOMPARE(sc3.readEntry("urlEntry1", QUrl()), QUrl("http://qt-project.org")); + QCOMPARE(sc3.readEntry("boolEntry1", BOOLENTRY1), BOOLENTRY1); + QCOMPARE(sc3.readEntry("boolEntry2", false), BOOLENTRY2); + QCOMPARE(sc3.readEntry("keywith=equalsign", QString("wrong")), QString(STRINGENTRY1)); + QCOMPARE(sc3.readEntry("byteArrayEntry1", QByteArray()), + QByteArray(STRINGENTRY1)); + QCOMPARE(sc3.readEntry("doubleEntry1", 0.0), DOUBLEENTRY); + QCOMPARE(sc3.readEntry("floatEntry1", 0.0f), FLOATENTRY); } void KConfigTest::testDefaults() @@ -396,14 +394,14 @@ void KConfigTest::testLocale() KConfigGroup group = config.group("Hello"); group.writeEntry("stringEntry1", Untranslated); config.setLocale("fr"); - group.writeEntry("stringEntry1", Translated, KConfig::Localized|KConfig::Persistent); + group.writeEntry("stringEntry1", Translated, KConfig::Localized | KConfig::Persistent); QVERIFY(config.sync()); QCOMPARE(group.readEntry("stringEntry1", QString()), Translated); QCOMPARE(group.readEntryUntranslated("stringEntry1"), Untranslated); config.setLocale("C"); // strings written in the "C" locale are written as nonlocalized - group.writeEntry("stringEntry1", Untranslated, KConfig::Localized|KConfig::Persistent); + group.writeEntry("stringEntry1", Untranslated, KConfig::Localized | KConfig::Persistent); QVERIFY(config.sync()); QCOMPARE(group.readEntry("stringEntry1", QString()), Untranslated); @@ -413,7 +411,7 @@ void KConfigTest::testEncoding() { QString groupstr = QString::fromUtf8("UTF-8:\xc3\xb6l"); - KConfig c( "kconfigtestencodings" ); + KConfig c("kconfigtestencodings"); KConfigGroup cg(&c, groupstr); cg.writeEntry("key", "value"); QVERIFY(c.sync()); @@ -422,7 +420,7 @@ void KConfigTest::testEncoding() QCOMPARE(lines.count(), 2); QCOMPARE(lines.first(), QByteArray("[UTF-8:\xc3\xb6l]\n")); - KConfig c2( "kconfigtestencodings" ); + KConfig c2("kconfigtestencodings"); KConfigGroup cg2(&c2, groupstr); QVERIFY(cg2.readEntry("key") == QByteArray("value")); @@ -431,137 +429,137 @@ void KConfigTest::testEncoding() void KConfigTest::testLists() { - KConfig sc2( "kconfigtest" ); - KConfigGroup sc3(&sc2, "List Types"); + KConfig sc2("kconfigtest"); + KConfigGroup sc3(&sc2, "List Types"); - QCOMPARE( sc3.readEntry( QString("stringListEntry"), QStringList()), - STRINGLISTENTRY ); + QCOMPARE(sc3.readEntry(QString("stringListEntry"), QStringList()), + STRINGLISTENTRY); - QCOMPARE( sc3.readEntry( QString("stringListEmptyEntry"), QStringList("wrong") ), - STRINGLISTEMPTYENTRY ); + QCOMPARE(sc3.readEntry(QString("stringListEmptyEntry"), QStringList("wrong")), + STRINGLISTEMPTYENTRY); - QCOMPARE( sc3.readEntry( QString("stringListJustEmptyElement"), QStringList() ), - STRINGLISTJUSTEMPTYELEMENT ); + QCOMPARE(sc3.readEntry(QString("stringListJustEmptyElement"), QStringList()), + STRINGLISTJUSTEMPTYELEMENT); - QCOMPARE( sc3.readEntry( QString("stringListEmptyTrailingElement"), QStringList() ), - STRINGLISTEMPTYTRAINLINGELEMENT ); + QCOMPARE(sc3.readEntry(QString("stringListEmptyTrailingElement"), QStringList()), + STRINGLISTEMPTYTRAINLINGELEMENT); - QCOMPARE( sc3.readEntry( QString("stringListEscapeOddEntry"), QStringList()), - STRINGLISTESCAPEODDENTRY ); + QCOMPARE(sc3.readEntry(QString("stringListEscapeOddEntry"), QStringList()), + STRINGLISTESCAPEODDENTRY); - QCOMPARE( sc3.readEntry( QString("stringListEscapeEvenEntry"), QStringList()), - STRINGLISTESCAPEEVENENTRY ); + QCOMPARE(sc3.readEntry(QString("stringListEscapeEvenEntry"), QStringList()), + STRINGLISTESCAPEEVENENTRY); - QCOMPARE( sc3.readEntry( QString("stringListEscapeCommaEntry"), QStringList()), - STRINGLISTESCAPECOMMAENTRY ); + QCOMPARE(sc3.readEntry(QString("stringListEscapeCommaEntry"), QStringList()), + STRINGLISTESCAPECOMMAENTRY); - QCOMPARE( sc3.readEntry( "listOfIntsEntry1" ), QString::fromLatin1( "1,2,3,4" ) ); - QList<int> expectedIntList = INTLISTENTRY1; - QVERIFY( sc3.readEntry( "listOfIntsEntry1", QList<int>() ) == expectedIntList ); + QCOMPARE(sc3.readEntry("listOfIntsEntry1"), QString::fromLatin1("1,2,3,4")); + QList<int> expectedIntList = INTLISTENTRY1; + QVERIFY(sc3.readEntry("listOfIntsEntry1", QList<int>()) == expectedIntList); - QCOMPARE( QVariant(sc3.readEntry( "variantListEntry", VARIANTLISTENTRY )).toStringList(), - QVariant(VARIANTLISTENTRY).toStringList() ); + QCOMPARE(QVariant(sc3.readEntry("variantListEntry", VARIANTLISTENTRY)).toStringList(), + QVariant(VARIANTLISTENTRY).toStringList()); - QCOMPARE( sc3.readEntry( "listOfByteArraysEntry1", QList<QByteArray>()), BYTEARRAYLISTENTRY1 ); + QCOMPARE(sc3.readEntry("listOfByteArraysEntry1", QList<QByteArray>()), BYTEARRAYLISTENTRY1); } void KConfigTest::testPath() { - KConfig sc2( "kconfigtest" ); - KConfigGroup sc3(&sc2, "Path Type"); - QCOMPARE( sc3.readPathEntry( "homepath", QString() ), HOMEPATH ); - QCOMPARE( sc3.readPathEntry( "homepathescape", QString() ), HOMEPATHESCAPE ); - QCOMPARE( sc3.entryMap()["homepath"], HOMEPATH ); - - { - QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/pathtest"); - file.open(QIODevice::WriteOnly|QIODevice::Text); - QTextStream out(&file); - out.setCodec("UTF-8"); - out << "[Test Group]" << endl - << "homePath=$HOME/foo" << endl - << "homePath2=file://$HOME/foo" << endl - << "withBraces[$e]=file://${HOME}/foo" << endl - << "URL[$e]=file://${HOME}/foo" << endl - << "hostname[$e]=$(hostname)" << endl - << "noeol=foo"; // no EOL - } - KConfig cf2("pathtest"); - KConfigGroup group = cf2.group("Test Group"); - QVERIFY(group.hasKey("homePath")); - QCOMPARE(group.readPathEntry("homePath", QString()), HOMEPATH); - QVERIFY(group.hasKey("homePath2")); - QCOMPARE(group.readPathEntry("homePath2", QString()), QString("file://" + HOMEPATH) ); - QVERIFY(group.hasKey("withBraces")); - QCOMPARE(group.readPathEntry("withBraces", QString()), QString("file://" + HOMEPATH) ); - QVERIFY(group.hasKey("URL")); - QCOMPARE(group.readEntry("URL", QString()), QString("file://" + HOMEPATH) ); + KConfig sc2("kconfigtest"); + KConfigGroup sc3(&sc2, "Path Type"); + QCOMPARE(sc3.readPathEntry("homepath", QString()), HOMEPATH); + QCOMPARE(sc3.readPathEntry("homepathescape", QString()), HOMEPATHESCAPE); + QCOMPARE(sc3.entryMap()["homepath"], HOMEPATH); + + { + QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/pathtest"); + file.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream out(&file); + out.setCodec("UTF-8"); + out << "[Test Group]" << endl + << "homePath=$HOME/foo" << endl + << "homePath2=file://$HOME/foo" << endl + << "withBraces[$e]=file://${HOME}/foo" << endl + << "URL[$e]=file://${HOME}/foo" << endl + << "hostname[$e]=$(hostname)" << endl + << "noeol=foo"; // no EOL + } + KConfig cf2("pathtest"); + KConfigGroup group = cf2.group("Test Group"); + QVERIFY(group.hasKey("homePath")); + QCOMPARE(group.readPathEntry("homePath", QString()), HOMEPATH); + QVERIFY(group.hasKey("homePath2")); + QCOMPARE(group.readPathEntry("homePath2", QString()), QString("file://" + HOMEPATH)); + QVERIFY(group.hasKey("withBraces")); + QCOMPARE(group.readPathEntry("withBraces", QString()), QString("file://" + HOMEPATH)); + QVERIFY(group.hasKey("URL")); + QCOMPARE(group.readEntry("URL", QString()), QString("file://" + HOMEPATH)); #if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) - // I don't know if this will work on windows - // This test hangs on OS X - QVERIFY(group.hasKey("hostname")); - char hostname[256]; - QVERIFY(::gethostname(hostname, sizeof(hostname)) == 0); - QCOMPARE(group.readEntry("hostname", QString()), QString::fromLatin1(hostname)); + // I don't know if this will work on windows + // This test hangs on OS X + QVERIFY(group.hasKey("hostname")); + char hostname[256]; + QVERIFY(::gethostname(hostname, sizeof(hostname)) == 0); + QCOMPARE(group.readEntry("hostname", QString()), QString::fromLatin1(hostname)); #endif - QVERIFY(group.hasKey("noeol")); - QCOMPARE(group.readEntry("noeol", QString()), QString("foo")); + QVERIFY(group.hasKey("noeol")); + QCOMPARE(group.readEntry("noeol", QString()), QString("foo")); } void KConfigTest::testPersistenceOfExpandFlagForPath() { - // This test checks that a path entry starting with $HOME is still flagged - // with the expand flag after the config was altered without rewriting the - // path entry. - - // 1st step: Open the config, add a new dummy entry and then sync the config - // back to the storage. - { - KConfig sc2( "kconfigtest" ); - KConfigGroup sc3(&sc2, "Path Type"); - sc3.writeEntry( "dummy", "dummy" ); - QVERIFY(sc2.sync()); - } - - // 2nd step: Call testPath() again. Rewriting the config must not break - // the testPath() test. - testPath(); + // This test checks that a path entry starting with $HOME is still flagged + // with the expand flag after the config was altered without rewriting the + // path entry. + + // 1st step: Open the config, add a new dummy entry and then sync the config + // back to the storage. + { + KConfig sc2("kconfigtest"); + KConfigGroup sc3(&sc2, "Path Type"); + sc3.writeEntry("dummy", "dummy"); + QVERIFY(sc2.sync()); + } + + // 2nd step: Call testPath() again. Rewriting the config must not break + // the testPath() test. + testPath(); } void KConfigTest::testComplex() { - KConfig sc2( "kconfigtest" ); - KConfigGroup sc3(&sc2, "Complex Types"); - - QCOMPARE( sc3.readEntry( "pointEntry", QPoint() ), POINTENTRY ); - QCOMPARE( sc3.readEntry( "sizeEntry", SIZEENTRY ), SIZEENTRY); - QCOMPARE( sc3.readEntry( "rectEntry", QRect(1,2,3,4) ), RECTENTRY ); - QCOMPARE( sc3.readEntry( "dateTimeEntry", QDateTime() ).toString(Qt::ISODate), - DATETIMEENTRY.toString(Qt::ISODate) ); - QCOMPARE( sc3.readEntry( "dateEntry", QDate() ).toString(Qt::ISODate), - DATETIMEENTRY.date().toString(Qt::ISODate) ); - QCOMPARE( sc3.readEntry( "dateTimeEntry", QDate() ), DATETIMEENTRY.date() ); + KConfig sc2("kconfigtest"); + KConfigGroup sc3(&sc2, "Complex Types"); + + QCOMPARE(sc3.readEntry("pointEntry", QPoint()), POINTENTRY); + QCOMPARE(sc3.readEntry("sizeEntry", SIZEENTRY), SIZEENTRY); + QCOMPARE(sc3.readEntry("rectEntry", QRect(1, 2, 3, 4)), RECTENTRY); + QCOMPARE(sc3.readEntry("dateTimeEntry", QDateTime()).toString(Qt::ISODate), + DATETIMEENTRY.toString(Qt::ISODate)); + QCOMPARE(sc3.readEntry("dateEntry", QDate()).toString(Qt::ISODate), + DATETIMEENTRY.date().toString(Qt::ISODate)); + QCOMPARE(sc3.readEntry("dateTimeEntry", QDate()), DATETIMEENTRY.date()); } void KConfigTest::testEnums() { - KConfig sc("kconfigtest"); - KConfigGroup sc3(&sc, "Enum Types" ); + KConfig sc("kconfigtest"); + KConfigGroup sc3(&sc, "Enum Types"); - QCOMPARE( sc3.readEntry( "enum-10" ), QString("Tens")); - QVERIFY( readEntry( sc3, "enum-100", Ones) != Ones); - QVERIFY( readEntry( sc3, "enum-100", Ones) != Tens); + QCOMPARE(sc3.readEntry("enum-10"), QString("Tens")); + QVERIFY(readEntry(sc3, "enum-100", Ones) != Ones); + QVERIFY(readEntry(sc3, "enum-100", Ones) != Tens); - QCOMPARE( sc3.readEntry( "flags-bit0" ), QString("bit0")); - QVERIFY( readEntry( sc3, "flags-bit0", Flags() ) == bit0 ); + QCOMPARE(sc3.readEntry("flags-bit0"), QString("bit0")); + QVERIFY(readEntry(sc3, "flags-bit0", Flags()) == bit0); - int eid = staticMetaObject.indexOfEnumerator( "Flags" ); - QVERIFY( eid != -1 ); - QMetaEnum me = staticMetaObject.enumerator( eid ); - Flags bitfield = bit0|bit1; + int eid = staticMetaObject.indexOfEnumerator("Flags"); + QVERIFY(eid != -1); + QMetaEnum me = staticMetaObject.enumerator(eid); + Flags bitfield = bit0 | bit1; - QCOMPARE( sc3.readEntry( "flags-bit0-bit1" ), QString( me.valueToKeys(bitfield) ) ); - QVERIFY( readEntry( sc3, "flags-bit0-bit1", Flags() ) == bitfield ); + QCOMPARE(sc3.readEntry("flags-bit0-bit1"), QString(me.valueToKeys(bitfield))); + QVERIFY(readEntry(sc3, "flags-bit0-bit1", Flags()) == bitfield); } void KConfigTest::testEntryMap() @@ -580,8 +578,8 @@ void KConfigTest::testEntryMap() QCOMPARE(entryMap.value("bytearrayEntry"), QString::fromUtf8(BYTEARRAYENTRY)); QCOMPARE(entryMap.value("emptyEntry"), QString()); QVERIFY(entryMap.contains("emptyEntry")); - QCOMPARE(entryMap.value("boolEntry1"), QString(BOOLENTRY1?"true":"false")); - QCOMPARE(entryMap.value("boolEntry2"), QString(BOOLENTRY2?"true":"false")); + QCOMPARE(entryMap.value("boolEntry1"), QString(BOOLENTRY1 ? "true" : "false")); + QCOMPARE(entryMap.value("boolEntry2"), QString(BOOLENTRY2 ? "true" : "false")); QCOMPARE(entryMap.value("keywith=equalsign"), QString(STRINGENTRY1)); QCOMPARE(entryMap.value("byteArrayEntry1"), QString(STRINGENTRY1)); QCOMPARE(entryMap.value("doubleEntry1"), QString::number(DOUBLEENTRY, 'g', 15)); @@ -590,74 +588,74 @@ void KConfigTest::testEntryMap() void KConfigTest::testInvalid() { - KConfig sc( "kconfigtest" ); - - // all of these should print a message to the kdebug.dbg file - KConfigGroup sc3(&sc, "Invalid Types" ); - sc3.writeEntry( "badList", VARIANTLISTENTRY2 ); - - QList<int> list; - - // 1 element list - list << 1; - sc3.writeEntry( QString("badList"), list); - - QVERIFY( sc3.readEntry( "badList", QPoint() ) == QPoint() ); - QVERIFY( sc3.readEntry( "badList", QRect() ) == QRect() ); - QVERIFY( sc3.readEntry( "badList", QSize() ) == QSize() ); - QVERIFY( sc3.readEntry( "badList", QDate() ) == QDate() ); - QVERIFY( sc3.readEntry( "badList", QDateTime() ) == QDateTime() ); - - // 2 element list - list << 2; - sc3.writeEntry( "badList", list); - - QVERIFY( sc3.readEntry( "badList", QRect() ) == QRect() ); - QVERIFY( sc3.readEntry( "badList", QDate() ) == QDate() ); - QVERIFY( sc3.readEntry( "badList", QDateTime() ) == QDateTime() ); - - // 3 element list - list << 303; - sc3.writeEntry( "badList", list); - - QVERIFY( sc3.readEntry( "badList", QPoint() ) == QPoint() ); - QVERIFY( sc3.readEntry( "badList", QRect() ) == QRect() ); - QVERIFY( sc3.readEntry( "badList", QSize() ) == QSize() ); - QVERIFY( sc3.readEntry( "badList", QDate() ) == QDate() ); // out of bounds - QVERIFY( sc3.readEntry( "badList", QDateTime() ) == QDateTime() ); - - // 4 element list - list << 4; - sc3.writeEntry( "badList", list ); - - QVERIFY( sc3.readEntry( "badList", QPoint() ) == QPoint() ); - QVERIFY( sc3.readEntry( "badList", QSize() ) == QSize() ); - QVERIFY( sc3.readEntry( "badList", QDate() ) == QDate() ); - QVERIFY( sc3.readEntry( "badList", QDateTime() ) == QDateTime() ); - - // 5 element list - list[2] = 3; - list << 5; - sc3.writeEntry( "badList", list); - - QVERIFY( sc3.readEntry( "badList", QPoint() ) == QPoint() ); - QVERIFY( sc3.readEntry( "badList", QRect() ) == QRect() ); - QVERIFY( sc3.readEntry( "badList", QSize() ) == QSize() ); - QVERIFY( sc3.readEntry( "badList", QDate() ) == QDate() ); - QVERIFY( sc3.readEntry( "badList", QDateTime() ) == QDateTime() ); - - // 6 element list - list << 6; - sc3.writeEntry( "badList", list); - - QVERIFY( sc3.readEntry( "badList", QPoint() ) == QPoint() ); - QVERIFY( sc3.readEntry( "badList", QRect() ) == QRect() ); - QVERIFY( sc3.readEntry( "badList", QSize() ) == QSize() ); + KConfig sc("kconfigtest"); + + // all of these should print a message to the kdebug.dbg file + KConfigGroup sc3(&sc, "Invalid Types"); + sc3.writeEntry("badList", VARIANTLISTENTRY2); + + QList<int> list; + + // 1 element list + list << 1; + sc3.writeEntry(QString("badList"), list); + + QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint()); + QVERIFY(sc3.readEntry("badList", QRect()) == QRect()); + QVERIFY(sc3.readEntry("badList", QSize()) == QSize()); + QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); + QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime()); + + // 2 element list + list << 2; + sc3.writeEntry("badList", list); + + QVERIFY(sc3.readEntry("badList", QRect()) == QRect()); + QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); + QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime()); + + // 3 element list + list << 303; + sc3.writeEntry("badList", list); + + QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint()); + QVERIFY(sc3.readEntry("badList", QRect()) == QRect()); + QVERIFY(sc3.readEntry("badList", QSize()) == QSize()); + QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); // out of bounds + QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime()); + + // 4 element list + list << 4; + sc3.writeEntry("badList", list); + + QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint()); + QVERIFY(sc3.readEntry("badList", QSize()) == QSize()); + QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); + QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime()); + + // 5 element list + list[2] = 3; + list << 5; + sc3.writeEntry("badList", list); + + QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint()); + QVERIFY(sc3.readEntry("badList", QRect()) == QRect()); + QVERIFY(sc3.readEntry("badList", QSize()) == QSize()); + QVERIFY(sc3.readEntry("badList", QDate()) == QDate()); + QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime()); + + // 6 element list + list << 6; + sc3.writeEntry("badList", list); + + QVERIFY(sc3.readEntry("badList", QPoint()) == QPoint()); + QVERIFY(sc3.readEntry("badList", QRect()) == QRect()); + QVERIFY(sc3.readEntry("badList", QSize()) == QSize()); } void KConfigTest::testChangeGroup() { - KConfig sc( "kconfigtest" ); + KConfig sc("kconfigtest"); KConfigGroup sc3(&sc, "Hello"); QCOMPARE(sc3.name(), QString("Hello")); KConfigGroup newGroup(sc3); @@ -687,7 +685,7 @@ void KConfigTest::testChangeGroup() // Simple test for deleteEntry void KConfigTest::testDeleteEntry() { - const char* configFile = "kconfigdeletetest"; + const char *configFile = "kconfigdeletetest"; { KConfig conf(configFile); conf.group("Hello").writeEntry("DelKey", "ToBeDeleted"); @@ -700,80 +698,82 @@ void KConfigTest::testDeleteEntry() KConfigGroup group(&sc, "Hello"); group.deleteEntry("DelKey"); - QCOMPARE( group.readEntry("DelKey", QString("Fietsbel")), QString("Fietsbel") ); + QCOMPARE(group.readEntry("DelKey", QString("Fietsbel")), QString("Fietsbel")); QVERIFY(group.sync()); Q_ASSERT(!readLines(configFile).contains("DelKey=ToBeDeleted\n")); - QCOMPARE( group.readEntry("DelKey", QString("still deleted")), QString("still deleted") ); + QCOMPARE(group.readEntry("DelKey", QString("still deleted")), QString("still deleted")); } void KConfigTest::testDelete() { - KConfig sc( "kconfigtest" ); - - KConfigGroup ct(&sc, "Complex Types"); - - // First delete a nested group - KConfigGroup delgr(&ct, "Nested Group 3"); - QVERIFY(delgr.exists()); - QVERIFY(ct.hasGroup("Nested Group 3")); - delgr.deleteGroup(); - QVERIFY(!delgr.exists()); - QVERIFY(!ct.hasGroup("Nested Group 3")); - QVERIFY(ct.groupList().contains("Nested Group 3")); - - KConfigGroup ng(&ct, "Nested Group 2"); - QVERIFY(sc.hasGroup("Complex Types")); - QVERIFY(!sc.hasGroup("Does not exist")); - sc.deleteGroup("Complex Types"); - QCOMPARE(sc.group("Complex Types").keyList().count(), 0); - QVERIFY(!sc.hasGroup("Complex Types")); // #192266 - QVERIFY(!sc.group("Complex Types").exists()); - QVERIFY(!ct.hasGroup("Nested Group 1")); - - QCOMPARE(ct.group("Nested Group 1").keyList().count(), 0); - QCOMPARE(ct.group("Nested Group 2").keyList().count(), 0); - QCOMPARE(ng.group("Nested Group 2.1").keyList().count(), 0); - - KConfigGroup cg(&sc , "AAA" ); - cg.deleteGroup(); - QVERIFY( sc.entryMap("Complex Types").isEmpty() ); - QVERIFY( sc.entryMap("AAA").isEmpty() ); - QVERIFY( !sc.entryMap("Hello").isEmpty() ); //not deleted group - QVERIFY( sc.entryMap("FooBar").isEmpty() ); //inexistant group - - QVERIFY(cg.sync()); - // Check what happens on disk - const QList<QByteArray> lines = readLines(); - //qDebug() << lines; - QVERIFY(!lines.contains("[Complex Types]\n")); - QVERIFY(!lines.contains("[Complex Types][Nested Group 1]\n")); - QVERIFY(!lines.contains("[Complex Types][Nested Group 2]\n")); - QVERIFY(!lines.contains("[Complex Types][Nested Group 2.1]\n")); - QVERIFY(!lines.contains("[AAA]\n")); - QVERIFY(lines.contains("[Hello]\n")); // a group that was not deleted - - // test for entries that are marked as deleted when there is no default - KConfig cf("kconfigtest", KConfig::SimpleConfig); // make sure there are no defaults - cg = cf.group("Portable Devices"); - cg.writeEntry("devices|manual|(null)", "whatever"); - cg.writeEntry("devices|manual|/mnt/ipod", "/mnt/ipod"); - QVERIFY(cf.sync()); - - int count=0; - Q_FOREACH(const QByteArray& item, readLines()) - if (item.startsWith("devices|")) // krazy:exclude=strings - count++; - QCOMPARE(count, 2); - cg.deleteEntry("devices|manual|/mnt/ipod"); - QVERIFY(cf.sync()); - Q_FOREACH(const QByteArray& item, readLines()) - QVERIFY(!item.contains("ipod")); + KConfig sc("kconfigtest"); + + KConfigGroup ct(&sc, "Complex Types"); + + // First delete a nested group + KConfigGroup delgr(&ct, "Nested Group 3"); + QVERIFY(delgr.exists()); + QVERIFY(ct.hasGroup("Nested Group 3")); + delgr.deleteGroup(); + QVERIFY(!delgr.exists()); + QVERIFY(!ct.hasGroup("Nested Group 3")); + QVERIFY(ct.groupList().contains("Nested Group 3")); + + KConfigGroup ng(&ct, "Nested Group 2"); + QVERIFY(sc.hasGroup("Complex Types")); + QVERIFY(!sc.hasGroup("Does not exist")); + sc.deleteGroup("Complex Types"); + QCOMPARE(sc.group("Complex Types").keyList().count(), 0); + QVERIFY(!sc.hasGroup("Complex Types")); // #192266 + QVERIFY(!sc.group("Complex Types").exists()); + QVERIFY(!ct.hasGroup("Nested Group 1")); + + QCOMPARE(ct.group("Nested Group 1").keyList().count(), 0); + QCOMPARE(ct.group("Nested Group 2").keyList().count(), 0); + QCOMPARE(ng.group("Nested Group 2.1").keyList().count(), 0); + + KConfigGroup cg(&sc, "AAA"); + cg.deleteGroup(); + QVERIFY(sc.entryMap("Complex Types").isEmpty()); + QVERIFY(sc.entryMap("AAA").isEmpty()); + QVERIFY(!sc.entryMap("Hello").isEmpty()); //not deleted group + QVERIFY(sc.entryMap("FooBar").isEmpty()); //inexistant group + + QVERIFY(cg.sync()); + // Check what happens on disk + const QList<QByteArray> lines = readLines(); + //qDebug() << lines; + QVERIFY(!lines.contains("[Complex Types]\n")); + QVERIFY(!lines.contains("[Complex Types][Nested Group 1]\n")); + QVERIFY(!lines.contains("[Complex Types][Nested Group 2]\n")); + QVERIFY(!lines.contains("[Complex Types][Nested Group 2.1]\n")); + QVERIFY(!lines.contains("[AAA]\n")); + QVERIFY(lines.contains("[Hello]\n")); // a group that was not deleted + + // test for entries that are marked as deleted when there is no default + KConfig cf("kconfigtest", KConfig::SimpleConfig); // make sure there are no defaults + cg = cf.group("Portable Devices"); + cg.writeEntry("devices|manual|(null)", "whatever"); + cg.writeEntry("devices|manual|/mnt/ipod", "/mnt/ipod"); + QVERIFY(cf.sync()); + + int count = 0; + Q_FOREACH (const QByteArray &item, readLines()) + if (item.startsWith("devices|")) { // krazy:exclude=strings + count++; + } + QCOMPARE(count, 2); + cg.deleteEntry("devices|manual|/mnt/ipod"); + QVERIFY(cf.sync()); + Q_FOREACH (const QByteArray &item, readLines()) { + QVERIFY(!item.contains("ipod")); + } } void KConfigTest::testDefaultGroup() { - KConfig sc( "kconfigtest" ); + KConfig sc("kconfigtest"); KConfigGroup defaultGroup(&sc, "<default>"); QCOMPARE(defaultGroup.name(), QString("<default>")); QVERIFY(!defaultGroup.exists()); @@ -804,7 +804,7 @@ void KConfigTest::testDefaultGroup() QCOMPARE(lines.first(), QByteArray("TestKey=defaultGroup\n")); // Now that the group exists make sure it isn't returned from groupList() - Q_FOREACH(const QString& group, sc.groupList()) { + Q_FOREACH (const QString &group, sc.groupList()) { QVERIFY(!group.isEmpty() && group != "<default>"); } @@ -818,7 +818,7 @@ void KConfigTest::testDefaultGroup() void KConfigTest::testEmptyGroup() { - KConfig sc( "kconfigtest" ); + KConfig sc("kconfigtest"); KConfigGroup emptyGroup(&sc, ""); QCOMPARE(emptyGroup.name(), QString("<default>")); // confusing, heh? QVERIFY(!emptyGroup.exists()); @@ -849,7 +849,7 @@ void KConfigTest::testEmptyGroup() QCOMPARE(lines.first(), QByteArray("TestKey=emptyGroup\n")); // Now that the group exists make sure it isn't returned from groupList() - Q_FOREACH(const QString& group, sc.groupList()) { + Q_FOREACH (const QString &group, sc.groupList()) { QVERIFY(!group.isEmpty() && group != "<default>"); } emptyGroup.deleteGroup(); @@ -872,7 +872,7 @@ void KConfigTest::testCascadingWithLocale() const QString globalConfigDir = globalDir.path(); QVERIFY(QDir().mkpath(globalConfigDir)); QFile global(globalConfigDir + "/foo.desktop"); - QVERIFY(global.open(QIODevice::WriteOnly|QIODevice::Text)); + QVERIFY(global.open(QIODevice::WriteOnly | QIODevice::Text)); QTextStream globalOut(&global); globalOut << "[Group]" << endl << "FromGlobal=true" << endl @@ -886,7 +886,7 @@ void KConfigTest::testCascadingWithLocale() const QString middleConfigDir = middleDir.path(); QVERIFY(QDir().mkpath(middleConfigDir)); QFile local(middleConfigDir + "/foo.desktop"); - QVERIFY(local.open(QIODevice::WriteOnly|QIODevice::Text)); + QVERIFY(local.open(QIODevice::WriteOnly | QIODevice::Text)); QTextStream out(&local); out << "[Group]" << endl << "FromLocal=true" << endl @@ -917,18 +917,19 @@ void KConfigTest::testMerge() cg.writeEntry("entry", " random entry"); cg.writeEntry("another entry", "blah blah blah"); - { // simulate writing by another process + { + // simulate writing by another process QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/mergetest"); - file.open(QIODevice::WriteOnly|QIODevice::Text); + file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out.setCodec("UTF-8"); out << "[Merged Group]" << endl - << "entry1=Testing" << endl - << "entry2=More Testing" << endl - << "[some group]" << endl - << "entry[fr]=French" << endl - << "entry[es]=Spanish" << endl - << "entry[de]=German" << endl; + << "entry1=Testing" << endl + << "entry2=More Testing" << endl + << "[some group]" << endl + << "entry[fr]=French" << endl + << "entry[es]=Spanish" << endl + << "entry[de]=German" << endl; } QVERIFY(config.sync()); @@ -936,18 +937,18 @@ void KConfigTest::testMerge() QList<QByteArray> lines; // this is what the file should look like lines << "[Merged Group]\n" - << "entry1=Testing\n" - << "entry2=More Testing\n" - << "\n" - << "[some group]\n" - << "another entry=blah blah blah\n" - << "entry=\\srandom entry\n" - << "entry[de]=German\n" - << "entry[es]=Spanish\n" - << "entry[fr]=French\n"; + << "entry1=Testing\n" + << "entry2=More Testing\n" + << "\n" + << "[some group]\n" + << "another entry=blah blah blah\n" + << "entry=\\srandom entry\n" + << "entry[de]=German\n" + << "entry[es]=Spanish\n" + << "entry[fr]=French\n"; QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/mergetest"); - file.open(QIODevice::ReadOnly|QIODevice::Text); - Q_FOREACH (const QByteArray& line, lines) { + file.open(QIODevice::ReadOnly | QIODevice::Text); + Q_FOREACH (const QByteArray &line, lines) { QCOMPARE(line, file.readLine()); } } @@ -957,11 +958,11 @@ void KConfigTest::testImmutable() { { QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/immutabletest"); - file.open(QIODevice::WriteOnly|QIODevice::Text); + file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out.setCodec("UTF-8"); out << "[$i]" << endl - << "entry1=Testing" << endl + << "entry1=Testing" << endl << "[group][$i]" << endl << "[group][subgroup][$i]" << endl; } @@ -982,7 +983,7 @@ void KConfigTest::testOptionOrder() { { QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/doubleattrtest"); - file.open(QIODevice::WriteOnly|QIODevice::Text); + file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out.setCodec("UTF-8"); out << "[group3]" << endl @@ -993,12 +994,12 @@ void KConfigTest::testOptionOrder() config.setLocale("de_DE"); KConfigGroup cg3 = config.group("group3"); QVERIFY(!cg3.isImmutable()); - QCOMPARE(cg3.readEntry("entry2",""), QString("t2")); + QCOMPARE(cg3.readEntry("entry2", ""), QString("t2")); QVERIFY(cg3.isEntryImmutable("entry2")); config.setLocale("C"); - QCOMPARE(cg3.readEntry("entry2",""), QString("unlocalized")); + QCOMPARE(cg3.readEntry("entry2", ""), QString("unlocalized")); QVERIFY(!cg3.isEntryImmutable("entry2")); - cg3.writeEntry("entry2","modified"); + cg3.writeEntry("entry2", "modified"); QVERIFY(config.sync()); { @@ -1009,37 +1010,36 @@ void KConfigTest::testOptionOrder() << "entry2[de_DE][$i]=t2\n"; QFile file(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/doubleattrtest"); - file.open(QIODevice::ReadOnly|QIODevice::Text); - Q_FOREACH (const QByteArray& line, lines) { + file.open(QIODevice::ReadOnly | QIODevice::Text); + Q_FOREACH (const QByteArray &line, lines) { QCOMPARE(line, file.readLine()); } } } - void KConfigTest::testGroupEscape() { KConfig config("groupescapetest", KConfig::SimpleConfig); - QVERIFY( config.group(DOLLARGROUP).exists() ); + QVERIFY(config.group(DOLLARGROUP).exists()); } void KConfigTest::testSubGroup() { - KConfig sc( "kconfigtest" ); - KConfigGroup cg( &sc, "ParentGroup" ); - QCOMPARE(cg.readEntry( "parentgrpstring", ""), QString("somevalue") ); - KConfigGroup subcg1( &cg, "SubGroup1"); + KConfig sc("kconfigtest"); + KConfigGroup cg(&sc, "ParentGroup"); + QCOMPARE(cg.readEntry("parentgrpstring", ""), QString("somevalue")); + KConfigGroup subcg1(&cg, "SubGroup1"); QCOMPARE(subcg1.name(), QString("SubGroup1")); - QCOMPARE(subcg1.readEntry( "somestring", ""), QString("somevalue") ); - KConfigGroup subcg2( &cg, "SubGroup2"); + QCOMPARE(subcg1.readEntry("somestring", ""), QString("somevalue")); + KConfigGroup subcg2(&cg, "SubGroup2"); QCOMPARE(subcg2.name(), QString("SubGroup2")); - QCOMPARE(subcg2.readEntry( "substring", ""), QString("somevalue") ); - KConfigGroup subcg3( &cg, "SubGroup/3"); - QCOMPARE(subcg3.readEntry( "sub3string", ""), QString("somevalue") ); + QCOMPARE(subcg2.readEntry("substring", ""), QString("somevalue")); + KConfigGroup subcg3(&cg, "SubGroup/3"); + QCOMPARE(subcg3.readEntry("sub3string", ""), QString("somevalue")); QCOMPARE(subcg3.name(), QString("SubGroup/3")); - KConfigGroup rcg( &sc, "" ); - KConfigGroup srcg( &rcg, "ParentGroup" ); - QCOMPARE(srcg.readEntry( "parentgrpstring", ""), QString("somevalue") ); + KConfigGroup rcg(&sc, ""); + KConfigGroup srcg(&rcg, "ParentGroup"); + QCOMPARE(srcg.readEntry("parentgrpstring", ""), QString("somevalue")); QStringList groupList = cg.groupList(); groupList.sort(); // comes from QSet, so order is undefined @@ -1058,13 +1058,13 @@ void KConfigTest::testSubGroup() // shows up in groupList of sc KConfigGroup neg(&sc, "NoEntryGroup"); KConfigGroup negsub1(&neg, "NEG Child1"); - negsub1.writeEntry( "entry", "somevalue" ); + negsub1.writeEntry("entry", "somevalue"); KConfigGroup negsub2(&neg, "NEG Child2"); KConfigGroup negsub3(&neg, "NEG Child3"); KConfigGroup negsub31(&negsub3, "NEG Child3-1"); KConfigGroup negsub4(&neg, "NEG Child4"); KConfigGroup negsub41(&negsub4, "NEG Child4-1"); - negsub41.writeEntry( "entry", "somevalue" ); + negsub41.writeEntry("entry", "somevalue"); // A group exists if it has content QVERIFY(negsub1.exists()); @@ -1090,11 +1090,11 @@ void KConfigTest::testSubGroup() QCOMPARE(groups, QStringList() << "NEG Child1" << "NEG Child4"); // make sure groupList() isn't returning something it shouldn't - Q_FOREACH(const QString& group, sc.groupList()) { - QVERIFY(!group.isEmpty() && group != "<default>"); - QVERIFY(!group.contains(QChar(0x1d))); - QVERIFY(!group.contains("subgroup")); - QVERIFY(!group.contains("SubGroup")); + Q_FOREACH (const QString &group, sc.groupList()) { + QVERIFY(!group.isEmpty() && group != "<default>"); + QVERIFY(!group.contains(QChar(0x1d))); + QVERIFY(!group.contains("subgroup")); + QVERIFY(!group.contains("SubGroup")); } QVERIFY(sc.sync()); @@ -1119,9 +1119,9 @@ void KConfigTest::testAddConfigSources() QCOMPARE(specificgrp.readEntry("ExistingEntry", ""), QString("DevValue")); KConfigGroup sharedgrp(&cf, "Shared Group"); - QCOMPARE(sharedgrp.readEntry("SomeSpecificOnlyEntry",""), QString("DevValue")); - QCOMPARE(sharedgrp.readEntry("SomeBaseOnlyEntry",""), QString("BaseValue")); - QCOMPARE(sharedgrp.readEntry("SomeSharedEntry",""), QString("DevValue")); + QCOMPARE(sharedgrp.readEntry("SomeSpecificOnlyEntry", ""), QString("DevValue")); + QCOMPARE(sharedgrp.readEntry("SomeBaseOnlyEntry", ""), QString("BaseValue")); + QCOMPARE(sharedgrp.readEntry("SomeSharedEntry", ""), QString("DevValue")); KConfigGroup basegrp(&cf, "Base Only Group"); QCOMPARE(basegrp.readEntry("ExistingEntry", ""), QString("BaseValue")); @@ -1236,7 +1236,7 @@ void KConfigTest::testReparent() QCOMPARE(group.entryMap(), originalMap); } -static void ageTimeStamp(const QString& path, int nsec) +static void ageTimeStamp(const QString &path, int nsec) { #ifdef Q_OS_UNIX QDateTime mtime = QFileInfo(path).lastModified().addSecs(-nsec); @@ -1278,7 +1278,7 @@ void KConfigTest::testWriteOnSync() // Should not rewrite the local config file. KConfigGroup cgGlobal(&sc, "Globals"); cgGlobal.writeEntry("someGlobalString", "whatever", - KConfig::Persistent|KConfig::Global); + KConfig::Persistent | KConfig::Global); QVERIFY(sc.sync()); // Verify that the timestamp of local config file didn't change. @@ -1344,7 +1344,6 @@ void KConfigTest::testDirtyOnEqualOverdo() QCOMPARE(cgLocal.readEntry("someKey", defvalr), val2); } - void KConfigTest::testCreateDir() { // Test auto-creating the parent directory when needed (KConfigIniBackend::createEnclosing) @@ -1436,7 +1435,6 @@ void KConfigTest::testLocaleConfig() QFile::remove(file); } - void KConfigTest::testDeleteWhenLocalized() { // Initialize the testdata @@ -1565,7 +1563,6 @@ void KConfigTest::testDeleteWhenLocalized() QFile::remove(file); } - void KConfigTest::testKdeGlobals() { { @@ -1629,6 +1626,7 @@ void KConfigTest::testThreads() // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... //futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); //futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); - Q_FOREACH(QFuture<void> f, futures) // krazy:exclude=foreach + Q_FOREACH (QFuture<void> f, futures) { // krazy:exclude=foreach f.waitForFinished(); + } } diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h index ba929086..6e947929 100644 --- a/autotests/kconfigtest.h +++ b/autotests/kconfigtest.h @@ -28,8 +28,8 @@ class KConfigTest : public QObject Q_FLAGS(Flags) public: - enum Testing { Ones=1, Tens=10, Hundreds=100}; - enum bits { bit0=1, bit1=2, bit2=4, bit3=8 }; + enum Testing { Ones = 1, Tens = 10, Hundreds = 100}; + enum bits { bit0 = 1, bit1 = 2, bit2 = 4, bit3 = 8 }; Q_DECLARE_FLAGS(Flags, bits) private Q_SLOTS: diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp index d77e3a50..08d9f142 100644 --- a/autotests/kdesktopfiletest.cpp +++ b/autotests/kdesktopfiletest.cpp @@ -23,20 +23,20 @@ #include <QtTest> -QTEST_MAIN( KDesktopFileTest ) +QTEST_MAIN(KDesktopFileTest) void KDesktopFileTest::testRead() { QTemporaryFile file("testReadXXXXXX.desktop"); - QVERIFY( file.open() ); + QVERIFY(file.open()); const QString fileName = file.fileName(); - QTextStream ts( &file ); + QTextStream ts(&file); ts << - "[Desktop Entry]\n" - "Type=Application\n" - "Name=My Application\n" - "Icon=foo\n" - "\n"; + "[Desktop Entry]\n" + "Type=Application\n" + "Name=My Application\n" + "Icon=foo\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); QVERIFY(KDesktopFile::isDesktopFile(fileName)); @@ -52,13 +52,13 @@ void KDesktopFileTest::testRead() void KDesktopFileTest::testSuccessfulTryExec() { QTemporaryFile file; - QVERIFY( file.open() ); + QVERIFY(file.open()); const QString fileName = file.fileName(); - QTextStream ts( &file ); + QTextStream ts(&file); ts << - "[Desktop Entry]\n" - "TryExec=whoami\n" - "\n"; + "[Desktop Entry]\n" + "TryExec=whoami\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); @@ -68,13 +68,13 @@ void KDesktopFileTest::testSuccessfulTryExec() void KDesktopFileTest::testUnsuccessfulTryExec() { QTemporaryFile file; - QVERIFY( file.open() ); + QVERIFY(file.open()); const QString fileName = file.fileName(); - QTextStream ts( &file ); + QTextStream ts(&file); ts << - "[Desktop Entry]\n" - "TryExec=/does/not/exist\n" - "\n"; + "[Desktop Entry]\n" + "TryExec=/does/not/exist\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); @@ -84,15 +84,15 @@ void KDesktopFileTest::testUnsuccessfulTryExec() void KDesktopFileTest::testActionGroup() { QTemporaryFile file; - QVERIFY( file.open() ); + QVERIFY(file.open()); const QString fileName = file.fileName(); - QTextStream ts( &file ); + QTextStream ts(&file); ts << - "[Desktop Entry]\n" - "Actions=encrypt;\n" - "[Desktop Action encrypt]\n" - "Name=Encrypt file\n" - "\n"; + "[Desktop Entry]\n" + "Actions=encrypt;\n" + "[Desktop Action encrypt]\n" + "Name=Encrypt file\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); KDesktopFile df(fileName); @@ -109,15 +109,15 @@ void KDesktopFileTest::testActionGroup() void KDesktopFileTest::testIsAuthorizedDesktopFile() { QTemporaryFile file("testAuthXXXXXX.desktop"); - QVERIFY( file.open() ); + QVERIFY(file.open()); const QString fileName = file.fileName(); - QTextStream ts( &file ); + QTextStream ts(&file); ts << - "[Desktop Entry]\n" - "Type=Application\n" - "Name=My Application\n" - "Exec=kfoo\n" - "\n"; + "[Desktop Entry]\n" + "Type=Application\n" + "Name=My Application\n" + "Exec=kfoo\n" + "\n"; file.close(); QVERIFY(QFile::exists(fileName)); QVERIFY(!KDesktopFile::isAuthorizedDesktopFile(fileName)); diff --git a/autotests/kentrymaptest.cpp b/autotests/kentrymaptest.cpp index 9e926d65..5e39df54 100644 --- a/autotests/kentrymaptest.cpp +++ b/autotests/kentrymaptest.cpp @@ -22,14 +22,13 @@ #include <QtTest> #include "kconfigdata.h" - const QByteArray group1("A Group"); const QByteArray key1("A Key"); const QByteArray key2("Another Key"); const QByteArray value1("A value"); const QByteArray value2("A different value"); -QTEST_MAIN( KEntryMapTest ) +QTEST_MAIN(KEntryMapTest) void KEntryMapTest::testKeyOrder() { @@ -142,7 +141,7 @@ void KEntryMapTest::testDelete() map.setEntry(group1, key2, value2, EntryDefault); QCOMPARE(map.size(), 5); - map.setEntry(group1, key2, QByteArray(), EntryDeleted|EntryDirty); + map.setEntry(group1, key2, QByteArray(), EntryDeleted | EntryDirty); QCOMPARE(map.size(), 5); // entry should still be in map, so it can override merged entries later QCOMPARE(map.findEntry(group1, key2)->mValue, QByteArray()); } @@ -193,9 +192,9 @@ void KEntryMapTest::testLocale() QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, translated); // has localized value now QVERIFY(map.findEntry(group1, key1, SearchLocalized)->mValue != map.findEntry(group1, key1)->mValue); - QCOMPARE(map.findEntry(group1, key1, SearchDefaults|SearchLocalized)->mValue, untranslated); // default should still be untranslated + QCOMPARE(map.findEntry(group1, key1, SearchDefaults | SearchLocalized)->mValue, untranslated); // default should still be untranslated - map.setEntry(group1, key1, translatedDefault, EntryDefault|EntryLocalized); + map.setEntry(group1, key1, translatedDefault, EntryDefault | EntryLocalized); QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, translatedDefault); map.setEntry(group1, key1, translated, EntryLocalized); // set the translated entry to a different locale QCOMPARE(map.findEntry(group1, key1, SearchLocalized)->mValue, translated); diff --git a/autotests/kentrymaptest.h b/autotests/kentrymaptest.h index 2855b5c4..b36ca763 100644 --- a/autotests/kentrymaptest.h +++ b/autotests/kentrymaptest.h @@ -32,17 +32,17 @@ public: typedef KEntryMap::SearchFlags SearchFlags; typedef KEntryMap::SearchFlag SearchFlag; - static const SearchFlag SearchLocalized=KEntryMap::SearchLocalized; - static const SearchFlag SearchDefaults=KEntryMap::SearchDefaults; + static const SearchFlag SearchLocalized = KEntryMap::SearchLocalized; + static const SearchFlag SearchDefaults = KEntryMap::SearchDefaults; typedef KEntryMap::EntryOption EntryOption; - static const EntryOption EntryDirty=KEntryMap::EntryDirty; - static const EntryOption EntryGlobal=KEntryMap::EntryGlobal; - static const EntryOption EntryImmutable=KEntryMap::EntryImmutable; - static const EntryOption EntryDeleted=KEntryMap::EntryDeleted; - static const EntryOption EntryExpansion=KEntryMap::EntryExpansion; - static const EntryOption EntryDefault=KEntryMap::EntryDefault; - static const EntryOption EntryLocalized=KEntryMap::EntryLocalized; + static const EntryOption EntryDirty = KEntryMap::EntryDirty; + static const EntryOption EntryGlobal = KEntryMap::EntryGlobal; + static const EntryOption EntryImmutable = KEntryMap::EntryImmutable; + static const EntryOption EntryDeleted = KEntryMap::EntryDeleted; + static const EntryOption EntryExpansion = KEntryMap::EntryExpansion; + static const EntryOption EntryDefault = KEntryMap::EntryDefault; + static const EntryOption EntryLocalized = KEntryMap::EntryLocalized; private Q_SLOTS: void testKeyOrder(); void testSimple(); diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp index 847cd074..a5bbacde 100644 --- a/autotests/kstandardshortcuttest.cpp +++ b/autotests/kstandardshortcuttest.cpp @@ -20,40 +20,40 @@ #include <QtTest/QtTest> #include "kstandardshortcuttest.h" -QTEST_MAIN( KStandardShortcutTest) // GUI needed by KAccel +QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel #include <kstandardshortcut.h> void KStandardShortcutTest::testShortcutDefault() { - QCOMPARE( QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut( KStandardShortcut::FullScreen )), QLatin1String( "Ctrl+Shift+F" ) ); - QCOMPARE( QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut( KStandardShortcut::BeginningOfLine )), QLatin1String( "Home" ) ); - QCOMPARE( QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut( KStandardShortcut::EndOfLine )), QLatin1String( "End" ) ); - QCOMPARE( QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut( KStandardShortcut::Home )), QLatin1String( "Alt+Home; Home Page" ) ); + QCOMPARE(QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::FullScreen)), QLatin1String("Ctrl+Shift+F")); + QCOMPARE(QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::BeginningOfLine)), QLatin1String("Home")); + QCOMPARE(QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::EndOfLine)), QLatin1String("End")); + QCOMPARE(QKeySequence::listToString(KStandardShortcut::hardcodedDefaultShortcut(KStandardShortcut::Home)), QLatin1String("Alt+Home; Home Page")); } void KStandardShortcutTest::testName() { - QCOMPARE( KStandardShortcut::name( KStandardShortcut::BeginningOfLine ), QLatin1String( "BeginningOfLine" ) ); - QCOMPARE( KStandardShortcut::name( KStandardShortcut::EndOfLine ), QLatin1String( "EndOfLine" ) ); - QCOMPARE( KStandardShortcut::name( KStandardShortcut::Home ), QLatin1String( "Home" ) ); + QCOMPARE(KStandardShortcut::name(KStandardShortcut::BeginningOfLine), QLatin1String("BeginningOfLine")); + QCOMPARE(KStandardShortcut::name(KStandardShortcut::EndOfLine), QLatin1String("EndOfLine")); + QCOMPARE(KStandardShortcut::name(KStandardShortcut::Home), QLatin1String("Home")); } void KStandardShortcutTest::testLabel() { // Tests run in English, right? - QCOMPARE( KStandardShortcut::label( KStandardShortcut::FindNext ), QLatin1String( "Find Next" ) ); - QCOMPARE( KStandardShortcut::label( KStandardShortcut::Home ), QLatin1String( "Home" ) ); + QCOMPARE(KStandardShortcut::label(KStandardShortcut::FindNext), QLatin1String("Find Next")); + QCOMPARE(KStandardShortcut::label(KStandardShortcut::Home), QLatin1String("Home")); } void KStandardShortcutTest::testShortcut() { - QCOMPARE( QKeySequence::listToString(KStandardShortcut::shortcut( KStandardShortcut::ZoomIn )), QKeySequence::listToString(KStandardShortcut::zoomIn()) ); + QCOMPARE(QKeySequence::listToString(KStandardShortcut::shortcut(KStandardShortcut::ZoomIn)), QKeySequence::listToString(KStandardShortcut::zoomIn())); } void KStandardShortcutTest::testFindStdAccel() { - QCOMPARE( KStandardShortcut::find( QString( "Ctrl+F" ) ), KStandardShortcut::Find ); - QCOMPARE( KStandardShortcut::find( QString( "Ctrl+Shift+Alt+G" ) ), KStandardShortcut::AccelNone ); + QCOMPARE(KStandardShortcut::find(QString("Ctrl+F")), KStandardShortcut::Find); + QCOMPARE(KStandardShortcut::find(QString("Ctrl+Shift+Alt+G")), KStandardShortcut::AccelNone); } diff --git a/autotests/kstandardshortcuttest.h b/autotests/kstandardshortcuttest.h index 91be854b..3e52c795 100644 --- a/autotests/kstandardshortcuttest.h +++ b/autotests/kstandardshortcuttest.h @@ -34,5 +34,4 @@ private Q_SLOTS: void testFindStdAccel(); }; - #endif diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index 8fae1c74..90faf989 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -52,9 +52,9 @@ static QString readFile(const QString &path) return QString::fromUtf8(file.readAll()); } -static QTemporaryFile* writeUpdFile(const QString &content) +static QTemporaryFile *writeUpdFile(const QString &content) { - QTemporaryFile* file = new QTemporaryFile(QDir::tempPath() + QLatin1String("/test_kconf_update_XXXXXX.upd")); + QTemporaryFile *file = new QTemporaryFile(QDir::tempPath() + QLatin1String("/test_kconf_update_XXXXXX.upd")); bool ok = file->open(); Q_UNUSED(ok) // silence warnings Q_ASSERT(ok); @@ -80,170 +80,170 @@ void TestKConfUpdate::test_data() QTest::addColumn<QString>("expectedOldConfContent"); QTest::newRow("moveKeysSameFile") - << - "File=testrc\n" - "Group=group\n" - "Key=old,new\n" - "Options=overwrite\n" - << - "testrc" - << - "[group]\n" - "old=value\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "new=value\n" - << - "" - ; + << + "File=testrc\n" + "Group=group\n" + "Key=old,new\n" + "Options=overwrite\n" + << + "testrc" + << + "[group]\n" + "old=value\n" + << + "testrc" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "new=value\n" + << + "" + ; QTest::newRow("moveKeysOtherFile") - << - "File=oldrc,newrc\n" - "Group=group1,group2\n" - "Key=old,new\n" - "Options=overwrite\n" - << - "oldrc" - << - "[group1]\n" - "old=value\n" - "[stay]\n" - "foo=bar\n" - << - "newrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "new=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[stay]\n" - "foo=bar\n" - ; + << + "File=oldrc,newrc\n" + "Group=group1,group2\n" + "Key=old,new\n" + "Options=overwrite\n" + << + "oldrc" + << + "[group1]\n" + "old=value\n" + "[stay]\n" + "foo=bar\n" + << + "newrc" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "new=value\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[stay]\n" + "foo=bar\n" + ; QTest::newRow("allKeys") - << - "File=testrc\n" - "Group=group1,group2\n" - "AllKeys\n" - << - "testrc" - << - "[group1]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "" - ; + << + "File=testrc\n" + "Group=group1,group2\n" + "AllKeys\n" + << + "testrc" + << + "[group1]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[stay]\n" + "foo=bar\n" + << + "testrc" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[stay]\n" + "foo=bar\n" + << + "" + ; QTest::newRow("allKeysSubGroup") - << - "File=testrc\n" - "Group=[group][sub1],[group][sub2]\n" - "AllKeys\n" - << - "testrc" - << - "[group][sub1]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[group][sub1][subsub]\n" - "key3=value3\n" - "key4=value4\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group][sub2]\n" - "key1=value1\n" - "key2=value2\n" - "\n" - "[group][sub2][subsub]\n" - "key3=value3\n" - "key4=value4\n" - "\n" - "[stay]\n" - "foo=bar\n" - << - "" - ; + << + "File=testrc\n" + "Group=[group][sub1],[group][sub2]\n" + "AllKeys\n" + << + "testrc" + << + "[group][sub1]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[group][sub1][subsub]\n" + "key3=value3\n" + "key4=value4\n" + "\n" + "[stay]\n" + "foo=bar\n" + << + "testrc" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group][sub2]\n" + "key1=value1\n" + "key2=value2\n" + "\n" + "[group][sub2][subsub]\n" + "key3=value3\n" + "key4=value4\n" + "\n" + "[stay]\n" + "foo=bar\n" + << + "" + ; QTest::newRow("removeGroup") - << - "File=testrc\n" - "RemoveGroup=remove\n" - << - "testrc" - << - "[keep]\n" - "key=value\n" - "" - "[remove]\n" - "key=value\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[keep]\n" - "key=value\n" - << - "" - ; + << + "File=testrc\n" + "RemoveGroup=remove\n" + << + "testrc" + << + "[keep]\n" + "key=value\n" + "" + "[remove]\n" + "key=value\n" + << + "testrc" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[keep]\n" + "key=value\n" + << + "" + ; QTest::newRow("moveKeysSameFileDontExist") - << - "File=testrc\n" - "Group=group,group2\n" - "Key=key1\n" - "Key=key2\n" - << - "testrc" - << - "[group]\n" - "key1=value1\n" - "key3=value3\n" - << - "testrc" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "key3=value3\n" - "\n" - "[group2]\n" - "key1=value1\n" - << - "" - ; + << + "File=testrc\n" + "Group=group,group2\n" + "Key=key1\n" + "Key=key2\n" + << + "testrc" + << + "[group]\n" + "key1=value1\n" + "key3=value3\n" + << + "testrc" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "key3=value3\n" + "\n" + "[group2]\n" + "key1=value1\n" + << + "" + ; } void TestKConfUpdate::test() @@ -269,8 +269,8 @@ void TestKConfUpdate::test() runKConfUpdate(updFile->fileName()); QString updateInfo = QString("%1:%2") - .arg(updFile->fileName().section('/', -1)) - .arg(QTest::currentDataTag()); + .arg(updFile->fileName().section('/', -1)) + .arg(QTest::currentDataTag()); QString newConfContentAfter = readFile(newConfPath); expectedNewConfContent = expectedNewConfContent.arg(updateInfo); @@ -291,234 +291,234 @@ void TestKConfUpdate::testScript_data() QTest::addColumn<QString>("expectedNewConfContent"); QTest::newRow("delete-key") - << - "File=testrc\n" - "Group=group\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE deprecated'\n" - << - "[group]\n" - "deprecated=foo\n" - "valid=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "valid=bar\n" - ; + << + "File=testrc\n" + "Group=group\n" + "Script=test.sh,sh\n" + << + "echo '# DELETE deprecated'\n" + << + "[group]\n" + "deprecated=foo\n" + "valid=bar\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "valid=bar\n" + ; QTest::newRow("delete-key2") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE [group]deprecated'\n" - "echo '# DELETE [group][sub]deprecated2'\n" - << - "[group]\n" - "deprecated=foo\n" - "valid=bar\n" - "\n" - "[group][sub]\n" - "deprecated2=foo\n" - "valid2=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "valid=bar\n" - "\n" - "[group][sub]\n" - "valid2=bar\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '# DELETE [group]deprecated'\n" + "echo '# DELETE [group][sub]deprecated2'\n" + << + "[group]\n" + "deprecated=foo\n" + "valid=bar\n" + "\n" + "[group][sub]\n" + "deprecated2=foo\n" + "valid2=bar\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "valid=bar\n" + "\n" + "[group][sub]\n" + "valid2=bar\n" + ; QTest::newRow("delete-group") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETEGROUP [group1]'\n" - "echo '# DELETEGROUP [group2][sub]'\n" - << - "[group1]\n" - "key=value\n" - "\n" - "[group2]\n" - "valid=bar\n" - "\n" - "[group2][sub]\n" - "key=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "valid=bar\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '# DELETEGROUP [group1]'\n" + "echo '# DELETEGROUP [group2][sub]'\n" + << + "[group1]\n" + "key=value\n" + "\n" + "[group2]\n" + "valid=bar\n" + "\n" + "[group2][sub]\n" + "key=value\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "valid=bar\n" + ; QTest::newRow("delete-group2") - << - "File=testrc\n" - "Group=group\n" - "Script=test.sh,sh\n" - << - "echo '# DELETEGROUP'\n" - << - "[group]\n" - "key=value\n" - "\n" - "[group2]\n" - "valid=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group2]\n" - "valid=bar\n" - ; + << + "File=testrc\n" + "Group=group\n" + "Script=test.sh,sh\n" + << + "echo '# DELETEGROUP'\n" + << + "[group]\n" + "key=value\n" + "\n" + "[group2]\n" + "valid=bar\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group2]\n" + "valid=bar\n" + ; QTest::newRow("new-key") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group]'\n" - "echo 'new=value'\n" - << - "[group]\n" - "valid=bar\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "new=value\n" - "valid=bar\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '[group]'\n" + "echo 'new=value'\n" + << + "[group]\n" + "valid=bar\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "new=value\n" + "valid=bar\n" + ; QTest::newRow("modify-key-no-overwrite") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group]'\n" - "echo 'existing=new'\n" - << - "[group]\n" - "existing=old\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "existing=old\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '[group]'\n" + "echo 'existing=new'\n" + << + "[group]\n" + "existing=old\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "existing=old\n" + ; QTest::newRow("modify-key-overwrite") - << - "File=testrc\n" - "Options=overwrite\n" - "Script=test.sh,sh\n" - << - "echo '[group]'\n" - "echo 'existing=new'\n" - << - "[group]\n" - "existing=old\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "existing=new\n" - ; + << + "File=testrc\n" + "Options=overwrite\n" + "Script=test.sh,sh\n" + << + "echo '[group]'\n" + "echo 'existing=new'\n" + << + "[group]\n" + "existing=old\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "existing=new\n" + ; QTest::newRow("new-key-in-subgroup") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group][sub]'\n" - "echo 'new=value2'\n" - << - "[group][sub]\n" - "existing=foo\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group][sub]\n" - "existing=foo\n" - "new=value2\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '[group][sub]'\n" + "echo 'new=value2'\n" + << + "[group][sub]\n" + "existing=foo\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group][sub]\n" + "existing=foo\n" + "new=value2\n" + ; QTest::newRow("new-key-in-subgroup2") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '[group][sub]'\n" - "echo 'new=value3'\n" - << - "[group][sub]\n" - "existing=foo\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group][sub]\n" - "existing=foo\n" - "new=value3\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '[group][sub]'\n" + "echo 'new=value3'\n" + << + "[group][sub]\n" + "existing=foo\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group][sub]\n" + "existing=foo\n" + "new=value3\n" + ; QTest::newRow("filter") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE [group]changed'\n" - "sed s/value/VALUE/\n" - << - "[group]\n" - "changed=value\n" - "unchanged=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "changed=VALUE\n" - "unchanged=value\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '# DELETE [group]changed'\n" + "sed s/value/VALUE/\n" + << + "[group]\n" + "changed=value\n" + "unchanged=value\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "changed=VALUE\n" + "unchanged=value\n" + ; QTest::newRow("filter-subgroup") - << - "File=testrc\n" - "Script=test.sh,sh\n" - << - "echo '# DELETE [group][sub]changed'\n" - "sed s/value/VALUE/\n" - << - "[group]\n" - "unchanged=value\n" - "\n" - "[group][sub]\n" - "changed=value\n" - "unchanged=value\n" - << - "[$Version]\n" - "update_info=%1\n" - "\n" - "[group]\n" - "unchanged=value\n" - "\n" - "[group][sub]\n" - "changed=VALUE\n" - "unchanged=value\n" - ; + << + "File=testrc\n" + "Script=test.sh,sh\n" + << + "echo '# DELETE [group][sub]changed'\n" + "sed s/value/VALUE/\n" + << + "[group]\n" + "unchanged=value\n" + "\n" + "[group][sub]\n" + "changed=value\n" + "unchanged=value\n" + << + "[$Version]\n" + "update_info=%1\n" + "\n" + "[group]\n" + "unchanged=value\n" + "\n" + "[group][sub]\n" + "changed=VALUE\n" + "unchanged=value\n" + ; } void TestKConfUpdate::testScript() @@ -544,8 +544,8 @@ void TestKConfUpdate::testScript() runKConfUpdate(updFile->fileName()); QString updateInfo = QString("%1:%2") - .arg(updFile->fileName().section('/', -1)) - .arg(QTest::currentDataTag()); + .arg(updFile->fileName().section('/', -1)) + .arg(QTest::currentDataTag()); QString newConfContent = readFile(confPath); expectedNewConfContent = expectedNewConfContent.arg(updateInfo); QCOMPARE(newConfContent, expectedNewConfContent); diff --git a/autotests/test_kconfigutils.cpp b/autotests/test_kconfigutils.cpp index 176d771f..b28e8e0a 100644 --- a/autotests/test_kconfigutils.cpp +++ b/autotests/test_kconfigutils.cpp @@ -36,28 +36,28 @@ void TestKConfigUtils::testParseGroupString_data() QTest::addColumn<bool>("expectedOk"); QTest::newRow("simple-group") - << " group " - << (QStringList() << "group") - << true - ; + << " group " + << (QStringList() << "group") + << true + ; QTest::newRow("sub-group") - << "[group][sub]" - << (QStringList() << "group" << "sub") - << true - ; + << "[group][sub]" + << (QStringList() << "group" << "sub") + << true + ; QTest::newRow("crazy-sub-group") - << "[a\\ttab\\x5d[and some hex esc\\x61pe]" - << (QStringList() << "a\ttab" << "and some hex escape") - << true - ; + << "[a\\ttab\\x5d[and some hex esc\\x61pe]" + << (QStringList() << "a\ttab" << "and some hex escape") + << true + ; QTest::newRow("missing-closing-brace") - << "[group][sub" - << QStringList() - << false - ; + << "[group][sub" + << QStringList() + << false + ; } void TestKConfigUtils::testParseGroupString() @@ -86,46 +86,46 @@ void TestKConfigUtils::testUnescapeString_data() QTest::addColumn<bool>("expectedOk"); QTest::newRow("plain") - << "Some text" - << "Some text" - << true - ; + << "Some text" + << "Some text" + << true + ; QTest::newRow("single-char-escapes") - << "01\\s23\\t45\\n67\\r89\\\\" - << "01 23\t45\n67\r89\\" - << true - ; + << "01\\s23\\t45\\n67\\r89\\\\" + << "01 23\t45\n67\r89\\" + << true + ; QTest::newRow("hex-escapes") - << "kd\\x65" - << "kde" - << true - ; + << "kd\\x65" + << "kde" + << true + ; QTest::newRow("unfinished-hex-escape") - << "kd\\x6" - << "" - << false - ; + << "kd\\x6" + << "" + << false + ; QTest::newRow("invalid-hex-escape") - << "kd\\xzz" - << "" - << false - ; + << "kd\\xzz" + << "" + << false + ; QTest::newRow("invalid-escape-sequence") - << "Foo\\a" - << "" - << false - ; + << "Foo\\a" + << "" + << false + ; QTest::newRow("unfinished-escape-sequence") - << "Foo\\" - << "" - << false - ; + << "Foo\\" + << "" + << false + ; } void TestKConfigUtils::testUnescapeString() |