[Telepathy-commits] [telepathy-gabble/master] Fix checking the absence of signal

Alban Crequy alban.crequy at collabora.co.uk
Tue Aug 19 10:52:45 PDT 2008


20080521154459-a41c0-f991a07ec11cccc2643f0a79737e6c1bd5eb8bf2.gz
---
 tests/twisted/test-caps-hash.py |   52 ++++++++++++++++++---------------------
 1 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/tests/twisted/test-caps-hash.py b/tests/twisted/test-caps-hash.py
index 44d03fb..c7eb1ff 100644
--- a/tests/twisted/test-caps-hash.py
+++ b/tests/twisted/test-caps-hash.py
@@ -26,9 +26,12 @@ import sys
 from twisted.words.xish import domish, xpath
 
 from gabbletest import exec_test, make_result_iq
+from servicetest import call_async
 
+gabble_service = 'org.freedesktop.Telepathy.ConnectionManager.gabble'
 text = 'org.freedesktop.Telepathy.Channel.Type.Text'
 sm = 'org.freedesktop.Telepathy.Channel.Type.StreamedMedia'
+conn_iface = 'org.freedesktop.Telepathy.Connection'
 caps_iface = 'org.freedesktop.Telepathy.Connection.Interface.Capabilities'
 
 caps_changed_flag = 0
@@ -61,6 +64,12 @@ def presence_add_caps(presence, ver, client, hash=None):
         c['hash'] = hash
     return presence
 
+def dbus_sync(bus, q, conn):
+    # Dummy D-Bus method call
+    call_async(q, conn, "InspectHandles", 1, [])
+
+    event = q.expect('dbus-return', method='InspectHandles')
+
 def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     global caps_changed_flag
 
@@ -124,10 +133,8 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     feature['var'] = 'http://jabber.org/protocol/bogus-feature'
     stream.send(result)
 
-    # Dummy synchronous D-Bus method call
-    assert conn.InspectHandles(1, []) == []
-
     # don't receive any D-Bus signal
+    dbus_sync(bus, q, conn)
     assert caps_changed_flag == 0
 
     # send presence with empty caps
@@ -142,10 +149,8 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     assert query_node.attributes['node'] == \
         client + '#' + '0.0'
 
-    # Dummy synchronous D-Bus method call
-    assert conn.InspectHandles(1, []) == []
-
     # still don't receive any D-Bus signal
+    dbus_sync(bus, q, conn)
     assert caps_changed_flag == 0
 
     # send good reply
@@ -166,10 +171,6 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     c['hash'] = 'sha-1'
     stream.send(presence)
 
-    # Dummy synchronous D-Bus method call
-    assert conn.InspectHandles(1, []) == []
-    assert caps_changed_flag == 0
-
     # Gabble looks up our capabilities
     event = q.expect('stream-iq', to=contact,
         query_ns='http://jabber.org/protocol/disco#info')
@@ -177,6 +178,10 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     assert query_node.attributes['node'] == \
         client + '#' + c['ver']
 
+    # don't receive any D-Bus signal
+    dbus_sync(bus, q, conn)
+    assert caps_changed_flag == 0
+
     # send good reply
     result = make_result_iq(stream, event.stanza)
     query = result.firstChildElement()
@@ -209,9 +214,6 @@ def test_hash(q, bus, conn, stream, contact, contact_handle, client):
     """)
     stream.send(result)
 
-    # Dummy synchronous D-Bus method call
-    assert conn.InspectHandles(1, []) == []
-
     # we can now do audio calls
     event = q.expect('dbus-signal', signal='CapabilitiesChanged')
     assert caps_changed_flag == 1
@@ -250,12 +252,6 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
             hash='sha-1')
     stream.send(presence)
 
-    # Dummy synchronous D-Bus method call
-    assert conn.InspectHandles(1, []) == []
-
-    # don't receive any D-Bus signal
-    assert caps_changed_flag == 0
-
     # Gabble looks up our capabilities
     event = q.expect('stream-iq', to=contact1,
         query_ns='http://jabber.org/protocol/disco#info')
@@ -263,6 +259,10 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
     assert query_node.attributes['node'] == \
         client + '#' + ver
 
+    # don't receive any D-Bus signal
+    dbus_sync(bus, q, conn)
+    assert caps_changed_flag == 0
+
     # send good reply
     result = make_result_iq(stream, event.stanza)
     query = result.firstChildElement()
@@ -279,12 +279,6 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
     stream.send(result)
 
     if broken_hash:
-        # Dummy synchronous D-Bus method call
-        assert conn.InspectHandles(1, []) == []
-
-        # don't receive any D-Bus signal
-        assert caps_changed_flag == 0
-        
         # Gabble looks up our capabilities again because the first contact
         # failed to provide a valid hash
         event = q.expect('stream-iq', to=contact2,
@@ -293,6 +287,10 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
         assert query_node.attributes['node'] == \
             client + '#' + ver
 
+        # don't receive any D-Bus signal
+        dbus_sync(bus, q, conn)
+        assert caps_changed_flag == 0
+
         # send good reply
         result = make_result_iq(stream, event.stanza)
         query = result.firstChildElement()
@@ -315,10 +313,8 @@ def test_two_clients(q, bus, conn, stream, contact1, contact2,
 
     caps_changed_flag = 0
 
-    # Dummy synchronous D-Bus method call
-    assert conn.InspectHandles(1, []) == []
-
     # don't receive any D-Bus signal
+    dbus_sync(bus, q, conn)
     assert caps_changed_flag == 0
 
 def test(q, bus, conn, stream):
-- 
1.5.6.3




More information about the Telepathy-commits mailing list