diff options
author | Jan Arne Petersen <jpetersen@openismus.com> | 2012-03-23 13:58:04 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-14 01:02:06 +0200 |
commit | a386194f9952683c0be5028f2b7f0ce9617fe404 (patch) | |
tree | 4ca5fe5802000566450f5eff7ed6784067b9804f /tests | |
parent | 019bb22ff1f340a9b14d4f93898c6cda376ee1a0 (diff) |
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: 24921
Change-Id: I4341e8d48d464f3fe0a314a6ab14f848545d65a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index f99220ea1a..9b998eb95d 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/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() |