summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Arne Petersen <jpetersen@openismus.com>2012-10-15 10:30:55 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-31 23:55:00 (GMT)
commit9b4bd98744623f81b7b0950e207209f0c19adb46 (patch)
tree9078f55d9a95e13214beb5ff0aae9fddfe78d4b5 /tests
parent7c60bee5678aaf5ca2141de65d173a4704bb259e (diff)
downloadQt-9b4bd98744623f81b7b0950e207209f0c19adb46.zip
Qt-9b4bd98744623f81b7b0950e207209f0c19adb46.tar.gz
Qt-9b4bd98744623f81b7b0950e207209f0c19adb46.tar.bz2
Fix QDBusServer with more than one connection
Create a new QDBusConnectionPrivate for every new connection in qDBusNewConnection instead of creating a single QDBusConnectionPrivate in the QDBusServer constructor which gets assigned the latest connected DBusConnection in qDBusNewConnection (and loses track on all previous DBusConnections). Also extend tst_QDBusConnection::registerObjectPeer() test with multiple connections to the server. Task-Number: QTBUG-24921 Change-Id: I4341e8d48d464f3fe0a314a6ab14f848545d65a0 (cherry picked from qtbase/a386194f9952683c0be5028f2b7f0ce9617fe404) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdbusconnection/tst_qdbusconnection.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp
index ae7affa..9436e16 100644
--- a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp
+++ b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp
@@ -391,38 +391,51 @@ class MyServer : public QDBusServer
public:
MyServer(QString path, QString addr, QObject* parent) : QDBusServer(addr, parent),
m_path(path),
- m_conn("none")
+ m_connections()
{
connect(this, SIGNAL(newConnection(const QDBusConnection&)), SLOT(handleConnection(const QDBusConnection&)));
}
- bool registerObject()
+ bool registerObject(const QDBusConnection& c)
{
- if( !m_conn.registerObject(m_path, &m_obj, QDBusConnection::ExportAllSlots) )
+ QDBusConnection conn(c);
+ if (!conn.registerObject(m_path, &m_obj, QDBusConnection::ExportAllSlots))
return false;
- if(! (m_conn.objectRegisteredAt(m_path) == &m_obj))
+ if (!(conn.objectRegisteredAt(m_path) == &m_obj))
return false;
return true;
}
+ bool registerObject()
+ {
+ Q_FOREACH (const QString &name, m_connections) {
+ if (!registerObject(QDBusConnection(name)))
+ return false;
+ }
+ return true;
+ }
+
void unregisterObject()
{
- m_conn.unregisterObject(m_path);
+ Q_FOREACH (const QString &name, m_connections) {
+ QDBusConnection c(name);
+ c.unregisterObject(m_path);
+ }
}
public slots:
void handleConnection(const QDBusConnection& c)
{
- m_conn = c;
+ m_connections << c.name();
QVERIFY(isConnected());
- QVERIFY(m_conn.isConnected());
- QVERIFY(registerObject());
+ QVERIFY(c.isConnected());
+ QVERIFY(registerObject(c));
}
private:
MyObject m_obj;
QString m_path;
- QDBusConnection m_conn;
+ QStringList m_connections;
};
@@ -443,6 +456,8 @@ void tst_QDBusConnection::registerObjectPeer()
MyServer server(path, "unix:tmpdir=/tmp", 0);
+ QDBusConnection::connectToPeer(server.address(), "beforeFoo");
+
{
QDBusConnection con = QDBusConnection::connectToPeer(server.address(), "foo");
@@ -454,6 +469,8 @@ void tst_QDBusConnection::registerObjectPeer()
QCOMPARE(obj.path, path);
}
+ QDBusConnection::connectToPeer(server.address(), "afterFoo");
+
{
QDBusConnection con("foo");
QVERIFY(con.isConnected());
@@ -483,6 +500,9 @@ void tst_QDBusConnection::registerObjectPeer()
QVERIFY(!con.isConnected());
QVERIFY(!callMethodPeer(con, path));
}
+
+ QDBusConnection::disconnectFromPeer("beforeFoo");
+ QDBusConnection::disconnectFromPeer("afterFoo");
}
void tst_QDBusConnection::registerObject2()