[telepathy-mission-control/telepathy-mission-control-5.2] mctest: simulate SimplePresence more accurately
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Sep 3 11:04:08 PDT 2009
---
test/twisted/mctest.py | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/test/twisted/mctest.py b/test/twisted/mctest.py
index 27afd11..55e377b 100644
--- a/test/twisted/mctest.py
+++ b/test/twisted/mctest.py
@@ -325,12 +325,16 @@ class SimulatedConnection(object):
presence = dbus.Struct((self.statuses[e.args[0]][0],
e.args[0], e.args[1]), signature='uss')
- if presence != self.presence:
+ old_presence = self.presence
+
+ if presence != old_presence:
self.presence = presence
- self.q.dbus_emit(self.object_path,
- cs.CONN_IFACE_SIMPLE_PRESENCE, 'PresencesChanged',
- { self.self_handle : presence },
- signature='a{u(uss)}')
+
+ if self.status == cs.CONN_STATUS_CONNECTED:
+ self.q.dbus_emit(self.object_path,
+ cs.CONN_IFACE_SIMPLE_PRESENCE, 'PresencesChanged',
+ { self.self_handle : presence },
+ signature='a{u(uss)}')
self.q.dbus_return(e.message, signature='')
else:
@@ -396,6 +400,15 @@ class SimulatedConnection(object):
self.reason = reason
self.q.dbus_emit(self.object_path, cs.CONN, 'StatusChanged',
status, reason, signature='uu')
+ if self.status == cs.CONN_STATUS_CONNECTED and self.has_presence:
+ if self.presence[0] == cs.PRESENCE_TYPE_OFFLINE:
+ self.presence = dbus.Struct((cs.PRESENCE_TYPE_AVAILABLE,
+ 'available', ''), signature='uss')
+
+ self.q.dbus_emit(self.object_path,
+ cs.CONN_IFACE_SIMPLE_PRESENCE, 'PresencesChanged',
+ { self.self_handle : self.presence },
+ signature='a{u(uss)}')
def ListChannels(self, e):
arr = dbus.Array(signature='(osuu)')
@@ -773,8 +786,6 @@ def enable_fakecm_account(q, bus, mc, account, expected_params,
q.expect('dbus-method-call', method='Connect',
path=conn.object_path, handled=True)
conn.StatusChanged(cs.CONN_STATUS_CONNECTED, cs.CONN_STATUS_REASON_NONE)
- conn.presence = dbus.Struct((cs.PRESENCE_TYPE_AVAILABLE, 'available', ''),
- signature='uss')
expect_after_connect = list(expect_after_connect)
--
1.5.6.5
More information about the telepathy-commits
mailing list