diff options
Diffstat (limited to 'autotests/kconfig_compiler')
18 files changed, 182 insertions, 40 deletions
diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 8a6289f9..c459243d 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -161,7 +161,6 @@ gen_kcfg_test_source(test12 test12_SRCS) ecm_add_test(TEST_NAME test12 ${test12_SRCS}) target_link_libraries(test12 KF5::ConfigGui) - ########### next target ############### set(test13_SRCS test13main.cpp ) @@ -171,6 +170,14 @@ gen_kcfg_test_source(test13 test13_SRCS GENERATE_MOC) ecm_add_test(TEST_NAME test13 ${test13_SRCS}) target_link_libraries(test13 KF5::ConfigGui) +########### next target ############### + +set(test_emptyentries_SRCS test_emptyentries_main.cpp ) + +gen_kcfg_test_source(test_emptyentries test_emptyentries_SRCS GENERATE_MOC) + +ecm_add_test(TEST_NAME test_emptyentries ${test_emptyentries_SRCS}) +target_link_libraries(test_emptyentries KF5::ConfigGui) ########### next target ############### diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index 383745b1..d5b7baa2 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -52,6 +52,7 @@ static CompilerTestSet testCases = { "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", nullptr }; @@ -76,6 +77,7 @@ static CompilerTestSet testCasesToRun = { "test_translation_kde", "test_translation_kde_domain", "test_translation_qt", + "test_emptyentries", nullptr }; @@ -125,9 +127,7 @@ void KConfigCompiler_Test::testBaselineComparison() if (content != contentRef) { appendFileDiff(fileRef.fileName(), file.fileName()); } - // use split('\n') to avoid - // the whole output shown inline - QCOMPARE(content.split('\n'), contentRef.split('\n')); + QVERIFY(content == contentRef); } @@ -166,17 +166,23 @@ void KConfigCompiler_Test::appendFileDiff(const QString &oldFile, const QString return; } - QStringList args; - args << QStringLiteral("-u"); - args << QFileInfo(oldFile).absoluteFilePath(); - args << QFileInfo(newFile).absoluteFilePath(); + QStringList args({ + QStringLiteral("-u"), + QFileInfo(oldFile).absoluteFilePath(), + QFileInfo(newFile).absoluteFilePath() }); QProcess process; process.start(m_diffExe, args, QIODevice::ReadOnly); process.waitForStarted(); process.waitForFinished(); + if (process.exitCode() == 1) { - QByteArray out = process.readAllStandardOutput(); - qDebug() << '\n' << out; + const QString diffFileName = oldFile + QStringLiteral(".diff"); + QFile diffFile(diffFileName); + QVERIFY2(diffFile.open(QIODevice::WriteOnly), qPrintable(QLatin1String("Could not save diff file for ") + oldFile)); + diffFile.write(process.readAllStandardOutput()); + + // force a failure to print the flename where we stored the diff. + QVERIFY2(false, qPrintable(QLatin1String("This test failed, look at the following file for details: ") + diffFileName)); } } diff --git a/autotests/kconfig_compiler/test1.h.ref b/autotests/kconfig_compiler/test1.h.ref index 77c3b65f..52921ac6 100644 --- a/autotests/kconfig_compiler/test1.h.ref +++ b/autotests/kconfig_compiler/test1.h.ref @@ -8,6 +8,7 @@ #include <QDebug> #include <qdir.h> + class Test1 : public KConfigSkeleton { public: diff --git a/autotests/kconfig_compiler/test10.h.ref b/autotests/kconfig_compiler/test10.h.ref index 93839a54..82bbab84 100644 --- a/autotests/kconfig_compiler/test10.h.ref +++ b/autotests/kconfig_compiler/test10.h.ref @@ -14,7 +14,6 @@ class Test10 : public KConfigSkeleton static Test10 *self(); ~Test10(); - /** Get foo bar */ @@ -24,7 +23,6 @@ class Test10 : public KConfigSkeleton return self()->mFooBar; } - /** Get bar foo */ diff --git a/autotests/kconfig_compiler/test11.h.ref b/autotests/kconfig_compiler/test11.h.ref index 395810ef..2acbe9e5 100644 --- a/autotests/kconfig_compiler/test11.h.ref +++ b/autotests/kconfig_compiler/test11.h.ref @@ -11,6 +11,7 @@ #include <QDebug> #include "test11_types.h" + class Test11 : public MyPrefs { public: diff --git a/autotests/kconfig_compiler/test11a.h.ref b/autotests/kconfig_compiler/test11a.h.ref index 23c83713..62b59381 100644 --- a/autotests/kconfig_compiler/test11a.h.ref +++ b/autotests/kconfig_compiler/test11a.h.ref @@ -11,6 +11,7 @@ #include <QDebug> #include "test11_types.h" + class Test11a : public MyPrefs { public: diff --git a/autotests/kconfig_compiler/test12.h.ref b/autotests/kconfig_compiler/test12.h.ref index d96d4609..e3954282 100644 --- a/autotests/kconfig_compiler/test12.h.ref +++ b/autotests/kconfig_compiler/test12.h.ref @@ -15,7 +15,6 @@ class Test12 : public KConfigSkeleton Test12( ); ~Test12(); - /** Get RnRSource */ diff --git a/autotests/kconfig_compiler/test13.h.ref b/autotests/kconfig_compiler/test13.h.ref index 6c67fc5d..3a6e7f89 100644 --- a/autotests/kconfig_compiler/test13.h.ref +++ b/autotests/kconfig_compiler/test13.h.ref @@ -16,7 +16,6 @@ class Test13 : public KConfigSkeleton Test13( ); ~Test13(); - Q_PROPERTY(QUrl picturesDir READ picturesDir CONSTANT) /** Get picturesDir @@ -46,7 +45,6 @@ class Test13 : public KConfigSkeleton return mBrightness; } - Q_PROPERTY(bool startsWithUppercase READ startsWithUppercase CONSTANT) /** Get StartsWithUppercase diff --git a/autotests/kconfig_compiler/test9.h.ref b/autotests/kconfig_compiler/test9.h.ref index 9bcf0001..6e40cf48 100644 --- a/autotests/kconfig_compiler/test9.h.ref +++ b/autotests/kconfig_compiler/test9.h.ref @@ -8,6 +8,7 @@ #include <QDebug> #include <qdir.h> + class Test9 : public KConfigSkeleton { public: diff --git a/autotests/kconfig_compiler/test_dpointer.cpp.ref b/autotests/kconfig_compiler/test_dpointer.cpp.ref index c69d38a4..1bfb9f52 100644 --- a/autotests/kconfig_compiler/test_dpointer.cpp.ref +++ b/autotests/kconfig_compiler/test_dpointer.cpp.ref @@ -157,8 +157,8 @@ TestDPointer::TestDPointer( ) void TestDPointer::setAutoSave( bool v ) { - if (!self()->isImmutable( QStringLiteral( "AutoSave" ) )) - self()->d->autoSave = v; + if (!self()->isImmutable( QStringLiteral( "AutoSave" ) )) + self()->d->autoSave = v; } bool TestDPointer::autoSave() @@ -174,8 +174,8 @@ KConfigSkeleton::ItemBool *TestDPointer::autoSaveItem() void TestDPointer::setAutoSaveInterval( int v ) { - if (!self()->isImmutable( QStringLiteral( "AutoSaveInterval" ) )) - self()->d->autoSaveInterval = v; + if (!self()->isImmutable( QStringLiteral( "AutoSaveInterval" ) )) + self()->d->autoSaveInterval = v; } int TestDPointer::autoSaveInterval() @@ -191,8 +191,8 @@ KConfigSkeleton::ItemInt *TestDPointer::autoSaveIntervalItem() void TestDPointer::setConfirm( bool v ) { - if (!self()->isImmutable( QStringLiteral( "Confirm" ) )) - self()->d->confirm = v; + if (!self()->isImmutable( QStringLiteral( "Confirm" ) )) + self()->d->confirm = v; } bool TestDPointer::confirm() @@ -208,8 +208,8 @@ KConfigSkeleton::ItemBool *TestDPointer::confirmItem() void TestDPointer::setArchiveFile( const QString & v ) { - if (!self()->isImmutable( QStringLiteral( "ArchiveFile" ) )) - self()->d->archiveFile = v; + if (!self()->isImmutable( QStringLiteral( "ArchiveFile" ) )) + self()->d->archiveFile = v; } QString TestDPointer::archiveFile() @@ -225,8 +225,8 @@ KConfigSkeleton::ItemString *TestDPointer::archiveFileItem() void TestDPointer::setDestination( int v ) { - if (!self()->isImmutable( QStringLiteral( "Destination" ) )) - self()->d->destination = v; + if (!self()->isImmutable( QStringLiteral( "Destination" ) )) + self()->d->destination = v; } int TestDPointer::destination() @@ -242,8 +242,8 @@ KConfigSkeleton::ItemEnum *TestDPointer::destinationItem() void TestDPointer::setHourSize( int v ) { - if (!self()->isImmutable( QStringLiteral( "HourSize" ) )) - self()->d->hourSize = v; + if (!self()->isImmutable( QStringLiteral( "HourSize" ) )) + self()->d->hourSize = v; } int TestDPointer::hourSize() @@ -259,8 +259,8 @@ KConfigSkeleton::ItemInt *TestDPointer::hourSizeItem() void TestDPointer::setSelectionStartsEditor( bool v ) { - if (!self()->isImmutable( QStringLiteral( "SelectionStartsEditor" ) )) - self()->d->selectionStartsEditor = v; + if (!self()->isImmutable( QStringLiteral( "SelectionStartsEditor" ) )) + self()->d->selectionStartsEditor = v; } bool TestDPointer::selectionStartsEditor() @@ -276,8 +276,8 @@ KConfigSkeleton::ItemBool *TestDPointer::selectionStartsEditorItem() void TestDPointer::setSelectedPlugins( const QStringList & v ) { - if (!self()->isImmutable( QStringLiteral( "SelectedPlugins" ) )) - self()->d->selectedPlugins = v; + if (!self()->isImmutable( QStringLiteral( "SelectedPlugins" ) )) + self()->d->selectedPlugins = v; } QStringList TestDPointer::selectedPlugins() @@ -293,8 +293,8 @@ KConfigSkeleton::ItemStringList *TestDPointer::selectedPluginsItem() void TestDPointer::setHighlightColor( const QColor & v ) { - if (!self()->isImmutable( QStringLiteral( "HighlightColor" ) )) - self()->d->highlightColor = v; + if (!self()->isImmutable( QStringLiteral( "HighlightColor" ) )) + self()->d->highlightColor = v; } QColor TestDPointer::highlightColor() @@ -310,8 +310,8 @@ KConfigSkeleton::ItemColor *TestDPointer::highlightColorItem() void TestDPointer::setAgendaBgColor( const QColor & v ) { - if (!self()->isImmutable( QStringLiteral( "AgendaBgColor" ) )) - self()->d->agendaBgColor = v; + if (!self()->isImmutable( QStringLiteral( "AgendaBgColor" ) )) + self()->d->agendaBgColor = v; } QColor TestDPointer::agendaBgColor() @@ -327,8 +327,8 @@ KConfigSkeleton::ItemColor *TestDPointer::agendaBgColorItem() void TestDPointer::setTimeBarFont( const QFont & v ) { - if (!self()->isImmutable( QStringLiteral( "TimeBarFont" ) )) - self()->d->timeBarFont = v; + if (!self()->isImmutable( QStringLiteral( "TimeBarFont" ) )) + self()->d->timeBarFont = v; } QFont TestDPointer::timeBarFont() diff --git a/autotests/kconfig_compiler/test_emptyentries.cpp.ref b/autotests/kconfig_compiler/test_emptyentries.cpp.ref new file mode 100644 index 00000000..e23ddc3c --- /dev/null +++ b/autotests/kconfig_compiler/test_emptyentries.cpp.ref @@ -0,0 +1,59 @@ +// This file is generated by kconfig_compiler_kf5 from test_emptyentries.kcfg. +// All changes you do to this file will be lost. + +#include "test_emptyentries.h" + +#include <qglobal.h> +#include <QFile> + +#include <QDebug> + +class QMakeBuilderSettingsHelper +{ + public: + QMakeBuilderSettingsHelper() : q(nullptr) {} + ~QMakeBuilderSettingsHelper() { delete q; } + QMakeBuilderSettingsHelper(const QMakeBuilderSettingsHelper&) = delete; + QMakeBuilderSettingsHelper& operator=(const QMakeBuilderSettingsHelper&) = delete; + QMakeBuilderSettings *q; +}; +Q_GLOBAL_STATIC(QMakeBuilderSettingsHelper, s_globalQMakeBuilderSettings) +QMakeBuilderSettings *QMakeBuilderSettings::self() +{ + if (!s_globalQMakeBuilderSettings()->q) + qFatal("you need to call QMakeBuilderSettings::instance before using"); + return s_globalQMakeBuilderSettings()->q; +} + +void QMakeBuilderSettings::instance(const QString& cfgfilename) +{ + if (s_globalQMakeBuilderSettings()->q) { + qDebug() << "QMakeBuilderSettings::instance called after the first use - ignoring"; + return; + } + new QMakeBuilderSettings(KSharedConfig::openConfig(cfgfilename)); + s_globalQMakeBuilderSettings()->q->read(); +} + +void QMakeBuilderSettings::instance(KSharedConfig::Ptr config) +{ + if (s_globalQMakeBuilderSettings()->q) { + qDebug() << "QMakeBuilderSettings::instance called after the first use - ignoring"; + return; + } + new QMakeBuilderSettings(std::move(config)); + s_globalQMakeBuilderSettings()->q->read(); +} + +QMakeBuilderSettings::QMakeBuilderSettings( KSharedConfig::Ptr config ) + : KConfigSkeleton( std::move( config ) ) +{ + Q_ASSERT(!s_globalQMakeBuilderSettings()->q); + s_globalQMakeBuilderSettings()->q = this; +} + +QMakeBuilderSettings::~QMakeBuilderSettings() +{ + s_globalQMakeBuilderSettings()->q = nullptr; +} + diff --git a/autotests/kconfig_compiler/test_emptyentries.h.ref b/autotests/kconfig_compiler/test_emptyentries.h.ref new file mode 100644 index 00000000..c2481e2d --- /dev/null +++ b/autotests/kconfig_compiler/test_emptyentries.h.ref @@ -0,0 +1,29 @@ +// This file is generated by kconfig_compiler_kf5 from test_emptyentries.kcfg. +// All changes you do to this file will be lost. +#ifndef QMAKEBUILDERSETTINGS_H +#define QMAKEBUILDERSETTINGS_H + +#include <kconfigskeleton.h> +#include <QCoreApplication> +#include <QDebug> + +#include <QString> + +class QMakeBuilderSettings : public KConfigSkeleton +{ + public: + static QMakeBuilderSettings *self(); + static void instance(const QString& cfgfilename); + static void instance(KSharedConfig::Ptr config); + ~QMakeBuilderSettings(); + + protected: + QMakeBuilderSettings(KSharedConfig::Ptr config); + friend class QMakeBuilderSettingsHelper; + + + private: +}; + +#endif + diff --git a/autotests/kconfig_compiler/test_emptyentries.kcfg b/autotests/kconfig_compiler/test_emptyentries.kcfg new file mode 100644 index 00000000..1ad9326d --- /dev/null +++ b/autotests/kconfig_compiler/test_emptyentries.kcfg @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd"> + <kcfgfile arg="true"/> + <include>QString</include> + <!-- save/restore is handled manually --> +</kcfg> diff --git a/autotests/kconfig_compiler/test_emptyentries.kcfgc b/autotests/kconfig_compiler/test_emptyentries.kcfgc new file mode 100644 index 00000000..5c9c71d7 --- /dev/null +++ b/autotests/kconfig_compiler/test_emptyentries.kcfgc @@ -0,0 +1,3 @@ +File=test_emptyentries.kcfg +ClassName=QMakeBuilderSettings +Singleton=true diff --git a/autotests/kconfig_compiler/test_emptyentries_main.cpp b/autotests/kconfig_compiler/test_emptyentries_main.cpp new file mode 100644 index 00000000..9396df77 --- /dev/null +++ b/autotests/kconfig_compiler/test_emptyentries_main.cpp @@ -0,0 +1,33 @@ +/* +Copyright (c) 2007 Andreas Pakulat <apaku@gmx.de> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "test_emptyentries.h" +#include <QGuiApplication> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + Q_UNUSED(app); + QMakeBuilderSettings::instance("abc"); + auto *t = QMakeBuilderSettings::self(); + delete t; + return 0; +} diff --git a/autotests/kconfig_compiler/test_translation_kde.h.ref b/autotests/kconfig_compiler/test_translation_kde.h.ref index f9b582c4..0e50b5a2 100644 --- a/autotests/kconfig_compiler/test_translation_kde.h.ref +++ b/autotests/kconfig_compiler/test_translation_kde.h.ref @@ -17,7 +17,6 @@ class TestTranslationKde : public KConfigSkeleton TestTranslationKde( ); ~TestTranslationKde(); - /** Get Enable automatic saving of calendar */ diff --git a/autotests/kconfig_compiler/test_translation_kde_domain.h.ref b/autotests/kconfig_compiler/test_translation_kde_domain.h.ref index 2fa42c71..4ed5d9bd 100644 --- a/autotests/kconfig_compiler/test_translation_kde_domain.h.ref +++ b/autotests/kconfig_compiler/test_translation_kde_domain.h.ref @@ -17,7 +17,6 @@ class TestTranslationKdeDomain : public KConfigSkeleton TestTranslationKdeDomain( ); ~TestTranslationKdeDomain(); - /** Get Enable automatic saving of calendar */ diff --git a/autotests/kconfig_compiler/test_translation_qt.h.ref b/autotests/kconfig_compiler/test_translation_qt.h.ref index 9831468b..2fe3274a 100644 --- a/autotests/kconfig_compiler/test_translation_qt.h.ref +++ b/autotests/kconfig_compiler/test_translation_qt.h.ref @@ -17,7 +17,6 @@ class TestTranslationQt : public KConfigSkeleton TestTranslationQt( ); ~TestTranslationQt(); - /** Get Enable automatic saving of calendar */ |