aboutsummaryrefslogtreecommitdiff
path: root/autotests/kconfig_compiler
diff options
context:
space:
mode:
authorKai Uwe Broulik <kde@privat.broulik.de>2019-04-24 16:20:56 +0200
committerKai Uwe Broulik <kde@privat.broulik.de>2019-04-24 16:21:29 +0200
commit5d2ed13479a480111355657bf22324118fa576e9 (patch)
treed55fe47fa3d017391b8c6c1a735d4b098adbe8f8 /autotests/kconfig_compiler
parentb327f5f6cef127980e84926b134d5c7c72e833b1 (diff)
downloadkconfig-5d2ed13479a480111355657bf22324118fa576e9.tar.gz
kconfig-5d2ed13479a480111355657bf22324118fa576e9.tar.bz2
Add Notify capability to KConfigXT
Lets you specify Notifiers= in .kcfg for config entries that should be written with Notify flag, i.e. announce the change to KConfigWatcher Differential Revision: https://phabricator.kde.org/D20196
Diffstat (limited to 'autotests/kconfig_compiler')
-rw-r--r--autotests/kconfig_compiler/CMakeLists.txt9
-rw-r--r--autotests/kconfig_compiler/kconfigcompiler_test.cpp1
-rw-r--r--autotests/kconfig_compiler/test_notifiers.cpp.ref34
-rw-r--r--autotests/kconfig_compiler/test_notifiers.h.ref94
-rw-r--r--autotests/kconfig_compiler/test_notifiers.kcfg25
-rw-r--r--autotests/kconfig_compiler/test_notifiers.kcfgc8
-rw-r--r--autotests/kconfig_compiler/test_notifiers_main.cpp32
7 files changed, 203 insertions, 0 deletions
diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt
index 70b2dbb8..8a6289f9 100644
--- a/autotests/kconfig_compiler/CMakeLists.txt
+++ b/autotests/kconfig_compiler/CMakeLists.txt
@@ -189,6 +189,15 @@ gen_kcfg_test_source(test_signal test_signal_SRCS GENERATE_MOC)
ecm_add_test(TEST_NAME test_signal ${test_signal_SRCS})
target_link_libraries(test_signal KF5::ConfigGui)
+
+########### next target ###############
+
+set(test_notifiers_SRCS test_notifiers_main.cpp )
+gen_kcfg_test_source(test_notifiers test_notifiers_SRCS)
+ecm_add_test(TEST_NAME test_notifiers ${test_notifiers_SRCS})
+target_link_libraries(test_notifiers KF5::ConfigGui)
+
+
########### next target ###############
set(kconfigcompiler_test_signals_SRCS kconfigcompiler_test_signals.cpp)
diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
index 24854612..383745b1 100644
--- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp
+++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp
@@ -48,6 +48,7 @@ static CompilerTestSet testCases = {
"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",
diff --git a/autotests/kconfig_compiler/test_notifiers.cpp.ref b/autotests/kconfig_compiler/test_notifiers.cpp.ref
new file mode 100644
index 00000000..1049137e
--- /dev/null
+++ b/autotests/kconfig_compiler/test_notifiers.cpp.ref
@@ -0,0 +1,34 @@
+// This file is generated by kconfig_compiler_kf5 from test_notifiers.kcfg.
+// All changes you do to this file will be lost.
+
+#include "test_notifiers.h"
+
+TestNotifiers::TestNotifiers( int Number )
+ : KConfigSkeleton( QStringLiteral( "test7rc" ) )
+ , mParamNumber(Number)
+{
+ setCurrentGroup( QStringLiteral( "Foo" ) );
+
+ KConfigSkeleton::ItemColor *itemColor;
+ itemColor = new KConfigSkeleton::ItemColor( currentGroup(), QStringLiteral( "color #%1" ).arg( mParamNumber ), mColor, QColor( "red" ) );
+ itemColor->setWriteFlags(KConfigBase::Notify);
+ addItem( itemColor, QStringLiteral( "Color" ) );
+
+ setCurrentGroup( QStringLiteral( "Bar%1" ).arg( mParamNumber ) );
+
+ KConfigSkeleton::ItemString *itemFooBar;
+ itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "foo bar" ), mFooBar );
+ itemFooBar->setWriteFlags(KConfigBase::Notify);
+ addItem( itemFooBar, QStringLiteral( "FooBar" ) );
+ KConfigSkeleton::ItemInt *itemAge;
+ itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "Age" ), mAge, 35 );
+ itemAge->setMinValue(8);
+ itemAge->setMaxValue(88);
+ itemAge->setWriteFlags(KConfigBase::Notify);
+ addItem( itemAge, QStringLiteral( "Age" ) );
+}
+
+TestNotifiers::~TestNotifiers()
+{
+}
+
diff --git a/autotests/kconfig_compiler/test_notifiers.h.ref b/autotests/kconfig_compiler/test_notifiers.h.ref
new file mode 100644
index 00000000..588427e2
--- /dev/null
+++ b/autotests/kconfig_compiler/test_notifiers.h.ref
@@ -0,0 +1,94 @@
+// This file is generated by kconfig_compiler_kf5 from test_notifiers.kcfg.
+// All changes you do to this file will be lost.
+#ifndef TESTNOTIFIERS_H
+#define TESTNOTIFIERS_H
+
+#include <kconfigskeleton.h>
+#include <QCoreApplication>
+#include <QDebug>
+
+class TestNotifiers : public KConfigSkeleton
+{
+ public:
+
+ TestNotifiers( int Number );
+ ~TestNotifiers();
+
+ /**
+ Set Block colors.
+ */
+ void setColor( const QColor & v )
+ {
+ if (!isImmutable( QStringLiteral( "Color" ) ))
+ mColor = v;
+ }
+
+ /**
+ Get Block colors.
+ */
+ QColor color() const
+ {
+ return mColor;
+ }
+
+ /**
+ Set foo bar
+ */
+ void setFooBar( const QString & v )
+ {
+ if (!isImmutable( QStringLiteral( "FooBar" ) ))
+ mFooBar = v;
+ }
+
+ /**
+ Get foo bar
+ */
+ QString fooBar() const
+ {
+ return mFooBar;
+ }
+
+ /**
+ Set Age
+ */
+ void setAge( int v )
+ {
+ if (v < 8)
+ {
+ qDebug() << "setAge: value " << v << " is less than the minimum value of 8";
+ v = 8;
+ }
+
+ if (v > 88)
+ {
+ qDebug() << "setAge: value " << v << " is greater than the maximum value of 88";
+ v = 88;
+ }
+
+ if (!isImmutable( QStringLiteral( "Age" ) ))
+ mAge = v;
+ }
+
+ /**
+ Get Age
+ */
+ int age() const
+ {
+ return mAge;
+ }
+
+ protected:
+ int mParamNumber;
+
+ // Foo
+ QColor mColor;
+
+ // Bar$(Number)
+ QString mFooBar;
+ int mAge;
+
+ private:
+};
+
+#endif
+
diff --git a/autotests/kconfig_compiler/test_notifiers.kcfg b/autotests/kconfig_compiler/test_notifiers.kcfg
new file mode 100644
index 00000000..2f54f608
--- /dev/null
+++ b/autotests/kconfig_compiler/test_notifiers.kcfg
@@ -0,0 +1,25 @@
+<?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 name="test7rc">
+ <parameter name="Number" type="Int"/>
+ </kcfgfile>
+
+ <group name="Foo">
+ <entry name="Color" type="Color" key="color #$(Number)">
+ <label>Block colors.</label>
+ <default>red</default>
+ </entry>
+ </group>
+ <group name="Bar$(Number)">
+ <entry name="FooBar" key="foo bar" type="String"/>
+ <entry name="Age" type="Int">
+ <default>35</default>
+ <min>8</min>
+ <max>88</max>
+ </entry>
+ </group>
+
+</kcfg>
diff --git a/autotests/kconfig_compiler/test_notifiers.kcfgc b/autotests/kconfig_compiler/test_notifiers.kcfgc
new file mode 100644
index 00000000..bfc85f34
--- /dev/null
+++ b/autotests/kconfig_compiler/test_notifiers.kcfgc
@@ -0,0 +1,8 @@
+# Code generation options for kconfig_compiler_kf5
+File=test_notifiers.kcfg
+ClassName=TestNotifiers
+Singleton=false
+Mutators=true
+GlobalEnums=true
+ItemAccessors=false
+Notifiers=true
diff --git a/autotests/kconfig_compiler/test_notifiers_main.cpp b/autotests/kconfig_compiler/test_notifiers_main.cpp
new file mode 100644
index 00000000..a4c6ba2c
--- /dev/null
+++ b/autotests/kconfig_compiler/test_notifiers_main.cpp
@@ -0,0 +1,32 @@
+/*
+Copyright (c) 2019 Kai Uwe Broulik <kde@privat.broulik.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_notifiers.h"
+#include <QGuiApplication>
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+ Q_UNUSED(app);
+ TestNotifiers *t = new TestNotifiers(42);
+ delete t;
+ return 0;
+}