telepathy-qt: dbus-tubes: Expand testAcceptTwice into a full fledged corner cases test

Dario Freddi drf at kemper.freedesktop.org
Tue Jul 3 15:08:50 PDT 2012


Module: telepathy-qt
Branch: master
Commit: 5bf3b0637dea687bf282619d808d33e2347f4815
URL:    http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=5bf3b0637dea687bf282619d808d33e2347f4815

Author: Dario Freddi <dario.freddi at collabora.com>
Date:   Fri Nov 11 00:40:20 2011 +0100

dbus-tubes: Expand testAcceptTwice into a full fledged corner cases test

---

 tests/dbus/dbus-tube-chan.cpp |   81 ++++++++++++++++++++++++++---------------
 1 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/tests/dbus/dbus-tube-chan.cpp b/tests/dbus/dbus-tube-chan.cpp
index a75500d..00f586b 100644
--- a/tests/dbus/dbus-tube-chan.cpp
+++ b/tests/dbus/dbus-tube-chan.cpp
@@ -70,12 +70,12 @@ private Q_SLOTS:
     void init();
 
     void testCreation();
-    void testAcceptTwice();
     void testAcceptSuccess();
     void testAcceptFail();
     void testOfferSuccess();
     void testOutgoingBusNameMonitoring();
     void testExtractBusNameMonitoring();
+    void testAcceptCornerCases();
     void testOfferCornerCases();
 
     void cleanup();
@@ -295,35 +295,6 @@ void TestDBusTubeChan::testCreation()
     QCOMPARE(mChan->address(), QString());
 }
 
-void TestDBusTubeChan::testAcceptTwice()
-{
-    /* incoming tube */
-    createTubeChannel(false, TP_SOCKET_ADDRESS_TYPE_UNIX,
-            TP_SOCKET_ACCESS_CONTROL_LOCALHOST, false);
-    QVERIFY(connect(mChan->becomeReady(IncomingDBusTubeChannel::FeatureCore |
-                        DBusTubeChannel::FeatureBusNameMonitoring),
-                SIGNAL(finished(Tp::PendingOperation *)),
-                SLOT(expectSuccessfulCall(Tp::PendingOperation *))));
-    QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(mChan->isReady(IncomingDBusTubeChannel::FeatureCore), true);
-    QCOMPARE(mChan->isReady(DBusTubeChannel::FeatureBusNameMonitoring), true);
-    QCOMPARE(mChan->state(), TubeChannelStateLocalPending);
-
-    IncomingDBusTubeChannelPtr chan = IncomingDBusTubeChannelPtr::qObjectCast(mChan);
-    QVERIFY(connect(chan->acceptTube(),
-                SIGNAL(finished(Tp::PendingOperation *)),
-                SLOT(expectSuccessfulCall(Tp::PendingOperation *))));
-    QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(mChan->state(), TubeChannelStateOpen);
-
-    /* try to re-accept the tube */
-    QVERIFY(connect(chan->acceptTube(),
-                SIGNAL(finished(Tp::PendingOperation *)),
-                SLOT(expectFailure(Tp::PendingOperation *))));
-    QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(mChan->state(), TubeChannelStateOpen);
-}
-
 void TestDBusTubeChan::testAcceptSuccess()
 {
     /* incoming tube */
@@ -650,6 +621,56 @@ void TestDBusTubeChan::testExtractBusNameMonitoring()
     QVERIFY(!mGotRemoteConnection);
 }
 
+void TestDBusTubeChan::testAcceptCornerCases()
+{
+    /* incoming tube */
+    createTubeChannel(false, TP_SOCKET_ADDRESS_TYPE_UNIX,
+            TP_SOCKET_ACCESS_CONTROL_LOCALHOST, false);
+
+    // These should not be ready yet
+    QCOMPARE(mChan->serviceName(), QString());
+    QCOMPARE(mChan->supportsCredentials(), false);
+    QCOMPARE(mChan->state(), TubeChannelStateNotOffered);
+    QCOMPARE(mChan->parameters(), QVariantMap());
+
+    IncomingDBusTubeChannelPtr chan = IncomingDBusTubeChannelPtr::qObjectCast(mChan);
+
+    // Fail as features are not ready
+    QVERIFY(connect(chan->acceptTube(), // DISCARD
+                SIGNAL(finished(Tp::PendingOperation *)),
+                SLOT(expectFailure(Tp::PendingOperation*))));
+    QCOMPARE(mLoop->exec(), 0);
+
+    // Become ready
+    QVERIFY(connect(mChan->becomeReady(IncomingDBusTubeChannel::FeatureCore),
+                SIGNAL(finished(Tp::PendingOperation *)),
+                SLOT(expectSuccessfulCall(Tp::PendingOperation *))));
+    QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(mChan->isReady(IncomingDBusTubeChannel::FeatureCore), true);
+    QCOMPARE(mChan->isReady(DBusTubeChannel::FeatureBusNameMonitoring), false);
+    QCOMPARE(mChan->state(), TubeChannelStateLocalPending);
+
+    // Offer using unsupported method
+    QVERIFY(connect(chan->acceptTube(true), // DISCARD
+                SIGNAL(finished(Tp::PendingOperation *)),
+                SLOT(expectFailure(Tp::PendingOperation*))));
+    QCOMPARE(mLoop->exec(), 0);
+
+    // Accept successfully
+    QVERIFY(connect(chan->acceptTube(),
+                SIGNAL(finished(Tp::PendingOperation *)),
+                SLOT(expectSuccessfulCall(Tp::PendingOperation *))));
+    QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(mChan->state(), TubeChannelStateOpen);
+
+    /* try to re-accept the tube */
+    QVERIFY(connect(chan->acceptTube(),
+                SIGNAL(finished(Tp::PendingOperation *)),
+                SLOT(expectFailure(Tp::PendingOperation *))));
+    QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(mChan->state(), TubeChannelStateOpen);
+}
+
 void TestDBusTubeChan::testOfferCornerCases()
 {
     mCurrentContext = 0; // should point to room, localhost



More information about the telepathy-commits mailing list