diff options
Diffstat (limited to 'autotests/kconfig_compiler')
9 files changed, 218 insertions, 0 deletions
diff --git a/autotests/kconfig_compiler/CMakeLists.txt b/autotests/kconfig_compiler/CMakeLists.txt index 73e89bd2..0cca6052 100644 --- a/autotests/kconfig_compiler/CMakeLists.txt +++ b/autotests/kconfig_compiler/CMakeLists.txt @@ -222,6 +222,7 @@ ecm_add_test(${kconfigcompiler_test_signals_SRCS} LINK_LIBRARIES Qt5::Test KF5::ConfigGui ) + ########### next target ############### ecm_add_test(kconfigcompiler_test.cpp @@ -229,6 +230,16 @@ ecm_add_test(kconfigcompiler_test.cpp LINK_LIBRARIES Qt5::Test ) + +########### next target ############### + +set(test_qcategory_SRCS test_qdebugcategorymain.cpp test_qdebugcategory_debug.cpp) +gen_kcfg_test_source(test_qdebugcategory test_qcategory_SRCS) +add_executable(test_qdebugcategory ${test_qcategory_SRCS}) +ecm_mark_as_test(test_qdebugcategory) +target_link_libraries(test_qdebugcategory KF5::ConfigGui) + + ########### install files ############### diff --git a/autotests/kconfig_compiler/kconfigcompiler_test.cpp b/autotests/kconfig_compiler/kconfigcompiler_test.cpp index cfe86e05..43623cef 100644 --- a/autotests/kconfig_compiler/kconfigcompiler_test.cpp +++ b/autotests/kconfig_compiler/kconfigcompiler_test.cpp @@ -45,6 +45,7 @@ static CompilerTestSet testCases = { "test12.h", "test12.cpp", "test_dpointer.cpp", "test_dpointer.h", "test_signal.cpp", "test_signal.h", + "test_qdebugcategory.cpp", "test_qdebugcategory.h", Q_NULLPTR }; @@ -64,6 +65,7 @@ static CompilerTestSet testCasesToRun = { "test12", "test_dpointer", "test_signal", + "test_qdebugcategory", Q_NULLPTR }; diff --git a/autotests/kconfig_compiler/test_qdebugcategory.cpp.ref b/autotests/kconfig_compiler/test_qdebugcategory.cpp.ref new file mode 100644 index 00000000..f2eea333 --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategory.cpp.ref @@ -0,0 +1,31 @@ +// This file is generated by kconfig_compiler_kf5 from test_qdebugcategory.kcfg. +// All changes you do to this file will be lost. + +#include "test_qdebugcategory.h" + +TestQCategory::TestQCategory( int Number ) + : KConfigSkeleton( QLatin1String( "test7rc" ) ) + , mParamNumber(Number) +{ + setCurrentGroup( QLatin1String( "Foo" ) ); + + KConfigSkeleton::ItemColor *itemColor; + itemColor = new KConfigSkeleton::ItemColor( currentGroup(), QString( QLatin1String( "color #%1" ) ).arg( mParamNumber ), mColor, QColor( "red" ) ); + addItem( itemColor, QLatin1String( "Color" ) ); + + setCurrentGroup( QString( QLatin1String( "Bar%1" ) ).arg( mParamNumber ) ); + + KConfigSkeleton::ItemString *itemFooBar; + itemFooBar = new KConfigSkeleton::ItemString( currentGroup(), QLatin1String( "foo bar" ), mFooBar ); + addItem( itemFooBar, QLatin1String( "FooBar" ) ); + KConfigSkeleton::ItemInt *itemAge; + itemAge = new KConfigSkeleton::ItemInt( currentGroup(), QLatin1String( "Age" ), mAge, 35 ); + itemAge->setMinValue(8); + itemAge->setMaxValue(88); + addItem( itemAge, QLatin1String( "Age" ) ); +} + +TestQCategory::~TestQCategory() +{ +} + diff --git a/autotests/kconfig_compiler/test_qdebugcategory.h.ref b/autotests/kconfig_compiler/test_qdebugcategory.h.ref new file mode 100644 index 00000000..b6d16fc0 --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategory.h.ref @@ -0,0 +1,96 @@ +// This file is generated by kconfig_compiler_kf5 from test_qdebugcategory.kcfg. +// All changes you do to this file will be lost. +#ifndef TESTQCATEGORY_H +#define TESTQCATEGORY_H + +#include <test_qdebugcategory_debug.h> + +#include <kconfigskeleton.h> +#include <QCoreApplication> +#include <QDebug> + +class TestQCategory : public KConfigSkeleton +{ + public: + + TestQCategory( int Number ); + ~TestQCategory(); + + /** + Set Block colors. + */ + void setColor( const QColor & v ) + { + if (!isImmutable( QString::fromLatin1( "Color" ) )) + mColor = v; + } + + /** + Get Block colors. + */ + QColor color() const + { + return mColor; + } + + /** + Set foo bar + */ + void setFooBar( const QString & v ) + { + if (!isImmutable( QString::fromLatin1( "FooBar" ) )) + mFooBar = v; + } + + /** + Get foo bar + */ + QString fooBar() const + { + return mFooBar; + } + + /** + Set Age + */ + void setAge( int v ) + { + if (v < 8) + { + qCDebug(CATEGORY_LOG) << "setAge: value " << v << " is less than the minimum value of 8"; + v = 8; + } + + if (v > 88) + { + qCDebug(CATEGORY_LOG) << "setAge: value " << v << " is greater than the maximum value of 88"; + v = 88; + } + + if (!isImmutable( QString::fromLatin1( "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_qdebugcategory.kcfg b/autotests/kconfig_compiler/test_qdebugcategory.kcfg new file mode 100644 index 00000000..2f54f608 --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategory.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_qdebugcategory.kcfgc b/autotests/kconfig_compiler/test_qdebugcategory.kcfgc new file mode 100644 index 00000000..a7ae26e7 --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategory.kcfgc @@ -0,0 +1,9 @@ +# Code generation options for kconfig_compiler_kf5 +File=test_qdebugcategory.kcfgc +ClassName=TestQCategory +Singleton=false +Mutators=true +GlobalEnums=true +ItemAccessors=false +CategoryLoggingName=CATEGORY_LOG +IncludeFiles=test_qdebugcategory_debug.h diff --git a/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp new file mode 100644 index 00000000..7c4f9f55 --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.cpp @@ -0,0 +1,4 @@ +#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 new file mode 100644 index 00000000..88ac4f35 --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategory_debug.h @@ -0,0 +1,8 @@ +#ifndef TEST_QCATEGORY_DEBUG_H +#define TEST_QCATEGORY_DEBUG_H + +#include <QLoggingCategory> +Q_DECLARE_LOGGING_CATEGORY(CATEGORY_LOG) + +#endif + diff --git a/autotests/kconfig_compiler/test_qdebugcategorymain.cpp b/autotests/kconfig_compiler/test_qdebugcategorymain.cpp new file mode 100644 index 00000000..247ffe4c --- /dev/null +++ b/autotests/kconfig_compiler/test_qdebugcategorymain.cpp @@ -0,0 +1,32 @@ +/* +Copyright (c) 2004 Waldo Bastian <bastian@kde.org> + +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_qdebugcategory.h" +#include <QGuiApplication> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + Q_UNUSED(app); + TestQCategory *t = new TestQCategory(42); + delete t; + return 0; +} |