aboutsummaryrefslogtreecommitdiff
path: root/autotests
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2021-02-22 17:38:09 +0200
committerAhmad Samir <a.samirh78@gmail.com>2021-02-22 17:38:09 +0200
commit8bed00ab34e31f2b9c70026d418d923913325798 (patch)
treef289c15575415a36bc19c047a2037998e9b11ce8 /autotests
parent186755fd56b58dc97250846c5305ef89f9487f86 (diff)
downloadkconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.gz
kconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.bz2
Run clang-format on all cpp/h files
NO_CHANGELOG
Diffstat (limited to 'autotests')
-rw-r--r--autotests/fallbackconfigresourcestest.cpp2
-rw-r--r--autotests/helper.h3
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test.cpp153
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test.h2
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp103
-rw-r--r--autotests/kconfig_compiler/myprefs.h5
-rw-r--r--autotests/kconfig_compiler/test1main.cpp2
-rw-r--r--autotests/kconfig_compiler/test4main.cpp2
-rw-r--r--autotests/kconfig_compiler/test9main.cpp2
-rw-r--r--autotests/kconfig_compiler/test_param_minmax_main.cpp1
-rw-r--r--autotests/kconfig_compiler/test_qdebugcategory_debug.cpp2
-rw-r--r--autotests/kconfig_compiler/test_qdebugcategory_debug.h1
-rw-r--r--autotests/kconfigguitest.cpp13
-rw-r--r--autotests/kconfigloadertest.cpp17
-rw-r--r--autotests/kconfignokdehometest.cpp2
-rw-r--r--autotests/kconfigskeletontest.cpp8
-rw-r--r--autotests/kconfigskeletontest.h2
-rw-r--r--autotests/kconfigtest.cpp126
-rw-r--r--autotests/kconfigtest.h13
-rw-r--r--autotests/kdesktopfiletest.cpp141
-rw-r--r--autotests/kdesktopfiletest.h1
-rw-r--r--autotests/kentrymaptest.h2
-rw-r--r--autotests/ksharedconfig_in_global_object.cpp4
-rw-r--r--autotests/ksharedconfigtest.cpp7
-rw-r--r--autotests/kstandardshortcuttest.cpp4
-rw-r--r--autotests/test_kconf_update.cpp757
-rw-r--r--autotests/test_kconfigutils.cpp101
27 files changed, 665 insertions, 811 deletions
diff --git a/autotests/fallbackconfigresourcestest.cpp b/autotests/fallbackconfigresourcestest.cpp
index 0b1a3697..56d065cc 100644
--- a/autotests/fallbackconfigresourcestest.cpp
+++ b/autotests/fallbackconfigresourcestest.cpp
@@ -6,8 +6,8 @@
*/
#include <QTest>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
class FallbackConfigResourcesTest : public QObject
{
diff --git a/autotests/helper.h b/autotests/helper.h
index 20aed445..513916a6 100644
--- a/autotests/helper.h
+++ b/autotests/helper.h
@@ -15,13 +15,14 @@ class DefaultLocale
{
public:
DefaultLocale()
- : m_defaultLocale()
+ : m_defaultLocale()
{
}
~DefaultLocale()
{
QLocale::setDefault(m_defaultLocale);
}
+
private:
QLocale m_defaultLocale;
};
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
index 4467a211..090fe01d 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
@@ -7,77 +7,101 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
+#include "kconfigcompiler_test.h"
#include <QDir>
#include <QProcess>
#include <QString>
#include <QTest>
#include <qstandardpaths.h>
-#include "kconfigcompiler_test.h"
// 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",
- "test8c.cpp", "test8c.h",
- "test9.h", "test9.cpp",
- "test10.h", "test10.cpp",
- "test11.h", "test11.cpp",
- "test11a.h", "test11a.cpp",
- "test12.h", "test12.cpp",
- "test13.h", "test13.cpp",
- "test_dpointer.cpp", "test_dpointer.h",
- "test_qdebugcategory.cpp", "test_qdebugcategory.h",
- "test_signal.cpp", "test_signal.h",
- "test_notifiers.cpp", "test_notifiers.h",
- "test_translation_kde.cpp", "test_translation_kde.h",
- "test_translation_kde_domain.cpp", "test_translation_kde_domain.h",
- "test_translation_qt.cpp", "test_translation_qt.h",
- "test_emptyentries.cpp", "test_emptyentries.h",
- "test_properties_minmax.cpp", "test_properties_minmax.h",
- "test_param_minmax.cpp", "test_param_minmax.h",
- "test_subgroups.cpp", "test_subgroups.h",
- nullptr
-};
-
-static CompilerTestSet testCasesToRun = {
- "test1",
- "test2",
- "test3",
- "test3a",
- "test4",
- "test5",
- "test6",
- "test7",
- "test8",
- "test9",
- "test10",
- "test11",
- "test12",
- "test13",
- "test_dpointer",
- "test_qdebugcategory",
- "test_signal",
- "test_translation_kde",
- "test_translation_kde_domain",
- "test_translation_qt",
- "test_emptyentries",
- "test_properties_minmax",
- "test_param_minmax",
- "test_subgroups",
- nullptr
-};
+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",
+ "test8c.cpp",
+ "test8c.h",
+ "test9.h",
+ "test9.cpp",
+ "test10.h",
+ "test10.cpp",
+ "test11.h",
+ "test11.cpp",
+ "test11a.h",
+ "test11a.cpp",
+ "test12.h",
+ "test12.cpp",
+ "test13.h",
+ "test13.cpp",
+ "test_dpointer.cpp",
+ "test_dpointer.h",
+ "test_qdebugcategory.cpp",
+ "test_qdebugcategory.h",
+ "test_signal.cpp",
+ "test_signal.h",
+ "test_notifiers.cpp",
+ "test_notifiers.h",
+ "test_translation_kde.cpp",
+ "test_translation_kde.h",
+ "test_translation_kde_domain.cpp",
+ "test_translation_kde_domain.h",
+ "test_translation_qt.cpp",
+ "test_translation_qt.h",
+ "test_emptyentries.cpp",
+ "test_emptyentries.h",
+ "test_properties_minmax.cpp",
+ "test_properties_minmax.h",
+ "test_param_minmax.cpp",
+ "test_param_minmax.h",
+ "test_subgroups.cpp",
+ "test_subgroups.h",
+ nullptr};
+
+static CompilerTestSet testCasesToRun = {"test1",
+ "test2",
+ "test3",
+ "test3a",
+ "test4",
+ "test5",
+ "test6",
+ "test7",
+ "test8",
+ "test9",
+ "test10",
+ "test11",
+ "test12",
+ "test13",
+ "test_dpointer",
+ "test_qdebugcategory",
+ "test_signal",
+ "test_translation_kde",
+ "test_translation_kde_domain",
+ "test_translation_qt",
+ "test_emptyentries",
+ "test_properties_minmax",
+ "test_param_minmax",
+ "test_subgroups",
+ nullptr};
#if 0
static CompilerTestSet willFailCases = {
@@ -89,7 +113,7 @@ static CompilerTestSet willFailCases = {
void KConfigCompiler_Test::initTestCase()
{
- m_diffExe = QStandardPaths::findExecutable( QStringLiteral("diff") );
+ m_diffExe = QStandardPaths::findExecutable(QStringLiteral("diff"));
if (m_diffExe.isEmpty()) {
qDebug() << "diff command not found, detailed info on comparison failure will not be available.";
}
@@ -122,7 +146,7 @@ void KConfigCompiler_Test::testBaselineComparison()
const QByteArray content = file.readAll();
const QByteArray contentRef = fileRef.readAll();
- if (content != contentRef) {
+ if (content != contentRef) {
appendFileDiff(fileRef.fileName(), file.fileName());
}
@@ -164,10 +188,7 @@ void KConfigCompiler_Test::appendFileDiff(const QString &oldFile, const QString
return;
}
- QStringList args({
- QStringLiteral("-u"),
- QFileInfo(oldFile).absoluteFilePath(),
- QFileInfo(newFile).absoluteFilePath() });
+ QStringList args({QStringLiteral("-u"), QFileInfo(oldFile).absoluteFilePath(), QFileInfo(newFile).absoluteFilePath()});
QProcess process;
process.start(m_diffExe, args, QIODevice::ReadOnly);
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.h b/autotests/kconfig_compiler/kconfigcompiler_test.h
index e0506db0..c8242cfd 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test.h
+++ b/autotests/kconfig_compiler/kconfigcompiler_test.h
@@ -24,6 +24,7 @@ private Q_SLOTS:
void testBaselineComparison();
void testRunning_data();
void testRunning();
+
private:
void appendFileDiff(const QString &oldFile, const QString &newFile);
@@ -31,4 +32,3 @@ private:
};
#endif
-
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
index 3637b1ff..f493d35f 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test_signals.cpp
@@ -4,17 +4,17 @@
SPDX-License-Identifier: MIT
*/
-#include "signals_test_singleton.h"
#include "signals_test_no_singleton.h"
-#include "signals_test_singleton_dpointer.h"
#include "signals_test_no_singleton_dpointer.h"
-#include <QtTestGui>
-#include <QSignalSpy>
-#include <QSharedPointer>
-#include <QtGlobal>
+#include "signals_test_singleton.h"
+#include "signals_test_singleton_dpointer.h"
#include <QDebug>
-#include <QTemporaryFile>
#include <QFileInfo>
+#include <QSharedPointer>
+#include <QSignalSpy>
+#include <QTemporaryFile>
+#include <QtGlobal>
+#include <QtTestGui>
#include <functional>
class KConfigCompiler_Test_Signals : public QObject
@@ -29,17 +29,17 @@ private Q_SLOTS:
void cleanupTestCase();
};
-static SignalsTestNoSingleton* noSingleton;
-static SignalsTestNoSingletonDpointer* noSingletonDpointer;
+static SignalsTestNoSingleton *noSingleton;
+static SignalsTestNoSingletonDpointer *noSingletonDpointer;
void KConfigCompiler_Test_Signals::initTestCase()
{
// These tests do a lot quite a few I/O operations, speed that up by using a QTemporaryFile.
// At least on Linux this is often a tmpfs which means only RAM operations
- QTemporaryFile* tempFile1 = new QTemporaryFile(this);
- QTemporaryFile* tempFile2 = new QTemporaryFile(this);
- QTemporaryFile* tempFile3 = new QTemporaryFile(this);
- QTemporaryFile* tempFile4 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile1 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile2 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile3 = new QTemporaryFile(this);
+ QTemporaryFile *tempFile4 = new QTemporaryFile(this);
QVERIFY(tempFile1->open());
QVERIFY(tempFile2->open());
QVERIFY(tempFile3->open());
@@ -47,15 +47,13 @@ void KConfigCompiler_Test_Signals::initTestCase()
SignalsTestSingleton::instance(QFileInfo(*tempFile1).absoluteFilePath());
SignalsTestSingletonDpointer::instance(QFileInfo(*tempFile2).absoluteFilePath());
- noSingleton = new SignalsTestNoSingleton(
- KSharedConfig::openConfig(QFileInfo(*tempFile3).absoluteFilePath(), KConfig::SimpleConfig));
- noSingletonDpointer = new SignalsTestNoSingletonDpointer(
- KSharedConfig::openConfig(QFileInfo(*tempFile4).absoluteFilePath(), KConfig::SimpleConfig));
+ noSingleton = new SignalsTestNoSingleton(KSharedConfig::openConfig(QFileInfo(*tempFile3).absoluteFilePath(), KConfig::SimpleConfig));
+ noSingletonDpointer = new SignalsTestNoSingletonDpointer(KSharedConfig::openConfig(QFileInfo(*tempFile4).absoluteFilePath(), KConfig::SimpleConfig));
}
void KConfigCompiler_Test_Signals::cleanupTestCase()
{
- //ensure these instances are deleted before the temporary files are closed
+ // ensure these instances are deleted before the temporary files are closed
delete noSingleton;
delete noSingletonDpointer;
delete SignalsTestSingleton::self();
@@ -64,18 +62,29 @@ void KConfigCompiler_Test_Signals::cleanupTestCase()
struct TestSettersArg {
// default constructor required for Q_DECLARE_METATYPE
- TestSettersArg() : obj(nullptr) {}
+ TestSettersArg()
+ : obj(nullptr)
+ {
+ }
template<typename T>
- TestSettersArg(T* object) : obj(object) {
+ TestSettersArg(T *object)
+ : obj(object)
+ {
// we can also call static methods using object->foo() so this works for all four cases
- getter = [object]() { return object->foo(); };
- defaultGetter = [object]() { return object->defaultFooValue(); };
- setter = [object](const QString& s) { object->setFoo(s); };
+ getter = [object]() {
+ return object->foo();
+ };
+ defaultGetter = [object]() {
+ return object->defaultFooValue();
+ };
+ setter = [object](const QString &s) {
+ object->setFoo(s);
+ };
}
- KCoreConfigSkeleton* obj;
+ KCoreConfigSkeleton *obj;
std::function<QString()> getter;
std::function<QString()> defaultGetter;
- std::function<void(const QString&)> setter;
+ std::function<void(const QString &)> setter;
};
Q_DECLARE_METATYPE(TestSettersArg) // so that QFETCH works
@@ -93,7 +102,7 @@ void KConfigCompiler_Test_Signals::testSetters_data()
void KConfigCompiler_Test_Signals::testSetters()
{
QFETCH(TestSettersArg, params);
- const char* signal = SIGNAL(fooChanged(QString));
+ const char *signal = SIGNAL(fooChanged(QString));
const QString defaultValue = QStringLiteral("default");
const QString changedValue = QStringLiteral("changed");
@@ -105,21 +114,21 @@ void KConfigCompiler_Test_Signals::testSetters()
QSignalSpy spy(params.obj, signal);
QVERIFY2(spy.isValid(), signal);
- //change value via setter, should get signal
+ // change value via setter, should get signal
QCOMPARE(params.getter(), defaultValue);
QCOMPARE(defaultValue, params.defaultGetter());
QCOMPARE(params.getter(), params.defaultGetter());
QVERIFY(changedValue != params.getter());
params.setter(changedValue);
QCOMPARE(params.getter(), changedValue);
- QCOMPARE(spy.count(), 0); //should have no change yet, only after save()
+ QCOMPARE(spy.count(), 0); // should have no change yet, only after save()
params.obj->save();
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
QCOMPARE(args.size(), 1);
QCOMPARE(args[0].toString(), changedValue);
- //reset to default values via setDefaults()
+ // reset to default values via setDefaults()
QVERIFY(params.getter() != params.defaultGetter());
QVERIFY(params.getter() != defaultValue);
QCOMPARE(params.getter(), changedValue);
@@ -127,67 +136,67 @@ void KConfigCompiler_Test_Signals::testSetters()
QCOMPARE(params.getter(), params.defaultGetter());
QCOMPARE(params.getter(), defaultValue);
- QCOMPARE(spy.count(), 0); //should have no change yet, only after save()
+ QCOMPARE(spy.count(), 0); // should have no change yet, only after save()
params.obj->save();
- //TODO: This currently fails since setDefaults() does not yet cause emitting a signal
+ // TODO: This currently fails since setDefaults() does not yet cause emitting a signal
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
QCOMPARE(args.size(), 1);
QCOMPARE(args[0].value<QString>(), defaultValue);
}
-Q_DECLARE_METATYPE(KCoreConfigSkeleton*)
+Q_DECLARE_METATYPE(KCoreConfigSkeleton *)
void KConfigCompiler_Test_Signals::testSetProperty_data()
{
- QTest::addColumn<KCoreConfigSkeleton*>("obj");
- QTest::newRow("singleton") << static_cast<KCoreConfigSkeleton*>(SignalsTestSingleton::self());
- QTest::newRow("singleton dpointer") << static_cast<KCoreConfigSkeleton*>(SignalsTestSingletonDpointer::self());
- QTest::newRow("non-singleton") << static_cast<KCoreConfigSkeleton*>(noSingleton);
- QTest::newRow("non-singleton dpointer") << static_cast<KCoreConfigSkeleton*>(noSingletonDpointer);
+ QTest::addColumn<KCoreConfigSkeleton *>("obj");
+ QTest::newRow("singleton") << static_cast<KCoreConfigSkeleton *>(SignalsTestSingleton::self());
+ QTest::newRow("singleton dpointer") << static_cast<KCoreConfigSkeleton *>(SignalsTestSingletonDpointer::self());
+ QTest::newRow("non-singleton") << static_cast<KCoreConfigSkeleton *>(noSingleton);
+ QTest::newRow("non-singleton dpointer") << static_cast<KCoreConfigSkeleton *>(noSingletonDpointer);
}
/** Test that the signal is emitted when modifying the values using the underlying KConfigSkeletonItem (bypassing the setters) */
void KConfigCompiler_Test_Signals::testSetProperty()
{
- QFETCH(KCoreConfigSkeleton*, obj);
- const char* signal = SIGNAL(fooChanged(QString));
+ QFETCH(KCoreConfigSkeleton *, obj);
+ const char *signal = SIGNAL(fooChanged(QString));
const QString propertyName = QStringLiteral("foo");
const QString defaultValue = QStringLiteral("default");
const QString newValue = QStringLiteral("changed");
obj->setDefaults();
obj->save();
- KConfigSkeletonItem* item = obj->findItem(propertyName);
+ KConfigSkeletonItem *item = obj->findItem(propertyName);
QVERIFY2(item, "Item must exist");
QVERIFY2(!item->isImmutable(), "Item must not be immutable");
QVERIFY2(!obj->isImmutable(propertyName), "Item must not be immutable");
- //listen for all expected signals
+ // listen for all expected signals
QSignalSpy spy(obj, signal);
QVERIFY2(spy.isValid(), signal);
QVERIFY(item->isEqual(defaultValue));
QVERIFY(!item->isEqual(newValue));
- item->setProperty(newValue); //change value now
- //should have no change yet, only after save()
+ item->setProperty(newValue); // change value now
+ // should have no change yet, only after save()
QCOMPARE(spy.count(), 0);
obj->save();
- //now check for the signal emissions
+ // now check for the signal emissions
QCOMPARE(spy.count(), 1);
QList<QVariant> args = spy.takeFirst();
QCOMPARE(args.size(), 1);
QVERIFY(item->isEqual(args[0]));
- //now reset to default
+ // now reset to default
QVERIFY(!item->isEqual(defaultValue));
item->setDefault();
QVERIFY(item->isEqual(defaultValue));
- //should have no change yet, only after save()
+ // should have no change yet, only after save()
QCOMPARE(spy.count(), 0);
obj->save();
- //now check for the signal emissions
+ // now check for the signal emissions
QCOMPARE(spy.count(), 1);
args = spy.takeFirst();
QCOMPARE(args.size(), 1);
diff --git a/autotests/kconfig_compiler/myprefs.h b/autotests/kconfig_compiler/myprefs.h
index 609fc546..073352b9 100644
--- a/autotests/kconfig_compiler/myprefs.h
+++ b/autotests/kconfig_compiler/myprefs.h
@@ -6,7 +6,10 @@
class MyPrefs : public KConfigSkeleton
{
public:
- MyPrefs(const QString &a) : KConfigSkeleton(a) {}
+ MyPrefs(const QString &a)
+ : KConfigSkeleton(a)
+ {
+ }
};
#endif
diff --git a/autotests/kconfig_compiler/test1main.cpp b/autotests/kconfig_compiler/test1main.cpp
index 5a7eda0c..43dcd2c1 100644
--- a/autotests/kconfig_compiler/test1main.cpp
+++ b/autotests/kconfig_compiler/test1main.cpp
@@ -4,9 +4,9 @@
SPDX-License-Identifier: MIT
*/
#include "test1.h"
-#include <QGuiApplication>
#include <KConfig>
#include <KConfigGroup>
+#include <QGuiApplication>
int main(int argc, char **argv)
{
diff --git a/autotests/kconfig_compiler/test4main.cpp b/autotests/kconfig_compiler/test4main.cpp
index 8792842f..fa9bf7dc 100644
--- a/autotests/kconfig_compiler/test4main.cpp
+++ b/autotests/kconfig_compiler/test4main.cpp
@@ -5,9 +5,9 @@
*/
#include "test4.h"
+#include <QFile>
#include <QGuiApplication>
#include <QStandardPaths>
-#include <QFile>
int main(int argc, char **argv)
{
diff --git a/autotests/kconfig_compiler/test9main.cpp b/autotests/kconfig_compiler/test9main.cpp
index 03c43f1b..0a7256f1 100644
--- a/autotests/kconfig_compiler/test9main.cpp
+++ b/autotests/kconfig_compiler/test9main.cpp
@@ -5,9 +5,9 @@
*/
#include "test9.h"
+#include <QDebug>
#include <QDir>
#include <QGuiApplication>
-#include <QDebug>
int main(int argc, char **argv)
{
diff --git a/autotests/kconfig_compiler/test_param_minmax_main.cpp b/autotests/kconfig_compiler/test_param_minmax_main.cpp
index 57fc26a7..9756a32f 100644
--- a/autotests/kconfig_compiler/test_param_minmax_main.cpp
+++ b/autotests/kconfig_compiler/test_param_minmax_main.cpp
@@ -26,4 +26,3 @@ int main(int, char **)
delete t;
return 0;
}
-
diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp
index 7c4f9f55..2526254c 100644
--- a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp
+++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp
@@ -1,4 +1,2 @@
#include "test_qdebugcategory_debug.h"
Q_LOGGING_CATEGORY(CATEGORY_LOG, "log_category")
-
-
diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.h b/autotests/kconfig_compiler/test_qdebugcategory_debug.h
index 88ac4f35..a92e54ca 100644
--- a/autotests/kconfig_compiler/test_qdebugcategory_debug.h
+++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.h
@@ -5,4 +5,3 @@
Q_DECLARE_LOGGING_CATEGORY(CATEGORY_LOG)
#endif
-
diff --git a/autotests/kconfigguitest.cpp b/autotests/kconfigguitest.cpp
index 2744d272..a9d3931a 100644
--- a/autotests/kconfigguitest.cpp
+++ b/autotests/kconfigguitest.cpp
@@ -4,13 +4,13 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
-#include <QtTestGui>
#include "kconfigguitest.h"
+#include <QtTestGui>
-#include <kconfig.h>
#include <QDir>
#include <QFont>
#include <QStandardPaths>
+#include <kconfig.h>
#include <kconfiggroup.h>
#include <kconfigskeleton.h>
@@ -77,8 +77,7 @@ void KConfigTest::testComplex()
KConfig sc2(QStringLiteral("kconfigtest"));
KConfigGroup sc3(&sc2, "ComplexTypes");
- QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(),
- QVariant(s_color_entry1).toString());
+ QCOMPARE(QVariant(sc3.readEntry("colorEntry1", QColor(Qt::black))).toString(), QVariant(s_color_entry1).toString());
QCOMPARE(sc3.readEntry("colorEntry1", QColor()), s_color_entry1);
QCOMPARE(sc3.readEntry("colorEntry2", QColor()), s_color_entry2);
QCOMPARE(sc3.readEntry("colorEntry3", QColor()), s_color_entry3);
@@ -118,19 +117,19 @@ void KConfigTest::testInvalid()
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());
- 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
+ QVERIFY(sc3.readEntry("badList", QColor()) == QColor()); // out of bounds
// 5 element list
list[2] = 3;
diff --git a/autotests/kconfigloadertest.cpp b/autotests/kconfigloadertest.cpp
index ab93c1da..17bfe403 100644
--- a/autotests/kconfigloadertest.cpp
+++ b/autotests/kconfigloadertest.cpp
@@ -7,20 +7,20 @@
#include <kconfig.h>
#include <kconfiggroup.h>
-#include <kconfigskeleton.h>
#include <kconfigloader.h>
+#include <kconfigskeleton.h>
Q_DECLARE_METATYPE(QList<int>)
static const QString s_testName(QStringLiteral("kconfigloadertest")); // clazy:exclude=non-pod-global-static
-#define GET_CONFIG_ITEM_VALUE(type, configName) \
- KConfigSkeletonItem* item = cl->findItem(s_testName, configName); \
- /* Check if we got back a valid item. */ \
- QVERIFY(item != nullptr); \
- /* Cast the item to the given type. */ \
- type typeItem = dynamic_cast<type>(item); \
- /* Make sure the cast was successful. */ \
+#define GET_CONFIG_ITEM_VALUE(type, configName) \
+ KConfigSkeletonItem *item = cl->findItem(s_testName, configName); \
+ /* Check if we got back a valid item. */ \
+ QVERIFY(item != nullptr); \
+ /* Cast the item to the given type. */ \
+ type typeItem = dynamic_cast<type>(item); \
+ /* Make sure the cast was successful. */ \
QVERIFY(typeItem != nullptr);
void ConfigLoaderTest::init()
@@ -191,4 +191,3 @@ void ConfigLoaderTest::ulongLongDefaultValue()
}
QTEST_MAIN(ConfigLoaderTest)
-
diff --git a/autotests/kconfignokdehometest.cpp b/autotests/kconfignokdehometest.cpp
index 1d05d98d..6cb105ef 100644
--- a/autotests/kconfignokdehometest.cpp
+++ b/autotests/kconfignokdehometest.cpp
@@ -6,8 +6,8 @@
#include <QObject>
-#include <QTest>
#include <QStandardPaths>
+#include <QTest>
#include <ksharedconfig.h>
#include <kconfig.h>
diff --git a/autotests/kconfigskeletontest.cpp b/autotests/kconfigskeletontest.cpp
index 950e6581..88936f1e 100644
--- a/autotests/kconfigskeletontest.cpp
+++ b/autotests/kconfigskeletontest.cpp
@@ -6,20 +6,20 @@
#include "kconfigskeletontest.h"
-#include <kconfig.h>
#include <QFont>
#include <QtTestGui>
+#include <kconfig.h>
QTEST_MAIN(KConfigSkeletonTest)
// clazy:excludeall=non-pod-global-static
static const bool s_default_setting1{false};
-static const QColor s_default_setting2{1,2,3};
+static const QColor s_default_setting2{1, 2, 3};
static const QString s_default_setting4{QStringLiteral("Hello World")};
static const bool s_write_setting1{true};
-static const QColor s_write_setting2{3,2,1};
+static const QColor s_write_setting2{3, 2, 1};
static const QString s_write_setting4{QStringLiteral("KDE")};
static QFont defaultSetting3()
@@ -29,7 +29,7 @@ static QFont defaultSetting3()
static QFont writeSettings3()
{
- return QFont{QStringLiteral("helvetica"), 14};
+ return QFont{QStringLiteral("helvetica"), 14};
}
void KConfigSkeletonTest::initTestCase()
diff --git a/autotests/kconfigskeletontest.h b/autotests/kconfigskeletontest.h
index 6bac81d2..8c6d3aa7 100644
--- a/autotests/kconfigskeletontest.h
+++ b/autotests/kconfigskeletontest.h
@@ -12,7 +12,6 @@ class KConfigSkeletonTest : public QObject
{
Q_OBJECT
public:
-
private Q_SLOTS:
void initTestCase();
void init();
@@ -31,7 +30,6 @@ private:
QColor mMyColor;
QFont mMyFont;
QString mMyString;
-
};
#endif
diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp
index be84efec..bf7882f0 100644
--- a/autotests/kconfigtest.cpp
+++ b/autotests/kconfigtest.cpp
@@ -9,16 +9,16 @@
#include "config-kconfig.h"
-#include <QTest>
-#include <qtemporarydir.h>
-#include <QStandardPaths>
#include <QSignalSpy>
+#include <QStandardPaths>
#include <QTemporaryFile>
+#include <QTest>
#include <kdesktopfile.h>
+#include <qtemporarydir.h>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
#include <kconfigwatcher.h>
+#include <ksharedconfig.h>
#ifdef Q_OS_UNIX
#include <utime.h>
@@ -125,7 +125,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("boolEntry2", s_bool_entry2);
QByteArray data(s_utf8bit_entry);
- QCOMPARE(data.size(), 12); // the source file is in utf8
+ QCOMPARE(data.size(), 12); // the source file is in utf8
QCOMPARE(QString::fromUtf8(data).length(), 9);
cg.writeEntry("Test", data);
cg.writeEntry("bytearrayEntry", s_bytearray_entry);
@@ -139,7 +139,7 @@ void KConfigTest::initTestCase()
cg.writeEntry("urlEntry1", QUrl(QStringLiteral("http://qt-project.org")));
cg.writeEntry("keywith=equalsign", s_string_entry1);
cg.deleteEntry("stringEntry5");
- cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry
+ cg.deleteEntry("stringEntry6"); // deleting a nonexistent entry
cg.writeEntry("byteArrayEntry1", s_string_entry1.toLatin1(), KConfig::Global | KConfig::Persistent);
cg.writeEntry("doubleEntry1", s_double_entry);
cg.writeEntry("floatEntry1", s_float_entry);
@@ -187,7 +187,7 @@ void KConfigTest::initTestCase()
#if defined(_MSC_VER) && _MSC_VER == 1600
cg.writeEntry("dummy", 42);
#else
- //Visual C++ 2010 throws an Internal Compiler Error here
+ // Visual C++ 2010 throws an Internal Compiler Error here
cg.writeEntry("enum-10", Tens);
cg.writeEntry("enum-100", Hundreds);
cg.writeEntry("flags-bit0", Flags(bit0));
@@ -217,7 +217,7 @@ void KConfigTest::initTestCase()
sg0.writeEntry("FatalOutput", 0);
QVERIFY(sc1.sync());
- //Setup stuff to test KConfig::addConfigSources()
+ // Setup stuff to test KConfig::addConfigSources()
KConfig devcfg(s_test_subdir + QLatin1String("specificrc"));
KConfigGroup devonlygrp(&devcfg, "Specific Only Group");
devonlygrp.writeEntry("ExistingEntry", "DevValue");
@@ -236,14 +236,13 @@ void KConfigTest::initTestCase()
KConfig gecfg(s_test_subdir + QLatin1String("groupescapetest"), KConfig::SimpleConfig);
cg = KConfigGroup(&gecfg, s_dollargroup);
cg.writeEntry("entry", "doesntmatter");
-
}
void KConfigTest::cleanupTestCase()
{
- //ensure we don't delete the real directory
+ // ensure we don't delete the real directory
QDir localConfig(m_testConfigDir);
- //qDebug() << "Erasing" << localConfig;
+ // qDebug() << "Erasing" << localConfig;
if (localConfig.exists()) {
QVERIFY(localConfig.removeRecursively());
}
@@ -342,7 +341,7 @@ void KConfigTest::testSimple()
KConfigGroup sc3(&sc2, "AAA");
- QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals
+ QVERIFY(sc3.hasKey("stringEntry1")); // from kdeglobals
QVERIFY(!sc3.isEntryImmutable("stringEntry1"));
QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1);
@@ -356,7 +355,7 @@ void KConfigTest::testSimple()
QCOMPARE(sc3.readEntry("bytearrayEntry", QByteArray()), s_bytearray_entry);
QCOMPARE(sc3.readEntry(s_escapekey), QString::fromLatin1(s_escape_entry));
QCOMPARE(sc3.readEntry("Test", QString{}), QString::fromUtf8(s_utf8bit_entry));
- QCOMPARE(sc3.readEntry("emptyEntry"/*, QString("Fietsbel")*/), QLatin1String(""));
+ QCOMPARE(sc3.readEntry("emptyEntry" /*, QString("Fietsbel")*/), QLatin1String(""));
QCOMPARE(sc3.readEntry("emptyEntry", QStringLiteral("Fietsbel")).isEmpty(), true);
QCOMPARE(sc3.readEntry("stringEntry1"), s_string_entry1);
QCOMPARE(sc3.readEntry("stringEntry2"), s_string_entry2);
@@ -542,7 +541,7 @@ void KConfigTest::testPath()
QVERIFY(group.hasKey("noeol"));
QCOMPARE(group.readEntry("noeol", QString{}), QStringLiteral("foo"));
- const auto val = QStringList { QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")};
+ const auto val = QStringList{QStringLiteral("aaa"), QStringLiteral("bb/b"), QStringLiteral("ccc,ccc")};
QCOMPARE(group.readPathEntry(QStringLiteral("escapes"), QStringList()), val);
}
@@ -586,14 +585,17 @@ void KConfigTest::testPathQtHome()
qunsetenv("QT_CACHE_HOME");
qunsetenv("QT_CONFIG_HOME");
QVERIFY(group.hasKey("dataDir"));
- QCOMPARE(group.readEntry("dataDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest")));
+ QCOMPARE(group.readEntry("dataDir", QString{}),
+ QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append(QStringLiteral("/kconfigtest")));
QVERIFY(group.hasKey("cacheDir"));
- QCOMPARE(group.readEntry("cacheDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest")));
+ QCOMPARE(group.readEntry("cacheDir", QString{}),
+ QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation).append(QStringLiteral("/kconfigtest")));
QVERIFY(group.hasKey("configDir"));
- QCOMPARE(group.readEntry("configDir", QString{}), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest")));
- qputenv("QT_DATA_HOME","/1");
- qputenv("QT_CACHE_HOME","/2");
- qputenv("QT_CONFIG_HOME","/3");
+ QCOMPARE(group.readEntry("configDir", QString{}),
+ QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation).append(QStringLiteral("/kconfigtest")));
+ qputenv("QT_DATA_HOME", "/1");
+ qputenv("QT_CACHE_HOME", "/2");
+ qputenv("QT_CONFIG_HOME", "/3");
QVERIFY(group.hasKey("dataDir"));
QCOMPARE(group.readEntry("dataDir", QString{}), QStringLiteral("/1/kconfigtest"));
QVERIFY(group.hasKey("cacheDir"));
@@ -618,9 +620,9 @@ void KConfigTest::testComplex()
void KConfigTest::testEnums()
{
- //Visual C++ 2010 (compiler version 16.0) throws an Internal Compiler Error
- //when compiling the code in initTestCase that creates these KConfig entries,
- //so we can't run this test
+ // Visual C++ 2010 (compiler version 16.0) throws an Internal Compiler Error
+ // when compiling the code in initTestCase that creates these KConfig entries,
+ // so we can't run this test
#if defined(_MSC_VER) && _MSC_VER == 1600
QSKIP("Visual C++ 2010 can't compile this test");
#endif
@@ -702,7 +704,7 @@ void KConfigTest::testInvalid()
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", QDate()) == QDate()); // out of bounds
QVERIFY(sc3.readEntry("badList", QDateTime()) == QDateTime());
// 4 element list
@@ -819,13 +821,13 @@ void KConfigTest::testDelete()
cg.deleteGroup();
QVERIFY(sc.entryMap(QStringLiteral("Complex Types")).isEmpty());
QVERIFY(sc.entryMap(QStringLiteral("AAA")).isEmpty());
- QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); //not deleted group
- QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); //inexistant group
+ QVERIFY(!sc.entryMap(QStringLiteral("Hello")).isEmpty()); // not deleted group
+ QVERIFY(sc.entryMap(QStringLiteral("FooBar")).isEmpty()); // inexistant group
QVERIFY(cg.sync());
// Check what happens on disk
const QList<QByteArray> lines = readLines();
- //qDebug() << lines;
+ // 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"));
@@ -1181,8 +1183,8 @@ void KConfigTest::testSubGroup()
QVERIFY(negsub4.exists());
// Only subgroups with content show up in groupList()
- //QEXPECT_FAIL("", "Empty subgroups do not show up in groupList()", Continue);
- //QCOMPARE(neg.groupList(), QStringList() << "NEG Child1" << "NEG Child2" << "NEG Child3" << "NEG Child4");
+ // QEXPECT_FAIL("", "Empty subgroups do not show up in groupList()", Continue);
+ // QCOMPARE(neg.groupList(), QStringList() << "NEG Child1" << "NEG Child2" << "NEG Child3" << "NEG Child4");
// This is what happens
QStringList groups = neg.groupList();
groups.sort(); // Qt5 made the ordering unreliable, due to QHash
@@ -1332,7 +1334,7 @@ void KConfigTest::testReparent()
QCOMPARE(group.entryMap(), originalMap);
group.reparent(&cf); // see if it can make it a top-level group again
-// QVERIFY(!parent.hasGroup(name));
+ // QVERIFY(!parent.hasGroup(name));
QCOMPARE(group.entryMap(), originalMap);
}
@@ -1377,8 +1379,7 @@ void KConfigTest::testWriteOnSync()
// Add a global entry and sync the config.
// Should not rewrite the local config file.
KConfigGroup cgGlobal(&sc, "Globals");
- cgGlobal.writeEntry("someGlobalString", "whatever",
- KConfig::Persistent | KConfig::Global);
+ cgGlobal.writeEntry("someGlobalString", "whatever", KConfig::Persistent | KConfig::Global);
QVERIFY(sc.sync());
// Verify that the timestamp of local config file didn't change.
@@ -1436,8 +1437,14 @@ void KConfigTest::testDirtyOnEqual()
void KConfigTest::testDirtyOnEqualOverdo()
{
- QByteArray val1("\0""one", 4);
- QByteArray val2("\0""two", 4);
+ QByteArray val1(
+ "\0"
+ "one",
+ 4);
+ QByteArray val2(
+ "\0"
+ "two",
+ 4);
QByteArray defvalr;
KConfig sc(s_kconfig_test_subdir);
@@ -1624,7 +1631,7 @@ void KConfigTest::testDeleteWhenLocalized()
QVERIFY(config.sync());
// Current state: [ca] and [de] entries left... oops.
- //qDebug() << readLinesFrom(file);
+ // qDebug() << readLinesFrom(file);
// Bug: The group still exists [because of the localized entries]...
QVERIFY(cg.exists());
@@ -1732,7 +1739,17 @@ void KConfigTest::testQByteArrayUtf8()
file.close();
QFile readFile(file.fileName());
QVERIFY(readFile.open(QFile::ReadOnly));
-#define VALUE "Utf8=\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff"
+#define VALUE \
+ "Utf8=" \
+ "\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x" \
+ "1f " \
+ "!\"#$%&'()*+,-./" \
+ "0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" \
+ "\\x7f\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\" \
+ "x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xb" \
+ "b\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9" \
+ "\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\" \
+ "xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff"
const QByteArray fileBytes = readFile.readAll();
#ifndef Q_OS_WIN
QCOMPARE(fileBytes, QByteArrayLiteral("[General]\n" VALUE "\n"));
@@ -1815,7 +1832,6 @@ void KConfigTest::testNewlines()
#else
QCOMPARE(readFile.readAll(), QByteArrayLiteral("[General]\r\nBar=Foo\r\nFoo=Bar\r\n"));
#endif
-
}
void KConfigTest::testXdgListEntry()
@@ -1823,7 +1839,7 @@ void KConfigTest::testXdgListEntry()
QTemporaryFile file;
QVERIFY(file.open());
QTextStream out(&file);
- out << "[General]\n"
+ out << "[General]\n"
<< "Key1=\n" // empty list
// emtpty entries
<< "Key2=;\n"
@@ -1852,7 +1868,7 @@ void KConfigTest::testXdgListEntry()
void KConfigTest::testThreads()
{
QThreadPool::globalInstance()->setMaxThreadCount(6);
- QList<QFuture<void> > futures;
+ QList<QFuture<void>> futures;
// Run in parallel some tests that work on different config files,
// otherwise unexpected things might indeed happen.
futures << QtConcurrent::run(this, &KConfigTest::testAddConfigSources);
@@ -1861,8 +1877,8 @@ void KConfigTest::testThreads()
futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig);
futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig);
// QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage...
- //futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized);
- //futures << QtConcurrent::run(this, &KConfigTest::testEntryMap);
+ // futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized);
+ // futures << QtConcurrent::run(this, &KConfigTest::testEntryMap);
for (QFuture<void> f : qAsConst(futures)) {
f.waitForFinished();
}
@@ -1877,28 +1893,28 @@ void KConfigTest::testNotify()
KConfig config(s_kconfig_test_subdir);
auto myConfigGroup = KConfigGroup(&config, "TopLevelGroup");
- //mimics a config in another process, which is watching for events
+ // mimics a config in another process, which is watching for events
auto remoteConfig = KSharedConfig::openConfig(s_kconfig_test_subdir);
KConfigWatcher::Ptr watcher = KConfigWatcher::create(remoteConfig);
- //some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals
+ // some random config that shouldn't be changing when kconfigtest changes, only on kdeglobals
auto otherRemoteConfig = KSharedConfig::openConfig(s_test_subdir + QLatin1String("kconfigtest2"));
KConfigWatcher::Ptr otherWatcher = KConfigWatcher::create(otherRemoteConfig);
QSignalSpy watcherSpy(watcher.data(), &KConfigWatcher::configChanged);
QSignalSpy otherWatcherSpy(otherWatcher.data(), &KConfigWatcher::configChanged);
- //write entries in a group and subgroup
- myConfigGroup.writeEntry("entryA", "foo", KConfig::Persistent | KConfig::Notify);
+ // write entries in a group and subgroup
+ myConfigGroup.writeEntry("entryA", "foo", KConfig::Persistent | KConfig::Notify);
auto subGroup = myConfigGroup.group("aSubGroup");
- subGroup.writeEntry("entry1", "foo", KConfig::Persistent | KConfig::Notify);
- subGroup.writeEntry("entry2", "foo", KConfig::Persistent | KConfig::Notify);
+ subGroup.writeEntry("entry1", "foo", KConfig::Persistent | KConfig::Notify);
+ subGroup.writeEntry("entry2", "foo", KConfig::Persistent | KConfig::Notify);
config.sync();
watcherSpy.wait();
QCOMPARE(watcherSpy.count(), 2);
- std::sort(watcherSpy.begin(), watcherSpy.end(), [] (QList<QVariant> a, QList<QVariant> b) {
- return a[0].value<KConfigGroup>().name() < b[0].value<KConfigGroup>().name();
+ std::sort(watcherSpy.begin(), watcherSpy.end(), [](QList<QVariant> a, QList<QVariant> b) {
+ return a[0].value<KConfigGroup>().name() < b[0].value<KConfigGroup>().name();
});
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
@@ -1908,7 +1924,7 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[1][0].value<KConfigGroup>().parent().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[1][1].value<QByteArrayList>(), QByteArrayList({"entry1", "entry2"}));
- //delete an entry
+ // delete an entry
watcherSpy.clear();
myConfigGroup.deleteEntry("entryA", KConfig::Persistent | KConfig::Notify);
config.sync();
@@ -1917,7 +1933,7 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"entryA"}));
- //revert to default an entry
+ // revert to default an entry
watcherSpy.clear();
myConfigGroup.revertToDefault("entryA", KConfig::Persistent | KConfig::Notify);
config.sync();
@@ -1926,7 +1942,7 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"entryA"}));
- //deleting a group, should notify that every entry in that group has changed
+ // deleting a group, should notify that every entry in that group has changed
watcherSpy.clear();
myConfigGroup.deleteGroup("aSubGroup", KConfig::Persistent | KConfig::Notify);
config.sync();
@@ -1935,16 +1951,16 @@ void KConfigTest::testNotify()
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("aSubGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"entry1", "entry2"}));
- //global write still triggers our notification
+ // global write still triggers our notification
watcherSpy.clear();
- myConfigGroup.writeEntry("someGlobalEntry", "foo", KConfig::Persistent | KConfig::Notify | KConfig::Global);
+ myConfigGroup.writeEntry("someGlobalEntry", "foo", KConfig::Persistent | KConfig::Notify | KConfig::Global);
config.sync();
watcherSpy.wait();
QCOMPARE(watcherSpy.count(), 1);
QCOMPARE(watcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(watcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"someGlobalEntry"}));
- //watching another file should have only triggered from the kdeglobals change
+ // watching another file should have only triggered from the kdeglobals change
QCOMPARE(otherWatcherSpy.count(), 1);
QCOMPARE(otherWatcherSpy[0][0].value<KConfigGroup>().name(), QStringLiteral("TopLevelGroup"));
QCOMPARE(otherWatcherSpy[0][1].value<QByteArrayList>(), QByteArrayList({"someGlobalEntry"}));
diff --git a/autotests/kconfigtest.h b/autotests/kconfigtest.h
index cb6e3712..d6502331 100644
--- a/autotests/kconfigtest.h
+++ b/autotests/kconfigtest.h
@@ -14,9 +14,18 @@ class KConfigTest : public QObject
Q_OBJECT
public:
- enum Testing { Ones = 1, Tens = 10, Hundreds = 100,};
+ enum Testing {
+ Ones = 1,
+ Tens = 10,
+ Hundreds = 100,
+ };
Q_ENUM(Testing)
- enum bits { bit0 = 1, bit1 = 2, bit2 = 4, bit3 = 8, };
+ enum bits {
+ bit0 = 1,
+ bit1 = 2,
+ bit2 = 4,
+ bit3 = 8,
+ };
Q_DECLARE_FLAGS(Flags, bits)
Q_FLAG(Flags)
diff --git a/autotests/kdesktopfiletest.cpp b/autotests/kdesktopfiletest.cpp
index e45ba44e..cadc3b3d 100644
--- a/autotests/kdesktopfiletest.cpp
+++ b/autotests/kdesktopfiletest.cpp
@@ -29,13 +29,12 @@ void KDesktopFileTest::testRead()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type= Application\n"
- "Name=My Application\n"
- "Icon = foo\n"
- "MimeType =text/plain;image/png;\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type= Application\n"
+ "Name=My Application\n"
+ "Icon = foo\n"
+ "MimeType =text/plain;image/png;\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
QVERIFY(KDesktopFile::isDesktopFile(fileName));
@@ -44,8 +43,7 @@ void KDesktopFileTest::testRead()
QVERIFY(df.hasApplicationType());
QCOMPARE(df.readName(), QString::fromLatin1("My Application"));
QCOMPARE(df.readIcon(), QString::fromLatin1("foo"));
- QCOMPARE(df.readMimeTypes(), QStringList() << QString::fromLatin1("text/plain")
- << QString::fromLatin1("image/png"));
+ QCOMPARE(df.readMimeTypes(), QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("image/png"));
QVERIFY(!df.hasLinkType());
QCOMPARE(df.fileName(), QFileInfo(fileName).canonicalFilePath());
}
@@ -57,17 +55,15 @@ void KDesktopFileTest::testReadDirectory()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Directory\n"
- "SortOrder=2.desktop;1.desktop;\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Directory\n"
+ "SortOrder=2.desktop;1.desktop;\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
QCOMPARE(df.readType(), QString::fromLatin1("Directory"));
- QCOMPARE(df.sortOrder(), QStringList() << QString::fromLatin1("2.desktop")
- << QString::fromLatin1("1.desktop"));
+ QCOMPARE(df.sortOrder(), QStringList() << QString::fromLatin1("2.desktop") << QString::fromLatin1("1.desktop"));
}
#endif
@@ -77,19 +73,19 @@ void KDesktopFileTest::testReadLocalized_data()
QTest::addColumn<QString>("translation");
const QString german = QStringLiteral("Meine Anwendung");
- const QString swiss = QStringLiteral("Mein Anwendungsli");
+ const QString swiss = QStringLiteral("Mein Anwendungsli");
- QTest::newRow("de") << QLocale(QLocale::German) << german;
- QTest::newRow("de_DE") << QLocale(QStringLiteral("de_DE")) << german;
+ QTest::newRow("de") << QLocale(QLocale::German) << german;
+ QTest::newRow("de_DE") << QLocale(QStringLiteral("de_DE")) << german;
QTest::newRow("de_DE@bayern") << QLocale(QStringLiteral("de_DE@bayern")) << german;
- QTest::newRow("de@bayern") << QLocale(QStringLiteral("de@bayern")) << german;
- QTest::newRow("de@freiburg") << QLocale(QStringLiteral("de@freiburg")) << QStringLiteral("Mein Anwendungsle");
+ QTest::newRow("de@bayern") << QLocale(QStringLiteral("de@bayern")) << german;
+ QTest::newRow("de@freiburg") << QLocale(QStringLiteral("de@freiburg")) << QStringLiteral("Mein Anwendungsle");
// For CH we have a special translation
- QTest::newRow("de_CH") << QLocale(QLocale::German, QLocale::Switzerland) << swiss;
- QTest::newRow("de_CH@bern") << QLocale(QStringLiteral("de_CH@bern")) << swiss;
+ QTest::newRow("de_CH") << QLocale(QLocale::German, QLocale::Switzerland) << swiss;
+ QTest::newRow("de_CH@bern") << QLocale(QStringLiteral("de_CH@bern")) << swiss;
// Austria should fall back to "de"
- QTest::newRow("de_AT") << QLocale(QLocale::German, QLocale::Austria) << german;
- QTest::newRow("de_AT@tirol") << QLocale(QStringLiteral("de_AT@tirol")) << german;
+ QTest::newRow("de_AT") << QLocale(QLocale::German, QLocale::Austria) << german;
+ QTest::newRow("de_AT@tirol") << QLocale(QStringLiteral("de_AT@tirol")) << german;
// no translation for French
QTest::newRow("fr") << QLocale(QLocale::French) << QStringLiteral("My Application");
}
@@ -100,15 +96,14 @@ void KDesktopFileTest::testReadLocalized()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Name[de]=Meine Anwendung\n"
- "Name[de@freiburg]=Mein Anwendungsle\n"
- "Name[de_CH]=Mein Anwendungsli\n"
- "Icon=foo\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Name[de]=Meine Anwendung\n"
+ "Name[de@freiburg]=Mein Anwendungsle\n"
+ "Name[de_CH]=Mein Anwendungsli\n"
+ "Icon=foo\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
QVERIFY(KDesktopFile::isDesktopFile(fileName));
@@ -129,10 +124,9 @@ void KDesktopFileTest::testSuccessfulTryExec()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "TryExec=whoami\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "TryExec=whoami\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
@@ -145,10 +139,9 @@ void KDesktopFileTest::testUnsuccessfulTryExec()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "TryExec=/does/not/exist\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "TryExec=/does/not/exist\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
@@ -161,18 +154,17 @@ void KDesktopFileTest::testActionGroup()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- // make sure escaping of ';' using "\;" works
- "Actions=encrypt;semi\\;colon;decrypt;\n"
- "[Desktop Action encrypt]\n"
- "Name=Encrypt file\n"
- "[Desktop Action decrypt]\n"
- "Name=Decrypt file\n"
- // no escaping needed in group header
- "[Desktop Action semi;colon]\n"
- "Name=With semicolon\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ // make sure escaping of ';' using "\;" works
+ "Actions=encrypt;semi\\;colon;decrypt;\n"
+ "[Desktop Action encrypt]\n"
+ "Name=Encrypt file\n"
+ "[Desktop Action decrypt]\n"
+ "Name=Decrypt file\n"
+ // no escaping needed in group header
+ "[Desktop Action semi;colon]\n"
+ "Name=With semicolon\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
KDesktopFile df(fileName);
@@ -200,12 +192,11 @@ void KDesktopFileTest::testIsAuthorizedDesktopFile()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Exec=kfoo\n"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Exec=kfoo\n"
+ "\n";
file.close();
QVERIFY(QFile::exists(fileName));
QVERIFY(!KDesktopFile::isAuthorizedDesktopFile(fileName));
@@ -232,14 +223,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Exec=kfoo\n"
- "TryExec=bash\n"
- "X-KDE-AuthorizeAction=someAction"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Exec=kfoo\n"
+ "TryExec=bash\n"
+ "X-KDE-AuthorizeAction=someAction"
+ "\n";
file.close();
KDesktopFile desktopFile(fileName);
@@ -250,14 +240,13 @@ void KDesktopFileTest::testTryExecWithAuthorizeAction()
QVERIFY(file.open());
const QString fileName = file.fileName();
QTextStream ts(&file);
- ts <<
- "[Desktop Entry]\n"
- "Type=Application\n"
- "Name=My Application\n"
- "Exec=kfoo\n"
- "TryExec=bash\n"
- "X-KDE-AuthorizeAction=someBlockedAction"
- "\n";
+ ts << "[Desktop Entry]\n"
+ "Type=Application\n"
+ "Name=My Application\n"
+ "Exec=kfoo\n"
+ "TryExec=bash\n"
+ "X-KDE-AuthorizeAction=someBlockedAction"
+ "\n";
file.close();
KDesktopFile desktopFile(fileName);
diff --git a/autotests/kdesktopfiletest.h b/autotests/kdesktopfiletest.h
index 1ab1498c..6bf97bf8 100644
--- a/autotests/kdesktopfiletest.h
+++ b/autotests/kdesktopfiletest.h
@@ -28,7 +28,6 @@ private Q_SLOTS:
void testTryExecWithAuthorizeAction();
void testLocateLocal_data();
void testLocateLocal();
-
};
#endif /* KDESKTOPFILETEST_H */
diff --git a/autotests/kentrymaptest.h b/autotests/kentrymaptest.h
index b1bcea74..faf3ad6d 100644
--- a/autotests/kentrymaptest.h
+++ b/autotests/kentrymaptest.h
@@ -7,8 +7,8 @@
#ifndef KENTRYMAPTEST_H
#define KENTRYMAPTEST_H
-#include <QObject>
#include "kconfigdata.h"
+#include <QObject>
class KEntryMapTest : public QObject
{
diff --git a/autotests/ksharedconfig_in_global_object.cpp b/autotests/ksharedconfig_in_global_object.cpp
index aab982c2..4d9b07d3 100644
--- a/autotests/ksharedconfig_in_global_object.cpp
+++ b/autotests/ksharedconfig_in_global_object.cpp
@@ -6,10 +6,10 @@
*/
#include <QCoreApplication>
-#include <QtGlobal>
#include <QTimer>
-#include <ksharedconfig.h>
+#include <QtGlobal>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
#include <stdio.h>
class Tester
diff --git a/autotests/ksharedconfigtest.cpp b/autotests/ksharedconfigtest.cpp
index 957b509f..06ed7898 100644
--- a/autotests/ksharedconfigtest.cpp
+++ b/autotests/ksharedconfigtest.cpp
@@ -6,8 +6,8 @@
*/
#include <QTest>
-#include <ksharedconfig.h>
#include <kconfiggroup.h>
+#include <ksharedconfig.h>
class KSharedConfigTest : public QObject
{
@@ -18,6 +18,7 @@ private Q_SLOTS:
void testReadWrite();
void testReadWriteSync();
void testQrcFile();
+
private:
QString m_path;
};
@@ -26,8 +27,8 @@ void KSharedConfigTest::initTestCase()
{
QStandardPaths::setTestModeEnabled(true);
- m_path = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)
- + QLatin1Char('/') + QCoreApplication::applicationName() + QStringLiteral("rc");
+ m_path =
+ QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + QCoreApplication::applicationName() + QStringLiteral("rc");
QFile::remove(m_path);
}
diff --git a/autotests/kstandardshortcuttest.cpp b/autotests/kstandardshortcuttest.cpp
index 1b7f88ff..cafad63f 100644
--- a/autotests/kstandardshortcuttest.cpp
+++ b/autotests/kstandardshortcuttest.cpp
@@ -4,10 +4,10 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
-#include <QTest>
#include "kstandardshortcuttest.h"
+#include <QTest>
-QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel
+QTEST_MAIN(KStandardShortcutTest) // GUI needed by KAccel
#include <kstandardshortcut.h>
diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp
index f08e06ca..565a86f8 100644
--- a/autotests/test_kconf_update.cpp
+++ b/autotests/test_kconf_update.cpp
@@ -9,13 +9,13 @@
#include <memory>
// Qt
-#include <QFile>
+#include "config-kconf.h"
#include <QDir>
-#include <QSharedPointer>
+#include <QFile>
#include <QProcess>
-#include <qtemporaryfile.h>
+#include <QSharedPointer>
#include <qstandardpaths.h>
-#include "config-kconf.h"
+#include <qtemporaryfile.h>
#include <qtest.h>
@@ -80,225 +80,146 @@ void TestKConfUpdate::test_data()
QTest::addColumn<bool>("useVersion5");
QTest::addColumn<bool>("shouldUpdateWork");
- 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"
- <<
- ""
- << true
- << true
- ;
- 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"
- << true
- << true
- ;
- 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"
- <<
- ""
- << true
- << true
- ;
- 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"
- <<
- ""
- << true
- << true
- ;
- 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"
- <<
- ""
- << true
- << true
- ;
- 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"
- <<
- ""
- << true
- << true
- ;
- QTest::newRow("DontMigrateWhenFileDoesntHaveVersion")
- <<
- "File=testrc\n"
- "Group=group\n"
- "Key=old,new\n"
- "Options=overwrite\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- ""
- << false
- << false
- ;
-
- QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename")
- <<
- "Group=group\n"
- "Key=old,new\n"
- "Options=overwrite\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- "testrc"
- <<
- "[group]\n"
- "old=value\n"
- <<
- ""
- << true
- << false
- ;
+ 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"
+ << "" << true << true;
+ 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"
+ << true << true;
+ 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"
+ << "" << true << true;
+ 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"
+ << "" << true << true;
+ 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"
+ << "" << true << true;
+ 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"
+ << "" << true << true;
+ QTest::newRow("DontMigrateWhenFileDoesntHaveVersion") << "File=testrc\n"
+ "Group=group\n"
+ "Key=old,new\n"
+ "Options=overwrite\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "" << false << false;
+
+ QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename") << "Group=group\n"
+ "Key=old,new\n"
+ "Options=overwrite\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "testrc"
+ << "[group]\n"
+ "old=value\n"
+ << "" << true << false;
}
void TestKConfUpdate::test()
@@ -362,238 +283,172 @@ void TestKConfUpdate::testScript_data()
QTest::addColumn<QString>("oldConfContent");
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"
- ;
-
- 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"
- ;
-
- 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"
- ;
-
- 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"
- ;
-
- 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"
- ;
-
- 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"
- ;
-
- 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"
- ;
-
- 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"
- ;
-
- 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"
- ;
+ 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";
+
+ 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";
+
+ 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";
+
+ 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";
+
+ 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";
+
+ 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";
+
+ 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";
+
+ 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";
+
+ 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";
if (QStandardPaths::findExecutable(QStringLiteral("sed")).isEmpty()) {
qWarning("sed executable not found, cannot run all tests!");
} else {
- 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"
- ;
-
- 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"
- ;
+ 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";
+
+ 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";
}
}
diff --git a/autotests/test_kconfigutils.cpp b/autotests/test_kconfigutils.cpp
index 1e6c49f7..96959474 100644
--- a/autotests/test_kconfigutils.cpp
+++ b/autotests/test_kconfigutils.cpp
@@ -20,35 +20,16 @@ void TestKConfigUtils::testParseGroupString_data()
QTest::addColumn<QStringList>("expected");
QTest::addColumn<bool>("expectedOk");
- QTest::newRow("simple-group")
- << " group "
- << (QStringList() << QStringLiteral("group"))
- << true
- ;
-
- QTest::newRow("sub-group")
- << "[group][sub]"
- << (QStringList() << QStringLiteral("group") << QStringLiteral("sub"))
- << true
- ;
-
- QTest::newRow("crazy-sub-group")
- << "[a\\ttab\\x5d[and some hex esc\\x61pe]"
- << (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape"))
- << true
- ;
-
- QTest::newRow("missing-closing-brace")
- << "[group][sub"
- << QStringList()
- << false
- ;
-
- QTest::newRow("invalid-escape-string")
- << "[a\\z]"
- << QStringList()
- << false
- ;
+ QTest::newRow("simple-group") << " group " << (QStringList() << QStringLiteral("group")) << true;
+
+ QTest::newRow("sub-group") << "[group][sub]" << (QStringList() << QStringLiteral("group") << QStringLiteral("sub")) << true;
+
+ QTest::newRow("crazy-sub-group") << "[a\\ttab\\x5d[and some hex esc\\x61pe]"
+ << (QStringList() << QStringLiteral("a\ttab") << QStringLiteral("and some hex escape")) << true;
+
+ QTest::newRow("missing-closing-brace") << "[group][sub" << QStringList() << false;
+
+ QTest::newRow("invalid-escape-string") << "[a\\z]" << QStringList() << false;
}
void TestKConfigUtils::testParseGroupString()
@@ -76,47 +57,26 @@ void TestKConfigUtils::testUnescapeString_data()
QTest::addColumn<QString>("expected");
QTest::addColumn<bool>("expectedOk");
- QTest::newRow("plain")
- << "Some text"
- << "Some text"
- << true
- ;
-
- QTest::newRow("single-char-escapes")
- << "01\\s23\\t45\\n67\\r89\\\\"
- << "01 23\t45\n67\r89\\"
- << true
- ;
-
- QTest::newRow("hex-escapes")
- << "kd\\x65"
- << "kde"
- << true
- ;
-
- QTest::newRow("unfinished-hex-escape")
- << "kd\\x6"
- << ""
- << false
- ;
-
- QTest::newRow("invalid-hex-escape")
- << "kd\\xzz"
- << ""
- << false
- ;
-
- QTest::newRow("invalid-escape-sequence")
- << "Foo\\a"
- << ""
- << false
- ;
-
- QTest::newRow("unfinished-escape-sequence")
- << "Foo\\"
- << ""
- << false
- ;
+ QTest::newRow("plain") << "Some text"
+ << "Some text" << true;
+
+ QTest::newRow("single-char-escapes") << "01\\s23\\t45\\n67\\r89\\\\"
+ << "01 23\t45\n67\r89\\" << true;
+
+ QTest::newRow("hex-escapes") << "kd\\x65"
+ << "kde" << true;
+
+ QTest::newRow("unfinished-hex-escape") << "kd\\x6"
+ << "" << false;
+
+ QTest::newRow("invalid-hex-escape") << "kd\\xzz"
+ << "" << false;
+
+ QTest::newRow("invalid-escape-sequence") << "Foo\\a"
+ << "" << false;
+
+ QTest::newRow("unfinished-escape-sequence") << "Foo\\"
+ << "" << false;
}
void TestKConfigUtils::testUnescapeString()
@@ -137,4 +97,3 @@ void TestKConfigUtils::testUnescapeString()
qDebug() << error;
}
}
-