summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2009-01-29 16:34:23 -0600
committerWill Thompson <will.thompson@collabora.co.uk>2012-04-08 09:43:09 +0100
commitdc777537db0f727951d51a09599c108f34b34dcd (patch)
tree5d36eb5fa0e10168f46fb8214b46d96539476d99
parent5ebe6a7cf1fac6df992cb65ca18cdabf8ece20be (diff)
Fix a bug and add a test for requesting multiple roomlist channels
I hadn't really excercised the code for returning an existing roomlist channel if we had already created one. So I added a test for it and in the process discovered a bug, which is also fixed by this patch. (The compiler found this bug when it was introduced while I was rebasing Jonathon's branch, so I fixed it there and then. -Will)
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/channels/room-list-multiple.py61
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e6b0005..b867240 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -16,6 +16,7 @@ TWISTED_TESTS = \
channels/requests-muc.py \
channels/muc-channel-topic.py \
channels/room-list-channel.py \
+ channels/room-list-multiple.py \
messages/accept-invalid-nicks.py \
messages/contactinfo-request.py \
messages/messages-iface.py \
diff --git a/tests/twisted/channels/room-list-multiple.py b/tests/twisted/channels/room-list-multiple.py
new file mode 100644
index 0000000..e168965
--- /dev/null
+++ b/tests/twisted/channels/room-list-multiple.py
@@ -0,0 +1,61 @@
+
+"""
+Test getting multiple room-list channels. telepathy-idle internally only
+creates a single roomlist channel (since there's not really any reason to have
+more than one) and passes that channel out whenever somebody asks for it.
+
+This test just excercises the case where we've already created the channel and
+we just need to hand it out to the next requestor
+"""
+
+from idletest import exec_test, BaseIRCServer
+from servicetest import EventPattern, call_async, tp_name_prefix, tp_path_prefix
+import dbus
+
+HANDLE_TYPE_NONE=0
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]),
+ EventPattern('irc-connected'))
+ q.expect('dbus-signal', signal='SelfHandleChanged',
+ args=[1L])
+
+ # request a roomlist channel
+ EXPECTED_ROOM = tp_path_prefix + '/Connection/idle/irc/test_40localhost/RoomListChannel0'
+ call_async(q, conn, 'RequestChannel',
+ tp_name_prefix + '.Channel.Type.RoomList', HANDLE_TYPE_NONE,
+ 0, True)
+ ret = q.expect('dbus-return', method='RequestChannel')
+ assert EXPECTED_ROOM == ret.value[0]
+
+ # verify that a new channel was created and signalled
+ q.expect('dbus-signal', signal='NewChannels',
+ args=[[(EXPECTED_ROOM,
+ { tp_name_prefix + u'.Channel.ChannelType':
+ tp_name_prefix + u'.Channel.Type.RoomList',
+ tp_name_prefix + u'.Channel.TargetHandle': 0,
+ tp_name_prefix + u'.Channel.TargetHandleType': 0})]])
+ q.expect('dbus-signal', signal='NewChannel',
+ args=[tp_path_prefix + '/Connection/idle/irc/test_40localhost/RoomListChannel0',
+ tp_name_prefix + u'.Channel.Type.RoomList', 0, 0, 1])
+
+ # try to request another roomlist channel
+ call_async(q, conn, 'RequestChannel',
+ tp_name_prefix + '.Channel.Type.RoomList', HANDLE_TYPE_NONE,
+ 0, True)
+ ret = q.expect('dbus-return', method='RequestChannel')
+ # assert that it returns the same channel
+ assert EXPECTED_ROOM == ret.value[0]
+
+ call_async(q, conn, 'Disconnect')
+ q.expect_many(
+ EventPattern('dbus-return', method='Disconnect'),
+ EventPattern('dbus-signal', signal='ChannelClosed', args=[EXPECTED_ROOM]),
+ EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]))
+ return True
+
+if __name__ == '__main__':
+ exec_test(test)
+