summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2018-03-19 16:49:01 +0100
committerAntti Hölttä <ahoelttae@luxoft.com>2018-03-23 13:38:28 +0000
commit97ba455a6ba0e41aab384678ebf62c234d85a344 (patch)
tree84bba9ceaa15fa2b7ad8e95ea656a29d4c3c49fb
parenta3af38e5f6df4a452f2be22d480faaffe31af908 (diff)
downloadqtivi-97ba455a6ba0e41aab384678ebf62c234d85a344.tar.gz
Use the new QIviPendingReply class in the autogenerator templates
Every method inside a qface file will now return a QIviPendingReply. This also changes the signature of the QIviVehicleFunctions module and its backend implementations. Also updated the window_qml example to make use of the new returned QIviPendingReplies from the open() and close() calls. Task-number: QTAUTO-837 Change-Id: Icf8a31fcd94630254f71b0c4fb2e1ef4296591af Reviewed-by: Antti Hölttä <ahoelttae@luxoft.com>
-rw-r--r--examples/ivivehiclefunctions/window_qml/WindowItem.qml4
-rw-r--r--src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.cpp42
-rw-r--r--src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.h9
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl22
-rw-r--r--src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl2
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl8
-rw-r--r--src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl6
-rw-r--r--src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl7
-rw-r--r--src/tools/ivigenerator/templates_frontend/interface.cpp.tpl4
-rw-r--r--src/tools/ivigenerator/templates_frontend/interface.h.tpl3
-rw-r--r--src/tools/ivigenerator/templates_frontend/module.cpp.tpl4
-rw-r--r--src/tools/ivigenerator/templates_test/tst_test.cpp.tpl11
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.cpp62
-rw-r--r--tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h1
14 files changed, 139 insertions, 46 deletions
diff --git a/examples/ivivehiclefunctions/window_qml/WindowItem.qml b/examples/ivivehiclefunctions/window_qml/WindowItem.qml
index a261ce8..d740fff 100644
--- a/examples/ivivehiclefunctions/window_qml/WindowItem.qml
+++ b/examples/ivivehiclefunctions/window_qml/WindowItem.qml
@@ -84,12 +84,12 @@ GroupBox {
Button {
text: "open"
- onClicked: zone.open()
+ onClicked: zone.open().then(function(){console.error(zone.zone + " window opened")}, function(){console.error("opening " + zone.zone + " window failed!")})
}
Button {
text: "close"
- onClicked: zone.close()
+ onClicked: zone.close().then(function(){console.error(zone.zone + " window closed")}, function(){console.error("closing " + zone.zone + " window failed!")})
}
RowLayout {
diff --git a/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.cpp b/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.cpp
index 9396d02..9c0c165 100644
--- a/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.cpp
+++ b/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.cpp
@@ -65,14 +65,24 @@ void WindowTimer::setOpeningTime(int intervalInSeconds)
m_interval = intervalInSeconds;
}
-void WindowTimer::open()
+void WindowTimer::open(QIviPendingReply<void> reply)
{
+ if (!m_pendingReply.isResultAvailable())
+ m_pendingReply.setFailed();
+
+ m_pendingReply = reply;
+
m_opening = true;
m_timer->start();
}
-void WindowTimer::close()
+void WindowTimer::close(QIviPendingReply<void> reply)
{
+ if (!m_pendingReply.isResultAvailable())
+ m_pendingReply.setFailed();
+
+ m_pendingReply = reply;
+
m_opening = false;
m_timer->start();
}
@@ -89,10 +99,12 @@ void WindowTimer::checkValue()
m_currentValue = 0;
m_timer->stop();
state = QtIviVehicleFunctionsModule::Closed;
+ m_pendingReply.setSuccess();
} else if (m_currentValue >= m_interval) {
m_currentValue = m_interval;
m_timer->stop();
state = QtIviVehicleFunctionsModule::FullyOpen;
+ m_pendingReply.setSuccess();
} else {
state = QtIviVehicleFunctionsModule::Open;
}
@@ -127,35 +139,41 @@ void QIviConcreteWindowControlBackend::setBlindMode(QtIviVehicleFunctionsModule:
return;
if (blindMode == QtIviVehicleFunctionsModule::BlindOpen)
- m_zoneBlindTimers[zone]->open();
+ m_zoneBlindTimers[zone]->open(QIviPendingReply<void>());
else if (blindMode == QtIviVehicleFunctionsModule::BlindClosed)
- m_zoneBlindTimers[zone]->close();
+ m_zoneBlindTimers[zone]->close(QIviPendingReply<void>());
QIviWindowControlBackend::setBlindMode(blindMode, zone);
}
-void QIviConcreteWindowControlBackend::open(const QString &zone)
+QIviPendingReply<void> QIviConcreteWindowControlBackend::open(const QString &zone)
{
if (!m_zoneMap.contains(zone))
- return;
+ return QIviPendingReply<void>::createFailedReply();
if (m_zoneMap[zone].state == QtIviVehicleFunctionsModule::Open)
- return;
+ return QIviPendingReply<void>::createFailedReply();
qWarning() << "SIMULATION open Window:" << zone;
- m_zoneWindowTimers[zone]->open();
+ QIviPendingReply<void> reply;
+ m_zoneWindowTimers[zone]->open(reply);
+
+ return reply;
}
-void QIviConcreteWindowControlBackend::close(const QString &zone)
+QIviPendingReply<void> QIviConcreteWindowControlBackend::close(const QString &zone)
{
if (!m_zoneMap.contains(zone))
- return;
+ return QIviPendingReply<void>::createFailedReply();
if (m_zoneMap[zone].state == QtIviVehicleFunctionsModule::Closed)
- return;
+ return QIviPendingReply<void>::createFailedReply();
qWarning() << "SIMULATION close Window:" << zone;
- m_zoneWindowTimers[zone]->close();
+ QIviPendingReply<void> reply;
+ m_zoneWindowTimers[zone]->close(reply);
+
+ return reply;
}
QtIviVehicleFunctionsModule::WindowState QIviConcreteWindowControlBackend::windowState(QString zone)
diff --git a/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.h b/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.h
index 6da7fc9..4405274 100644
--- a/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.h
+++ b/src/plugins/ivivehiclefunctions/qiviconcretewindowcontrolbackend.h
@@ -55,8 +55,8 @@ public:
WindowTimer(const QString &zone, bool isBlind, QIviConcreteWindowControlBackend *backend);
void setOpeningTime(int intervalInSeconds);
- void open();
- void close();
+ void open(QIviPendingReply<void> reply);
+ void close(QIviPendingReply<void> reply);
public slots:
void checkValue();
@@ -69,6 +69,7 @@ private:
QString m_zone;
bool m_blind;
QIviConcreteWindowControlBackend *m_backend;
+ QIviPendingReply<void> m_pendingReply;
};
class QIviConcreteWindowControlBackend : public QIviWindowControlBackend
@@ -78,8 +79,8 @@ public:
~QIviConcreteWindowControlBackend();
virtual void setBlindMode(QtIviVehicleFunctionsModule::BlindMode blindMode, const QString &zone) override;
- virtual void open(const QString &zone) override;
- virtual void close(const QString &zone) override;
+ virtual QIviPendingReply<void> open(const QString &zone) override;
+ virtual QIviPendingReply<void> close(const QString &zone) override;
QtIviVehicleFunctionsModule::WindowState windowState(QString zone);
void setWindowState(QtIviVehicleFunctionsModule::WindowState state, const QString &zone);
diff --git a/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl b/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl
index 2c7f5a0..ac99d59 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/backend.cpp.tpl
@@ -104,18 +104,26 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }})
{% for operation in interface.operations %}
{% set operation_parameters = operation.parameters|map('parameter_type')|join(', ') %}
-{{operation|return_type}} {{class}}::{{operation}}({{operation_parameters}}){%if operation.const %} const{% endif %}
+QIviPendingReply<{{operation|return_type}}> {{class}}::{{operation}}({{operation_parameters}}){%if operation.const %} const{% endif %}
{
+ QIviPendingReply<{{operation|return_type}}> iviReply;
{% if not operation.type.is_void %}
- QRemoteObjectPendingReply<{{operation|return_type}}> reply;
- reply = m_replica->{{operation}}({{operation.parameters|join(', ')}});
- if (reply.waitForFinished())
- return reply.returnValue();
- qDebug() << "{{class}}, remote call of method {{operation}} failed";
- return {{operation|default_value}};
+ QRemoteObjectPendingReply<{{operation|return_type}}> reply = m_replica->{{operation}}({{operation.parameters|join(', ')}});
+ auto watcher = new QRemoteObjectPendingCallWatcher(reply);
+ connect(watcher, &QRemoteObjectPendingCallWatcher::finished, this, [this, iviReply](QRemoteObjectPendingCallWatcher *self) mutable {
+ if (self->error() == QRemoteObjectPendingCallWatcher::NoError) {
+ iviReply.setSuccess(self->returnValue().value<{{operation|return_type}}>());
+ } else {
+ iviReply.setFailed();
+ emit errorChanged(QIviAbstractFeature::InvalidOperation, QStringLiteral("{{class}}, remote call of method {{operation}} failed"));
+ }
+ self->deleteLater();
+ });
{% else %}
m_replica->{{operation}}({{operation.parameters|join(', ')}});
+ iviReply.setSuccess();
{% endif %}
+ return iviReply;
}
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl b/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl
index e49215d..eb50a38 100644
--- a/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl
+++ b/src/tools/ivigenerator/templates_backend_qtro/backend.h.tpl
@@ -71,7 +71,7 @@ public Q_SLOTS:
{% endfor %}
{% for operation in interface.operations %}
- virtual {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} override;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} override;
{% endfor %}
protected Q_SLOTS:
diff --git a/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl b/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl
index 090dd46..3ba180b 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/backend.cpp.tpl
@@ -231,7 +231,7 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }})
{{ utils.format_comments(operation.comment) }}
*/
-{{operation|return_type}} {{class}}::{{operation}}({{operation_parameters}}){%if operation.const %} const{% endif %}
+QIviPendingReply<{{operation|return_type}}> {{class}}::{{operation}}({{operation_parameters}}){%if operation.const %} const{% endif %}
{
{% for operation_parameter in operation.parameters %}
@@ -254,7 +254,11 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameter_type }})
{% endif %}
qWarning() << "Not implemented!";
- return {{operation|default_value}};
+
+ //Fake that the reply always succeeded
+ QIviPendingReply<{{operation|return_type}}> successReply;
+ successReply.setSuccess({{operation|default_value}});
+ return successReply;
}
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl b/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl
index 125af5a..4503e6a 100644
--- a/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl
+++ b/src/tools/ivigenerator/templates_backend_simulator/backend.h.tpl
@@ -85,12 +85,12 @@ public Q_SLOTS:
{% for operation in interface.operations %}
{% if interface_zoned %}
{% if operation.parameters|length %}
- virtual {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}, const QString &zone){%if operation.const %} const{% endif %} override;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}, const QString &zone){%if operation.const %} const{% endif %} override;
{% else %}
- virtual {{operation|return_type}} {{operation}}(const QString &zone){%if operation.const %} const{% endif %} override;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}(const QString &zone){%if operation.const %} const{% endif %} override;
{% endif %}
{% else %}
- virtual {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} override;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} override;
{% endif %}
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl b/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl
index 637970e..55874ee 100644
--- a/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl
+++ b/src/tools/ivigenerator/templates_frontend/backendinterface.h.tpl
@@ -55,6 +55,7 @@
{% else %}
#include <QtIviCore/QIviFeatureInterface>
{% endif %}
+#include <QtIviCore/QIviPendingReply>
QT_BEGIN_NAMESPACE
@@ -81,12 +82,12 @@ public:
{% for operation in interface.operations %}
{% if interface.tags.config.zoned %}
{% if operation.parameters|length %}
- virtual {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}, const QString &zone){%if operation.const %} const{% endif %} = 0;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}, const QString &zone){%if operation.const %} const{% endif %} = 0;
{% else %}
- virtual {{operation|return_type}} {{operation}}(const QString &zone){%if operation.const %} const{% endif %} = 0;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}(const QString &zone){%if operation.const %} const{% endif %} = 0;
{% endif %}
{% else %}
- virtual {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} = 0;
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){%if operation.const %} const{% endif %} = 0;
{% endif %}
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl b/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl
index f327da4..8dc6002 100644
--- a/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl
+++ b/src/tools/ivigenerator/templates_frontend/interface.cpp.tpl
@@ -340,7 +340,7 @@ void {{class}}::{{property|setter_name}}({{ property|parameter_type }})
/*!
{{ utils.format_comments(operation.comment) }}
*/
-{{operation|return_type}} {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %}
+QIviPendingReply<{{operation|return_type}}> {{class}}::{{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %}
{
if ({{class}}BackendInterface *backend = ({{class}}BackendInterface *) this->backend())
@@ -353,7 +353,7 @@ void {{class}}::{{property|setter_name}}({{ property|parameter_type }})
{% else %}
return backend->{{operation}}({{operation.parameters|join(', ')}});
{% endif %}
- return {{operation|default_type_value}};
+ return QIviPendingReply<{{operation|return_type}}>::createFailedReply();
}
{% endfor %}
diff --git a/src/tools/ivigenerator/templates_frontend/interface.h.tpl b/src/tools/ivigenerator/templates_frontend/interface.h.tpl
index 4b07044..9786210 100644
--- a/src/tools/ivigenerator/templates_frontend/interface.h.tpl
+++ b/src/tools/ivigenerator/templates_frontend/interface.h.tpl
@@ -55,6 +55,7 @@
{% else %}
#include <QtIviCore/QIviAbstractFeature>
{% endif %}
+#include <QtIviCore/QIviPendingReply>
QT_BEGIN_NAMESPACE
@@ -90,7 +91,7 @@ public:
public Q_SLOTS:
{% for operation in interface.operations %}
- {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %};
+ QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}){% if operation.const %} const{% endif %};
{% endfor %}
{% for property in interface.properties %}
{% if not property.readonly and not property.const %}
diff --git a/src/tools/ivigenerator/templates_frontend/module.cpp.tpl b/src/tools/ivigenerator/templates_frontend/module.cpp.tpl
index 2408691..ef6e112 100644
--- a/src/tools/ivigenerator/templates_frontend/module.cpp.tpl
+++ b/src/tools/ivigenerator/templates_frontend/module.cpp.tpl
@@ -48,6 +48,7 @@
{% for struct in module.structs %}
#include "{{struct|lower}}model.h"
{% endfor %}
+#include <QtIviCore/QIviPendingReply>
#include <QQmlEngine>
#include <QDebug>
#include <QDataStream>
@@ -108,11 +109,14 @@ void {{class}}::registerTypes()
{% for enum in module.enums %}
qRegisterMetaType<{{class}}::{{enum|flag_type}}>();
qRegisterMetaTypeStreamOperators<{{class}}::{{enum|flag_type}}>();
+ qIviRegisterPendingReplyType<{{class}}::{{enum|flag_type}}>();
{% endfor %}
{% for struct in module.structs %}
qRegisterMetaType<{{struct}}>();
qRegisterMetaType<{{struct}}Model*>();
qRegisterMetaTypeStreamOperators<{{struct}}>();
+ qIviRegisterPendingReplyType<{{struct}}>();
+ qIviRegisterPendingReplyType<{{struct}}Model*>();
{% endfor %}
}
diff --git a/src/tools/ivigenerator/templates_test/tst_test.cpp.tpl b/src/tools/ivigenerator/templates_test/tst_test.cpp.tpl
index 106be23..0975017 100644
--- a/src/tools/ivigenerator/templates_test/tst_test.cpp.tpl
+++ b/src/tools/ivigenerator/templates_test/tst_test.cpp.tpl
@@ -139,12 +139,13 @@ public:
{% endfor %}
{% for operation in interface.operations %}
- virtual {{operation|return_type}} {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}{% if interface_zoned %}{%
+ virtual QIviPendingReply<{{operation|return_type}}> {{operation}}({{operation.parameters|map('parameter_type')|join(', ')}}{% if interface_zoned %}{%
if operation.parameters|length %}, {%endif%}const QString &zone{% endif %}) override
{
emit {{operation}}Called({% if operation.parameters|length %}{{operation.parameters|join(', ')}}{% endif %}{%
if interface_zoned %}{%if operation.parameters|length %}, {%endif%} zone{% endif %});
- return {{operation|return_type}}();
+
+ return QIviPendingReply<{{operation|return_type}}>::createFailedReply();
}
Q_SIGNAL void {{operation}}Called({{operation.parameters|map('parameter_type')|join(', ')}}{% if interface_zoned %}{%
@@ -414,8 +415,12 @@ void {{interface}}Test::testMethods()
QSignalSpy {{operation}}Spy(service->testBackend(), SIGNAL({{operation}}Called({{operation.parameters|map('return_type')|join(', ')}}{%if interface_zoned %}{%
if operation.parameters|length %}, {%endif%}QString{% endif %})));
- cc.{{operation}}({% if operation.parameters|length %}{{operation.parameters|map('test_type_value')|join(' ')}}{% endif %});
+ auto {{operation}}Reply = cc.{{operation}}({% if operation.parameters|length %}{{operation.parameters|map('test_type_value')|join(' ')}}{% endif %});
QCOMPARE({{operation}}Spy.count(), 1);
+ QVERIFY({{operation}}Reply.isValid());
+ QVERIFY({{operation}}Reply.isResultAvailable());
+ //To make the generation easier our generated methods always return a failed reply
+ QVERIFY(!{{operation}}Reply.isSuccessful());
{% endfor %}
}
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 34d77cd..7e5fa90 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
@@ -330,21 +330,30 @@ void EchoQtroTest::testSlots()
QSignalSpy echoSpy(&server.m_service, SIGNAL(echoSlotCalled(const QString&)));
QVERIFY(echoSpy.isValid());
QString echoTestValue("this will be echoed");
- QString echoReturnValue = client.echo(echoTestValue);
- QCOMPARE(echoReturnValue, echoTestValue);
+ QIviPendingReply<QString> echoReply = client.echo(echoTestValue);
+ QSignalSpy echoReplySpy(echoReply.watcher(), SIGNAL(replySuccess()));
+ echoReplySpy.wait();
+ QCOMPARE(echoReplySpy.count(), 1);
+ QCOMPARE(echoReply.reply(), echoTestValue);
QCOMPARE(echoSpy.count(),1);
QCOMPARE(echoSpy[0][0].toString(), echoTestValue);
QSignalSpy idSpy(&server.m_service, SIGNAL(idSlotCalled()));
QVERIFY(idSpy.isValid());
- QString idReturnValue = client.id();
- QCOMPARE(idReturnValue, server.m_service.m_testId);
+ QIviPendingReply<QString> idReply = client.id();
+ QSignalSpy idReplySpy(idReply.watcher(), SIGNAL(replySuccess()));
+ idReplySpy.wait();
+ QCOMPARE(idReplySpy.count(), 1);
+ QCOMPARE(idReply.reply(), server.m_service.m_testId);
QCOMPARE(idSpy.count(),1);
QSignalSpy getComboSpy(&server.m_service, SIGNAL(getComboSlotCalled()));
QVERIFY(getComboSpy.isValid());
- Combo comboReturnValue = client.getCombo();
- QCOMPARE(comboReturnValue, server.m_service.m_testCombo);
+ QIviPendingReply<Combo> comboReply = client.getCombo();
+ QSignalSpy comboReplySpy(comboReply.watcher(), SIGNAL(replySuccess()));
+ comboReplySpy.wait();
+ QCOMPARE(comboReplySpy.count(), 1);
+ QCOMPARE(comboReply.reply(), server.m_service.m_testCombo);
QCOMPARE(getComboSpy.count(),1);
QSignalSpy voidSlotSpy(&server.m_service, SIGNAL(voidSlotCalled()));
@@ -362,6 +371,47 @@ void EchoQtroTest::testSlots()
QCOMPARE(voidSlot2Spy[0][0].toInt(), voidSlot2TestValue);
}
+void EchoQtroTest::testMultipleSlotCalls()
+{
+ Server server;
+ server.start();
+
+ Echo client;
+ client.startAutoDiscovery();
+
+
+ //wait until the client has connected and initial values are set
+ QSignalSpy initSpy(&client, SIGNAL(isInitializedChanged(bool)));
+ QVERIFY(initSpy.isValid());
+ initSpy.wait(1000);
+ QCOMPARE(initSpy.count(), 1);
+ QVERIFY(client.isInitialized());
+
+ //test the pending replies by calling the same slot with 3 different values
+ QSignalSpy echoSpy(&server.m_service, SIGNAL(echoSlotCalled(const QString&)));
+ QVERIFY(echoSpy.isValid());
+ QString echoTestValue("first");
+ QString echoTestValue2("second");
+ QString echoTestValue3("third");
+ QIviPendingReply<QString> echoReply = client.echo(echoTestValue);
+ QIviPendingReply<QString> echoReply2 = client.echo(echoTestValue2);
+ QIviPendingReply<QString> echoReply3 = client.echo(echoTestValue3);
+ QSignalSpy echoReplySpy(echoReply.watcher(), SIGNAL(replySuccess()));
+ QSignalSpy echoReplySpy2(echoReply2.watcher(), SIGNAL(replySuccess()));
+ QSignalSpy echoReplySpy3(echoReply3.watcher(), SIGNAL(replySuccess()));
+ echoReplySpy3.wait();
+ QCOMPARE(echoReplySpy.count(), 1);
+ QCOMPARE(echoReplySpy2.count(), 1);
+ QCOMPARE(echoReplySpy3.count(), 1);
+ QCOMPARE(echoReply.reply(), echoTestValue);
+ QCOMPARE(echoReply2.reply(), echoTestValue2);
+ QCOMPARE(echoReply3.reply(), echoTestValue3);
+ QCOMPARE(echoSpy.count(),3);
+ QCOMPARE(echoSpy[0][0].toString(), echoTestValue);
+ QCOMPARE(echoSpy[1][0].toString(), echoTestValue2);
+ QCOMPARE(echoSpy[2][0].toString(), echoTestValue3);
+}
+
void EchoQtroTest::testSignals()
{
Server server;
diff --git a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h
index 263afc1..e2e4856 100644
--- a/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h
+++ b/tests/auto/core/ivigenerator/projects/org-example-echo-qtro/server_qtro_test/tst_echoqtro.h
@@ -46,6 +46,7 @@ private slots:
void testClient2Server();
void testServer2Client();
void testSlots();
+ void testMultipleSlotCalls();
void testSignals();
};