summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2021-12-07 19:02:41 +0200
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-01-20 12:42:46 +0000
commit212c3c4f122ea921336137c7987a9c866c5cc347 (patch)
treeb0b98f5edb468e7569c0d7bbe5042524efcc829d /tests
parent766cd66f40f494642a1f83646299920e118eac4b (diff)
RemoteObject: Fix warning on calling QLocalSocket::waitForDisconnected()
Change-Id: I1d5fdfedaee35c530b383951e6fc69b75bd67d64 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/clientserver/tst_clientserver.cpp47
-rw-r--r--tests/auto/installer/shared/packagemanager.h13
2 files changed, 57 insertions, 3 deletions
diff --git a/tests/auto/installer/clientserver/tst_clientserver.cpp b/tests/auto/installer/clientserver/tst_clientserver.cpp
index 7b9971056..bcd87815d 100644
--- a/tests/auto/installer/clientserver/tst_clientserver.cpp
+++ b/tests/auto/installer/clientserver/tst_clientserver.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -27,6 +27,7 @@
**************************************************************************/
#include "../shared/verifyinstaller.h"
+#include "../shared/packagemanager.h"
#include <protocol.h>
#include <qprocesswrapper.h>
@@ -51,6 +52,17 @@
using namespace QInstaller;
+class MyRemoteObject : public RemoteObject
+{
+public:
+ MyRemoteObject()
+ : RemoteObject(QLatin1String("MyRemoteObject")) {};
+
+ ~MyRemoteObject() = default;
+
+ bool connectToServer() { return RemoteObject::connectToServer(); }
+};
+
class tst_ClientServer : public QObject
{
Q_OBJECT
@@ -78,7 +90,7 @@ private:
}
private slots:
- void initTestCase()
+ void init()
{
RemoteClient::instance().setActive(true);
}
@@ -269,6 +281,37 @@ private slots:
}
}
+ void testCreateDestroyRemoteObject()
+ {
+ RemoteServer server;
+ QString socketName = QUuid::createUuid().toString();
+ server.init(socketName, QLatin1String("SomeKey"), Protocol::Mode::Production);
+ server.start();
+
+ RemoteClient::instance().init(socketName, QLatin1String("SomeKey"), Protocol::Mode::Debug,
+ Protocol::StartAs::User);
+
+ // Look for warnings on connection and disconnection..
+ qInstallMessageHandler(exitOnWarningMessageHandler);
+
+ MyRemoteObject *object = new MyRemoteObject;
+ QVERIFY(!object->isConnectedToServer());
+ delete object;
+
+ object = new MyRemoteObject;
+ QVERIFY(object->connectToServer());
+ QVERIFY(object->isConnectedToServer());
+ delete object;
+
+ object = new MyRemoteObject;
+ QVERIFY(object->connectToServer());
+ QVERIFY(object->isConnectedToServer());
+
+ RemoteClient::instance().setActive(false);
+ QVERIFY(!object->isConnectedToServer());
+ delete object;
+ }
+
void testQSettingsWrapper()
{
RemoteServer server;
diff --git a/tests/auto/installer/shared/packagemanager.h b/tests/auto/installer/shared/packagemanager.h
index c4d86cf32..a95dd4442 100644
--- a/tests/auto/installer/shared/packagemanager.h
+++ b/tests/auto/installer/shared/packagemanager.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -35,12 +35,23 @@
#include <fileutils.h>
#include <settings.h>
#include <init.h>
+#include <errors.h>
#include <QTest>
using namespace QInstaller;
void silentTestMessageHandler(QtMsgType, const QMessageLogContext &, const QString &) {}
+void exitOnWarningMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ const QByteArray localMsg = msg.toLocal8Bit();
+ const char *file = context.file ? context.file : "";
+ const char *function = context.function ? context.function : "";
+ if (!(type == QtDebugMsg) && !(type == QtInfoMsg)) {
+ fprintf(stderr, "Caught message: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
+ exit(1);
+ }
+}
struct PackageManager
{