diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-14 16:43:46 +0000 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2012-11-14 17:10:54 +0000 |
commit | 39ee2f08cf4e2d46aae86307f6dfa023fe347248 (patch) | |
tree | fef2e4d2a0f40fed89c9eb619f5fd3e28c88a51e /tests | |
parent | f51c7b9cd378a561a9926d0860c26b7581dd4dc0 (diff) |
muc-channel: implement Destroy(), make Close() respawn
This fixes the issue where empathy-chat crashing means you get kicked
out of all your channels.
It's technically backwards-incompatible but empathy-chat has been using
RemoveMembers() to leave rooms for ages, and it's a pretty destructive
and annoying bug, so let's just get on with it.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=24614
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/Makefile.am | 1 | ||||
-rw-r--r-- | tests/twisted/channels/muc-destroy.py | 32 | ||||
-rw-r--r-- | tests/twisted/channels/requests-muc.py | 29 |
3 files changed, 61 insertions, 1 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 185ffec..8329514 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -16,6 +16,7 @@ TWISTED_TESTS = \ channels/requests-create.py \ channels/requests-muc.py \ channels/muc-channel-topic.py \ + channels/muc-destroy.py \ channels/room-list-channel.py \ channels/room-list-multiple.py \ messages/accept-invalid-nicks.py \ diff --git a/tests/twisted/channels/muc-destroy.py b/tests/twisted/channels/muc-destroy.py new file mode 100644 index 0000000..3513098 --- /dev/null +++ b/tests/twisted/channels/muc-destroy.py @@ -0,0 +1,32 @@ +""" +Tests Destroy()ing a MUC. +""" + +from servicetest import call_async, wrap_channel, EventPattern +from idletest import exec_test +import constants as cs + +def test(q, bus, conn, stream): + conn.Connect() + q.expect('dbus-signal', signal='StatusChanged', + args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]) + + call_async(q, conn.Requests, "CreateChannel", { + cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, + cs.ROOM_NAME: "#everythingyoutouch", + }) + q.expect('stream-JOIN') + event = q.expect('dbus-return', method='CreateChannel') + path, props = event.value + chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text', + ['Destroyable']) + + call_async(q, chan.Destroyable, "Destroy") + q.expect_many( + EventPattern('stream-PART'), + EventPattern('dbus-signal', signal='Closed', path=path), + EventPattern('dbus-return', method='Destroy'), + ) + +if __name__ == '__main__': + exec_test(test) diff --git a/tests/twisted/channels/requests-muc.py b/tests/twisted/channels/requests-muc.py index 8d37526..27de685 100644 --- a/tests/twisted/channels/requests-muc.py +++ b/tests/twisted/channels/requests-muc.py @@ -3,7 +3,7 @@ Test connecting to a IRC channel via the Requests interface """ import functools -from idletest import exec_test, BaseIRCServer +from idletest import exec_test, BaseIRCServer, sync_stream from servicetest import ( EventPattern, call_async, sync_dbus, make_channel_proxy, assertEquals, assertSameSets, assertContains, @@ -89,6 +89,7 @@ def test(q, bus, conn, stream, use_room=False): cs.CHANNEL_IFACE_ROOM, cs.CHANNEL_IFACE_SUBJECT, cs.CHANNEL_IFACE_ROOM_CONFIG, + cs.CHANNEL_IFACE_DESTROYABLE, ], props[cs.INTERFACES]) assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM assert props[cs.TARGET_ID] == '#idletest' @@ -123,6 +124,32 @@ def test(q, bus, conn, stream, use_room=False): assert chans[0] == (path, props) chan = make_channel_proxy(conn, path, 'Channel') + + # Make sure Close()ing the channel makes it respawn. This avoids the old + # bug where empathy-chat crashing booted you out of all your channels. + patterns = [EventPattern('stream-PART')] + q.forbid_events(patterns) + chan.Close() + q.expect('dbus-signal', signal='Closed', path=chan.object_path) + e = q.expect('dbus-signal', signal='NewChannels') + + path, props = e.args[0][0] + assertEquals(chan.object_path, path) + # We requested the channel originally, but we didn't request it popping + # back up. + assertEquals(0, props[cs.INITIATOR_HANDLE]) + assert not props[cs.REQUESTED] + + # Check that ensuring a respawned channel does what you'd expect. + ec_yours, ec_path, ec_props = conn.EnsureChannel(request, + dbus_interface=cs.CONN_IFACE_REQUESTS) + assert not ec_yours + assertEquals(chan.object_path, ec_path) + assertEquals(props, ec_props) + + sync_stream(q, stream) + q.unforbid_events(patterns) + chan.RemoveMembers([self_handle], "bye bye cruel\r\nworld", dbus_interface=cs.CHANNEL_IFACE_GROUP) |