summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-02-18 16:04:13 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2010-02-18 17:24:00 +0000
commit1d732ed2d07652e47ccab4dbdef85796d57ab7fa (patch)
tree740cb1cef491c02080a7bce857fd1f25d8f9854d
parenta9879b6325a0faae823d6da7476ed5b83a962389 (diff)
Fix tests with --enable-is-a-phone
Not only did two different C source files hardcode that Gabble is a PC, but so did the test suite. This is why the tests passed when I only changed one of the hardcoded C strings; I don't know why I thought they passed when I fixed that, but... they didn't. :)
-rw-r--r--configure.ac4
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/caps_helper.py36
3 files changed, 26 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac
index 40a9c9c63..ef0ddccef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,11 +128,15 @@ AC_ARG_ENABLE([is-a-phone],
if test x$is_a_phone = xyes; then
AC_DEFINE(CLIENT_TYPE, ["phone"],
[Client type from http://xmpp.org/registrar/disco-categories.html#client])
+ CLIENT_TYPE=phone
else
AC_DEFINE(CLIENT_TYPE, ["pc"],
[Client type from http://xmpp.org/registrar/disco-categories.html#client])
+ CLIENT_TYPE=pc
fi
+AC_SUBST(CLIENT_TYPE)
+
dnl Check for Glib
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.16, gobject-2.0 >= 2.16, gthread-2.0 >= 2.16])
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 0c758e2d4..f497a9a03 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -195,6 +195,7 @@ endif
config.py: Makefile
$(QUIET_GEN) { \
echo "PACKAGE_STRING = \"$(PACKAGE_STRING)\""; \
+ echo "CLIENT_TYPE = '$(CLIENT_TYPE)'"; \
echo "DEBUGGING = $(DEBUGGING_PYBOOL)"; \
echo "ENABLE_ASSUMED_FT_CAP = $(ENABLE_ASSUMED_FT_CAP_PYBOOL)"; \
} > $@
diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
index 5a185420f..a200bacb3 100644
--- a/tests/twisted/caps_helper.py
+++ b/tests/twisted/caps_helper.py
@@ -4,13 +4,13 @@ import base64
import dbus
from twisted.words.xish import domish, xpath
-from gabbletest import make_result_iq, make_presence
+from gabbletest import make_result_iq, make_presence, elem_iq, elem
from servicetest import (
EventPattern,
assertEquals, assertContains, assertDoesNotContain, assertLength,
)
-from config import PACKAGE_STRING, ENABLE_ASSUMED_FT_CAP
+import config
import ns
import constants as cs
@@ -61,7 +61,7 @@ VARIABLE_CAPS = (
ns.TUBES + '/dbus#com.example.Xiangqi',
])
-if ENABLE_ASSUMED_FT_CAP:
+if config.ENABLE_ASSUMED_FT_CAP:
# For backwards compatibility, the default behaviour of the stable
# branch is to say that we can receive file transfers, even if no
# client seems to be able to. Disable with
@@ -222,27 +222,33 @@ def disco_caps(q, stream, presence):
assertEquals('sha-1', hash)
# ask caps
- request = """
-<iq from='fake_contact@jabber.org/resource'
- id='disco1'
- to='gabble@jabber.org/resource'
- type='get'>
- <query xmlns='""" + ns.DISCO_INFO + """'
- node='""" + node + '#' + ver + """'/>
-</iq>
-"""
+ request = \
+ elem_iq(stream, 'get', from_='fake_contact@jabber.org/resource')(
+ elem(ns.DISCO_INFO, 'query', node=(node + '#' + ver))
+ )
stream.send(request)
# receive caps
- event = q.expect('stream-iq', query_ns=ns.DISCO_INFO)
+ event = q.expect('stream-iq', query_ns=ns.DISCO_INFO, iq_id=request['id'])
+
+ # Check that Gabble's announcing the identity we think it should be.
+ identity_nodes = xpath.queryForNodes('/iq/query/identity', event.stanza)
+ assertLength(1, identity_nodes)
+ identity_node = identity_nodes[0]
+
+ assertEquals('client', identity_node['category'])
+ assertEquals(config.CLIENT_TYPE, identity_node['type'])
+ assertEquals(config.PACKAGE_STRING, identity_node['name'])
+ assertDoesNotContain('xml:lang', identity_node.attributes)
+
+ identity = 'client/%s//%s' % (config.CLIENT_TYPE, config.PACKAGE_STRING)
features = []
for feature in xpath.queryForNodes('/iq/query/feature', event.stanza):
features.append(feature['var'])
# Check if the hash matches the announced capabilities
- assertEquals(compute_caps_hash(['client/pc//%s' % PACKAGE_STRING], features, {}),
- ver)
+ assertEquals(compute_caps_hash([identity], features, {}), ver)
return (event, features)