summaryrefslogtreecommitdiff
path: root/tests
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 /tests
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>
Diffstat (limited to 'tests')
-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
2 files changed, 57 insertions, 6 deletions
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();
};