aboutsummaryrefslogtreecommitdiff
path: root/autotests/kconfig_compiler
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/kconfig_compiler
parent186755fd56b58dc97250846c5305ef89f9487f86 (diff)
downloadkconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.gz
kconfig-8bed00ab34e31f2b9c70026d418d923913325798.tar.bz2
Run clang-format on all cpp/h files
NO_CHANGELOG
Diffstat (limited to 'autotests/kconfig_compiler')
-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
10 files changed, 151 insertions, 122 deletions
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
-