diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2013-07-25 15:35:23 +0200 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2013-07-25 15:35:23 +0200 |
commit | e082220c260414ef2fd9646b2070587f8f09cb80 (patch) | |
tree | 18fb878f5251460cd408700b0019519d9b49ddee | |
parent | bc681a770e1846ef0ae7cbd3f514f5164d9de203 (diff) |
phoenix-test: send a message to the contact if we don't have caps for Calls
-rwxr-xr-x | src/phoenix-test.py | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/src/phoenix-test.py b/src/phoenix-test.py index c821bda..f04c691 100755 --- a/src/phoenix-test.py +++ b/src/phoenix-test.py @@ -13,6 +13,8 @@ from util import setup_run_dir, create_account, scrub_env from gi.repository import GObject, Gio, GLib from gi.repository import TelepathyGLib as Tp +MESSAGE = "Test from TpRing" + class TestCase: def __init__ (self, loop, test_contact, quiet = False): self.loop = loop @@ -138,6 +140,14 @@ class TestConnection: reason.actor) self.t.done() + def message_sent(self, channel, message, flags, token, data): + message, flags = message.to_text() + + self.t.assertEqual(MESSAGE, message) + + self.channel.close_async(None, None) + self.t.done() + def create_channel_finished (self, req, r, u): try: self.channel = channel = req.create_and_observe_channel_finish (r) @@ -146,27 +156,45 @@ class TestConnection: print e.message self.t.done(False) - d = Gio.bus_get_sync (Gio.BusType.SESSION, None) - self.proxy = proxy = Gio.DBusProxy.new_sync (d, 0, None, - "org.freedesktop.Telepathy.Phoenix.Calls", - "/org/freedesktop/Telepathy/Phoenix/Calls" + - channel.get_object_path(), - "org.freedesktop.Telepathy.Phoenix.CallInfo", - None) - proxy.connect ("g-properties-changed", - self.check_call_status, None) - channel.connect ("notify::state", - self.check_call_status, None) + if isinstance(self.channel, Tp.CallChannel): + d = Gio.bus_get_sync (Gio.BusType.SESSION, None) + self.proxy = proxy = Gio.DBusProxy.new_sync (d, 0, None, + "org.freedesktop.Telepathy.Phoenix.Calls", + "/org/freedesktop/Telepathy/Phoenix/Calls" + + channel.get_object_path(), + "org.freedesktop.Telepathy.Phoenix.CallInfo", + None) + proxy.connect ("g-properties-changed", + self.check_call_status, None) + channel.connect ("notify::state", + self.check_call_status, None) + elif isinstance(self.channel, Tp.TextChannel): + channel.connect ("message-sent", + self.message_sent, None) + + m = Tp.ClientMessage.new_text (Tp.ChannelTextMessageType.NORMAL, MESSAGE) + self.channel.send_message_async (m, 0, None, None) + else: + print "unknown channel type created:", self.channel + self.t.done(Fail) def handle_capabilities (self): - if self.contact.get_capabilities().supports_audio_video_call ( - Tp.HandleType.CONTACT): - a = self.contact.get_account() - req = Tp.AccountChannelRequest.new_audio_video_call (a, 0) - req.set_target_contact (self.contact) - req.set_hint ("call-mode", GLib.Variant('s', "test-inputs")) - req.create_and_observe_channel_async ( "", None, - self.create_channel_finished, None) + caps = self.contact.get_capabilities() + account = self.contact.get_account() + + if caps.supports_audio_video_call (Tp.HandleType.CONTACT): + req = Tp.AccountChannelRequest.new_audio_video_call (account, 0) + req.set_hint ("call-mode", GLib.Variant('s', "test-inputs")) + elif caps.supports_text_chats (): + req = Tp.AccountChannelRequest.new_text (account, 0) + else: + print "no caps for call or text chat" + self.t.done(False) + return + + req.set_target_contact (self.contact) + req.create_and_observe_channel_async ("", None, + self.create_channel_finished, None) def handle_test_contact_states (self): p = self.contact.get_publish_state () |