summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Freddi <dario.freddi@collabora.com>2011-11-11 00:31:58 +0100
committerDario Freddi <dario.freddi@collabora.com>2012-07-03 11:11:22 +0200
commit3e873121045aeb3cc53eab3391d6aa0bbfc8b922 (patch)
tree468f47530b00dbb5b1e84e333ae2edf0b394f92c
parent5e32aa281dbe52f84b4a763ec664d74b599aa207 (diff)
dbus-tubes: Test the late activation of BusNamesMonitoring
-rw-r--r--tests/dbus/dbus-tube-chan.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/dbus/dbus-tube-chan.cpp b/tests/dbus/dbus-tube-chan.cpp
index a150eb3d..80b63e5a 100644
--- a/tests/dbus/dbus-tube-chan.cpp
+++ b/tests/dbus/dbus-tube-chan.cpp
@@ -75,6 +75,7 @@ private Q_SLOTS:
void testAcceptFail();
void testOfferSuccess();
void testOutgoingBusNameMonitoring();
+ void testExtractBusNameMonitoring();
void cleanup();
void cleanupTestCase();
@@ -584,6 +585,70 @@ void TestDBusTubeChan::testOutgoingBusNameMonitoring()
QCOMPARE(mChan->busNames().size(), 0);
}
+void TestDBusTubeChan::testExtractBusNameMonitoring()
+{
+ mCurrentContext = 0; // should point to room, localhost
+ createTubeChannel(true, TP_SOCKET_ADDRESS_TYPE_UNIX, TP_SOCKET_ACCESS_CONTROL_LOCALHOST, false);
+ QVERIFY(connect(mChan->becomeReady(OutgoingDBusTubeChannel::FeatureCore),
+ SIGNAL(finished(Tp::PendingOperation *)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation *))));
+ QCOMPARE(mLoop->exec(), 0);
+
+ QVERIFY(connect(mChan.data(),
+ SIGNAL(busNamesChanged(QHash<ContactPtr,QString>,QList<ContactPtr>)),
+ SLOT(onBusNamesChanged(QHash<ContactPtr,QString>,QList<ContactPtr>))));
+
+ OutgoingDBusTubeChannelPtr chan = OutgoingDBusTubeChannelPtr::qObjectCast(mChan);
+ QVERIFY(connect(chan->offerTube(QVariantMap()), // DISCARD
+ SIGNAL(finished(Tp::PendingOperation *)),
+ SLOT(onOfferFinished(Tp::PendingOperation *))));
+
+ while (mChan->state() != TubeChannelStateRemotePending) {
+ mLoop->processEvents();
+ }
+
+ // Simulate a peer connection from someone
+ TpHandleRepoIface *contactRepo = tp_base_connection_get_handles(
+ TP_BASE_CONNECTION(mConn->service()), TP_HANDLE_TYPE_CONTACT);
+ TpHandle handle = tp_handle_ensure(contactRepo, "YouHaventSeenMeYet", NULL, NULL);
+ gchar *service = g_strdup("org.not.seen.yet");
+
+ mExpectedHandle = handle;
+ mExpectedService = QLatin1String("org.not.seen.yet");
+
+ tp_tests_dbus_tube_channel_peer_connected_no_stream(mChanService,
+ service, handle);
+
+ while (mChan->state() != TubeChannelStateOpen) {
+ mLoop->processEvents();
+ }
+
+ // Test that we didn't get a remote connection
+ while (!mOfferFinished) {
+ QCOMPARE(mLoop->exec(), 0);
+ }
+
+ QVERIFY(!mGotConnectionClosed);
+ QVERIFY(!mGotRemoteConnection);
+
+ // This should also trigger a warning
+ QCOMPARE(mChan->busNames().size(), 0);
+
+ // Now, enable the feature, and let it extract participants
+ QVERIFY(connect(mChan->becomeReady(OutgoingDBusTubeChannel::FeatureBusNameMonitoring),
+ SIGNAL(finished(Tp::PendingOperation *)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation *))));
+ QCOMPARE(mLoop->exec(), 0);
+
+ // This should now be fine
+ QCOMPARE(mChan->busNames().size(), 1);
+ // The name should match
+ QCOMPARE(mChan->busNames().value(mChan->busNames().keys().first()), QLatin1String("org.not.seen.yet"));
+ // And the signal shouldn't have been called
+ QVERIFY(!mGotConnectionClosed);
+ QVERIFY(!mGotRemoteConnection);
+}
+
void TestDBusTubeChan::cleanup()
{
cleanupImpl();