[Telepathy-commits] [telepathy-qt4/master] text-chan: workaround: don't assert that the Connection is ready when it should be

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Feb 20 06:08:03 PST 2009


We should be able to revert this after Andre's Connection refactoring is
reviewed.
---
 tests/dbus/text-chan.cpp |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/tests/dbus/text-chan.cpp b/tests/dbus/text-chan.cpp
index 3081dd7..0ef4515 100644
--- a/tests/dbus/text-chan.cpp
+++ b/tests/dbus/text-chan.cpp
@@ -51,6 +51,7 @@ protected:
 protected Q_SLOTS:
     void onMessageSent(const Telepathy::Client::Message &,
             Telepathy::MessageSendingFlags, const QString &);
+    void expectConnReady(uint, uint);
 
 private Q_SLOTS:
     void initTestCase();
@@ -85,6 +86,29 @@ void TestTextChan::onMessageSent(const Telepathy::Client::Message &message,
     sent << SentMessageDetails(message, flags, token);
 }
 
+void TestTextChan::expectConnReady(uint newStatus, uint newStatusReason)
+{
+    qDebug() << "connection changed to status" << newStatus;
+    switch (newStatus) {
+    case Connection::StatusDisconnected:
+        qWarning() << "Disconnected";
+        mLoop->exit(1);
+        break;
+    case Connection::StatusConnecting:
+        /* do nothing */
+        break;
+    case Connection::StatusConnected:
+        qDebug() << "Ready";
+        mLoop->exit(0);
+        break;
+    default:
+        qWarning().nospace() << "What sort of status is "
+            << newStatus << "?!";
+        mLoop->exit(2);
+        break;
+    }
+}
+
 void TestTextChan::sendText(const char *text)
 {
     // FIXME: there's no high-level API for Send() yet, so...
@@ -144,8 +168,23 @@ void TestTextChan::initTestCase()
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
     QCOMPARE(mLoop->exec(), 0);
     QCOMPARE(mConn->isReady(), true);
+#if 0
+    // should be able to do this, when Connection is no longer broken
     QCOMPARE(static_cast<uint>(mConn->status()),
             static_cast<uint>(Connection::StatusConnected));
+#else
+    if (mConn->status() != Connection::StatusConnected) {
+        QVERIFY(connect(mConn,
+                        SIGNAL(statusChanged(uint, uint)),
+                        SLOT(expectConnReady(uint, uint))));
+        QCOMPARE(mLoop->exec(), 0);
+        QVERIFY(disconnect(mConn,
+                           SIGNAL(statusChanged(uint, uint)),
+                           this,
+                           SLOT(expectConnReady(uint, uint))));
+        QCOMPARE(mConn->status(), (uint) Connection::StatusConnected);
+    }
+#endif
 
     // create a Channel by magic, rather than doing D-Bus round-trips for it
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list