diff options
Diffstat (limited to 'tests')
30 files changed, 460 insertions, 120 deletions
diff --git a/tests/auto/core/ivigenerator/include-test.qface b/tests/auto/core/ivigenerator/include-test.qface new file mode 100644 index 0000000..dd13fe3 --- /dev/null +++ b/tests/auto/core/ivigenerator/include-test.qface @@ -0,0 +1,115 @@ +/** + * module + */ +module include.test 1.0 + +import Common 1.0 + +/** + * \brief the brief + * the description + * continues \l http://qt.io + */ +interface IncludeTester { + readonly string lastMessage; + int intValue; + var varValue; + @config_simulator: {minimum: 10.} + real floatValue1; + @config_simulator: {maximum: 10.} + real floatValue2; + string stringValue; + + model<NestedStruct> nestedStructModel; + model<NestedImportedStruct> nestedImportedStructModel; + list<int> intList; + list<Common.CommonStruct> commonStructList; + list<NestedImportedStruct> nestedImportedStructList; + TestEnum testEnum; + Common.CommonEnum commonEnum; + + string echo(string msg); + string id() const; + NestedStruct getNestedStruct(); + NestedImportedStruct getNestedImportedStruct(); + Common.CommonStruct getCommonStruct(); + void voidSlot(); + void voidSlot2(int param); + void timer(int interval); + Common.CommonFlag flagMethod(Common.CommonFlag testFlag); + Common.CommonEnum enumMethod(Common.CommonEnum testEnum); + + signal anotherChanged(NestedImportedStruct another); + signal foobar(string foo); + signal somethingHappened(); + signal newValueAvailable(var newValue); +} + +@config: { zoned: true } +interface IncludeTesterZoned { + readonly string lastMessage; + int intValue; + var varValue; + @config_simulator: {minimum: 10.} + real floatValue1; + @config_simulator: {maximum: 10.} + real floatValue2; + string stringValue; + + model<NestedStruct> nestedStructModel; + model<NestedImportedStruct> nestedImportedStructModel; + list<int> intList; + list<Common.CommonStruct> commonStructList; + list<NestedImportedStruct> nestedImportedStructList; + TestEnum testEnum; + Common.CommonEnum commonEnum; + + string echo(string msg); + string id() const; + NestedStruct getNestedStruct(); + NestedImportedStruct getNestedImportedStruct(); + Common.CommonStruct getCommonStruct(); + void voidSlot(); + void voidSlot2(int param); + void timer(int interval); + Common.CommonFlag flagMethod(Common.CommonFlag testFlag); + Common.CommonEnum enumMethod(Common.CommonEnum testEnum); + + signal anotherChanged(NestedImportedStruct another); + signal foobar(string foo); + signal somethingHappened(); + signal newValueAvailable(var newValue); +} + +/** + * \brief A TestFlag + */ +flag TestFlag { + /** + * \brief The first value + */ + TestFlagValue = 1, + /** + * \brief The second value + */ + TestFlagValue = 2, +} + +enum TestEnum { + FirstEnumValue = 1, + SecondEnumValue = 2 +} + +struct NestedStruct { + AnotherStruct anotherStruct; + TestEnum testEnum; +} + +struct AnotherStruct { + int justANumber; +} + +struct NestedImportedStruct { + Common.CommonStruct commonStruct; + TestFlag testFlag; +} diff --git a/tests/auto/core/ivigenerator/ivigenerator.pro b/tests/auto/core/ivigenerator/ivigenerator.pro index 00f5307..26f1401 100644 --- a/tests/auto/core/ivigenerator/ivigenerator.pro +++ b/tests/auto/core/ivigenerator/ivigenerator.pro @@ -6,4 +6,5 @@ SUBDIRS = projects \ OTHER_FILES = org.example.echo.qface \ org.example.echo.yaml \ org.example.echo.noannotation.qface \ - no-private.yaml + no-private.yaml \ + include-test.qface \ diff --git a/tests/auto/core/ivigenerator/projects/include-test/backend_qtro/backend_qtro.pro b/tests/auto/core/ivigenerator/projects/include-test/backend_qtro/backend_qtro.pro new file mode 100644 index 0000000..fe69f82 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/backend_qtro/backend_qtro.pro @@ -0,0 +1,16 @@ +TEMPLATE=lib +TARGET = $$qtLibraryTarget(include_test_qtro) +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) +DESTDIR = ../qtivi + +CONFIG += warn_off ivigenerator plugin + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +PLUGIN_TYPE = qtivi +PLUGIN_CLASS_NAME = IncludeTestQtROPlugin + +QT += core ivicore + +QFACE_FORMAT = backend_qtro +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/include-test/backend_simulator/backend_simulator.pro b/tests/auto/core/ivigenerator/projects/include-test/backend_simulator/backend_simulator.pro new file mode 100644 index 0000000..b48d2c8 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/backend_simulator/backend_simulator.pro @@ -0,0 +1,16 @@ +TEMPLATE=lib +TARGET = $$qtLibraryTarget(include_test_simulator) +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) +DESTDIR = ../qtivi + +CONFIG += warn_off ivigenerator plugin + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +PLUGIN_TYPE = qtivi +PLUGIN_CLASS_NAME = IncludeTestSimulatorPlugin + +QT += core ivicore + +QFACE_FORMAT = backend_simulator +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/include-test/common/common.pro b/tests/auto/core/ivigenerator/projects/include-test/common/common.pro new file mode 100644 index 0000000..306669a --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/common/common.pro @@ -0,0 +1,14 @@ +TEMPLATE=lib +TARGET= $$qtLibraryTarget(include_test_common) +DESTDIR = ../ + +CONFIG += ivigenerator + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_COMMON_LIB + +macos: QMAKE_SONAME_PREFIX = @rpath + +QFACE_SOURCES = "../../../qface imports/common.qface" + diff --git a/tests/auto/core/ivigenerator/projects/include-test/frontend/frontend.pro b/tests/auto/core/ivigenerator/projects/include-test/frontend/frontend.pro new file mode 100644 index 0000000..e287e47 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/frontend/frontend.pro @@ -0,0 +1,17 @@ +TEMPLATE=lib +TARGET= $$qtLibraryTarget(include_test_frontend) +DESTDIR = ../ + +CONFIG += ivigenerator + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_INCLUDE_TEST_LIB +INCLUDEPATH += $$OUT_PWD/../common +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_common) + +macos: QMAKE_SONAME_PREFIX = @rpath + +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" + diff --git a/tests/auto/core/ivigenerator/projects/include-test/include-test.pro b/tests/auto/core/ivigenerator/projects/include-test/include-test.pro new file mode 100644 index 0000000..3febe98 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/include-test.pro @@ -0,0 +1,22 @@ +TEMPLATE = subdirs + +SUBDIRS = common \ + frontend \ + qmlplugin \ + backend_simulator \ + test \ + +frontend.depends = common +backend_simulator.depends = frontend +test.depends = frontend +qmlplugin.depends = frontend + +QT_FOR_CONFIG += ivicore + +qtConfig(remoteobjects) { + SUBDIRS += backend_qtro \ + simulation_server_qtro + + backend_qtro.depends = frontend + simulation_server_qtro.depends = frontend +} diff --git a/tests/auto/core/ivigenerator/projects/include-test/qmlplugin/qmlplugin.pro b/tests/auto/core/ivigenerator/projects/include-test/qmlplugin/qmlplugin.pro new file mode 100644 index 0000000..b0a45d8 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/qmlplugin/qmlplugin.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +QT = ivicore +CONFIG += c++11 plugin + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) + +QFACE_FORMAT = qmlplugin +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" + +load(ivigenerator) diff --git a/tests/auto/core/ivigenerator/projects/include-test/simulation_server_qtro/simulation_server_qtro.pro b/tests/auto/core/ivigenerator/projects/include-test/simulation_server_qtro/simulation_server_qtro.pro new file mode 100644 index 0000000..2618076 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/simulation_server_qtro/simulation_server_qtro.pro @@ -0,0 +1,16 @@ +TEMPLATE = app +TARGET = org-example-echo-qtro-simulation-server +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) + +DESTDIR = .. + +CONFIG += c++11 ivigenerator +CONFIG -= app_bundle + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common + +QT += qml quick core ivicore + +QFACE_FORMAT = server_qtro_simulator +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/include-test/test/test.pro b/tests/auto/core/ivigenerator/projects/include-test/test/test.pro new file mode 100644 index 0000000..6b7e344 --- /dev/null +++ b/tests/auto/core/ivigenerator/projects/include-test/test/test.pro @@ -0,0 +1,15 @@ +TARGET = tst_include +QMAKE_PROJECT_NAME = $$TARGET +DESTDIR = ../ + +QT += testlib core ivicore +CONFIG += c++11 ivigenerator testcase + +INCLUDEPATH += $$OUT_PWD/../frontend $$OUT_PWD/../common +LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(include_test_frontend) -l$$qtLibraryTarget(include_test_common) + +QMAKE_RPATHDIR += $$OUT_PWD/.. + +QFACE_FORMAT = test +QFACE_SOURCES = ../../../include-test.qface +QFACE_IMPORT_PATH += "../../../qface imports" diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro index 4f13551..3fd1d44 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_qtro/backend_qtro.pro @@ -7,7 +7,7 @@ CONFIG += warn_off ivigenerator plugin INCLUDEPATH += $$OUT_PWD/../frontend PLUGIN_TYPE = qtivi -PLUGIN_CLASS_NAME = EchoPlugin +PLUGIN_CLASS_NAME = EchoQtROPlugin QT += core ivicore diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro index ffefda0..e8eedb7 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/backend_simulator/backend_simulator.pro @@ -7,7 +7,7 @@ CONFIG += warn_off ivigenerator plugin INCLUDEPATH += $$OUT_PWD/../frontend PLUGIN_TYPE = qtivi -PLUGIN_CLASS_NAME = EchoPlugin +PLUGIN_CLASS_NAME = EchoSimulatorPlugin QT += core ivicore diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro index 993ce2a..bd2e628 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/org-example-echo-noannotation.pro @@ -3,11 +3,9 @@ TEMPLATE = subdirs SUBDIRS = frontend \ qmlplugin \ backend_simulator \ - validator \ test \ backend_simulator.depends = frontend -validator.depends = frontend test.depends = frontend qmlplugin.depends = frontend diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/validator/validator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/validator/validator.pro deleted file mode 100644 index 09ec4d1..0000000 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noannotation/validator/validator.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = validator_org-example-echo-noannotation -QMAKE_PROJECT_NAME = $$TARGET -LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noannotation_frontend) - -DESTDIR = .. - -CONFIG += c++11 ivigenerator -CONFIG -= app_bundle - -INCLUDEPATH += $$OUT_PWD/../frontend - -QT += qml quick core ivicore - -QFACE_FORMAT = generation_validator -QFACE_SOURCES = ../../../org.example.echo.noannotation.qface diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/backend_simulator/backend_simulator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/backend_simulator/backend_simulator.pro index c3ac195..fe5ec81 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/backend_simulator/backend_simulator.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/backend_simulator/backend_simulator.pro @@ -7,7 +7,7 @@ CONFIG += warn_off ivigenerator plugin INCLUDEPATH += $$OUT_PWD/../frontend PLUGIN_TYPE = qtivi -PLUGIN_CLASS_NAME = EchoPlugin +PLUGIN_CLASS_NAME = EchoSimulatorPlugin QT += core ivicore diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro index c751801..0967ee4 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/org-example-echo-noprivate.pro @@ -5,10 +5,8 @@ QT_FOR_CONFIG += ivicore SUBDIRS = frontend \ qmlplugin \ backend_simulator \ - validator \ test backend_simulator.depends = frontend -validator.depends = frontend test.depends = frontend qmlplugin.depends = frontend diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/validator/validator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/validator/validator.pro deleted file mode 100644 index 016c77d..0000000 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-noprivate/validator/validator.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = validator_org-example-echo-noprivate -QMAKE_PROJECT_NAME = $$TARGET -LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_noprivate_frontend) - -DESTDIR = .. - -CONFIG += c++11 ivigenerator -CONFIG -= app_bundle - -INCLUDEPATH += $$OUT_PWD/../frontend - -QT += qml quick core ivicore - -QFACE_FORMAT = generation_validator -QFACE_SOURCES = ../../../org.example.echo.qface -QFACE_ANNOTATIONS += ../../../no-private.yaml diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro index 09efc01..3c84052 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/backend_qtro/backend_qtro.pro @@ -7,7 +7,7 @@ CONFIG += warn_off ivigenerator plugin INCLUDEPATH += $$OUT_PWD/../frontend PLUGIN_TYPE = qtivi -PLUGIN_CLASS_NAME = EchoPlugin +PLUGIN_CLASS_NAME = EchoQtROPlugin QT += core ivicore diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp index 2e7d542..78584de 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.cpp @@ -30,7 +30,7 @@ #include "contactsmodelservice.h" ContactsModelService::ContactsModelService(QObject* parent) - : PagingModelSimpleSource(parent) + : QIviPagingModelSimpleSource(parent) { } diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h index 5a257f5..6578fa8 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/contactsmodelservice.h @@ -31,9 +31,9 @@ #define CONTACTSMODELSERVICE_H #include "contact.h" -#include "rep_pagingmodel_source.h" +#include "rep_qivipagingmodel_source.h" -class ContactsModelService : public PagingModelSimpleSource +class ContactsModelService : public QIviPagingModelSimpleSource { public: ContactsModelService(QObject* parent = nullptr); diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp index 6f16ae2..2befbe2 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp @@ -28,7 +28,6 @@ ****************************************************************************/ #include "tst_echoqtro.h" -#include "echoplugin.h" #include "server.h" #include "echo.h" #include "echozoned.h" diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.cpp index f0dca77..d2bb99f 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.cpp +++ b/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.cpp @@ -1,10 +1,10 @@ #include "echobackend.h" #include "echozonedbackend.h" -#include "echoplugin.h" +#include "echosimulatorplugin.h" QT_BEGIN_NAMESPACE -extern QVector<QIviFeatureInterface *> echoInterfaceBuilder(EchoPlugin *plugin) +extern QVector<QIviFeatureInterface *> echoInterfaceBuilder(EchoSimulatorPlugin *plugin) { QVector<QIviFeatureInterface *> res; res << new EchoBackend(plugin); diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.pro index 9922d05..242a073 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo/backend_simulator/backend_simulator.pro @@ -7,7 +7,7 @@ CONFIG += warn_off ivigenerator plugin INCLUDEPATH += $$OUT_PWD/../frontend PLUGIN_TYPE = qtivi -PLUGIN_CLASS_NAME = EchoPlugin +PLUGIN_CLASS_NAME = EchoSimulatorPlugin QT += core ivicore diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro b/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro index 38be75d..f6f762c 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro +++ b/tests/auto/core/ivigenerator/projects/org-example-echo/org-example-echo.pro @@ -3,10 +3,8 @@ TEMPLATE = subdirs SUBDIRS = frontend \ qmlplugin \ backend_simulator \ - validator \ test \ backend_simulator.depends = frontend -validator.depends = frontend test.depends = frontend qmlplugin.depends = frontend diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo/validator/validator.pro b/tests/auto/core/ivigenerator/projects/org-example-echo/validator/validator.pro deleted file mode 100644 index 122db41..0000000 --- a/tests/auto/core/ivigenerator/projects/org-example-echo/validator/validator.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = validator_org-example-echo -QMAKE_PROJECT_NAME = $$TARGET -LIBS += -L$$OUT_PWD/.. -l$$qtLibraryTarget(echo_frontend) - -DESTDIR = .. - -CONFIG += c++11 ivigenerator -CONFIG -= app_bundle - -INCLUDEPATH += $$OUT_PWD/../frontend - -QT += qml quick core ivicore - -QFACE_FORMAT = generation_validator -QFACE_SOURCES = ../../../org.example.echo.qface diff --git a/tests/auto/core/ivigenerator/projects/projects.pro b/tests/auto/core/ivigenerator/projects/projects.pro index bc349a5..eb8d2b7 100644 --- a/tests/auto/core/ivigenerator/projects/projects.pro +++ b/tests/auto/core/ivigenerator/projects/projects.pro @@ -5,6 +5,7 @@ QT_FOR_CONFIG += ivicore SUBDIRS = org-example-echo \ org-example-echo-noprivate \ org-example-echo-noannotation \ + include-test \ qtConfig(remoteobjects) { SUBDIRS += org-example-echo-qtro diff --git a/tests/auto/core/ivigenerator/qface imports/common.qface b/tests/auto/core/ivigenerator/qface imports/common.qface new file mode 100644 index 0000000..b9cee0c --- /dev/null +++ b/tests/auto/core/ivigenerator/qface imports/common.qface @@ -0,0 +1,20 @@ +module Common 1.0; + +struct CommonStruct { + string name + OtherCommonStruct otherStruct +} + +struct OtherCommonStruct { + bool checked +} + +enum CommonEnum { + CommonValue1, + CommonValue2 +} + +flag CommonFlag { + FlagValue1 = 1, + FlagValue2 = 2 +} diff --git a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp index 65882e0..1d1ceea 100644 --- a/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp +++ b/tests/auto/core/qivisearchandbrowsemodel/tst_qivisearchandbrowsemodel.cpp @@ -105,12 +105,12 @@ public: void registerInstance(const QUuid &identifier) override { - Q_UNUSED(identifier); + Q_UNUSED(identifier) } void unregisterInstance(const QUuid &identifier) override { - Q_UNUSED(identifier); + Q_UNUSED(identifier) } void setContentType(const QUuid &identifier, const QString &contentType) override @@ -197,7 +197,7 @@ public: QMetaProperty mp = mo.property(mpi); - qSort(list.begin(), list.end(), [mp, this](const QIviStandardItem &s1, const QIviStandardItem &s2) { + std::sort(list.begin(), list.end(), [mp, this](const QIviStandardItem &s1, const QIviStandardItem &s2) { QVariant var1 = mp.readOnGadget(&s1); QVariant var2 = mp.readOnGadget(&s2); if (var1.canConvert(QMetaType::Int) && var1.canConvert(QMetaType::Int)) { diff --git a/tests/auto/core/servicemanagertest/tst_servicemanagertest.cpp b/tests/auto/core/servicemanagertest/tst_servicemanagertest.cpp index 1923ee6..5c0ba96 100644 --- a/tests/auto/core/servicemanagertest/tst_servicemanagertest.cpp +++ b/tests/auto/core/servicemanagertest/tst_servicemanagertest.cpp @@ -87,6 +87,9 @@ class ServiceManagerTest : public QObject public: ServiceManagerTest(); + void ignoreStaticPluginWarnings(); + void ignoreDynamicPluginWarnings(); + private Q_SLOTS: void initTestCase(); void cleanup(); @@ -110,35 +113,63 @@ ServiceManagerTest::ServiceManagerTest() { } +void ServiceManagerTest::ignoreStaticPluginWarnings() +{ + QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in static plugin '.*'. MetaData must contain a list of interfaces")); +} + +void ServiceManagerTest::ignoreDynamicPluginWarnings() +{ + QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in '.*'. MetaData must contain a list of interfaces")); +#ifdef DEBUG_AND_RELEASE +# ifndef Q_OS_WIN + // Because the plugin is build in both configurations, the error is also emitted twice + QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in '.*'. MetaData must contain a list of interfaces")); +# endif + + QTest::ignoreMessage(QtInfoMsg, QRegularExpression("Found the same plugin in two configurations. Using the '.*' configuration: .*")); +#endif +} + void ServiceManagerTest::initTestCase() { - QStringList origList = QCoreApplication::libraryPaths(); + // Make sure the dynamic plugins can't be found in the beginning QCoreApplication::setLibraryPaths(QStringList()); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in static plugin '.*'. MetaData must contain a list of interfaces")); - QTest::ignoreMessage(QtWarningMsg, "No plugins found in search path: \"\""); + ignoreStaticPluginWarnings(); manager = QIviServiceManager::instance(); QList<QIviServiceObject *> services = manager->findServiceByInterface("simple_plugin"); QCOMPARE(services.count(), 0); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in static plugin '.*'. MetaData must contain a list of interfaces")); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in '.*'. MetaData must contain a list of interfaces")); -#ifdef DEBUG_AND_RELEASE - QTest::ignoreMessage(QtInfoMsg, QRegularExpression("Found the same plugin in two configurations. Using the '.*' configuration: .*")); -#endif - //Reset original setting - QCoreApplication::setLibraryPaths(origList); - QIviServiceManagerPrivate::get(manager)->searchPlugins(); + // Unload all plugins and don't search for the static plugins to trigger the 'no plugins found' warning + manager->unloadAllBackends(); + QIviServiceManagerPrivate::get(manager)->m_staticLoaded = true; + + QTest::ignoreMessage(QtWarningMsg, "No plugins found in search path: \"\""); + services = manager->findServiceByInterface("simple_plugin_static"); + QCOMPARE(services.count(), 0); + + // Change the library path to the current directory to be able to test loading dynamic plugins + QCoreApplication::setLibraryPaths({QDir::currentPath()}); + ignoreDynamicPluginWarnings(); - //Save the id of the service object. This needed in the pluginLoaderTest + // This needs to trigger a search for new plugins in the library path, as it is supposed to + // reevaluate QCoreApplication::libraryPaths(); services = manager->findServiceByInterface("simple_plugin"); QCOMPARE(services.count(), 1); + // Save the id of the service object. This needed in the pluginLoaderTest m_simplePluginID = services.at(0)->id(); } void ServiceManagerTest::cleanup() { manager->unloadAllBackends(); + + // Make sure to search for all plugins here explicitly to catch all expected warning messages + // Otherwise a findServiceByInterface call will implictly trigger it. + ignoreStaticPluginWarnings(); + ignoreDynamicPluginWarnings(); + QIviServiceManagerPrivate::get(manager)->searchPlugins(); } void ServiceManagerTest::testRetakeSingleton() @@ -251,10 +282,14 @@ void ServiceManagerTest::testRegisterNonServiceBackendInterfaceObject() */ void ServiceManagerTest::testManagerListModel() { + // Because of the plugin loading test and the static plugins, we always have some backends already + // in the list + const int backendCount = manager->rowCount(); + QSignalSpy managerModelSpy(manager, SIGNAL(rowsInserted(QModelIndex,int,int))); // Sanity check - QCOMPARE(manager->rowCount(), 0); + QCOMPARE(manager->rowCount(), backendCount); QCOMPARE(managerModelSpy.count(), 0); QCOMPARE(manager->data(QModelIndex(), QIviServiceManager::NameRole), QVariant()); QCOMPARE(manager->data(QModelIndex(), QIviServiceManager::ServiceObjectRole), QVariant()); @@ -264,11 +299,11 @@ void ServiceManagerTest::testManagerListModel() MockServiceBackend *backend0 = new MockServiceBackend(manager); bool regResult = manager->registerService(backend0, QStringList() << "Interface0"); QCOMPARE(regResult, true); - QCOMPARE(manager->rowCount(), 1); + QCOMPARE(manager->rowCount(), backendCount + 1); //QCOMPARE(manager->data(manager->index(0), Qt::DisplayRole).value<QIviServiceInterface*>(), backend0); - QCOMPARE(manager->data(manager->index(0), QIviServiceManager::NameRole).toString(), QStringLiteral("MockServiceBackend")); - QCOMPARE(manager->data(manager->index(0), QIviServiceManager::ServiceObjectRole).value<QIviProxyServiceObject*>()->d_ptr->m_serviceInterface, backend0); - QCOMPARE(manager->data(manager->index(0), QIviServiceManager::InterfacesRole).toStringList(), QStringList() << "Interface0"); + QCOMPARE(manager->data(manager->index(backendCount), QIviServiceManager::NameRole).toString(), QStringLiteral("MockServiceBackend")); + QCOMPARE(manager->data(manager->index(backendCount), QIviServiceManager::ServiceObjectRole).value<QIviProxyServiceObject*>()->d_ptr->m_serviceInterface, backend0); + QCOMPARE(manager->data(manager->index(backendCount), QIviServiceManager::InterfacesRole).toStringList(), QStringList() << "Interface0"); QCOMPARE(managerModelSpy.count(), 1); // Extendend sanity check QCOMPARE(manager->data(manager->index(0,0), Qt::UserRole + 200), QVariant()); @@ -277,32 +312,25 @@ void ServiceManagerTest::testManagerListModel() MockServiceBackend *backend1 = new MockServiceBackend(manager); regResult = manager->registerService(backend1, QStringList() << "Interface1" << "Interface2"); QCOMPARE(regResult, true); - QCOMPARE(manager->rowCount(), 2); - QCOMPARE(manager->data(manager->index(0), QIviServiceManager::NameRole).toString(), QStringLiteral("MockServiceBackend")); - QCOMPARE(manager->data(manager->index(0), QIviServiceManager::ServiceObjectRole).value<QIviProxyServiceObject*>()->d_ptr->m_serviceInterface, backend0); - QCOMPARE(manager->data(manager->index(0), QIviServiceManager::InterfacesRole).toStringList(), QStringList() << "Interface0"); - QCOMPARE(manager->data(manager->index(1), QIviServiceManager::NameRole).toString(), QStringLiteral("MockServiceBackend")); - QCOMPARE(manager->data(manager->index(1), QIviServiceManager::ServiceObjectRole).value<QIviProxyServiceObject*>()->d_ptr->m_serviceInterface, backend1); - QCOMPARE(manager->data(manager->index(1), QIviServiceManager::InterfacesRole).toStringList(), QStringList() << "Interface1" << "Interface2"); + QCOMPARE(manager->rowCount(), backendCount + 2); + QCOMPARE(manager->data(manager->index(backendCount), QIviServiceManager::NameRole).toString(), QStringLiteral("MockServiceBackend")); + QCOMPARE(manager->data(manager->index(backendCount), QIviServiceManager::ServiceObjectRole).value<QIviProxyServiceObject*>()->d_ptr->m_serviceInterface, backend0); + QCOMPARE(manager->data(manager->index(backendCount), QIviServiceManager::InterfacesRole).toStringList(), QStringList() << "Interface0"); + QCOMPARE(manager->data(manager->index(backendCount + 1), QIviServiceManager::NameRole).toString(), QStringLiteral("MockServiceBackend")); + QCOMPARE(manager->data(manager->index(backendCount + 1), QIviServiceManager::ServiceObjectRole).value<QIviProxyServiceObject*>()->d_ptr->m_serviceInterface, backend1); + QCOMPARE(manager->data(manager->index(backendCount + 1), QIviServiceManager::InterfacesRole).toStringList(), QStringList() << "Interface1" << "Interface2"); QCOMPARE(managerModelSpy.count(), 2); // Register backend-2 with 'Interface1' and 'Interface2'. Should not result in any model changes MockServiceBackend *backend2 = new MockServiceBackend(manager); regResult = manager->registerService(backend2, QStringList() << "Interface1" << "Interface2"); QCOMPARE(regResult, true); - QCOMPARE(manager->rowCount(), 3); + QCOMPARE(manager->rowCount(), backendCount + 3); QCOMPARE(managerModelSpy.count(), 3); } void ServiceManagerTest::pluginLoaderTest() { - //Test the error message for plugins with invalid metadata - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in '(.*)wrongmetadata_plugin(.*)'. MetaData must contain a list of interfaces")); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression("PluginManager - Malformed metaData in static plugin 'WrongMetadataStaticPlugin'. MetaData must contain a list of interfaces")); -#ifdef DEBUG_AND_RELEASE - QTest::ignoreMessage(QtInfoMsg, QRegularExpression("Found the same plugin in two configurations. Using the '.*' configuration: .*")); -#endif - QIviServiceManagerPrivate::get(manager)->searchPlugins(); QVERIFY(manager->hasInterface("simple_plugin")); QList<QIviServiceObject *> services = manager->findServiceByInterface("simple_plugin", QIviServiceManager::IncludeProductionBackends); QCOMPARE(services.count(), 1); @@ -320,10 +348,7 @@ void ServiceManagerTest::pluginLoaderTest() //Test that the plugin is unloaded (or at least removed from the registry) manager->unloadAllBackends(); - services = manager->findServiceByInterface("simple_plugin"); - QCOMPARE(services.count(), 0); - services = manager->findServiceByInterface("simple_plugin_static"); - QCOMPARE(services.count(), 0); + QCOMPARE(manager->rowCount(), 0); } Q_IMPORT_PLUGIN(SimpleStaticPlugin) diff --git a/tests/auto/dlt/tst_dlt.cpp b/tests/auto/dlt/tst_dlt.cpp index 3fb7136..12185af 100644 --- a/tests/auto/dlt/tst_dlt.cpp +++ b/tests/auto/dlt/tst_dlt.cpp @@ -40,6 +40,25 @@ Q_LOGGING_CATEGORY(TEST1, "qtgeniviextras.test1") +static QString longMsg = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy " +"eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et " +"accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est " +"Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam " +"nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero " +"eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata anctu " +"sest Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,sed diam " +"nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero " +"eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimta sanctu " +"sest Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit " +"esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et " +"iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugit null " +"afacilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nih euismod " +"tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veiam, quis nostru " +"dexerci dolor"; + +// Copied from dlt-daemon_cfg.h +// Defines how big the buffer for a msg payload needs to be to copy long msg +#define DLT_DAEMON_TEXTSIZE 10024 struct QDltMessage { QString appId; @@ -62,28 +81,31 @@ public: { QVERIFY(dlt_file_close(dltFile, false) >= 0); QVERIFY(dlt_file_free(dltFile, false) >= 0); + delete dltFile; } QString idToString(char *id) { QByteArray appData(DLT_ID_SIZE, '\0'); - dlt_print_id(appData.data(),id); + dlt_print_id(appData.data(), id); return QString(appData); } QString readPayload(DltMessage *msg) { - QByteArray payload(msg->datasize, '\0'); - dlt_message_payload(msg,payload.data(),msg->datasize,DLT_OUTPUT_ASCII,false); + QByteArray payload(DLT_DAEMON_TEXTSIZE, '\0'); + dlt_message_payload(msg, payload.data(), DLT_DAEMON_TEXTSIZE, DLT_OUTPUT_ASCII, false); return QString::fromLocal8Bit(payload); } QList<QDltMessage> readNextMessages() { QList<QDltMessage> messageList; - while (dlt_file_read(dltFile, false) == 1) - { - dlt_file_message(dltFile, 0, false); + //Read the complete file + while (dlt_file_read(dltFile, false) >= 0){}; + //Parse the messages + for (int i = 0; i < dltFile->counter; i++) { + dlt_file_message(dltFile, i, false); QDltMessage msg; msg.appId = idToString(dltFile->msg.extendedheader->apid); @@ -111,13 +133,18 @@ public: m_dltParser = new QDltParser(&m_tempFile); } + ~QDltTest() + { + delete m_dltParser; + } + private Q_SLOTS: void initTestCase(); -// void registerApplication(); -// void registerTwoApplications(); -// void registerContexts(); + void init(); + void testLongMessages_data(); void testLogging(); + void testLongMessages(); private: QTemporaryFile m_tempFile; @@ -126,21 +153,30 @@ private: void QDltTest::initTestCase() { - //Initialize the dlt system before the QDltRegistration can do it to log to a file. - dlt_init_file(m_tempFile.fileName().toLocal8Bit()); - + qRegisterMetaType<QDltRegistration::LongMessageBehavior>(); //Install the DLT message handler qInstallMessageHandler(QDltRegistration::messageHandler); } +void QDltTest::init() +{ + //Reset the log file after each test + m_tempFile.resize(0); + //Initialize the DLT log file and write the header to it. + dlt_init_file(m_tempFile.fileName().toLocal8Bit()); + //Create a new Parser (to start reading the file from the beginning) + delete m_dltParser; + m_dltParser = new QDltParser(&m_tempFile); +} + void QDltTest::testLogging() { QDltRegistration *registration = globalDltRegistration(); registration->registerApplication("APP1", "Description for APP"); registration->registerCategory(&TEST1(), "TES1", "Test Category One"); - QString msg = QLatin1String("TEST"); - QString expectedMsg = QString("%1: \"%2\"").arg(TEST1().categoryName(), msg); + QString msg = QStringLiteral("TEST"); + QString expectedMsg = QString(QStringLiteral("%1: \"%2\"")).arg(TEST1().categoryName(), msg); qWarning(TEST1) << msg; @@ -151,6 +187,76 @@ void QDltTest::testLogging() QCOMPARE(dltMessages.at(0).payload, expectedMsg); } +void QDltTest::testLongMessages_data() +{ + QTest::addColumn<QDltRegistration::LongMessageBehavior>("behavior"); + QTest::addColumn<QString>("msg"); + QTest::addColumn<QStringList>("expected_msgs"); + + QTest::addRow("Truncate ASCII") << QDltRegistration::LongMessageBehavior::Truncate + << longMsg + QStringLiteral("ipsum") + << QStringList(longMsg + QStringLiteral("ipsu")); + QTest::addRow("Truncate UTF-8 2 bytes") << QDltRegistration::LongMessageBehavior::Truncate + << longMsg + QStringLiteral("©®¥¶¼") + << QStringList(longMsg + QStringLiteral("©®")); + QTest::addRow("Truncate UTF-8 3 bytes") << QDltRegistration::LongMessageBehavior::Truncate + << longMsg + QStringLiteral("你好世界") + << QStringList(longMsg + QStringLiteral("你")); + QTest::addRow("Split ASCII") << QDltRegistration::LongMessageBehavior::Split + << longMsg + QStringLiteral("ipsum") + << QStringList({longMsg + QStringLiteral("ipsu"), QStringLiteral("m\"")}); + QTest::addRow("Split UTF-8 2 bytes") << QDltRegistration::LongMessageBehavior::Split + << longMsg + QStringLiteral("©®¥¶¼") + << QStringList({longMsg + QStringLiteral("©®"), QStringLiteral("¥¶¼\"")}); + QTest::addRow("Split UTF-8 3 bytes") << QDltRegistration::LongMessageBehavior::Split + << longMsg + QStringLiteral("你好世界") + << QStringList({longMsg + QStringLiteral("你"), QStringLiteral("好世界\"")}); + QTest::addRow("Pass ASCII") << QDltRegistration::LongMessageBehavior::Pass + << longMsg + QStringLiteral("ipsum123456789a") + << QStringList(QString()); + QTest::addRow("Pass UTF-8 2 bytes") << QDltRegistration::LongMessageBehavior::Pass + << longMsg + QStringLiteral("©®¥¶¼") + << QStringList(QString()); + QTest::addRow("Pass UTF-8 3 bytes") << QDltRegistration::LongMessageBehavior::Pass + << longMsg + QStringLiteral("你好世界") + << QStringList(QString()); +} + +void QDltTest::testLongMessages() +{ + QFETCH(QDltRegistration::LongMessageBehavior, behavior); + QFETCH(QString, msg); + QFETCH(QStringList, expected_msgs); + + QDltRegistration *registration = globalDltRegistration(); + registration->registerApplication("APP1", "Description for APP"); + registration->registerCategory(&TEST1(), "TES1", "Test Category One"); + registration->setLongMessageBehavior(behavior); + + qWarning(TEST1) << msg; + + QList<QDltMessage> dltMessages = m_dltParser->readNextMessages(); + QCOMPARE(dltMessages.count(), expected_msgs.count()); + + int i = 0; + for (const QString &expected_msg : expected_msgs) { + QString expectedMsg; + //The logging category will be added before the splitting, it's only part of the first msg + if (i == 0 && behavior != QDltRegistration::LongMessageBehavior::Pass) { + //The closing quotes are part of the message pattern and will be cut as well. + expectedMsg = QString(QStringLiteral("%1: \"%2")).arg(TEST1().categoryName(), expected_msg); + } else { + expectedMsg = expected_msg; + } + + QCOMPARE(dltMessages.at(i).appId, QLatin1String("APP1")); + QCOMPARE(dltMessages.at(i).ctxId, QLatin1String("TES1")); + // Enable me to compare the full content on the console + // std::cout << dltMessages.at(i).payload.toStdString() << "\n" << expectedMsg.toStdString() << std::endl; + QCOMPARE(dltMessages.at(i).payload, expectedMsg); + i++; + } +} QTEST_APPLESS_MAIN(QDltTest) |