diff options
Diffstat (limited to 'autotests/kconfig_compiler')
14 files changed, 356 insertions, 5 deletions
diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index c459243d..93ab9b09 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -218,6 +218,25 @@ ecm_add_test(${kconfigcompiler_test_signals_SRCS}      LINK_LIBRARIES Qt5::Test KF5::ConfigGui  ) +########### next target ############### + +set(test_properties_minmax_SRCS test_properties_minmax_main.cpp) +gen_kcfg_test_source(test_properties_minmax test_properties_minmax_SRCS GENERATE_MOC) + +ecm_add_test(${test_properties_minmax_SRCS} +    TEST_NAME test-properties-minmax +    LINK_LIBRARIES KF5::ConfigGui +) + +########### next target ############### + +set(test_param_minmax_SRCS test_param_minmax_main.cpp) +gen_kcfg_test_source(test_param_minmax test_param_minmax_SRCS GENERATE_MOC) + +ecm_add_test(${test_param_minmax_SRCS} +    TEST_NAME test-param-minmax +    LINK_LIBRARIES KF5::ConfigGui +)  ########### next target ############### diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index d5b7baa2..e4892e4f 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -53,6 +53,8 @@ static CompilerTestSet testCases = {      "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",      nullptr  }; @@ -78,6 +80,8 @@ static CompilerTestSet testCasesToRun = {      "test_translation_kde_domain",      "test_translation_qt",      "test_emptyentries", +    "test_properties_minmax", +    "test_param_minmax",      nullptr  }; diff --git a/autotests/kconfig_compiler/test13.cpp.ref b/autotests/kconfig_compiler/test13.cpp.ref index 3fa79b18..c038c93c 100644 --- a/autotests/kconfig_compiler/test13.cpp.ref +++ b/autotests/kconfig_compiler/test13.cpp.ref @@ -14,7 +14,9 @@ Test13::Test13( )    itemPicturesDir = new KConfigSkeleton::ItemUrl( currentGroup(), QStringLiteral( "picturesDir" ), mPicturesDir );    addItem( itemPicturesDir, QStringLiteral( "picturesDir" ) );    KConfigCompilerSignallingItem  *itemBrightness; -  itemBrightness = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "brightness" ), mBrightness ), this, notifyFunction, signalBrightnessChanged); +  KConfigSkeleton::ItemDouble  *innerItemBrightness; +  innerItemBrightness = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "brightness" ), mBrightness ); +  itemBrightness = new KConfigCompilerSignallingItem(innerItemBrightness, this, notifyFunction, signalBrightnessChanged);    addItem( itemBrightness, QStringLiteral( "brightness" ) );    KConfigSkeleton::ItemBool  *itemStartsWithUppercase;    itemStartsWithUppercase = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "StartsWithUppercase" ), mStartsWithUppercase ); diff --git a/autotests/kconfig_compiler/test_param_minmax.cpp.ref b/autotests/kconfig_compiler/test_param_minmax.cpp.ref new file mode 100644 index 00000000..ceb224b2 --- /dev/null +++ b/autotests/kconfig_compiler/test_param_minmax.cpp.ref @@ -0,0 +1,41 @@ +// This file is generated by kconfig_compiler_kf5 from test_param_minmax.kcfg. +// All changes you do to this file will be lost. + +#include "test_param_minmax.h" + +TestParamMinMax::TestParamMinMax( KSharedConfig::Ptr config ) +  : KConfigSkeleton( std::move( config ) ) +{ +  setCurrentGroup( QStringLiteral( "Something" ) ); + +  KConfigSkeleton::ItemDouble  *itemFoo[6]; +  itemFoo[0] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#0" ), mFoo[0], 1.23 ); +  itemFoo[0]->setMinValue(0.01); +  itemFoo[0]->setMaxValue(89898.23); +  addItem( itemFoo[0], QStringLiteral( "Foo0" ) ); +  itemFoo[1] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#1" ), mFoo[1], 1.23 ); +  itemFoo[1]->setMinValue(0.01); +  itemFoo[1]->setMaxValue(89898.23); +  addItem( itemFoo[1], QStringLiteral( "Foo1" ) ); +  itemFoo[2] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#2" ), mFoo[2], 1.23 ); +  itemFoo[2]->setMinValue(0.01); +  itemFoo[2]->setMaxValue(89898.23); +  addItem( itemFoo[2], QStringLiteral( "Foo2" ) ); +  itemFoo[3] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#3" ), mFoo[3], 1.23 ); +  itemFoo[3]->setMinValue(0.01); +  itemFoo[3]->setMaxValue(89898.23); +  addItem( itemFoo[3], QStringLiteral( "Foo3" ) ); +  itemFoo[4] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#4" ), mFoo[4], 1.23 ); +  itemFoo[4]->setMinValue(0.01); +  itemFoo[4]->setMaxValue(89898.23); +  addItem( itemFoo[4], QStringLiteral( "Foo4" ) ); +  itemFoo[5] = new KConfigSkeleton::ItemDouble( currentGroup(), QStringLiteral( "foo_#5" ), mFoo[5], 1.23 ); +  itemFoo[5]->setMinValue(0.01); +  itemFoo[5]->setMaxValue(89898.23); +  addItem( itemFoo[5], QStringLiteral( "Foo5" ) ); +} + +TestParamMinMax::~TestParamMinMax() +{ +} + diff --git a/autotests/kconfig_compiler/test_param_minmax.h.ref b/autotests/kconfig_compiler/test_param_minmax.h.ref new file mode 100644 index 00000000..3cc8717c --- /dev/null +++ b/autotests/kconfig_compiler/test_param_minmax.h.ref @@ -0,0 +1,64 @@ +// This file is generated by kconfig_compiler_kf5 from test_param_minmax.kcfg. +// All changes you do to this file will be lost. +#ifndef TESTPARAMMINMAX_H +#define TESTPARAMMINMAX_H + +#include <qglobal.h> +#include <kconfigskeleton.h> +#include <QCoreApplication> +#include <QDebug> + +class TestParamMinMax : public KConfigSkeleton +{ +  public: + +    TestParamMinMax( KSharedConfig::Ptr config = KSharedConfig::openConfig() ); +    ~TestParamMinMax(); + +    /** +      Set foo_#$(myparam) +    */ +    void setFoo( int i, double v ) +    { +      if (v < 0.01) +      { +        qDebug() << "setFoo: value " << v << " is less than the minimum value of 0.01"; +        v = 0.01; +      } + +      if (v > 89898.23) +      { +        qDebug() << "setFoo: value " << v << " is greater than the maximum value of 89898.23"; +        v = 89898.23; +      } + +      if (!isFooImmutable( i )) +        mFoo[i] = v; +    } + +    /** +      Get foo_#$(myparam) +    */ +    double foo( int i ) const +    { +      return mFoo[i]; +    } + +    /** +      Is foo_#$(myparam) Immutable +    */ +    bool isFooImmutable( int i ) const +    { +      return isImmutable( QStringLiteral( "Foo%1" ).arg( i ) ); +    } + +  protected: + +    // Something +    double mFoo[6]; + +  private: +}; + +#endif + diff --git a/autotests/kconfig_compiler/test_param_minmax.kcfg b/autotests/kconfig_compiler/test_param_minmax.kcfg new file mode 100644 index 00000000..32046fd3 --- /dev/null +++ b/autotests/kconfig_compiler/test_param_minmax.kcfg @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Author: Henri Chain --> +<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"/> +  <group name="Something"> +    <entry name="Foo$(myparam)" type="double" key="foo_#$(myparam)"> +      <parameter name="myparam" type="Int" max="5"/> +      <default>1.23</default> +      <min>0.01</min> +      <max>89898.23</max> +    </entry> +  </group> +</kcfg> + diff --git a/autotests/kconfig_compiler/test_param_minmax.kcfgc b/autotests/kconfig_compiler/test_param_minmax.kcfgc new file mode 100644 index 00000000..3d9d2768 --- /dev/null +++ b/autotests/kconfig_compiler/test_param_minmax.kcfgc @@ -0,0 +1,4 @@ +ClassName=TestParamMinMax +File=test_param_minmax.kcfgc +Mutators=true + diff --git a/autotests/kconfig_compiler/test_param_minmax_main.cpp b/autotests/kconfig_compiler/test_param_minmax_main.cpp new file mode 100644 index 00000000..57fc26a7 --- /dev/null +++ b/autotests/kconfig_compiler/test_param_minmax_main.cpp @@ -0,0 +1,29 @@ +/* +Copyright (c) 2020 Henri chain <henri.chain@enioka.com> + +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_param_minmax.h" + +int main(int, char **) +{ +    TestParamMinMax *t = new TestParamMinMax(); +    delete t; +    return 0; +} + diff --git a/autotests/kconfig_compiler/test_properties_minmax.cpp.ref b/autotests/kconfig_compiler/test_properties_minmax.cpp.ref new file mode 100644 index 00000000..1736889b --- /dev/null +++ b/autotests/kconfig_compiler/test_properties_minmax.cpp.ref @@ -0,0 +1,35 @@ +// This file is generated by kconfig_compiler_kf5 from test_properties_minmax.kcfg. +// All changes you do to this file will be lost. + +#include "test_properties_minmax.h" + +TestPropertiesMinMax::TestPropertiesMinMax( KSharedConfig::Ptr config ) +  : KConfigSkeleton( std::move( config ) ) +{ +  KConfigCompilerSignallingItem::NotifyFunction notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&TestPropertiesMinMax::itemChanged); + +  setCurrentGroup( QStringLiteral( "Something" ) ); + +  KConfigCompilerSignallingItem  *itemBar; +  KConfigSkeleton::ItemInt  *innerItemBar; +  innerItemBar = new KConfigSkeleton::ItemInt( currentGroup(), QStringLiteral( "bar" ), mBar, 42 ); +  itemBar = new KConfigCompilerSignallingItem(innerItemBar, this, notifyFunction, signalBarChanged); +  innerItemBar->setMinValue(36); +  innerItemBar->setMaxValue(102); +  addItem( itemBar, QStringLiteral( "bar" ) ); +} + +TestPropertiesMinMax::~TestPropertiesMinMax() +{ +} + + +void TestPropertiesMinMax::itemChanged(quint64 flags) { + +  if ( flags & signalBarChanged ) { +    Q_EMIT barChanged(); +  } +} + +#include "test_properties_minmax.moc" + diff --git a/autotests/kconfig_compiler/test_properties_minmax.h.ref b/autotests/kconfig_compiler/test_properties_minmax.h.ref new file mode 100644 index 00000000..26b79e63 --- /dev/null +++ b/autotests/kconfig_compiler/test_properties_minmax.h.ref @@ -0,0 +1,80 @@ +// This file is generated by kconfig_compiler_kf5 from test_properties_minmax.kcfg. +// All changes you do to this file will be lost. +#ifndef TESTPROPERTIESMINMAX_H +#define TESTPROPERTIESMINMAX_H + +#include <qglobal.h> +#include <kconfigskeleton.h> +#include <QCoreApplication> +#include <QDebug> + +class TestPropertiesMinMax : public KConfigSkeleton +{ +  Q_OBJECT +  public: + +    TestPropertiesMinMax( KSharedConfig::Ptr config = KSharedConfig::openConfig() ); +    ~TestPropertiesMinMax(); + +    /** +      Set bar +    */ +    void setBar( int v ) +    { +      if (v < 36) +      { +        qDebug() << "setBar: value " << v << " is less than the minimum value of 36"; +        v = 36; +      } + +      if (v > 102) +      { +        qDebug() << "setBar: value " << v << " is greater than the maximum value of 102"; +        v = 102; +      } + +      if (v != mBar && !isBarImmutable()) { +        mBar = v; +        Q_EMIT barChanged(); +      } +    } + +    Q_PROPERTY(int bar READ bar WRITE setBar NOTIFY barChanged) +    Q_PROPERTY(bool isBarImmutable CONSTANT) +    /** +      Get bar +    */ +    int bar() const +    { +      return mBar; +    } + +    /** +      Is bar Immutable +    */ +    bool isBarImmutable() const +    { +      return isImmutable( QStringLiteral( "bar" ) ); +    } + + +    enum { +      signalBarChanged = 0x1 +    }; + +  Q_SIGNALS: +    void barChanged(); + +  private: +    void itemChanged(quint64 flags); + +  protected: + +    // Something +    int mBar; + +  private: +}; + +#endif + diff --git a/autotests/kconfig_compiler/test_properties_minmax.kcfg b/autotests/kconfig_compiler/test_properties_minmax.kcfg new file mode 100644 index 00000000..621a793a --- /dev/null +++ b/autotests/kconfig_compiler/test_properties_minmax.kcfg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Author: Henri Chain --> +<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"/> +  <group name="Something"> +    <entry name="bar" type="Int"> +      <default>42</default> +      <min>36</min> +      <max>102</max> +    </entry> +  </group> +</kcfg> diff --git a/autotests/kconfig_compiler/test_properties_minmax.kcfgc b/autotests/kconfig_compiler/test_properties_minmax.kcfgc new file mode 100644 index 00000000..5cda329b --- /dev/null +++ b/autotests/kconfig_compiler/test_properties_minmax.kcfgc @@ -0,0 +1,5 @@ +ClassName=TestPropertiesMinMax +GenerateProperties=true +File=test_properties_minmax.kcfgc +Mutators=true + diff --git a/autotests/kconfig_compiler/test_properties_minmax_main.cpp b/autotests/kconfig_compiler/test_properties_minmax_main.cpp new file mode 100644 index 00000000..6d789718 --- /dev/null +++ b/autotests/kconfig_compiler/test_properties_minmax_main.cpp @@ -0,0 +1,28 @@ +/* +Copyright (c) 2020 Henri Chain <henri.chain@enioka.com> + +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_properties_minmax.h" + +int main(int, char **) +{ +    TestPropertiesMinMax *t = new TestPropertiesMinMax(); +    delete t; +    return 0; +} diff --git a/autotests/kconfig_compiler/test_signal.cpp.ref b/autotests/kconfig_compiler/test_signal.cpp.ref index be06a745..71ab7a09 100644 --- a/autotests/kconfig_compiler/test_signal.cpp.ref +++ b/autotests/kconfig_compiler/test_signal.cpp.ref @@ -37,16 +37,24 @@ TestSignal::TestSignal( )    setCurrentGroup( QStringLiteral( "Appearance" ) );    KConfigCompilerSignallingItem  *itemEmoticonTheme; -  itemEmoticonTheme = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "emoticonTheme" ), mEmoticonTheme, QStringLiteral( "Default" ) ), this, notifyFunction, signalEmoticonSettingsChanged); +  KConfigSkeleton::ItemString  *innerItemEmoticonTheme; +  innerItemEmoticonTheme = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "emoticonTheme" ), mEmoticonTheme, QStringLiteral( "Default" ) ); +  itemEmoticonTheme = new KConfigCompilerSignallingItem(innerItemEmoticonTheme, this, notifyFunction, signalEmoticonSettingsChanged);    addItem( itemEmoticonTheme, QStringLiteral( "emoticonTheme" ) );    KConfigCompilerSignallingItem  *itemUseEmoticon; -  itemUseEmoticon = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "useEmoticon" ), mUseEmoticon, true ), this, notifyFunction, signalEmoticonSettingsChanged); +  KConfigSkeleton::ItemBool  *innerItemUseEmoticon; +  innerItemUseEmoticon = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "useEmoticon" ), mUseEmoticon, true ); +  itemUseEmoticon = new KConfigCompilerSignallingItem(innerItemUseEmoticon, this, notifyFunction, signalEmoticonSettingsChanged);    addItem( itemUseEmoticon, QStringLiteral( "useEmoticon" ) );    KConfigCompilerSignallingItem  *itemEmoticonRequireSpace; -  itemEmoticonRequireSpace = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "emoticonRequireSpace" ), mEmoticonRequireSpace, true ), this, notifyFunction, signalEmoticonSettingsChanged); +  KConfigSkeleton::ItemBool  *innerItemEmoticonRequireSpace; +  innerItemEmoticonRequireSpace = new KConfigSkeleton::ItemBool( currentGroup(), QStringLiteral( "emoticonRequireSpace" ), mEmoticonRequireSpace, true ); +  itemEmoticonRequireSpace = new KConfigCompilerSignallingItem(innerItemEmoticonRequireSpace, this, notifyFunction, signalEmoticonSettingsChanged);    addItem( itemEmoticonRequireSpace, QStringLiteral( "emoticonRequireSpace" ) );    KConfigCompilerSignallingItem  *itemStylePath; -  itemStylePath = new KConfigCompilerSignallingItem(new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "stylePath" ), mStylePath ), this, notifyFunction, signalStyleChanged); +  KConfigSkeleton::ItemString  *innerItemStylePath; +  innerItemStylePath = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "stylePath" ), mStylePath ); +  itemStylePath = new KConfigCompilerSignallingItem(innerItemStylePath, this, notifyFunction, signalStyleChanged);    addItem( itemStylePath, QStringLiteral( "stylePath" ) );    KConfigSkeleton::ItemString  *itemStyleCSSVariant;    itemStyleCSSVariant = new KConfigSkeleton::ItemString( currentGroup(), QStringLiteral( "styleVariant" ), mStyleCSSVariant );  | 
