From 4c24f66f079b81b3d67a3138eb238f25b6f946f8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 8 Jan 2014 15:36:10 +0000 Subject: [PATCH 2/5] tests: resync constants, servicetest with Gabble --- tests/twisted/constants.py | 42 +++++++++++++++++++++++++++++++++--------- tests/twisted/servicetest.py | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 67 insertions(+), 16 deletions(-) diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index a9181ac..d710529 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -33,8 +33,6 @@ CM = PREFIX + ".ConnectionManager" HT_NONE = 0 HT_CONTACT = 1 HT_ROOM = 2 -HT_LIST = 3 -HT_GROUP = 4 CHANNEL = PREFIX + ".Channel" @@ -73,6 +71,15 @@ INITIATOR_HANDLE = CHANNEL + '.InitiatorHandle' INITIATOR_ID = CHANNEL + '.InitiatorID' INTERFACES = CHANNEL + '.Interfaces' +CALL_CONTENTS = CHANNEL_TYPE_CALL + '.Contents' +CALL_CALL_STATE_DETAILS = CHANNEL_TYPE_CALL + '.CallStateDetails' +CALL_CALL_STATE = CHANNEL_TYPE_CALL + '.CallState' +CALL_CALL_FLAGS = CHANNEL_TYPE_CALL + '.CallFlags' +CALL_CALL_STATE_REASON = CHANNEL_TYPE_CALL + '.CallStateReason' +CALL_HARDWARE_STREAMING = CHANNEL_TYPE_CALL + '.HardwareStreaming' +CALL_CALL_MEMBERS = CHANNEL_TYPE_CALL + '.CallMembers' +CALL_MEMBER_IDENTIFIERS = CHANNEL_TYPE_CALL + '.MemberIdentifiers' +CALL_INITIAL_TRANSPORT = CHANNEL_TYPE_CALL + '.InitialTransport' CALL_INITIAL_AUDIO = CHANNEL_TYPE_CALL + '.InitialAudio' CALL_INITIAL_AUDIO_NAME = CHANNEL_TYPE_CALL + '.InitialAudioName' CALL_INITIAL_VIDEO = CHANNEL_TYPE_CALL + '.InitialVideo' @@ -83,7 +90,7 @@ CALL_CONTENT = PREFIX + '.Call1.Content' CALL_CONTENT_IFACE_MEDIA = CALL_CONTENT + '.Interface.Media' CALL_CONTENT_IFACE_DTMF = CALL_CONTENT + '.Interface.DTMF1' -CALL_CONTENT_MEDIADESCRIPTION = CALL_CONTENT + '.MediaDescription' +CALL_CONTENT_MEDIA_DESCRIPTION = CALL_CONTENT + '.MediaDescription' CALL_STREAM = PREFIX + '.Call1.Stream' CALL_STREAM_IFACE_MEDIA = CALL_STREAM + '.Interface.Media' @@ -178,10 +185,11 @@ CONTACT_LIST_STATE_SUCCESS = 3 CONN = PREFIX + ".Connection" CONN_IFACE_AVATARS = CONN + '.Interface.Avatars1' CONN_IFACE_ALIASING = CONN + '.Interface.Aliasing1' -CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts' CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities1' CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo1" CONN_IFACE_PRESENCE = CONN + '.Interface.Presence1' +CONN_IFACE_RENAMING = CONN + '.Interface.Renaming1' +CONN_IFACE_SIDECARS1 = CONN + '.Interface.Sidecars1' CONN_IFACE_REQUESTS = CONN + '.Interface.Requests' CONN_IFACE_LOCATION = CONN + '.Interface.Location1' CONN_IFACE_GABBLE_DECLOAK = CONN + '.Interface.Gabble.Decloak' @@ -194,12 +202,17 @@ CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking1' CONN_IFACE_ADDRESSING = CONN + '.Interface.Addressing1' CONN_IFACE_SERVICE_POINT = CONN + '.Interface.ServicePoint1' -ATTR_CONTACT_ID = CONN + '/contact-id' +ATTR_ALIAS = CONN_IFACE_ALIASING + '/alias' +ATTR_AVATAR_TOKEN = CONN_IFACE_AVATARS + '/token' +ATTR_CLIENT_TYPES = CONN_IFACE_CLIENT_TYPES + '/client-types' ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities' +ATTR_CONTACT_ID = CONN + '/contact-id' +ATTR_CONTACT_INFO = CONN_IFACE_CONTACT_INFO + '/info' +ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups' +ATTR_LOCATION = CONN_IFACE_LOCATION + '/location' ATTR_PRESENCE = CONN_IFACE_PRESENCE + '/presence' -ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe' ATTR_PUBLISH = CONN_IFACE_CONTACT_LIST + '/publish' -ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups' +ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe' STREAM_HANDLER = PREFIX + '.Media.StreamHandler' @@ -325,7 +338,7 @@ FT_DATE = CHANNEL_TYPE_FILE_TRANSFER + '.Date' FT_AVAILABLE_SOCKET_TYPES = CHANNEL_TYPE_FILE_TRANSFER + '.AvailableSocketTypes' FT_TRANSFERRED_BYTES = CHANNEL_TYPE_FILE_TRANSFER + '.TransferredBytes' FT_INITIAL_OFFSET = CHANNEL_TYPE_FILE_TRANSFER + '.InitialOffset' -FT_FILE_COLLECTION = CHANNEL_TYPE_FILE_TRANSFER + '.FUTURE.FileCollection' +FT_FILE_COLLECTION = CHANNEL_TYPE_FILE_TRANSFER + '.FileCollection' FT_URI = CHANNEL_TYPE_FILE_TRANSFER + '.URI' FT_SERVICE_NAME = CHANNEL_IFACE_FILE_TRANSFER_METADATA + '.ServiceName' FT_METADATA = CHANNEL_IFACE_FILE_TRANSFER_METADATA + '.Metadata' @@ -458,6 +471,12 @@ MT_NOTICE = 2 MT_AUTO_REPLY = 3 MT_DELIVERY_REPORT = 4 +class MessageFlag(object): + TRUNCATED = 1 + NON_TEXT_CONTENT = 2 + SCROLLBACK = 4 + RESCUED = 8 + class SendError(object): UNKNOWN = 0 OFFLINE = 1 @@ -522,7 +541,7 @@ SUBJECT = CHANNEL_IFACE_ROOM + '.Subject' SUBJECT_PRESENT = 1 SUBJECT_CAN_SET = 2 -DEBUG_IFACE = PREFIX + '.Debug' +DEBUG_IFACE = PREFIX + '.Debug1' DEBUG_PATH = PATH_PREFIX + '/debug' SERVICE_POINT_TYPE_NONE = 0 @@ -551,12 +570,17 @@ CR = PREFIX + '.ChannelRequest' CDO = PREFIX + '.ChannelDispatchOperation' CD = PREFIX + '.ChannelDispatcher' +CD_IFACE_MESSAGES1 = PREFIX + '.ChannelDispatcher.Interface.Messages1' CD_IFACE_OP_LIST = PREFIX + '.ChannelDispatcher.Interface.OperationList1' CD_PATH = PATH_PREFIX + '/ChannelDispatcher' MC = PREFIX + '.MissionControl6' MC_PATH = PATH_PREFIX + '/MissionControl6' +DTMF_CURRENTLY_SENDING_TONES = CHANNEL_IFACE_DTMF + '.CurrentlySendingTones' +DTMF_INITIAL_TONES = CHANNEL_IFACE_DTMF + '.InitialTones' +DTMF_DEFERRED_TONES = CHANNEL_IFACE_DTMF + '.DeferredTones' +TESTS = PREFIX + ".Tests" TESTDOT = PREFIX + ".Test." TESTSLASH = PATH_PREFIX + "/Test/" diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 8a813f5..86212f3 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -197,7 +197,14 @@ class BaseEventQueue: t = time.time() while True: - event = self.wait([pattern.subqueue]) + try: + event = self.wait([pattern.subqueue]) + except TimeoutError: + self.log('timeout') + self.log('still expecting:') + self.log(' - %r' % pattern) + raise + self._check_forbidden(event) if pattern.match(event): @@ -575,8 +582,7 @@ def sync_dbus(bus, q, proxy): # dbus-glib and thence the application, which means that Ping()ing the # application doesn't ensure that it's processed all D-Bus messages prior # to our ping. - call_async(q, dbus.Interface(proxy, 'org.freedesktop.Telepathy.Tests'), - 'DummySyncDBus') + call_async(q, dbus.Interface(proxy, cs.TESTS), 'DummySyncDBus') q.expect('dbus-error', method='DummySyncDBus') class ProxyWrapper: @@ -620,26 +626,44 @@ def wrap_connection(conn): return ConnWrapper(conn, tp_name_prefix + '.Connection', dict( [('Peer', 'org.freedesktop.DBus.Peer'), + ('Contacts', cs.CONN), # backwards compat with Telepathy 0 ('Aliasing', cs.CONN_IFACE_ALIASING), ('Avatars', cs.CONN_IFACE_AVATARS), - ('Contacts', cs.CONN_IFACE_CONTACTS), ('ContactCapabilities', cs.CONN_IFACE_CONTACT_CAPS), ('ContactInfo', cs.CONN_IFACE_CONTACT_INFO), ('Location', cs.CONN_IFACE_LOCATION), ('Presence', cs.CONN_IFACE_PRESENCE), ('Requests', cs.CONN_IFACE_REQUESTS), - ('Future', tp_name_prefix + '.Connection.FUTURE'), ('MailNotification', cs.CONN_IFACE_MAIL_NOTIFICATION), ('ContactList', cs.CONN_IFACE_CONTACT_LIST), ('ContactGroups', cs.CONN_IFACE_CONTACT_GROUPS), + ('ContactBlocking', cs.CONN_IFACE_CONTACT_BLOCKING), ('PowerSaving', cs.CONN_IFACE_POWER_SAVING), ('Addressing', cs.CONN_IFACE_ADDRESSING), + ('ClientTypes', cs.CONN_IFACE_CLIENT_TYPES), + ('Renaming', cs.CONN_IFACE_RENAMING), + ('Sidecars1', cs.CONN_IFACE_SIDECARS1), ])) +class ChannelWrapper(ProxyWrapper): + def send_msg_sync(self, txt): + message = [ + { 'message-type': cs.MT_NORMAL, }, + { 'content-type': 'text/plain', + 'content': txt + }] + self.Text.SendMessage(message, 0) + def wrap_channel(chan, type_, extra=None): interfaces = { type_: tp_name_prefix + '.Channel.Type.' + type_, + 'Channel': cs.CHANNEL, 'Group': cs.CHANNEL_IFACE_GROUP, + 'Hold': cs.CHANNEL_IFACE_HOLD, + 'RoomConfig1': cs.CHANNEL_IFACE_ROOM_CONFIG, + 'ChatState': cs.CHANNEL_IFACE_CHAT_STATE, + 'Destroyable': cs.CHANNEL_IFACE_DESTROYABLE, + 'Password': cs.CHANNEL_IFACE_PASSWORD, } if extra: @@ -647,11 +671,14 @@ def wrap_channel(chan, type_, extra=None): (name, tp_name_prefix + '.Channel.Interface.' + name) for name in extra])) - return ProxyWrapper(chan, tp_name_prefix + '.Channel', interfaces) + return ChannelWrapper(chan, tp_name_prefix + '.Channel', interfaces) def wrap_content(chan, extra=None): - interfaces = { } + interfaces = { + 'DTMF': cs.CALL_CONTENT_IFACE_DTMF, + 'Media': cs.CALL_CONTENT_IFACE_MEDIA, + } if extra: interfaces.update(dict([ -- 1.8.5.2