summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-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
{