Ejemplo n.º 1
0
        audio_cstream.CompleteSendingStateChange(
                cs.CALL_STREAM_FLOW_STATE_STOPPED,
                dbus_interface = cs.CALL_STREAM_IFACE_MEDIA)
        video_cstream.CompleteSendingStateChange(
                cs.CALL_STREAM_FLOW_STATE_STOPPED,
                dbus_interface = cs.CALL_STREAM_IFACE_MEDIA)
        q.expect_many(
            EventPattern('dbus-signal', signal='HoldStateChanged',
                args=[cs.HS_HELD, cs.HSR_RESOURCE_NOT_AVAILABLE]),
            EventPattern('dbus-signal', signal='SendingStateChanged',
                args = [cs.CALL_STREAM_FLOW_STATE_STOPPED],
                interface = cs.CALL_STREAM_IFACE_MEDIA),
            EventPattern('dbus-signal', signal='SendingStateChanged',
                args = [cs.CALL_STREAM_FLOW_STATE_STOPPED],
                interface = cs.CALL_STREAM_IFACE_MEDIA),
            EventPattern('dbus-signal', signal='ReceivingStateChanged',
                args = [cs.CALL_STREAM_FLOW_STATE_STOPPED],
                interface = cs.CALL_STREAM_IFACE_MEDIA),
            )
    
        sync_stream(q, stream)
        q.unforbid_events(self.unhold_event + self.hold_event)
    
        if self.jp.has_mutable_streams():
            self.mutable_stream_tests()


if __name__ == '__main__':
    test_all_dialects(partial(run_call_test, klass=CallHoldAVTest,
                incoming=False))
Ejemplo n.º 2
0
            predicate=jp.action_predicate('session-accept')),
        EventPattern('dbus-signal', signal='SetStreamSending', args=[True]),
        EventPattern('dbus-signal', signal='SetStreamPlaying', args=[True]),
        EventPattern('dbus-signal', signal='StreamDirectionChanged',
            args=[stream_id, cs.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL, 0]),
        )

    stream.send(make_result_iq(stream, acc.stanza))

    # Also, if this is a Jingle dialect that supports it, Gabble should send an
    # <active/> notification when the session-accept is acked (until the
    # Telepathy spec lets the UI say it's not ringing any more).
    active_event = jp.rtp_info_event("active")
    if active_event is not None:
        q.expect_many(active_event)

    # we are now both in members
    members = media_chan.GetMembers()
    assert set(members) == set([self_handle, remote_handle]), members

    # Connected! Blah, blah, ...

    # 'Nuff said
    jt.terminate()
    q.expect('dbus-signal', signal='Closed', path=path)

if __name__ == '__main__':
    test_all_dialects(test)
    test_all_dialects(lambda jp, q, bus, conn, stream:
            test(jp, q, bus, conn, stream, '*****@*****.**'))
Ejemplo n.º 3
0
        # Checked that DeferredTones is properly reset
        assertEquals(
            '',
            content.Get(cs.CALL_CONTENT_IFACE_DTMF,
                        'DeferredTones',
                        dbus_interface=dbus.PROPERTIES_IFACE))

        content.Media.AcknowledgeDTMFChange(7, cs.CALL_SENDING_STATE_SENDING)

        q.expect('dbus-signal', signal='SendingTones', args=['7']),

        call_async(q, content.DTMF, 'StopTone')
        q.expect_many(
            EventPattern('dbus-signal',
                         signal='DTMFChangeRequested',
                         args=[7, cs.CALL_SENDING_STATE_PENDING_STOP_SENDING]),
            EventPattern('dbus-return', method='StopTone'),
        )

        content.Media.AcknowledgeDTMFChange(7, cs.CALL_SENDING_STATE_NONE)
        q.expect('dbus-signal', signal='StoppedTones', args=[False])

    def pickup(self):
        CallTest.pickup(self)
        self.test_dtmf()


if __name__ == '__main__':
    test_all_dialects(
        partial(run_call_test, klass=CallDtmfTest, incoming=False))
Ejemplo n.º 4
0
            '1,1' * 100)
    q.expect('dbus-return', method='MultipleTones')

    call_async(q, chan.DTMF, 'MultipleTones', '9')
    q.expect('dbus-error', method='MultipleTones',
            name=cs.SERVICE_BUSY)
    call_async(q, chan.DTMF, 'StartTone', 666, 9)
    q.expect('dbus-error', method='StartTone', name=cs.SERVICE_BUSY)
    call_async(q, chan.DTMF, 'StopTone', 666)
    q.expect_many(
            EventPattern('dbus-signal', signal='StopTelephonyEvent',
                path=audio_path),
            EventPattern('dbus-signal', signal='StopTelephonyEvent',
                path=audio2_path),
            EventPattern('dbus-signal', signal='StoppedTones', args=[True],
                path=chan_path),
            EventPattern('dbus-return', method='StopTone'),
            )

    # emitting any sound resets TonesDeferred
    assertEquals('',
            chan.Properties.Get(cs.CHANNEL_IFACE_DTMF, 'DeferredTones'))

    q.unforbid_events(forbidden)

    chan.Group.RemoveMembers([self_handle], 'closed')
    e = q.expect('dbus-signal', signal='Closed', path=chan_path)

if __name__ == '__main__':
    test_all_dialects(test)
"""

from functools import partial
from servicetest import call_async
from jingletest2 import test_all_dialects
from call_helper import CallTest, run_call_test

from config import VOIP_ENABLED

if not VOIP_ENABLED:
    print "NOTE: built with --disable-voip"
    raise SystemExit(77)


class CallDtmfNoAudioTest(CallTest):

    # We want vieo only channel
    initial_audio = False
    initial_video = True

    def pickup(self):
        CallTest.pickup(self)

        # Check the DTMF method does not exist
        call_async(self.q, self.video_content.DTMF, "StartTone", 3)
        self.q.expect("dbus-error", method="StartTone")


if __name__ == "__main__":
    test_all_dialects(partial(run_call_test, klass=CallDtmfNoAudioTest, incoming=False))
Ejemplo n.º 6
0
            self.chan.Hangup(0, "", "",
                dbus_interface=cs.CHANNEL_TYPE_CALL)

        self.check_channel_state(cs.CALL_STATE_ENDED, wait = True)


    def run(self):
        if self.initial_video:
            if not self.initial_audio and not self.jp.can_do_video_only():
                return
            elif not self.jp.can_do_video():
                return
        self.advertise()
        self.prepare()
        self.initiate()
        self.accept_outgoing()
        self.connect()
        self.pickup()
        self.hangup()


def run_call_test(jp, q, bus, conn, stream, klass=CallTest, incoming=False,
        params={}):
    test = klass(jp, q, bus, conn, stream, incoming, params)
    test.run()

if __name__ == '__main__':
    test_all_dialects(partial(run_call_test, incoming=False))
    test_all_dialects(partial(run_call_test, incoming=True))

                                                              msg, jp))
    # Bye bye members.
    mc = q.expect('dbus-signal', signal='MembersChanged',
                  interface=cs.CHANNEL_IFACE_GROUP, path=channel_path,
                  args=[msg, [], [self_handle, remote_handle], [],
                        [], self_handle, group_change_reason])

    q.expect('dbus-signal', signal='StreamError',
             interface=cs.CHANNEL_TYPE_STREAMED_MEDIA,
             args=[stream_id, stream_error, msg])

    # Bye bye stream
    q.expect('dbus-signal', signal='Close')
    q.expect('dbus-signal', signal='StreamRemoved')

    # Bye bye channel.
    q.expect('dbus-signal', signal='Closed')
    q.expect('dbus-signal', signal='ChannelClosed')

def test_connection_error(jp, q, bus, conn, stream):
    _test(jp, q, bus, conn, stream, "connectivity-error", cs.GC_REASON_ERROR,
          cs.MEDIA_STREAM_ERROR_NETWORK_ERROR)

def test_codec_negotiation_fail(jp, q, bus, conn, stream):
    _test(jp, q, bus, conn, stream, "failed-application", cs.GC_REASON_ERROR,
          cs.MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED)

if __name__ == '__main__':
    test_all_dialects(test_connection_error)
    test_all_dialects(test_codec_negotiation_fail)
            EventPattern('dbus-return', method='RequestHold', value=()),
            )
    
        # Ensure that if Gabble sent the <unhold/> stanza too early it's already
        # arrived.
        sync_stream(q, stream)
        q.unforbid_events(self.unhold_event)
    
        cstream.CompleteReceivingStateChange(
                cs.CALL_STREAM_FLOW_STATE_STARTED,
                dbus_interface = cs.CALL_STREAM_IFACE_MEDIA)
        cstream.CompleteSendingStateChange(
                cs.CALL_STREAM_FLOW_STATE_STARTED,
                dbus_interface = cs.CALL_STREAM_IFACE_MEDIA)
        q.expect_many(
            EventPattern('dbus-signal', signal='HoldStateChanged',
                args=[cs.HS_UNHELD, cs.HSR_REQUESTED]),
            EventPattern('dbus-signal', signal='SendingStateChanged',
                args = [cs.CALL_STREAM_FLOW_STATE_STARTED],
                interface = cs.CALL_STREAM_IFACE_MEDIA),
            EventPattern('dbus-signal', signal='ReceivingStateChanged',
                args = [cs.CALL_STREAM_FLOW_STATE_STARTED],
                interface = cs.CALL_STREAM_IFACE_MEDIA),
            *self.unhold_event
            )


if __name__ == '__main__':
    test_all_dialects(partial(run_call_test, klass=CallHoldAudioTest,
                incoming=False))
Ejemplo n.º 9
0
        if a == None and v != None and not jp.can_do_video_only():
            continue

        jt.incoming_call(audio=a, video=v)
        e = q.expect('dbus-signal', signal='NewChannels',
            predicate=lambda e:
                cs.CHANNEL_TYPE_CONTACT_LIST not in e.args[0][0][1].values())
        chans = e.args[0]
        assertLength(1, chans)

        path, props = chans[0]

        assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA, props[cs.CHANNEL_TYPE])
        assertEquals(a != None, props[cs.INITIAL_AUDIO])
        assertEquals(v != None, props[cs.INITIAL_VIDEO])

        # FIXME: This doesn't check non-Google contacts that can only do one
        # media type, as such contacts as simulated by JingleTest2 can always
        # do both.
        assertEquals(not jp.can_do_video() or not jp.can_do_video_only(),
            props[cs.IMMUTABLE_STREAMS])

        chan = wrap_channel(bus.get_object(conn.bus_name, path),
            cs.CHANNEL_TYPE_STREAMED_MEDIA)
        chan.Close()


if __name__ == '__main__':
    test_all_dialects(outgoing)
    test_all_dialects(incoming)
Ejemplo n.º 10
0
            assertEquals(cs.CALL_STREAM_FLOW_STATE_STOPPED, o.args[0])

            jt2.content_modify(content_name, "initiator", "both")
            ret = q.expect_many(
                    EventPattern('dbus-signal', signal='ReceivingStateChanged'),
                    EventPattern('dbus-signal', signal='RemoteMembersChanged'))
            assertEquals(cs.CALL_STREAM_FLOW_STATE_PENDING_START,
                    ret[0].args[0])
            assert ret[1].args[0].has_key(remote_handle)
            assertEquals(cs.CALL_SENDING_STATE_SENDING,
                    ret[1].args[0][remote_handle])

            cstream.CompleteReceivingStateChange(
                    cs.CALL_STREAM_FLOW_STATE_STARTED,
                    dbus_interface = cs.CALL_STREAM_IFACE_MEDIA)
            o = q.expect('dbus-signal', signal='ReceivingStateChanged')
            assertEquals(cs.CALL_STREAM_FLOW_STATE_STARTED, o.args[0])

        try:
            self.test_content_addition()
        except DBusException, e:
            assertEquals(cs.NOT_AVAILABLE, e.get_dbus_name())
            assert not jp.can_do_video()


if __name__ == '__main__':
    test_all_dialects(
            partial(run_call_test, klass=CallBasicsTest, incoming=True))
    test_all_dialects(
            partial(run_call_test, klass=CallBasicsTest, incoming=False))
Ejemplo n.º 11
0
            self.chan.Hangup(0, "", "",
                dbus_interface=cs.CHANNEL_TYPE_CALL)

        self.check_channel_state(cs.CALL_STATE_ENDED, wait = True)


    def run(self):
        if self.initial_video:
            if not self.initial_audio and not self.jp.can_do_video_only():
                return
            elif not self.jp.can_do_video():
                return
        self.advertise()
        self.prepare()
        self.initiate()
        self.accept_outgoing()
        self.connect()
        self.pickup()
        self.hangup()


def run_call_test(jp, q, bus, conn, stream, klass=CallTest, incoming=False,
        params={}):
    test = klass(jp, q, bus, conn, stream, incoming, params)
    test.run()

if __name__ == '__main__':
    test_all_dialects(partial(run_call_test, incoming=False))
    test_all_dialects(partial(run_call_test, incoming=True))

Ejemplo n.º 12
0
            )
    q.expect_many(
            EventPattern('dbus-signal', signal='StoppedTones', args=[False],
                path=chan_path),
            )

    # This is technically a race condition, but this dialstring is almost
    # certainly long enough that the Python script will win the race, i.e.
    # cancel before Gabble processes the whole dialstring.
    call_async(q, chan.DTMF, 'MultipleTones',
            '1,1' * 100)
    q.expect('dbus-return', method='MultipleTones')
    call_async(q, chan.DTMF, 'MultipleTones', '9')
    q.expect('dbus-error', method='MultipleTones',
            name=cs.SERVICE_BUSY)
    call_async(q, chan.DTMF, 'StartTone', 666, 9)
    q.expect('dbus-error', method='StartTone', name=cs.SERVICE_BUSY)
    call_async(q, chan.DTMF, 'StopTone', 666)
    q.expect_many(
            EventPattern('dbus-signal', signal='StoppedTones', args=[True],
                path=chan_path),
            EventPattern('dbus-return', method='StopTone'),
            )

    chan.Hangup (0, "", "",
        dbus_interface=cs.CHANNEL_TYPE_CALL)

if __name__ == '__main__':
    test_all_dialects(lambda jp, q, bus, conn, stream:
        run_test(jp, q, bus, conn, stream))
Ejemplo n.º 13
0
    assertEquals({remote_handle: cs.CALL_SENDING_STATE_SENDING}, stream_props["RemoteMembers"])
    assertEquals(cs.CALL_SENDING_STATE_NONE, stream_props["LocalSendingState"])

    cstream.SetSending(True, dbus_interface=cs.CALL_STREAM)

    q.expect(
        "dbus-signal", signal="LocalSendingStateChanged", interface=cs.CALL_STREAM, args=[cs.CALL_SENDING_STATE_SENDING]
    )

    stream_props = cstream.GetAll(cs.CALL_STREAM, dbus_interface=dbus.PROPERTIES_IFACE)
    assertEquals({remote_handle: cs.CALL_SENDING_STATE_SENDING}, stream_props["RemoteMembers"])
    assertEquals(cs.CALL_SENDING_STATE_SENDING, stream_props["LocalSendingState"])

    try:
        test_content_addition(jt2, jp, q, bus, conn, chan, self_handle)
    except DBusException, e:
        assertEquals(cs.NOT_AVAILABLE, e.get_dbus_name())
        assert not jp.can_do_video()

    if incoming:
        jt2.terminate()
    else:
        chan.Hangup(0, "", "", dbus_interface=cs.CHANNEL_TYPE_CALL)

    check_state(q, chan, cs.CALL_STATE_ENDED, wait=True)


if __name__ == "__main__":
    test_all_dialects(lambda jp, q, bus, conn, stream: run_test(jp, q, bus, conn, stream, False))
    test_all_dialects(lambda jp, q, bus, conn, stream: run_test(jp, q, bus, conn, stream, True))
    jt.terminate(reason=jingle_reason, text=text)

    mc = q.expect('dbus-signal', signal='MembersChanged')
    message, added, removed, lp, rp, actor, reason = mc.args
    assert added == [], added
    assert set(removed) == set([self_handle, remote_handle]), \
        (removed, self_handle, remote_handle)
    assert lp == [], lp
    assert rp == [], rp
    assert actor == remote_handle, (actor, remote_handle)
    if jp.is_modern_jingle():
        assertEquals(text, message)
        assertEquals(group_change_reason, reason)

    if jp.is_modern_jingle() and stream_error:
        se = q.expect('dbus-signal', signal='StreamError')
        assertEquals(stream_error, se.args[1])

    q.expect('dbus-signal', signal='Close') #XXX - match against the path

def test_busy(jp, q, bus, conn, stream):
    _test(jp, q, bus, conn, stream, "busy", cs.GC_REASON_BUSY, None)

def test_codec_fail(jp, q, bus, conn, stream):
    _test(jp, q, bus, conn, stream, "failed-application", cs.GC_REASON_ERROR,
          cs.MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED)

if __name__ == '__main__':
    test_all_dialects(test_busy)
    test_all_dialects(test_codec_fail)
    # Test the call's Stream's properties
    call_stream = make_channel_proxy(conn, content_props[0],
                                     'Call.Stream.Interface.Media.Draft')
    stream_props = call_stream.GetAll(cs.CALL_STREAM_IFACE_MEDIA,
                                      dbus_interface=dbus.PROPERTIES_IFACE)
    assertEquals(cs.CALL_STREAM_TRANSPORT_GTALK_P2P, stream_props['Transport'])

    test_stun_server(stream_props['STUNServers'], expected_stun_servers)

    assertEquals(expected_relays, stream_props['RelayInfo'])
    assertEquals(True, stream_props['HasServerInfo'])


if __name__ == '__main__':
    # Call tests
    test_all_dialects(partial(test_call, google=False))
    test_all_dialects(partial(test_call,
                              google=False,
                              expected_stun_servers=[('5.4.3.2', 54321)]),
                      params={
                          'fallback-stun-server': 'resolves-to-5.4.3.2',
                          'fallback-stun-port': dbus.UInt16(54321)
                      })
    test_all_dialects(partial(test_call,
                              google=False,
                              expected_stun_servers=[('5.4.3.2', 1)]),
                      params={'account': '*****@*****.**'})

    if GOOGLE_RELAY_ENABLED:
        test_all_dialects(partial(test_call,
                                  google=True,
Ejemplo n.º 16
0
    hts = []

    for mc in media_classes:
        fixed, allowed = mc

        hts.append (fixed[cs.TARGET_HANDLE_TYPE])

        expected_allowed = [
            cs.TARGET_ID, cs.TARGET_HANDLE,
            cs.CALL_INITIAL_VIDEO, cs.CALL_INITIAL_AUDIO,
            cs.CALL_INITIAL_VIDEO_NAME, cs.CALL_INITIAL_AUDIO_NAME,
            cs.CALL_MUTABLE_CONTENTS
        ]

        allowed.sort()
        expected_allowed.sort()
        assertEquals(expected_allowed, allowed)

    assertEquals(sorted([cs.HT_CONTACT, cs.HT_ROOM]),  sorted(hts))

if __name__ == '__main__':
    exec_test(rccs)
    test_all_dialects(create)
    test_all_dialects(request_anonymous)
    test_all_dialects(request_anonymous_and_add)
    test_all_dialects(request_nonymous)
    test_all_dialects(partial(create, peer='*****@*****.**'))
    test_all_dialects(partial(request_anonymous, peer='*****@*****.**'))
    test_all_dialects(partial(request_anonymous_and_add, peer='*****@*****.**'))
    test_all_dialects(partial(request_nonymous, peer='*****@*****.**'))
    jt2.send_presence_and_caps()

    # Two peers happen to pick the same Jingle session ID
    jt1.sid = '1'
    jt2.sid = '1'

    jt1.incoming_call()
    q.expect('dbus-signal',
             signal='NewChannels',
             predicate=lambda e: cs.CHANNEL_TYPE_CALL in e.args[0][0][1][
                 cs.CHANNEL_TYPE])

    # If Gabble confuses the two sessions, it'll NAK the IQ rather than
    # realising this is a new call.
    jt2.incoming_call()
    q.expect('dbus-signal',
             signal='NewChannels',
             predicate=lambda e: cs.CHANNEL_TYPE_CALL in e.args[0][0][1][
                 cs.CHANNEL_TYPE])

    # On the other hand, if the same person calls twice with the same sid,
    # Gabble _should_ NAK the second s-i.
    jt2.incoming_call()
    q.expect('stream-iq',
             iq_type='error',
             predicate=jp.action_predicate('session-initiate'))


if __name__ == '__main__':
    test_all_dialects(test)
Ejemplo n.º 18
0
    # Test the call's Stream's properties
    call_stream = make_channel_proxy(conn,
        content_props[0], 'Call.Stream.Interface.Media.Draft')
    stream_props = call_stream.GetAll(cs.CALL_STREAM_IFACE_MEDIA,
        dbus_interface=dbus.PROPERTIES_IFACE)
    assertEquals(cs.CALL_STREAM_TRANSPORT_GTALK_P2P, stream_props['Transport'])

    test_stun_server(stream_props['STUNServers'], expected_stun_servers)

    assertEquals(expected_relays, stream_props['RelayInfo'])
    assertEquals(True, stream_props['HasServerInfo'])

if __name__ == '__main__':
    # Call tests
    test_all_dialects(partial(test_call,
        google=False))
    test_all_dialects(partial(test_call,
        google=False, expected_stun_servers=[('5.4.3.2', 54321)]),
        params={'fallback-stun-server': 'resolves-to-5.4.3.2',
            'fallback-stun-port': dbus.UInt16(54321)})
    test_all_dialects(partial(test_call,
        google=False, expected_stun_servers=[('5.4.3.2', 1)]),
        params={'account': '*****@*****.**'})

    if GOOGLE_RELAY_ENABLED:
        test_all_dialects(partial(test_call,
            google=True, expected_stun_servers=[('1.2.3.4', 12345)]),
            protocol=GoogleXmlStream)
        test_all_dialects(partial(test_call,
            google=True, expected_stun_servers=[('5.4.3.2', 54321)]),
            protocol=GoogleXmlStream,
        EventPattern('stream-iq',
            predicate=jp.action_predicate('session-terminate')),
        EventPattern('dbus-signal', signal='MembersChanged'),
        EventPattern('dbus-signal', signal='Closed'),
        )

    _, added, removed, lp, rp, actor, reason = mc.args
    assert added == [], added
    assert set(removed) == set([self_handle, remote_handle]), \
        (removed, self_handle, remote_handle)
    assert lp == [], lp
    assert rp == [], rp
    assert actor == self_handle, (actor, self_handle)
    if busy:
        assert reason == cs.GC_REASON_BUSY, reason
    else:
        assert reason == cs.GC_REASON_NONE, reason

    if jp.is_modern_jingle():
        jingle = iq.query
        if busy:
            r = "/jingle/reason/busy"
        else:
            r = "/jingle/reason/cancel"
        assert xpath.queryForNodes(r, jingle) is not None, (jingle.toXml(), r)

if __name__ == '__main__':
    test_all_dialects(test_busy)
    test_all_dialects(test_no_reason)

def rccs(q, bus, conn, stream):
    """
    Tests that the connection's RequestableChannelClasses for StreamedMedia are
    sane.
    """
    conn.Connect()

    q.expect('dbus-signal', signal='StatusChanged',
        args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])

    rccs = conn.Properties.Get(cs.CONN_IFACE_REQUESTS,
        'RequestableChannelClasses')

    media_classes = [ rcc for rcc in rccs
        if rcc[0][cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAMED_MEDIA ]

    assertLength(1, media_classes)

    fixed, allowed = media_classes[0]

    assertEquals(cs.HT_CONTACT, fixed[cs.TARGET_HANDLE_TYPE])

    assertContains(cs.TARGET_HANDLE, allowed)
    assertContains(cs.TARGET_ID, allowed)

if __name__ == '__main__':
    exec_test(rccs)
    test_all_dialects(request_anonymous)
    test_all_dialects(request_anonymous_and_add)
    test_all_dialects(request_nonymous)