[telepathy-gabble/master] Test calling SessionHandler methods early
Will Thompson
will.thompson at collabora.co.uk
Mon May 11 09:53:30 PDT 2009
---
tests/twisted/Makefile.am | 1 +
tests/twisted/jingle/misuse.py | 49 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/jingle/misuse.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ec781a4..42df05f 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -79,6 +79,7 @@ TWISTED_TESTS = \
jingle/hold-av.py \
jingle/incoming-basics.py \
jingle/initial-audio-video.py \
+ jingle/misuse.py \
jingle/stun-server.py \
jingle/outgoing-basics.py \
jingle/outgoing-ensure.py \
diff --git a/tests/twisted/jingle/misuse.py b/tests/twisted/jingle/misuse.py
new file mode 100644
index 0000000..05913aa
--- /dev/null
+++ b/tests/twisted/jingle/misuse.py
@@ -0,0 +1,49 @@
+"""
+Test misuse of the streamed media API, which should return error messages
+rather than asserting Gabble.
+"""
+
+from dbus import DBusException
+
+from servicetest import make_channel_proxy, wrap_channel, assertEquals
+from gabbletest import exec_test
+from jingletest2 import JingleTest2, JingleProtocol031
+
+import constants as cs
+
+def test(q, bus, conn, stream):
+ jp = JingleProtocol031()
+ remote_jid = 'foo at example.com/misc'
+ jt = JingleTest2(jp, conn, q, stream, 'test at localhost', remote_jid)
+
+ jt.prepare()
+
+ self_handle = conn.GetSelfHandle()
+ remote_handle = conn.RequestHandles(cs.HT_CONTACT, [remote_jid])[0]
+ path, _ = conn.Requests.CreateChannel({
+ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: remote_handle})
+
+ chan = wrap_channel(bus.get_object(conn.bus_name, path), 'StreamedMedia')
+
+ # In Gabble, the StreamedMedia channel is secretly also the SessionHandler.
+ # Let's make up a proxy and call some methods on it. They should fail
+ # gracefully, rather than crashing Gabble.
+ session_handler = make_channel_proxy(conn, path, 'Media.SessionHandler')
+
+ try:
+ session_handler.Ready()
+ except DBusException, e:
+ assertEquals(cs.NOT_AVAILABLE, e.get_dbus_name())
+
+ try:
+ session_handler.Error(0, "slowing down but with a sense of speeding up")
+ except DBusException, e:
+ assertEquals(cs.NOT_AVAILABLE, e.get_dbus_name())
+
+ conn.Disconnect()
+
+
+if __name__ == '__main__':
+ exec_test(test)
--
1.5.6.5
More information about the telepathy-commits
mailing list