summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--configure.ac17
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/README56
-rw-r--r--tests/twisted/Makefile.am84
-rw-r--r--tests/twisted/channel_text/init.py17
-rw-r--r--tests/twisted/constants.py306
-rw-r--r--tests/twisted/main-debug.c67
-rw-r--r--tests/twisted/observer/init.py17
-rw-r--r--tests/twisted/servicetest.py510
-rw-r--r--tests/twisted/tools/Makefile.am33
-rw-r--r--tests/twisted/tools/exec-with-log.sh.in31
-rw-r--r--tests/twisted/tools/failure-helper.sh105
-rw-r--r--tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service.in3
-rw-r--r--tests/twisted/tools/tmp-session-bus.conf.in27
-rw-r--r--tests/twisted/tools/with-session-bus.sh94
-rw-r--r--tests/twisted/tpltest.py580
17 files changed, 9 insertions, 1948 deletions
diff --git a/.gitignore b/.gitignore
index 4d1b4ff..9e2d6bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -84,12 +84,6 @@ tags
/tests/dbus/dbus-1/session.conf
/tests/dbus/capture-*.log
-/tests/twisted/config.py
-/tests/twisted/telepathy-logger-debug
-/tests/twisted/tools/exec-with-log.sh
-/tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service
-/tests/twisted/tools/tmp-session-bus.conf
-
/po/Makefile.in.in
/po/POTFILES
/po/stamp-it
diff --git a/configure.ac b/configure.ac
index c5d9129..e8d2135 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,21 +108,6 @@ if test -z "$XSLTPROC"; then
fi
# -----------------------------------------------------------
-# Check for a Python >= 2.5 with Twisted, to run the tests
-# -----------------------------------------------------------
-AM_PATH_PYTHON([2.5])
-AC_MSG_CHECKING([for Python with Twisted])
-if $PYTHON -c "import twisted.internet.reactor" >/dev/null 2>&1; then
- TEST_PYTHON="$PYTHON"
-else
- TEST_PYTHON=false
-fi
-AC_MSG_RESULT([$TEST_PYTHON])
-AC_SUBST(TEST_PYTHON)
-AM_CONDITIONAL([WANT_TWISTED_TESTS], test false != "$TEST_PYTHON")
-
-
-# -----------------------------------------------------------
# Error flags
# -----------------------------------------------------------
@@ -223,8 +208,6 @@ AC_CONFIG_FILES([
tests/dbus/Makefile
tests/lib/Makefile
tests/suppressions/Makefile
- tests/twisted/Makefile
- tests/twisted/tools/Makefile
])
AC_OUTPUT
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0e22692..53bebc5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,3 @@
-if WANT_TWISTED_TESTS
-CHECKTWISTED = twisted
-endif
-
SUBDIRS = $(CHECKTWISTED) suppressions lib dbus
EXTRA_DIST = logs
diff --git a/tests/README b/tests/README
index b9aab0d..b402ba5 100644
--- a/tests/README
+++ b/tests/README
@@ -25,62 +25,24 @@ To run an individual test under Valgrind:
make -C tests check-valgrind TESTS=test-handles
-== Twisted tests ==
-
-To run all Twisted tests:
-
- make check-twisted
-
-To run an individual Twisted test:
-
- make -C tests/twisted check-twisted TWISTED_TESTS=test-connect.py
-
-or:
-
- cd tests/twisted
- sh tools/with-session-bus.sh --config-file=tools/tmp-session-bus.conf \
- -- python test-connect.py
-
-To run with debug information:
-
- make -C tests/twisted check-twisted TWISTED_TESTS=test-connect.py \
- CHECK_TWISTED_VERBOSE=1
-
-or:
-
- cd tests/twisted
- sh tools/with-session-bus.sh --config-file=tools/tmp-session-bus.conf \
- -- python test-connect.py -v
-
To debug an individual test you can set one of the following env variable:
- * GABBLE_TEST_VALGRIND : to run Gabble inside valgrind. The report is
+ * TPL_TEST_VALGRIND : to run Gabble inside valgrind. The report is
added to tools/tpl-testing.log.
- export GABBLE_TEST_VALGRIND=1
+ export TPL_TEST_VALGRIND=1
- * GABBLE_TEST_REFDBG : to run Gabble inside refdbg. The report is written
- to tools/refdbg.log. You can change GABBLE_WRAPPER to use an alternative
+ * TPL_TEST_REFDBG : to run Gabble inside refdbg. The report is written
+ to tools/refdbg.log. You can change TPL_WRAPPER to use an alternative
refdbg and change REFDBG_OPTIONS to set your own parameters. Example:
- export GABBLE_TEST_REFDBG=1
- export GABBLE_WRAPPER="/path/to/refdbg"
+ export TPL_TEST_REFDBG=1
+ export TPL_WRAPPER="/path/to/refdbg"
export REFDBG_OPTIONS="btnum=16"
- * GABBLE_WRAPPER="nemiver" : to run Gabble inside the graphical debugger
+ * TPL_WRAPPER="nemiver" : to run Gabble inside the graphical debugger
nemiver. You'll be able to set up breakpoints; then hit the "continue"
button to launch Gabble.
- * GABBLE_TEST_STRACE : to run Gabble inside strace. The report is written
+ * TPL_TEST_STRACE : to run Gabble inside strace. The report is written
to tools/strace.log.
- export GABBLE_TEST_STRACE=1
-
-
-== Jingle tests ==
-
-Various jingle tests run the same tests with different dialects. To only test
-certain dialects use the JINGLE_DIALECTS environment variable. Currently
-supported are jingle015, jingle031, gtalk03 and gtalk04. For example to only
-run generic tests with the two jingle dialects you can do:
-
- make -C tests/twisted check-twisted TWISTED_TESTS=jingle/\*.py \
- JINGLE_DIALECTS=jingle015,jingle031
+ export TPL_TEST_STRACE=1
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
deleted file mode 100644
index bfaa51a..0000000
--- a/tests/twisted/Makefile.am
+++ /dev/null
@@ -1,84 +0,0 @@
-SUBDIRS = tools
-
-TWISTED_TESTS = \
- channel_text/init.py \
- observer/init.py
-
-TESTS =
-
-TESTS_ENVIRONMENT = \
- PYTHONPATH=@abs_top_srcdir@/tests/twisted:@abs_top_builddir@/tests/twisted
-
-# check-local: check-coding-style check-twisted
-check-local: check-coding-style
-
-# set to 6 when using refdbg, to give Gabble time to exit
-CHECK_TWISTED_SLEEP=0
-
-check-twisted:
- $(MAKE) -C tools
- rm -f tools/core
- rm -f tools/vgcore.*
- rm -f tools/tpl-testing.log
- rm -f tools/strace.log
- if test -n "$$GABBLE_TEST_REFDBG"; then \
- sleep=6; \
- else \
- sleep=$(CHECK_TWISTED_SLEEP); \
- fi; \
- sh $(srcdir)/tools/with-session-bus.sh \
- --sleep=$$sleep \
- --config-file=tools/tmp-session-bus.conf \
- -- $(MAKE) check-TESTS \
- TESTS="$(TWISTED_TESTS)" \
- TESTS_ENVIRONMENT="$(TESTS_ENVIRONMENT) $(TEST_PYTHON) -u"
- @if test -e tools/core; then\
- echo "Core dump exists: tools/core";\
- exit 1;\
- fi
-
-if ENABLE_DEBUG
-DEBUGGING_PYBOOL = True
-else
-DEBUGGING_PYBOOL = False
-endif
-
-config.py: Makefile
- $(AM_V_GEN) { \
- echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\""; \
- echo "DEBUGGING = $(DEBUGGING_PYBOOL)"; \
- } > $@
-
-BUILT_SOURCES = config.py
-
-EXTRA_DIST = \
- $(TWISTED_TESTS) \
- constants.py \
- tpltest.py \
- servicetest.py
-
-noinst_PROGRAMS = \
- telepathy-logger-debug
-
-telepathy_logger_debug_SOURCES = \
- main-debug.c \
- ../tpl-channel-test.c
-
-telepathy_logger_debug_LDADD = \
- $(top_builddir)/telepathy-logger/libtelepathy-logger.la \
- $(TPL_LIBS)
-
-telepathy_logger_debug_LDFLAGS = -export-dynamic
-
-AM_CFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/tests \
- -I$(top_builddir) \
- $(ERROR_CFLAGS) \
- ${TPL_CFLAGS}
-
-CLEANFILES = tpl-[1-9]*.log *.pyc */*.pyc config.py
-
-check_misc_sources = $(TESTS)
-
-include $(top_srcdir)/tools/check-coding-style.mk
diff --git a/tests/twisted/channel_text/init.py b/tests/twisted/channel_text/init.py
deleted file mode 100644
index 7489922..0000000
--- a/tests/twisted/channel_text/init.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-Test text channel initiated by me.
-"""
-
-import dbus
-
-from tpltest import exec_test
-from servicetest import call_async, EventPattern
-import constants as cs
-
-def test(q, bus):
- #pect('dbus-signal', signal='NewChannels')
-
- print "GOT NewChannels TEXT"
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
deleted file mode 100644
index f80e7dd..0000000
--- a/tests/twisted/constants.py
+++ /dev/null
@@ -1,306 +0,0 @@
-"""
-Some handy constants for other tests to share and enjoy.
-"""
-
-from dbus import PROPERTIES_IFACE
-
-HT_NONE = 0
-HT_CONTACT = 1
-HT_ROOM = 2
-HT_LIST = 3
-HT_GROUP = 4
-
-CHANNEL = "org.freedesktop.Telepathy.Channel"
-
-CHANNEL_IFACE_CALL_STATE = CHANNEL + ".Interface.CallState"
-CHANNEL_IFACE_CHAT_STATE = CHANNEL + '.Interface.ChatState'
-CHANNEL_IFACE_DESTROYABLE = CHANNEL + ".Interface.Destroyable"
-CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group"
-CHANNEL_IFACE_HOLD = CHANNEL + ".Interface.Hold"
-CHANNEL_IFACE_MEDIA_SIGNALLING = CHANNEL + ".Interface.MediaSignalling"
-CHANNEL_IFACE_MESSAGES = CHANNEL + ".Interface.Messages"
-CHANNEL_IFACE_PASSWORD = CHANNEL + ".Interface.Password"
-CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube"
-
-CHANNEL_TYPE_CALL = CHANNEL + ".Type.Call.DRAFT"
-CHANNEL_TYPE_CONTACT_LIST = CHANNEL + ".Type.ContactList"
-CHANNEL_TYPE_CONTACT_SEARCH = CHANNEL + ".Type.ContactSearch.DRAFT2"
-CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text"
-CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes"
-CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube"
-CHANNEL_TYPE_DBUS_TUBE = CHANNEL + ".Type.DBusTube"
-CHANNEL_TYPE_STREAMED_MEDIA = CHANNEL + ".Type.StreamedMedia"
-CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text"
-CHANNEL_TYPE_FILE_TRANSFER = CHANNEL + ".Type.FileTransfer"
-
-TP_AWKWARD_PROPERTIES = "org.freedesktop.Telepathy.Properties"
-PROPERTY_FLAG_READ = 1
-PROPERTY_FLAG_WRITE = 2
-PROPERTY_FLAGS_RW = PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE
-
-CHANNEL_TYPE = CHANNEL + '.ChannelType'
-TARGET_HANDLE_TYPE = CHANNEL + '.TargetHandleType'
-TARGET_HANDLE = CHANNEL + '.TargetHandle'
-TARGET_ID = CHANNEL + '.TargetID'
-REQUESTED = CHANNEL + '.Requested'
-INITIATOR_HANDLE = CHANNEL + '.InitiatorHandle'
-INITIATOR_ID = CHANNEL + '.InitiatorID'
-INTERFACES = CHANNEL + '.Interfaces'
-
-INITIAL_AUDIO = CHANNEL_TYPE_STREAMED_MEDIA + '.InitialAudio'
-INITIAL_VIDEO = CHANNEL_TYPE_STREAMED_MEDIA + '.InitialVideo'
-IMMUTABLE_STREAMS = CHANNEL_TYPE_STREAMED_MEDIA + '.ImmutableStreams'
-
-CALL_INITIAL_AUDIO = CHANNEL_TYPE_CALL + '.InitialAudio'
-CALL_INITIAL_VIDEO = CHANNEL_TYPE_CALL + '.InitialVideo'
-CALL_MUTABLE_CONTENTS = CHANNEL_TYPE_CALL + '.MutableContents'
-
-CALL_CONTENT = 'org.freedesktop.Telepathy.Call.Content.DRAFT'
-CALL_CONTENT_IFACE_MEDIA = \
- 'org.freedesktop.Telepathy.Call.Content.Interface.Media.DRAFT'
-
-CALL_CONTENT_CODECOFFER = \
- 'org.freedesktop.Telepathy.Call.Content.CodecOffer.DRAFT'
-
-CALL_STREAM = 'org.freedesktop.Telepathy.Call.Stream.DRAFT'
-CALL_STREAM_IFACE_MEDIA = \
- 'org.freedesktop.Telepathy.Call.Stream.Interface.Media.DRAFT'
-
-CALL_STREAM_ENDPOINT = 'org.freedesktop.Telepathy.Call.Stream.Endpoint.DRAFT'
-
-CALL_MEDIA_TYPE_AUDIO = 0
-CALL_MEDIA_TYPE_VIDEO = 1
-
-CALL_STREAM_TRANSPORT_RAW_UDP = 0
-CALL_STREAM_TRANSPORT_ICE = 1
-CALL_STREAM_TRANSPORT_GOOGLE = 2
-
-CALL_STATE_UNKNOWN = 0
-CALL_STATE_PENDING_INITIATOR = 1
-CALL_STATE_PENDING_RECEIVER = 2
-CALL_STATE_ACCEPTED = 3
-CALL_STATE_ENDED = 4
-
-CALL_MEMBER_FLAG_RINGING = 1
-CALL_MEMBER_FLAG_HELD = 2
-
-CALL_DISPOSITION_NONE = 0
-CALL_DISPOSITION_EARLY_MEDIA = 1
-CALL_DISPOSITION_INITIAL = 2
-
-CALL_SENDING_STATE_NONE = 0
-CALL_SENDING_STATE_PENDING_SEND = 1
-CALL_SENDING_STATE_SENDING = 2
-
-CONN = "org.freedesktop.Telepathy.Connection"
-CONN_IFACE_AVATARS = CONN + '.Interface.Avatars'
-CONN_IFACE_CAPS = CONN + '.Interface.Capabilities'
-CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts'
-CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities'
-CONN_IFACE_SIMPLE_PRESENCE = CONN + '.Interface.SimplePresence'
-CONN_IFACE_REQUESTS = CONN + '.Interface.Requests'
-CONN_IFACE_LOCATION = CONN + '.Interface.Location'
-CONN_IFACE_GABBLE_DECLOAK = CONN + '.Interface.Gabble.Decloak'
-
-ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities'
-
-STREAM_HANDLER = 'org.freedesktop.Telepathy.Media.StreamHandler'
-
-ERROR = 'org.freedesktop.Telepathy.Error'
-INVALID_ARGUMENT = ERROR + '.InvalidArgument'
-NOT_IMPLEMENTED = ERROR + '.NotImplemented'
-NOT_AVAILABLE = ERROR + '.NotAvailable'
-PERMISSION_DENIED = ERROR + '.PermissionDenied'
-OFFLINE = ERROR + '.Offline'
-NOT_CAPABLE = ERROR + '.NotCapable'
-CONNECTION_REFUSED = ERROR + '.ConnectionRefused'
-CONNECTION_FAILED = ERROR + '.ConnectionFailed'
-CONNECTION_LOST = ERROR + '.ConnectionLost'
-CANCELLED = ERROR + '.Cancelled'
-DISCONNECTED = ERROR + '.Disconnected'
-REGISTRATION_EXISTS = ERROR + '.RegistrationExists'
-
-UNKNOWN_METHOD = 'org.freedesktop.DBus.Error.UnknownMethod'
-
-TUBE_PARAMETERS = CHANNEL_IFACE_TUBE + '.Parameters'
-TUBE_STATE = CHANNEL_IFACE_TUBE + '.State'
-STREAM_TUBE_SERVICE = CHANNEL_TYPE_STREAM_TUBE + '.Service'
-DBUS_TUBE_SERVICE_NAME = CHANNEL_TYPE_DBUS_TUBE + '.ServiceName'
-DBUS_TUBE_DBUS_NAMES = CHANNEL_TYPE_DBUS_TUBE + '.DBusNames'
-DBUS_TUBE_SUPPORTED_ACCESS_CONTROLS = CHANNEL_TYPE_DBUS_TUBE + '.SupportedAccessControls'
-STREAM_TUBE_SUPPORTED_SOCKET_TYPES = CHANNEL_TYPE_STREAM_TUBE + '.SupportedSocketTypes'
-
-CONTACT_SEARCH_ASK = CHANNEL_TYPE_CONTACT_SEARCH + '.AvailableSearchKeys'
-CONTACT_SEARCH_SERVER = CHANNEL_TYPE_CONTACT_SEARCH + '.Server'
-CONTACT_SEARCH_STATE = CHANNEL_TYPE_CONTACT_SEARCH + '.SearchState'
-
-SEARCH_NOT_STARTED = 0
-SEARCH_IN_PROGRESS = 1
-SEARCH_MORE_AVAILABLE = 2
-SEARCH_COMPLETED = 3
-SEARCH_FAILED = 4
-
-TUBE_CHANNEL_STATE_LOCAL_PENDING = 0
-TUBE_CHANNEL_STATE_REMOTE_PENDING = 1
-TUBE_CHANNEL_STATE_OPEN = 2
-TUBE_CHANNEL_STATE_NOT_OFFERED = 3
-
-MEDIA_STREAM_TYPE_AUDIO = 0
-MEDIA_STREAM_TYPE_VIDEO = 1
-
-SOCKET_ADDRESS_TYPE_UNIX = 0
-SOCKET_ADDRESS_TYPE_ABSTRACT_UNIX = 1
-SOCKET_ADDRESS_TYPE_IPV4 = 2
-SOCKET_ADDRESS_TYPE_IPV6 = 3
-
-SOCKET_ACCESS_CONTROL_LOCALHOST = 0
-SOCKET_ACCESS_CONTROL_PORT = 1
-SOCKET_ACCESS_CONTROL_NETMASK = 2
-SOCKET_ACCESS_CONTROL_CREDENTIALS = 3
-
-TUBE_STATE_LOCAL_PENDING = 0
-TUBE_STATE_REMOTE_PENDING = 1
-TUBE_STATE_OPEN = 2
-TUBE_STATE_NOT_OFFERED = 3
-
-TUBE_TYPE_DBUS = 0
-TUBE_TYPE_STREAM = 1
-
-MEDIA_STREAM_DIRECTION_NONE = 0
-MEDIA_STREAM_DIRECTION_SEND = 1
-MEDIA_STREAM_DIRECTION_RECEIVE = 2
-MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3
-
-MEDIA_STREAM_PENDING_LOCAL_SEND = 1
-MEDIA_STREAM_PENDING_REMOTE_SEND = 2
-
-MEDIA_STREAM_TYPE_AUDIO = 0
-MEDIA_STREAM_TYPE_VIDEO = 1
-
-MEDIA_STREAM_STATE_DISCONNECTED = 0
-MEDIA_STREAM_STATE_CONNECTING = 1
-MEDIA_STREAM_STATE_CONNECTED = 2
-
-MEDIA_STREAM_DIRECTION_NONE = 0
-MEDIA_STREAM_DIRECTION_SEND = 1
-MEDIA_STREAM_DIRECTION_RECEIVE = 2
-MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3
-
-FT_STATE_NONE = 0
-FT_STATE_PENDING = 1
-FT_STATE_ACCEPTED = 2
-FT_STATE_OPEN = 3
-FT_STATE_COMPLETED = 4
-FT_STATE_CANCELLED = 5
-
-FT_STATE_CHANGE_REASON_NONE = 0
-FT_STATE_CHANGE_REASON_REQUESTED = 1
-FT_STATE_CHANGE_REASON_LOCAL_STOPPED = 2
-FT_STATE_CHANGE_REASON_REMOTE_STOPPED = 3
-FT_STATE_CHANGE_REASON_LOCAL_ERROR = 4
-FT_STATE_CHANGE_REASON_REMOTE_ERROR = 5
-
-FILE_HASH_TYPE_NONE = 0
-FILE_HASH_TYPE_MD5 = 1
-FILE_HASH_TYPE_SHA1 = 2
-FILE_HASH_TYPE_SHA256 = 3
-
-FT_STATE = CHANNEL_TYPE_FILE_TRANSFER + '.State'
-FT_CONTENT_TYPE = CHANNEL_TYPE_FILE_TRANSFER + '.ContentType'
-FT_FILENAME = CHANNEL_TYPE_FILE_TRANSFER + '.Filename'
-FT_SIZE = CHANNEL_TYPE_FILE_TRANSFER + '.Size'
-FT_CONTENT_HASH_TYPE = CHANNEL_TYPE_FILE_TRANSFER + '.ContentHashType'
-FT_CONTENT_HASH = CHANNEL_TYPE_FILE_TRANSFER + '.ContentHash'
-FT_DESCRIPTION = CHANNEL_TYPE_FILE_TRANSFER + '.Description'
-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'
-
-GF_CAN_ADD = 1
-GF_CAN_REMOVE = 2
-GF_CAN_RESCIND = 4
-GF_MESSAGE_ADD = 8
-GF_MESSAGE_REMOVE = 16
-GF_MESSAGE_ACCEPT = 32
-GF_MESSAGE_REJECT = 64
-GF_MESSAGE_RESCIND = 128
-GF_CHANNEL_SPECIFIC_HANDLES = 256
-GF_ONLY_ONE_GROUP = 512
-GF_HANDLE_OWNERS_NOT_AVAILABLE = 1024
-GF_PROPERTIES = 2048
-GF_MEMBERS_CHANGED_DETAILED = 4096
-
-GC_REASON_NONE = 0
-GC_REASON_OFFLINE = 1
-GC_REASON_KICKED = 2
-GC_REASON_BUSY = 3
-GC_REASON_INVITED = 4
-GC_REASON_BANNED = 5
-GC_REASON_ERROR = 6
-GC_REASON_INVALID_CONTACT = 7
-GC_REASON_NO_ANSWER = 8
-GC_REASON_RENAMED = 9
-GC_REASON_PERMISSION_DENIED = 10
-GC_REASON_SEPARATED = 11
-
-HS_UNHELD = 0
-HS_HELD = 1
-HS_PENDING_HOLD = 2
-HS_PENDING_UNHOLD = 3
-
-HSR_NONE = 0
-HSR_REQUESTED = 1
-HSR_RESOURCE_NOT_AVAILABLE = 2
-
-CALL_STATE_RINGING = 1
-CALL_STATE_QUEUED = 2
-CALL_STATE_HELD = 4
-CALL_STATE_FORWARDED = 8
-
-CONN_STATUS_CONNECTED = 0
-CONN_STATUS_CONNECTING = 1
-CONN_STATUS_DISCONNECTED = 2
-
-CSR_NONE_SPECIFIED = 0
-CSR_REQUESTED = 1
-CSR_NETWORK_ERROR = 2
-CSR_AUTHENTICATION_FAILED = 3
-CSR_ENCRYPTION_ERROR = 4
-CSR_NAME_IN_USE = 5
-CSR_CERT_NOT_PROVIDED = 6
-CSR_CERT_UNTRUSTED = 7
-CSR_CERT_EXPIRED = 8
-CSR_CERT_NOT_ACTIVATED = 9
-CSR_CERT_HOSTNAME_MISMATCH = 10
-CSR_CERT_FINGERPRINT_MISMATCH = 11
-CSR_CERT_SELF_SIGNED = 12
-CSR_CERT_OTHER_ERROR = 13
-
-BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo'
-ACTIVITY_PROPERTIES = 'org.laptop.Telepathy.ActivityProperties'
-
-CHAT_STATE_GONE = 0
-CHAT_STATE_INACTIVE = 1
-CHAT_STATE_ACTIVE = 2
-CHAT_STATE_PAUSED = 3
-CHAT_STATE_COMPOSING = 4
-
-# Channel_Media_Capabilities
-MEDIA_CAP_AUDIO = 1
-MEDIA_CAP_VIDEO = 2
-MEDIA_CAP_STUN = 4
-MEDIA_CAP_GTALKP2P = 8
-MEDIA_CAP_ICEUDP = 16
-MEDIA_CAP_IMMUTABLE_STREAMS = 32
-
-CLIENT = 'org.freedesktop.Telepathy.Client'
-
-PRESENCE_OFFLINE = 1
-PRESENCE_AVAILABLE = 2
-PRESENCE_AWAY = 3
-PRESENCE_EXTENDED_AWAY = 4
-PRESENCE_HIDDEN = 5
-PRESENCE_BUSY = 6
-PRESENCE_UNKNOWN = 7
-PRESENCE_ERROR = 8
diff --git a/tests/twisted/main-debug.c b/tests/twisted/main-debug.c
deleted file mode 100644
index 36b6cf9..0000000
--- a/tests/twisted/main-debug.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * main.c - entry point for telepathy-tpl-debug used by tests
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <tpl-channel-test.h>
-
-#include <stdlib.h>
-
-#include <dbus/dbus.h>
-
-#include <telepathy-logger/observer-internal.h>
-#include <telepathy-logger/channel-factory-internal.h>
-#include <telepathy-logger/text-channel-internal.h>
-
-
-static TplObserver *
-tpl_init (void)
-{
- TplObserver *observer;
- GError *error;
-
- g_type_init ();
-
- _tpl_channel_factory_init ();
- _tpl_channel_factory_add ("org.freedesktop.Telepathy.Channel.Type.Text",
- (TplChannelConstructor) tpl_channel_test_new);
-
- observer = _tpl_observer_new ();
- if (!tp_base_client_register (TP_BASE_CLIENT (observer), &error))
- {
- g_debug ("Error during D-Bus registration: %s", error->message);
- g_error_free (error);
- return NULL;
- }
-
- return observer;
-}
-
-
-int
-main (int argc,
- char *argv[])
-{
- int ret = 1;
- TplObserver *observer;
-
- observer = tpl_init ();
-
- dbus_shutdown ();
-
- return ret;
-}
diff --git a/tests/twisted/observer/init.py b/tests/twisted/observer/init.py
deleted file mode 100644
index e5de829..0000000
--- a/tests/twisted/observer/init.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-Test text channel initiated by me.
-"""
-
-import dbus
-
-from tpltest import exec_test
-from servicetest import call_async, EventPattern
-import constants as cs
-
-def test(q, bus):
- #pect('dbus-signal', signal='NewChannels')
-
- print "GOT NewChannels Obs"
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py
deleted file mode 100644
index 0634678..0000000
--- a/tests/twisted/servicetest.py
+++ /dev/null
@@ -1,510 +0,0 @@
-
-"""
-Infrastructure code for testing connection managers.
-"""
-
-from twisted.internet import glib2reactor
-from twisted.internet.protocol import Protocol, Factory, ClientFactory
-glib2reactor.install()
-import sys
-
-import pprint
-import unittest
-
-import dbus.glib
-
-from twisted.internet import reactor
-
-import constants as cs
-
-tp_name_prefix = 'org.freedesktop.Telepathy'
-tp_path_prefix = '/org/freedesktop/Telepathy'
-
-class Event:
- def __init__(self, type, **kw):
- self.__dict__.update(kw)
- self.type = type
-
-def format_event(event):
- ret = ['- type %s' % event.type]
-
- for key in dir(event):
- if key != 'type' and not key.startswith('_'):
- ret.append('- %s: %s' % (
- key, pprint.pformat(getattr(event, key))))
-
- if key == 'error':
- ret.append('%s' % getattr(event, key))
-
- return ret
-
-class EventPattern:
- def __init__(self, type, **properties):
- self.type = type
- self.predicate = lambda x: True
- if 'predicate' in properties:
- self.predicate = properties['predicate']
- del properties['predicate']
- self.properties = properties
-
- def __repr__(self):
- properties = dict(self.properties)
-
- if self.predicate:
- properties['predicate'] = self.predicate
-
- return '%s(%r, **%r)' % (
- self.__class__.__name__, self.type, properties)
-
- def match(self, event):
- if event.type != self.type:
- return False
-
- for key, value in self.properties.iteritems():
- try:
- if getattr(event, key) != value:
- return False
- except AttributeError:
- return False
-
- if self.predicate(event):
- return True
-
- return False
-
-
-class TimeoutError(Exception):
- pass
-
-class BaseEventQueue:
- """Abstract event queue base class.
-
- Implement the wait() method to have something that works.
- """
-
- def __init__(self, timeout=None):
- self.verbose = False
- self.forbidden_events = set()
-
- if timeout is None:
- self.timeout = 5
- else:
- self.timeout = timeout
-
- def log(self, s):
- if self.verbose:
- print s
-
- def log_event(self, event):
- if self.verbose:
- self.log('got event:')
-
- if self.verbose:
- map(self.log, format_event(event))
-
- def forbid_events(self, patterns):
- """
- Add patterns (an iterable of EventPattern) to the set of forbidden
- events. If a forbidden event occurs during an expect or expect_many,
- the test will fail.
- """
- self.forbidden_events.update(set(patterns))
-
- def unforbid_events(self, patterns):
- """
- Remove 'patterns' (an iterable of EventPattern) from the set of
- forbidden events. These must be the same EventPattern pointers that
- were passed to forbid_events.
- """
- self.forbidden_events.difference_update(set(patterns))
-
- def _check_forbidden(self, event):
- for e in self.forbidden_events:
- if e.match(event):
- print "forbidden event occurred:"
- for x in format_event(event):
- print x
- assert False
-
- def expect(self, type, **kw):
- pattern = EventPattern(type, **kw)
-
- while True:
- event = self.wait()
- self.log_event(event)
- self._check_forbidden(event)
-
- if pattern.match(event):
- self.log('handled')
- self.log('')
- return event
-
- self.log('not handled')
- self.log('')
-
- def expect_many(self, *patterns):
- ret = [None] * len(patterns)
-
- while None in ret:
- try:
- event = self.wait()
- except TimeoutError:
- self.log('timeout')
- self.log('still expecting:')
- for i, pattern in enumerate(patterns):
- if ret[i] is None:
- self.log(' - %r' % pattern)
- raise
- self.log_event(event)
- self._check_forbidden(event)
-
- for i, pattern in enumerate(patterns):
- if ret[i] is None and pattern.match(event):
- self.log('handled')
- self.log('')
- ret[i] = event
- break
- else:
- self.log('not handled')
- self.log('')
-
- return ret
-
- def demand(self, type, **kw):
- pattern = EventPattern(type, **kw)
-
- event = self.wait()
- self.log_event(event)
-
- if pattern.match(event):
- self.log('handled')
- self.log('')
- return event
-
- self.log('not handled')
- raise RuntimeError('expected %r, got %r' % (pattern, event))
-
-class IteratingEventQueue(BaseEventQueue):
- """Event queue that works by iterating the Twisted reactor."""
-
- def __init__(self, timeout=None):
- BaseEventQueue.__init__(self, timeout)
- self.events = []
-
- def wait(self):
- stop = [False]
-
- def later():
- stop[0] = True
-
- delayed_call = reactor.callLater(self.timeout, later)
-
- while (not self.events) and (not stop[0]):
- reactor.iterate(0.1)
-
- if self.events:
- delayed_call.cancel()
- return self.events.pop(0)
- else:
- raise TimeoutError
-
- def append(self, event):
- self.events.append(event)
-
- # compatibility
- handle_event = append
-
-class TestEventQueue(BaseEventQueue):
- def __init__(self, events):
- BaseEventQueue.__init__(self)
- self.events = events
-
- def wait(self):
- if self.events:
- return self.events.pop(0)
- else:
- raise TimeoutError
-
-class EventQueueTest(unittest.TestCase):
- def test_expect(self):
- queue = TestEventQueue([Event('foo'), Event('bar')])
- assert queue.expect('foo').type == 'foo'
- assert queue.expect('bar').type == 'bar'
-
- def test_expect_many(self):
- queue = TestEventQueue([Event('foo'), Event('bar')])
- bar, foo = queue.expect_many(
- EventPattern('bar'),
- EventPattern('foo'))
- assert bar.type == 'bar'
- assert foo.type == 'foo'
-
- def test_expect_many2(self):
- # Test that events are only matched against patterns that haven't yet
- # been matched. This tests a regression.
- queue = TestEventQueue([Event('foo', x=1), Event('foo', x=2)])
- foo1, foo2 = queue.expect_many(
- EventPattern('foo'),
- EventPattern('foo'))
- assert foo1.type == 'foo' and foo1.x == 1
- assert foo2.type == 'foo' and foo2.x == 2
-
- def test_timeout(self):
- queue = TestEventQueue([])
- self.assertRaises(TimeoutError, queue.expect, 'foo')
-
- def test_demand(self):
- queue = TestEventQueue([Event('foo'), Event('bar')])
- foo = queue.demand('foo')
- assert foo.type == 'foo'
-
- def test_demand_fail(self):
- queue = TestEventQueue([Event('foo'), Event('bar')])
- self.assertRaises(RuntimeError, queue.demand, 'bar')
-
-def unwrap(x):
- """Hack to unwrap D-Bus values, so that they're easier to read when
- printed."""
-
- if isinstance(x, list):
- return map(unwrap, x)
-
- if isinstance(x, tuple):
- return tuple(map(unwrap, x))
-
- if isinstance(x, dict):
- return dict([(unwrap(k), unwrap(v)) for k, v in x.iteritems()])
-
- if isinstance(x, dbus.Boolean):
- return bool(x)
-
- for t in [unicode, str, long, int, float]:
- if isinstance(x, t):
- return t(x)
-
- return x
-
-def call_async(test, proxy, method, *args, **kw):
- """Call a D-Bus method asynchronously and generate an event for the
- resulting method return/error."""
-
- def reply_func(*ret):
- test.handle_event(Event('dbus-return', method=method,
- value=unwrap(ret)))
-
- def error_func(err):
- test.handle_event(Event('dbus-error', method=method, error=err,
- name=err.get_dbus_name(), message=str(err)))
-
- method_proxy = getattr(proxy, method)
- kw.update({'reply_handler': reply_func, 'error_handler': error_func})
- method_proxy(*args, **kw)
-
-def sync_dbus(bus, q, conn):
- # Dummy D-Bus method call
- # This won't do the right thing unless the proxy has a unique name.
- assert conn.object.bus_name.startswith(':')
- root_object = bus.get_object(conn.object.bus_name, '/')
- call_async(
- q, dbus.Interface(root_object, 'org.freedesktop.DBus.Peer'), 'Ping')
- q.expect('dbus-return', method='Ping')
-
-class ProxyWrapper:
- def __init__(self, object, default, others):
- self.object = object
- self.default_interface = dbus.Interface(object, default)
- self.Properties = dbus.Interface(object, dbus.PROPERTIES_IFACE)
- self.TpProperties = \
- dbus.Interface(object, tp_name_prefix + '.Properties')
- self.interfaces = dict([
- (name, dbus.Interface(object, iface))
- for name, iface in others.iteritems()])
-
- def __getattr__(self, name):
- if name in self.interfaces:
- return self.interfaces[name]
-
- if name in self.object.__dict__:
- return getattr(self.object, name)
-
- return getattr(self.default_interface, name)
-
-def wrap_connection(conn):
- return ProxyWrapper(conn, tp_name_prefix + '.Connection',
- dict([
- (name, tp_name_prefix + '.Connection.Interface.' + name)
- for name in ['Aliasing', 'Avatars', 'Capabilities', 'Contacts',
- 'Presence', 'SimplePresence', 'Requests']] +
- [('Peer', 'org.freedesktop.DBus.Peer'),
- ('ContactCapabilities', cs.CONN_IFACE_CONTACT_CAPS),
- ('Location', cs.CONN_IFACE_LOCATION),
- ('Future', tp_name_prefix + '.Connection.FUTURE'),
- ]))
-
-def wrap_channel(chan, type_, extra=None):
- interfaces = {
- type_: tp_name_prefix + '.Channel.Type.' + type_,
- 'Group': tp_name_prefix + '.Channel.Interface.Group',
- }
-
- if extra:
- interfaces.update(dict([
- (name, tp_name_prefix + '.Channel.Interface.' + name)
- for name in extra]))
-
- return ProxyWrapper(chan, tp_name_prefix + '.Channel', interfaces)
-
-def make_connection(bus, event_func, name, proto, params):
- cm = bus.get_object(
- tp_name_prefix + '.ConnectionManager.%s' % name,
- tp_path_prefix + '/ConnectionManager/%s' % name)
- cm_iface = dbus.Interface(cm, tp_name_prefix + '.ConnectionManager')
-
- connection_name, connection_path = cm_iface.RequestConnection(
- proto, params)
- conn = wrap_connection(bus.get_object(connection_name, connection_path))
-
- bus.add_signal_receiver(
- lambda *args, **kw:
- event_func(
- Event('dbus-signal',
- path=unwrap(kw['path']),
- signal=kw['member'], args=map(unwrap, args),
- interface=kw['interface'])),
- None, # signal name
- None, # interface
- None,
- path_keyword='path',
- member_keyword='member',
- interface_keyword='interface',
- byte_arrays=True
- )
-
- return conn
-
-def make_channel_proxy(conn, path, iface):
- bus = dbus.SessionBus()
- chan = bus.get_object(conn.object.bus_name, path)
- chan = dbus.Interface(chan, tp_name_prefix + '.' + iface)
- return chan
-
-# block_reading can be used if the test want to choose when we start to read
-# data from the socket.
-class EventProtocol(Protocol):
- def __init__(self, queue=None, block_reading=False):
- self.queue = queue
- self.block_reading = block_reading
-
- def dataReceived(self, data):
- if self.queue is not None:
- self.queue.handle_event(Event('socket-data', protocol=self,
- data=data))
-
- def sendData(self, data):
- self.transport.write(data)
-
- def connectionMade(self):
- if self.block_reading:
- self.transport.stopReading()
-
- def connectionLost(self, reason=None):
- if self.queue is not None:
- self.queue.handle_event(Event('socket-disconnected', protocol=self))
-
-class EventProtocolFactory(Factory):
- def __init__(self, queue, block_reading=False):
- self.queue = queue
- self.block_reading = block_reading
-
- def _create_protocol(self):
- return EventProtocol(self.queue, self.block_reading)
-
- def buildProtocol(self, addr):
- proto = self._create_protocol()
- self.queue.handle_event(Event('socket-connected', protocol=proto))
- return proto
-
-class EventProtocolClientFactory(EventProtocolFactory, ClientFactory):
- pass
-
-def watch_tube_signals(q, tube):
- def got_signal_cb(*args, **kwargs):
- q.handle_event(Event('tube-signal',
- path=kwargs['path'],
- signal=kwargs['member'],
- args=map(unwrap, args),
- tube=tube))
-
- tube.add_signal_receiver(got_signal_cb,
- path_keyword='path', member_keyword='member',
- byte_arrays=True)
-
-def pretty(x):
- return pprint.pformat(unwrap(x))
-
-def assertEquals(expected, value):
- if expected != value:
- raise AssertionError(
- "expected:\n%s\ngot:\n%s" % (pretty(expected), pretty(value)))
-
-def assertNotEquals(expected, value):
- if expected == value:
- raise AssertionError(
- "expected something other than:\n%s" % pretty(value))
-
-def assertContains(element, value):
- if element not in value:
- raise AssertionError(
- "expected:\n%s\nin:\n%s" % (pretty(element), pretty(value)))
-
-def assertDoesNotContain(element, value):
- if element in value:
- raise AssertionError(
- "expected:\n%s\nnot in:\n%s" % (pretty(element), pretty(value)))
-
-def assertLength(length, value):
- if len(value) != length:
- raise AssertionError("expected: length %d, got length %d:\n%s" % (
- length, len(value), pretty(value)))
-
-def assertFlagsSet(flags, value):
- masked = value & flags
- if masked != flags:
- raise AssertionError(
- "expected flags %u, of which only %u are set in %u" % (
- flags, masked, value))
-
-def assertFlagsUnset(flags, value):
- masked = value & flags
- if masked != 0:
- raise AssertionError(
- "expected none of flags %u, but %u are set in %u" % (
- flags, masked, value))
-
-def install_colourer():
- def red(s):
- return '\x1b[31m%s\x1b[0m' % s
-
- def green(s):
- return '\x1b[32m%s\x1b[0m' % s
-
- patterns = {
- 'handled': green,
- 'not handled': red,
- }
-
- class Colourer:
- def __init__(self, fh, patterns):
- self.fh = fh
- self.patterns = patterns
-
- def write(self, s):
- f = self.patterns.get(s, lambda x: x)
- self.fh.write(f(s))
-
- sys.stdout = Colourer(sys.stdout, patterns)
- return sys.stdout
-
-if __name__ == '__main__':
- unittest.main()
-
diff --git a/tests/twisted/tools/Makefile.am b/tests/twisted/tools/Makefile.am
deleted file mode 100644
index 466ca33..0000000
--- a/tests/twisted/tools/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-exec-with-log.sh: exec-with-log.sh.in
- $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" \
- -e "s|[@]abs_top_srcdir[@]|@abs_top_srcdir@|g" $< > $@
- @chmod +x $@
-
-%.conf: %.conf.in
- $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@
-
-%.service: %.service.in
- $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@
-
-# D-Bus service file for testing
-# Don't use the full filename for the .in if > 99 character: >99 char filenames
-# in tarballs are non-portable (and automake 1.8 doesn't let us build
-# non-archaic tarballs)
-service_in_files = org.freedesktop.Telepathy.Client.Logger.service.in
-service_files = $(service_in_files:.service.in=.service)
-
-# D-Bus config file for testing
-conf_in_files = tmp-session-bus.conf.in
-conf_files = $(conf_in_files:.conf.in=.conf)
-
-BUILT_SOURCES = $(service_files) $(conf_files) exec-with-log.sh
-
-EXTRA_DIST = \
- $(service_in_files) \
- $(conf_in_files) \
- exec-with-log.sh.in \
- with-session-bus.sh
-
-CLEANFILES = \
- $(BUILT_SOURCES) \
- tpl-testing.log
diff --git a/tests/twisted/tools/exec-with-log.sh.in b/tests/twisted/tools/exec-with-log.sh.in
deleted file mode 100644
index d3a80f4..0000000
--- a/tests/twisted/tools/exec-with-log.sh.in
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-cd "@abs_top_builddir@/tests/twisted/tools"
-
-export TPL_DEBUG=all
-ulimit -c unlimited
-exec >> tpl-testing.log 2>&1
-
-if test -n "$TPL_TEST_VALGRIND"; then
- export G_DEBUG=${G_DEBUG:+"${G_DEBUG},"}gc-friendly
- export G_SLICE=always-malloc
- export DBUS_DISABLE_MEM_POOLS=1
- TPL_WRAPPER="valgrind --leak-check=full --num-callers=20"
- TPL_WRAPPER="$TPL_WRAPPER --show-reachable=yes"
- TPL_WRAPPER="$TPL_WRAPPER --gen-suppressions=all"
- TPL_WRAPPER="$TPL_WRAPPER --child-silent-after-fork=yes"
- TPL_WRAPPER="$TPL_WRAPPER --suppressions=@abs_top_srcdir@/tests/suppressions/tp-glib.supp"
- TPL_WRAPPER="$TPL_WRAPPER --suppressions=@abs_top_srcdir@/tests/suppressions/tpl.supp"
-elif test -n "$TPL_TEST_REFDBG"; then
- if test -z "$REFDBG_OPTIONS" ; then
- export REFDBG_OPTIONS="btnum=10"
- fi
- if test -z "$TPL_WRAPPER" ; then
- TPL_WRAPPER="refdbg"
- fi
-elif test -n "$TPL_TEST_STRACE"; then
- TPL_WRAPPER="strace -o strace.log"
-fi
-
-export G_DEBUG=fatal-warnings,fatal-criticals" ${G_DEBUG}"
-exec @abs_top_builddir@/libtool --mode=execute $TPL_WRAPPER ../telepathy-tpl-debug
diff --git a/tests/twisted/tools/failure-helper.sh b/tests/twisted/tools/failure-helper.sh
deleted file mode 100644
index d30f961..0000000
--- a/tests/twisted/tools/failure-helper.sh
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/sh
-#
-# Run a given test repeatedly until it fails at least once and passes at least
-# once. Places logs from the test and from the service being tested in the
-# given directory, and generates diffs between the fail and pass cases.
-
-error()
-{
- echo "$@" >&2
- exit 1
-}
-
-abspath()
-{
- if echo "$1" | grep -q "^/"; then
- echo "$1"
- else
- echo "$PWD/$1"
- fi
-}
-
-stripdiff()
-{
- a=`mktemp`
- b=`mktemp`
- python ../../tools/log-strip.py < "$1" > "$a"
- python ../../tools/log-strip.py < "$2" > "$b"
- diff -U40 "$a" "$b"
- rm "$a" "$b"
-}
-
-prog=tpl
-test_name="$1"
-log_dir="$2"
-
-usage="usage: $0 test-name log-directory"
-test -n "$test_name" || error "$usage"
-test -n "$log_dir" || error "$usage"
-
-cd `dirname $0`/..
-test -f "servicetest.py" || error "can't find servicetest.py"
-test -f "$test_name" || error "can't find that test"
-
-if ! test -d "$log_dir"; then
- if ! test -e "$log_dir"; then
- mkdir "$log_dir"
- else
- error "not a directory: $log_dir"
- fi
-fi
-
-log_dir=`abspath "$log_dir"`
-test_pass_log="$log_dir/test-pass.log"
-test_fail_log="$log_dir/test-fail.log"
-prog_pass_log="$log_dir/$prog-pass.log"
-prog_fail_log="$log_dir/$prog-fail.log"
-
-if test -e "$test_pass_log" -a -e "$prog_pass_log"; then
- echo "using existing pass"
- got_pass=true
-else
- got_pass=false
-fi
-
-if test -e "$test_fail_log" -a -e "$prog_fail_log"; then
- echo "using existing fail"
- got_fail=true
-else
- got_fail=false
-fi
-
-run=1
-
-while test "$got_pass" != true -o "$got_fail" != true; do
- echo -n "run $run: "
-
- CHECK_TWISTED_VERBOSE=1 make check-twisted TWISTED_TESTS="$test_name" \
- > "$log_dir/test.log" 2>&1
- ret=$?
-
- if test $ret -eq 0; then
- echo "pass"
- else
- echo "fail"
- fi
-
- if test $ret -eq 0 -a "$got_pass" != true; then
- mv "$log_dir/test.log" "$test_pass_log"
- cp "tools/$prog-testing.log" "$prog_pass_log"
- got_pass=true
- elif test $ret -ne 0 -a "$got_fail" != true; then
- mv "$log_dir/test.log" "$test_fail_log"
- cp "tools/$prog-testing.log" "$prog_fail_log"
- got_fail=true
- else
- rm "$log_dir/test.log"
- fi
-
- run=`expr $run + 1`
-done
-
-stripdiff "$test_pass_log" "$test_fail_log" > "$log_dir/test-log.diff"
-stripdiff "$prog_pass_log" "$prog_fail_log" > "$log_dir/$prog-log.diff"
-
-echo done
diff --git a/tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service.in b/tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service.in
deleted file mode 100644
index 3deff28..0000000
--- a/tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.freedesktop.Telepathy.Client.Logger
-Exec=@abs_top_builddir@/tests/twisted/tools/exec-with-log.sh
diff --git a/tests/twisted/tools/tmp-session-bus.conf.in b/tests/twisted/tools/tmp-session-bus.conf.in
deleted file mode 100644
index e863edd..0000000
--- a/tests/twisted/tools/tmp-session-bus.conf.in
+++ /dev/null
@@ -1,27 +0,0 @@
-<!-- This configuration file controls the per-user-login-session message bus.
- Add a session-local.conf and edit that rather than changing this
- file directly. -->
-
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
- <!-- Our well-known bus type, don't change this -->
- <type>session</type>
-
- <listen>unix:tmpdir=/tmp</listen>
-
- <servicedir>@abs_top_builddir@/tests/twisted/tools</servicedir>
-
- <policy context="default">
- <!-- Allow everything to be sent -->
- <allow send_destination="*" eavesdrop="true"/>
- <!-- Allow everything to be received -->
- <allow eavesdrop="true"/>
- <!-- Allow anyone to own anything -->
- <allow own="*"/>
- </policy>
-
- <!-- This is included last so local configuration can override what's
- in this standard file -->
-
-</busconfig>
diff --git a/tests/twisted/tools/with-session-bus.sh b/tests/twisted/tools/with-session-bus.sh
deleted file mode 100644
index 063bd7e..0000000
--- a/tests/twisted/tools/with-session-bus.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-# with-session-bus.sh - run a program with a temporary D-Bus session daemon
-#
-# The canonical location of this program is the telepathy-glib tools/
-# directory, please synchronize any changes with that copy.
-#
-# Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/>
-#
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved.
-
-set -e
-
-me=with-session-bus
-
-dbus_daemon_args="--print-address=5 --print-pid=6 --fork"
-sleep=0
-
-usage ()
-{
- echo "usage: $me [options] -- program [program_options]" >&2
- echo "Requires write access to the current directory." >&2
- echo "" >&2
- echo "If \$WITH_SESSION_BUS_FORK_DBUS_MONITOR is set, fork dbus-monitor" >&2
- echo "with the arguments in \$WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT." >&2
- echo "The output of dbus-monitor is saved in $me-<pid>.dbus-monitor-logs" >&2
- exit 2
-}
-
-while test "z$1" != "z--"; do
- case "$1" in
- --sleep=*)
- sleep="$1"
- sleep="${sleep#--sleep=}"
- shift
- ;;
- --session)
- dbus_daemon_args="$dbus_daemon_args --session"
- shift
- ;;
- --config-file=*)
- # FIXME: assumes config file doesn't contain any special characters
- dbus_daemon_args="$dbus_daemon_args $1"
- shift
- ;;
- *)
- usage
- ;;
- esac
-done
-shift
-if test "z$1" = "z"; then usage; fi
-
-exec 5> $me-$$.address
-exec 6> $me-$$.pid
-
-cleanup ()
-{
- pid=`head -n1 $me-$$.pid`
- if test -n "$pid" ; then
- echo "Killing temporary bus daemon: $pid" >&2
- kill -INT "$pid"
- fi
- rm -f $me-$$.address
- rm -f $me-$$.pid
-}
-
-trap cleanup INT HUP TERM
-dbus-daemon $dbus_daemon_args
-
-{ echo -n "Temporary bus daemon is "; cat $me-$$.address; } >&2
-{ echo -n "Temporary bus daemon PID is "; head -n1 $me-$$.pid; } >&2
-
-e=0
-DBUS_SESSION_BUS_ADDRESS="`cat $me-$$.address`"
-export DBUS_SESSION_BUS_ADDRESS
-
-if [ -n "$WITH_SESSION_BUS_FORK_DBUS_MONITOR" ] ; then
- echo -n "Forking dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT" >&2
- dbus-monitor $WITH_SESSION_BUS_FORK_DBUS_MONITOR_OPT \
- > $me-$$.dbus-monitor-logs 2>&1 &
-fi
-
-"$@" || e=$?
-
-if test $sleep != 0; then
- sleep $sleep
-fi
-
-trap - INT HUP TERM
-cleanup
-
-exit $e
diff --git a/tests/twisted/tpltest.py b/tests/twisted/tpltest.py
deleted file mode 100644
index 845bdfd..0000000
--- a/tests/twisted/tpltest.py
+++ /dev/null
@@ -1,580 +0,0 @@
-
-"""
-Infrastructure code for testing TPL by pretending to be a TP Channel Dispatcher.
-"""
-
-import base64
-import os
-import hashlib
-import sys
-import random
-import re
-import traceback
-
-import constants as cs
-import servicetest
-from servicetest import (
- assertEquals, assertLength, assertContains, wrap_channel, EventPattern, call_async
- )
-import twisted
-from twisted.words.xish import domish, xpath
-from twisted.words.protocols.jabber.client import IQ
-from twisted.words.protocols.jabber import xmlstream
-from twisted.internet import reactor
-
-import dbus
-
-NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl'
-NS_XMPP_BIND = 'urn:ietf:params:xml:ns:xmpp-bind'
-
-#def make_result_iq(stream, iq):
-# result = IQ(stream, "result")
-# result["id"] = iq["id"]
-# to = iq.getAttribute('to')
-# if to is not None:
-# result["from"] = to
-# query = iq.firstChildElement()
-#
-# if query:
-# result.addElement((query.uri, query.name))
-#
-# return result
-#
-#def acknowledge_iq(stream, iq):
-# stream.send(make_result_iq(stream, iq))
-#
-#def send_error_reply(stream, iq, error_stanza=None):
-# result = IQ(stream, "error")
-# result["id"] = iq["id"]
-# query = iq.firstChildElement()
-# to = iq.getAttribute('to')
-# if to is not None:
-# result["from"] = to
-#
-# if query:
-# result.addElement((query.uri, query.name))
-#
-# if error_stanza:
-# result.addChild(error_stanza)
-#
-# stream.send(result)
-#
-#def request_muc_handle(q, conn, stream, muc_jid):
-# servicetest.call_async(q, conn, 'RequestHandles', 2, [muc_jid])
-# event = q.expect('dbus-return', method='RequestHandles')
-# return event.value[0][0]
-#
-#def make_muc_presence(affiliation, role, muc_jid, alias, jid=None):
-# presence = domish.Element((None, 'presence'))
-# presence['from'] = '%s/%s' % (muc_jid, alias)
-# x = presence.addElement((ns.MUC_USER, 'x'))
-# item = x.addElement('item')
-# item['affiliation'] = affiliation
-# item['role'] = role
-# if jid is not None:
-# item['jid'] = jid
-# return presence
-#
-#def sync_stream(q, stream):
-# """Used to ensure that Gabble has processed all stanzas sent to it."""
-#
-# iq = IQ(stream, "get")
-# id = iq['id']
-# iq.addElement(('http://jabber.org/protocol/disco#info', 'query'))
-# stream.send(iq)
-# q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info',
-# predicate=(lambda event:
-# event.stanza['id'] == id and event.iq_type == 'result'))
-#
-#class JabberAuthenticator(xmlstream.Authenticator):
-# "Trivial XML stream authenticator that accepts one username/digest pair."
-#
-# def __init__(self, username, password, resource=None):
-# self.username = username
-# self.password = password
-# self.resource = resource
-# xmlstream.Authenticator.__init__(self)
-#
-# # Patch in fix from http://twistedmatrix.com/trac/changeset/23418.
-# # This monkeypatch taken from Gadget source code
-# from twisted.words.xish.utility import EventDispatcher
-#
-# def _addObserver(self, onetime, event, observerfn, priority, *args,
-# **kwargs):
-# if self._dispatchDepth > 0:
-# self._updateQueue.append(lambda: self._addObserver(onetime, event,
-# observerfn, priority, *args, **kwargs))
-#
-# return self._oldAddObserver(onetime, event, observerfn, priority,
-# *args, **kwargs)
-#
-# EventDispatcher._oldAddObserver = EventDispatcher._addObserver
-# EventDispatcher._addObserver = _addObserver
-#
-# def streamStarted(self, root=None):
-# if root:
-# self.xmlstream.sid = '%x' % random.randint(1, sys.maxint)
-#
-# self.xmlstream.sendHeader()
-# self.xmlstream.addOnetimeObserver(
-# "/iq/query[@xmlns='jabber:iq:auth']", self.initialIq)
-#
-# def initialIq(self, iq):
-# result = IQ(self.xmlstream, "result")
-# result["id"] = iq["id"]
-# query = result.addElement('query')
-# query["xmlns"] = "jabber:iq:auth"
-# query.addElement('username', content='test')
-# query.addElement('password')
-# query.addElement('digest')
-# query.addElement('resource')
-# self.xmlstream.addOnetimeObserver('/iq/query/username', self.secondIq)
-# self.xmlstream.send(result)
-#
-# def secondIq(self, iq):
-# username = xpath.queryForNodes('/iq/query/username', iq)
-# assert map(str, username) == [self.username]
-#
-# digest = xpath.queryForNodes('/iq/query/digest', iq)
-# expect = hashlib.sha1(self.xmlstream.sid + self.password).hexdigest()
-# assert map(str, digest) == [expect]
-#
-# resource = xpath.queryForNodes('/iq/query/resource', iq)
-# assertLength(1, resource)
-# if self.resource is not None:
-# assertEquals(self.resource, str(resource[0]))
-#
-# result = IQ(self.xmlstream, "result")
-# result["id"] = iq["id"]
-# self.xmlstream.send(result)
-# self.xmlstream.dispatch(self.xmlstream, xmlstream.STREAM_AUTHD_EVENT)
-
-
-#class XmppAuthenticator(xmlstream.Authenticator):
-# def __init__(self, username, password, resource=None):
-# xmlstream.Authenticator.__init__(self)
-# self.username = username
-# self.password = password
-# self.resource = resource
-# self.authenticated = False
-#
-# def streamStarted(self, root=None):
-# if root:
-# self.xmlstream.sid = root.getAttribute('id')
-#
-# self.xmlstream.sendHeader()
-#
-# if self.authenticated:
-# # Initiator authenticated itself, and has started a new stream.
-#
-# features = domish.Element((xmlstream.NS_STREAMS, 'features'))
-# bind = features.addElement((NS_XMPP_BIND, 'bind'))
-# self.xmlstream.send(features)
-#
-# self.xmlstream.addOnetimeObserver(
-# "/iq/bind[@xmlns='%s']" % NS_XMPP_BIND, self.bindIq)
-# else:
-# features = domish.Element((xmlstream.NS_STREAMS, 'features'))
-# mechanisms = features.addElement((NS_XMPP_SASL, 'mechanisms'))
-# mechanism = mechanisms.addElement('mechanism', content='PLAIN')
-# self.xmlstream.send(features)
-#
-# self.xmlstream.addOnetimeObserver("/auth", self.auth)
-#
-# def auth(self, auth):
-# assert (base64.b64decode(str(auth)) ==
-# '\x00%s\x00%s' % (self.username, self.password))
-#
-# success = domish.Element((NS_XMPP_SASL, 'success'))
-# self.xmlstream.send(success)
-# self.xmlstream.reset()
-# self.authenticated = True
-#
-# def bindIq(self, iq):
-# resource = xpath.queryForString('/iq/bind/resource', iq)
-# if self.resource is not None:
-# assertEquals(self.resource, resource)
-# else:
-# assert resource is not None
-#
-# result = IQ(self.xmlstream, "result")
-# result["id"] = iq["id"]
-# bind = result.addElement((NS_XMPP_BIND, 'bind'))
-# jid = bind.addElement('jid', content=('test@localhost/%s' % resource))
-# self.xmlstream.send(result)
-#
-# self.xmlstream.dispatch(self.xmlstream, xmlstream.STREAM_AUTHD_EVENT)
-
-#def make_stream_event(type, stanza):
-# event = servicetest.Event(type, stanza=stanza)
-# event.to = stanza.getAttribute("to")
-# return event
-#
-#def make_iq_event(iq):
-# event = make_stream_event('stream-iq', iq)
-# event.iq_type = iq.getAttribute("type")
-# event.iq_id = iq.getAttribute("id")
-# query = iq.firstChildElement()
-#
-# if query:
-# event.query = query
-# event.query_ns = query.uri
-# event.query_name = query.name
-#
-# if query.getAttribute("node"):
-# event.query_node = query.getAttribute("node")
-# else:
-# event.query = None
-#
-# return event
-#
-#def make_presence_event(stanza):
-# event = make_stream_event('stream-presence', stanza)
-# event.presence_type = stanza.getAttribute('type')
-# return event
-#
-#def make_message_event(stanza):
-# event = make_stream_event('stream-message', stanza)
-# event.message_type = stanza.getAttribute('type')
-# return event
-
-#class BaseXmlStream(xmlstream.XmlStream):
-# initiating = False
-# namespace = 'jabber:client'
-#
-# def __init__(self, event_func, authenticator):
-# xmlstream.XmlStream.__init__(self, authenticator)
-# self.event_func = event_func
-# self.addObserver('//iq', lambda x: event_func(
-# make_iq_event(x)))
-# self.addObserver('//message', lambda x: event_func(
-# make_message_event(x)))
-# self.addObserver('//presence', lambda x: event_func(
-# make_presence_event(x)))
-# self.addObserver('//event/stream/authd', self._cb_authd)
-#
-# def _cb_authd(self, _):
-# # called when stream is authenticated
-# self.addObserver(
-# "/iq/query[@xmlns='http://jabber.org/protocol/disco#info']",
-# self._cb_disco_iq)
-# self.event_func(servicetest.Event('stream-authenticated'))
-#
-# def _cb_disco_iq(self, iq):
-# if iq.getAttribute('to') == 'localhost':
-# # add PEP support
-# nodes = xpath.queryForNodes(
-# "/iq/query[@xmlns='http://jabber.org/protocol/disco#info']",
-# iq)
-# query = nodes[0]
-# identity = query.addElement('identity')
-# identity['category'] = 'pubsub'
-# identity['type'] = 'pep'
-#
-# iq['type'] = 'result'
-# iq['from'] = iq['to']
-# self.send(iq)
-#
-# def onDocumentEnd(self):
-# self.event_func(servicetest.Event('stream-closed'))
-# # We don't chain up XmlStream.onDocumentEnd() because it will
-# # disconnect the TCP connection making tests as
-# # connect/disconnect-timeout.py not working
-#
-#class JabberXmlStream(BaseXmlStream):
-# version = (0, 9)
-#
-#class XmppXmlStream(BaseXmlStream):
-# version = (1, 0)
-#
-#class GoogleXmlStream(BaseXmlStream):
-# version = (1, 0)
-#
-# def _cb_disco_iq(self, iq):
-# if iq.getAttribute('to') == 'localhost':
-# nodes = xpath.queryForNodes(
-# "/iq/query[@xmlns='http://jabber.org/protocol/disco#info']",
-# iq)
-# query = nodes[0]
-# feature = query.addElement('feature')
-# feature['var'] = ns.GOOGLE_ROSTER
-# feature = query.addElement('feature')
-# feature['var'] = ns.GOOGLE_JINGLE_INFO
-#
-# iq['type'] = 'result'
-# iq['from'] = 'localhost'
-# self.send(iq)
-
-#def make_connection(bus, event_func, params=None):
-# # Gabble accepts a resource in 'account', but the value of 'resource'
-# # overrides it if there is one.
-# account = 'test@localhost/%s' % re.sub(r'.*tests/twisted/', '', sys.argv[0])
-# default_params = {
-# 'account': account,
-# 'password': 'pass',
-# 'resource': 'Resource',
-# 'server': 'localhost',
-# 'port': dbus.UInt32(4242),
-# 'fallback-socks5-proxies': dbus.Array([], signature='s'),
-# }
-#
-# if params:
-# default_params.update(params)
-#
-# return servicetest.make_connection(bus, event_func, 'gabble', 'jabber',
-# default_params)
-#
-#def make_stream(event_func, authenticator=None, protocol=None, port=4242, resource=None):
-# # set up Jabber server
-#
-# if authenticator is None:
-# authenticator = XmppAuthenticator('test', 'pass', resource=resource)
-#
-# if protocol is None:
-# protocol = XmppXmlStream
-#
-# stream = protocol(event_func, authenticator)
-# factory = twisted.internet.protocol.Factory()
-# factory.protocol = lambda *args: stream
-# port = reactor.listenTCP(port, factory)
-# return (stream, port)
-#
-#def disconnect_conn(q, conn, stream, expected_before=[], expected_after=[]):
-# call_async(q, conn, 'Disconnect')
-#
-# tmp = expected_before + [
-# EventPattern('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]),
-# EventPattern('stream-closed')]
-#
-# before_events = q.expect_many(*tmp)
-#
-# stream.sendFooter()
-#
-# tmp = expected_after + [EventPattern('dbus-return', method='Disconnect')]
-# after_events = q.expect_many(*tmp)
-#
-# return before_events[:-2], after_events[:-1]
-
-def exec_test_deferred(fun, params, protocol=None, timeout=None,
- authenticator=None):
- # hack to ease debugging
- # TODO ? only gabble (1)
- domish.Element.__repr__ = domish.Element.toXml
- colourer = None
-
- if sys.stdout.isatty() or 'CHECK_FORCE_COLOR' in os.environ:
- colourer = servicetest.install_colourer()
-
- queue = servicetest.IteratingEventQueue(timeout)
- queue.verbose = (
- os.environ.get('CHECK_TWISTED_VERBOSE', '') != ''
- or '-v' in sys.argv)
-
- bus = dbus.SessionBus()
-
- error = None
-
- try:
- fun(queue, bus)
- except Exception, e:
- traceback.print_exc()
- error = e
-
- if colourer:
- sys.stdout = colourer.fh
-
-
-def exec_test(fun, params=None, protocol=None, timeout=None,
- authenticator=None):
- reactor.callWhenRunning(
- exec_test_deferred, fun, params, protocol, timeout, authenticator)
- reactor.run()
-
-# Useful routines for server-side vCard handling
-current_vcard = domish.Element(('vcard-temp', 'vCard'))
-
-def expect_and_handle_get_vcard(q, stream):
- get_vcard_event = q.expect('stream-iq', query_ns=ns.VCARD_TEMP,
- query_name='vCard', iq_type='get')
-
- iq = get_vcard_event.stanza
- vcard = iq.firstChildElement()
- assert vcard.name == 'vCard', vcard.toXml()
-
- # Send back current vCard
- result = make_result_iq(stream, iq)
- result.addChild(current_vcard)
- stream.send(result)
-
-def expect_and_handle_set_vcard(q, stream, check=None):
- set_vcard_event = q.expect('stream-iq', query_ns=ns.VCARD_TEMP,
- query_name='vCard', iq_type='set')
- iq = set_vcard_event.stanza
- vcard = iq.firstChildElement()
- assert vcard.name == 'vCard', vcard.toXml()
-
- if check is not None:
- check(vcard)
-
- # Update current vCard
- current_vcard = vcard
-
- stream.send(make_result_iq(stream, iq))
-
-def _elem_add(elem, *children):
- for child in children:
- if isinstance(child, domish.Element):
- elem.addChild(child)
- elif isinstance(child, unicode):
- elem.addContent(child)
- else:
- raise ValueError(
- 'invalid child object %r (must be element or unicode)', child)
-
-def elem(a, b=None, **kw):
- r"""
- >>> elem('foo')().toXml()
- u'<foo/>'
- >>> elem('foo', x='1')().toXml()
- u"<foo x='1'/>"
- >>> elem('foo', x='1')(u'hello').toXml()
- u"<foo x='1'>hello</foo>"
- >>> elem('foo', x='1')(u'hello',
- ... elem('http://foo.org', 'bar', y='2')(u'bye')).toXml()
- u"<foo x='1'>hello<bar xmlns='http://foo.org' y='2'>bye</bar></foo>"
- """
-
- class _elem(domish.Element):
- def __call__(self, *children):
- _elem_add(self, *children)
- return self
-
- if b is not None:
- elem = _elem((a, b))
- else:
- elem = _elem((None, a))
-
- for k, v in kw.iteritems():
- if k == 'from_':
- elem['from'] = v
- else:
- elem[k] = v
-
- return elem
-
-def elem_iq(server, type, **kw):
- class _iq(IQ):
- def __call__(self, *children):
- _elem_add(self, *children)
- return self
-
- iq = _iq(server, type)
-
- for k, v in kw.iteritems():
- if k == 'from_':
- iq['from'] = v
- else:
- iq[k] = v
-
- return iq
-
-def make_presence(_from, to='test@localhost', type=None, show=None,
- status=None, caps=None, photo=None):
- presence = domish.Element((None, 'presence'))
- presence['from'] = _from
- presence['to'] = to
-
- if type is not None:
- presence['type'] = type
-
- if show is not None:
- presence.addElement('show', content=show)
-
- if status is not None:
- presence.addElement('status', content=status)
-
- if caps is not None:
- cel = presence.addElement(('http://jabber.org/protocol/caps', 'c'))
- for key,value in caps.items():
- cel[key] = value
-
- # <x xmlns="vcard-temp:x:update"><photo>4a1...</photo></x>
- if photo is not None:
- x = presence.addElement((ns.VCARD_TEMP_UPDATE, 'x'))
- x.addElement('photo').addContent(photo)
-
- return presence
-
-def expect_list_channel(q, bus, conn, name, contacts, lp_contacts=[],
- rp_contacts=[]):
- return expect_contact_list_channel(q, bus, conn, cs.HT_LIST, name,
- contacts, lp_contacts=lp_contacts, rp_contacts=rp_contacts)
-
-def expect_group_channel(q, bus, conn, name, contacts, lp_contacts=[],
- rp_contacts=[]):
- return expect_contact_list_channel(q, bus, conn, cs.HT_GROUP, name,
- contacts, lp_contacts=lp_contacts, rp_contacts=rp_contacts)
-
-def expect_contact_list_channel(q, bus, conn, ht, name, contacts,
- lp_contacts=[], rp_contacts=[]):
- """
- Expects NewChannel and NewChannels signals for the
- contact list with handle type 'ht' and ID 'name', and checks that its
- members, lp members and rp members are exactly 'contacts', 'lp_contacts'
- and 'rp_contacts'.
- Returns a proxy for the channel.
- """
-
- old_signal, new_signal = q.expect_many(
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
-
- path, type, handle_type, handle, suppress_handler = old_signal.args
-
- assertEquals(cs.CHANNEL_TYPE_CONTACT_LIST, type)
- assertEquals(name, conn.InspectHandles(handle_type, [handle])[0])
-
- chan = wrap_channel(bus.get_object(conn.bus_name, path),
- cs.CHANNEL_TYPE_CONTACT_LIST)
- members = chan.Group.GetMembers()
-
- assertEquals(sorted(contacts),
- sorted(conn.InspectHandles(cs.HT_CONTACT, members)))
-
- lp_handles = conn.RequestHandles(cs.HT_CONTACT, lp_contacts)
- rp_handles = conn.RequestHandles(cs.HT_CONTACT, rp_contacts)
-
- # NB. comma: we're unpacking args. Thython!
- info, = new_signal.args
- assertLength(1, info) # one channel
- path_, emitted_props = info[0]
-
- assertEquals(path_, path)
-
- assertEquals(cs.CHANNEL_TYPE_CONTACT_LIST, emitted_props[cs.CHANNEL_TYPE])
- assertEquals(ht, emitted_props[cs.TARGET_HANDLE_TYPE])
- assertEquals(handle, emitted_props[cs.TARGET_HANDLE])
-
- channel_props = chan.Properties.GetAll(cs.CHANNEL)
- assertEquals(handle, channel_props.get('TargetHandle'))
- assertEquals(ht, channel_props.get('TargetHandleType'))
- assertEquals(cs.CHANNEL_TYPE_CONTACT_LIST, channel_props.get('ChannelType'))
- assertContains(cs.CHANNEL_IFACE_GROUP, channel_props.get('Interfaces'))
- assertEquals(name, channel_props['TargetID'])
- assertEquals(False, channel_props['Requested'])
- assertEquals('', channel_props['InitiatorID'])
- assertEquals(0, channel_props['InitiatorHandle'])
-
- group_props = chan.Properties.GetAll(cs.CHANNEL_IFACE_GROUP)
- assertContains('HandleOwners', group_props)
- assertContains('Members', group_props)
- assertEquals(members, group_props['Members'])
- assertContains('LocalPendingMembers', group_props)
- actual_lp_handles = [x[0] for x in group_props['LocalPendingMembers']]
- assertEquals(sorted(lp_handles), sorted(actual_lp_handles))
- assertContains('RemotePendingMembers', group_props)
- assertEquals(sorted(rp_handles), sorted(group_props['RemotePendingMembers']))
- assertContains('GroupFlags', group_props)
-
- return chan