From fbf59071450f81b7bfd8914cc109ece3c2ba8139 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Wed, 21 Aug 2019 14:07:42 +0200 Subject: ivigenerator: Support enums and flags as return values of operations Also add a generation test, as well as as testing the functionality using QtRO. Change-Id: I9a26ca595fdb9e8522fd3cc01d0b7337e86a1dad Fixes: AUTOSUITE-1190 Reviewed-by: Robert Griebl --- .../auto/core/ivigenerator/org.example.echo.qface | 5 +++ .../server_qtro_test/echoservice.cpp | 12 +++++++ .../server_qtro_test/echoservice.h | 4 +++ .../server_qtro_test/echozonedservice.cpp | 12 +++++++ .../server_qtro_test/echozonedservice.h | 4 +++ .../server_qtro_test/tst_echoqtro.cpp | 42 ++++++++++++++++++++++ 6 files changed, 79 insertions(+) (limited to 'tests') diff --git a/tests/auto/core/ivigenerator/org.example.echo.qface b/tests/auto/core/ivigenerator/org.example.echo.qface index 6ea92bc..d5d9f23 100644 --- a/tests/auto/core/ivigenerator/org.example.echo.qface +++ b/tests/auto/core/ivigenerator/org.example.echo.qface @@ -39,6 +39,9 @@ interface Echo { void voidSlot(); void voidSlot2(int param); void timer(int interval); + AirflowDirection flagMethod(AirflowDirection direction); + TestEnum enumMethod(TestEnum testEnum); + signal anotherChanged(AnotherStruct another); signal foobar(string foo); signal somethingHappened(); @@ -80,6 +83,8 @@ interface EchoZoned { var varMethod(); Combo getCombo(); string timer(int interval); + AirflowDirection flagMethod(AirflowDirection direction); + TestEnum enumMethod(TestEnum testEnum); signal anotherChanged(AnotherStruct another); signal foobar(string foo); diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp index 80a2735..8088015 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.cpp @@ -82,3 +82,15 @@ QVariant EchoService::timer(int interval) }); return QVariant::fromValue(pendingResult); } + +QVariant EchoService::flagMethod(EchoModule::AirflowDirections direction) +{ + emit flagMethodCalled(direction); + return QVariant::fromValue(direction); +} + +QVariant EchoService::enumMethod(EchoModule::TestEnum testEnum) +{ + emit enumMethodCalled(testEnum); + return QVariant::fromValue(testEnum); +} diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h index 2bdbf54..3cd188b 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echoservice.h @@ -51,6 +51,8 @@ public Q_SLOTS: virtual QVariant voidSlot() override; virtual QVariant voidSlot2(int param) override; virtual QVariant timer(int interval) override; + virtual QVariant flagMethod(EchoModule::AirflowDirections direction) override; + virtual QVariant enumMethod(EchoModule::TestEnum testEnum) override; Q_SIGNALS: void echoSlotCalled(const QString &msg); @@ -58,6 +60,8 @@ Q_SIGNALS: void getComboSlotCalled(); void voidSlotCalled(); void voidSlot2Called(int param); + void flagMethodCalled(EchoModule::AirflowDirections direction); + void enumMethodCalled(EchoModule::TestEnum testEnum); }; #endif // ECHOSERVICE_H diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp index e5c6634..0010d89 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.cpp @@ -263,3 +263,15 @@ QVariant EchoZonedService::timer(int interval, const QString &zone) }); return QVariant::fromValue(pendingResult); } + +QVariant EchoZonedService::flagMethod(EchoModule::AirflowDirections direction, const QString &zone) +{ + emit flagMethodCalled(direction, zone); + return QVariant::fromValue(direction); +} + +QVariant EchoZonedService::enumMethod(EchoModule::TestEnum testEnum, const QString &zone) +{ + emit enumMethodCalled(testEnum, zone); + return QVariant::fromValue(testEnum); +} diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h index c0b72a9..cf7cf63 100644 --- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h +++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/echozonedservice.h @@ -79,6 +79,8 @@ public slots: QVariant varMethod(const QString &zone) override; QVariant getCombo(const QString &zone) override; QVariant timer(int interval, const QString &zone) override; + QVariant flagMethod(EchoModule::AirflowDirections direction, const QString &zone) override; + QVariant enumMethod(EchoModule::TestEnum testEnum, const QString &zone) override; Q_SIGNALS: void echoSlotCalled(const QString &msg, const QString& zone); @@ -87,6 +89,8 @@ Q_SIGNALS: void getComboSlotCalled(const QString& zone); void voidSlotCalled(const QString& zone); void voidSlot2Called(int param, const QString& zone); + void flagMethodCalled(EchoModule::AirflowDirections direction, const QString& zone); + void enumMethodCalled(EchoModule::TestEnum testEnum, const QString& zone); private: struct ZoneObject { 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 7452a3e..6f16ae2 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 @@ -718,6 +718,26 @@ void EchoQtroTest::testSlots() voidSlot2Spy.wait(1000); QCOMPARE(voidSlot2Spy.count(), 1); QCOMPARE(voidSlot2Spy[0][0].toInt(), voidSlot2TestValue); + + QSignalSpy flagMethodSpy(&server.m_echoService, SIGNAL(flagMethodCalled(EchoModule::AirflowDirections))); + QVERIFY(flagMethodSpy.isValid()); + EchoModule::AirflowDirections flagTestValue = EchoModule::Dashboard; + QIviPendingReply flagMethodReply = client.flagMethod(flagTestValue); + QSignalSpy flagMethodReplySpy(flagMethodReply.watcher(), SIGNAL(replySuccess())); + WAIT_AND_COMPARE(flagMethodReplySpy, 1); + QCOMPARE(flagMethodReply.reply(), flagTestValue); + QCOMPARE(flagMethodSpy.count(), 1); + QCOMPARE(flagMethodSpy[0][0].value(), flagTestValue); + + QSignalSpy enumMethodSpy(&server.m_echoService, SIGNAL(enumMethodCalled(EchoModule::TestEnum))); + QVERIFY(enumMethodSpy.isValid()); + EchoModule::TestEnum enumTestValue = EchoModule::SecondEnumValue; + QIviPendingReply enumMethodReply = client.enumMethod(enumTestValue); + QSignalSpy enumMethodReplySpy(enumMethodReply.watcher(), SIGNAL(replySuccess())); + WAIT_AND_COMPARE(enumMethodReplySpy, 1); + QCOMPARE(enumMethodReply.reply(), enumTestValue); + QCOMPARE(enumMethodSpy.count(), 1); + QCOMPARE(enumMethodSpy[0][0].value(), enumTestValue); } void EchoQtroTest::testZonedSlots() @@ -766,6 +786,28 @@ void EchoQtroTest::testZonedSlots() WAIT_AND_COMPARE(comboReplySpy, 1); QCOMPARE(comboReply.reply(), server.m_echoService.m_testCombo); QCOMPARE(getComboSpy.count(), 1); + + QSignalSpy flagMethodSpy(&server.m_echoZonedService, SIGNAL(flagMethodCalled(EchoModule::AirflowDirections, QString))); + QVERIFY(flagMethodSpy.isValid()); + EchoModule::AirflowDirections flagTestValue = EchoModule::Dashboard; + QIviPendingReply flagMethodReply = zone->flagMethod(flagTestValue); + QSignalSpy flagMethodReplySpy(flagMethodReply.watcher(), SIGNAL(replySuccess())); + WAIT_AND_COMPARE(flagMethodReplySpy, 1); + QCOMPARE(flagMethodReply.reply(), flagTestValue); + QCOMPARE(flagMethodSpy.count(), 1); + QCOMPARE(flagMethodSpy[0][0].value(), flagTestValue); + QCOMPARE(flagMethodSpy[0][1].toString(), frontLeftZone); + + QSignalSpy enumMethodSpy(&server.m_echoZonedService, SIGNAL(enumMethodCalled(EchoModule::TestEnum, QString))); + QVERIFY(enumMethodSpy.isValid()); + EchoModule::TestEnum enumTestValue = EchoModule::SecondEnumValue; + QIviPendingReply enumMethodReply = zone->enumMethod(enumTestValue); + QSignalSpy enumMethodReplySpy(enumMethodReply.watcher(), SIGNAL(replySuccess())); + WAIT_AND_COMPARE(enumMethodReplySpy, 1); + QCOMPARE(enumMethodReply.reply(), enumTestValue); + QCOMPARE(enumMethodSpy.count(), 1); + QCOMPARE(enumMethodSpy[0][0].value(), enumTestValue); + QCOMPARE(enumMethodSpy[0][1].toString(), frontLeftZone); } void EchoQtroTest::testMultipleSlotCalls() -- cgit v1.2.1