blob: d19f81b27111030b021ce9fce6d3ab587b13ab9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (C) 2017 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "rep_server_source.h"
#include <QCoreApplication>
#include <QtTest/QtTest>
class MyTestServer : public TestClassSimpleSource
{
Q_OBJECT
public:
bool shouldQuit = false;
// TestClassSimpleSource interface
public slots:
bool slot1() override {return true;}
QString slot2() override {return QLatin1String("Hello there");}
void ping(const QString &message) override
{
emit pong(message);
}
bool quit() override
{
qDebug() << "quit() called";
return shouldQuit = true;
}
};
class tst_Server_Process : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testRun()
{
QRemoteObjectHost srcNode(QUrl(QStringLiteral("tcp://127.0.0.1:65214")));
MyTestServer myTestServer{};
TestChildClassSimpleSource child;
myTestServer.setChildProp(&child);
srcNode.enableRemoting(&myTestServer);
qDebug() << "Waiting for incoming connections";
QTRY_VERIFY_WITH_TIMEOUT(myTestServer.shouldQuit, 20000); // wait up to 20s
qDebug() << "Stopping server";
QTest::qWait(200); // wait for server to send reply to client invoking quit() function
}
};
QTEST_MAIN(tst_Server_Process)
#include "main.moc"
|