From ef939874f0b344eec7b792b76b583066817b3ca8 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 6 Jun 2012 12:04:27 +0100 Subject: muc-manager: only expose the text MUC channel when necessary Signed-off-by: Jonny Lamb --- tests/twisted/avahi/tubes/request-muc-tubes.py | 30 +++++------- tests/twisted/avahi/tubes/two-muc-stream-tubes.py | 57 ++++++++++------------- 2 files changed, 35 insertions(+), 52 deletions(-) (limited to 'tests') diff --git a/tests/twisted/avahi/tubes/request-muc-tubes.py b/tests/twisted/avahi/tubes/request-muc-tubes.py index ce54ab35..72ecbb19 100644 --- a/tests/twisted/avahi/tubes/request-muc-tubes.py +++ b/tests/twisted/avahi/tubes/request-muc-tubes.py @@ -61,25 +61,17 @@ def test(q, bus, conn): # text and tube channels are announced channels = new_sig.args[0] - assert len(channels) == 2 - got_text, got_tube = False, False - - for path, props in channels: - if props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT: - got_text = True - assert props[REQUESTED] == False - elif props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE: - got_tube = True - assert path == tube_path - assert props == tube_props - else: - assert False - - assert props[TARGET_HANDLE_TYPE] == HT_ROOM - assert props[TARGET_HANDLE] == handle - assert props[TARGET_ID] == 'my-second-room' - assert props[INITIATOR_HANDLE] == conn.GetSelfHandle() - assert props[INITIATOR_ID] == self_name + assert len(channels) == 1 + + path, props = channels[0] + assert props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE + assert path == tube_path + assert props == tube_props + assert props[TARGET_HANDLE_TYPE] == HT_ROOM + assert props[TARGET_HANDLE] == handle + assert props[TARGET_ID] == 'my-second-room' + assert props[INITIATOR_HANDLE] == conn.GetSelfHandle() + assert props[INITIATOR_ID] == self_name # ensure the same channel # yours, ensured_path, ensured_props = conn.Requests.EnsureChannel( diff --git a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py index 51a7f880..82696335 100644 --- a/tests/twisted/avahi/tubes/two-muc-stream-tubes.py +++ b/tests/twisted/avahi/tubes/two-muc-stream-tubes.py @@ -80,49 +80,32 @@ def test(q, bus, conn): TARGET_ID: muc_name, STREAM_TUBE_SERVICE: 'test'}) - e = q.expect('dbus-signal', signal='NewChannels', - predicate=lambda e: len(e.args[0]) == 2) + e = q.expect('dbus-signal', signal='NewChannels') channels = e.args[0] + assert len(channels) == 1 # get the list of all channels to check that newly announced ones are in it all_channels = conn.Properties.Get(CONN_IFACE_REQUESTS, 'Channels', byte_arrays=True) - got_text, got_tube = False, False - for path, props in channels: - if props[CHANNEL_TYPE] == CHANNEL_TYPE_TEXT: - got_text = True - assert props[REQUESTED] == False - text1 = wrap_channel(bus.get_object(conn.bus_name, path), 'Text') - txt_path = path - elif props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE: - got_tube = True - assert props[REQUESTED] == True - assert props[INTERFACES] == [CHANNEL_IFACE_GROUP, - CHANNEL_IFACE_TUBE] - assert props[STREAM_TUBE_SERVICE] == 'test' - - contact1_tube = wrap_channel(bus.get_object(conn.bus_name, path), 'StreamTube') - tube1_path = path - else: - assert False - - assert props[INITIATOR_HANDLE] == conn1_self_handle - assert props[INITIATOR_ID] == contact1_name - assert props[TARGET_ID] == muc_name - - assert (path, props) in all_channels, (path, props) - - assert got_text - assert got_tube + path, props = channels[0] + assert props[CHANNEL_TYPE] == CHANNEL_TYPE_STREAM_TUBE + assert props[REQUESTED] == True + assert props[INTERFACES] == [CHANNEL_IFACE_GROUP, + CHANNEL_IFACE_TUBE] + assert props[STREAM_TUBE_SERVICE] == 'test' + assert props[INITIATOR_HANDLE] == conn1_self_handle + assert props[INITIATOR_ID] == contact1_name + assert props[TARGET_ID] == muc_name + + assert (path, props) in all_channels, (path, props) + + contact1_tube = wrap_channel(bus.get_object(conn.bus_name, path), 'StreamTube') + tube1_path = path state = contact1_tube.Properties.Get(CHANNEL_IFACE_TUBE, 'State') assert state == TUBE_CHANNEL_STATE_NOT_OFFERED - # added as member - q.expect('dbus-signal', signal='MembersChanged', path=txt_path, - args=['', [conn1_self_handle], [], [], [], conn1_self_handle, 0]) - call_async(q, contact1_tube.StreamTube, 'Offer', SOCKET_ADDRESS_TYPE_UNIX, dbus.ByteArray(server_socket_address), SOCKET_ACCESS_CONTROL_LOCALHOST, sample_parameters) @@ -135,6 +118,14 @@ def test(q, bus, conn): state = contact1_tube.Properties.Get(CHANNEL_IFACE_TUBE, 'State') assert state == TUBE_CHANNEL_STATE_OPEN + # now let's get the text channel so we can invite contact2 using + # the utility t.invite_to_muc + _, path, _ = conn.Requests.EnsureChannel({ + CHANNEL_TYPE: CHANNEL_TYPE_TEXT, + TARGET_HANDLE_TYPE: HT_ROOM, + TARGET_ID: muc_name}) + text1 = wrap_channel(bus.get_object(conn.bus_name, path), 'Text') + t.invite_to_muc(q, text1.Group, conn2, contact2_handle_on_conn1, contact1_handle_on_conn2) # tubes channel is created -- cgit v1.2.1