|
Packit |
130fc8 |
#!/usr/bin/env python
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
# Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
|
|
Packit |
130fc8 |
#
|
|
Packit |
130fc8 |
# Permission is hereby granted, free of charge, to any person
|
|
Packit |
130fc8 |
# obtaining a copy of this software and associated documentation
|
|
Packit |
130fc8 |
# files (the "Software"), to deal in the Software without
|
|
Packit |
130fc8 |
# restriction, including without limitation the rights to use, copy,
|
|
Packit |
130fc8 |
# modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
Packit |
130fc8 |
# of the Software, and to permit persons to whom the Software is
|
|
Packit |
130fc8 |
# furnished to do so, subject to the following conditions:
|
|
Packit |
130fc8 |
#
|
|
Packit |
130fc8 |
# The above copyright notice and this permission notice shall be
|
|
Packit |
130fc8 |
# included in all copies or substantial portions of the Software.
|
|
Packit |
130fc8 |
#
|
|
Packit |
130fc8 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
130fc8 |
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit |
130fc8 |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
Packit |
130fc8 |
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
Packit |
130fc8 |
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
Packit |
130fc8 |
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
Packit |
130fc8 |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
Packit |
130fc8 |
# DEALINGS IN THE SOFTWARE.
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
from __future__ import print_function, unicode_literals
|
|
Packit |
130fc8 |
import logging
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
try:
|
|
Packit |
130fc8 |
from gi.repository import GObject as gobject
|
|
Packit |
130fc8 |
except ImportError:
|
|
Packit |
130fc8 |
raise SystemExit(77)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
from dbus import (
|
|
Packit |
130fc8 |
Array, Boolean, Byte, ByteArray, Double, Int16, Int32, Int64,
|
|
Packit |
130fc8 |
Interface, SessionBus, String, UInt16, UInt32, UInt64)
|
|
Packit |
130fc8 |
from dbus._compat import is_py2, is_py3
|
|
Packit |
130fc8 |
import dbus.glib
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if is_py2:
|
|
Packit |
130fc8 |
from dbus import UTF8String
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
from crosstest import (
|
|
Packit |
130fc8 |
CROSS_TEST_BUS_NAME, CROSS_TEST_PATH, INTERFACE_CALLBACK_TESTS,
|
|
Packit |
130fc8 |
INTERFACE_SIGNAL_TESTS, INTERFACE_SINGLE_TESTS, INTERFACE_TESTS,
|
|
Packit |
130fc8 |
SignalTestsImpl)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if is_py3:
|
|
Packit |
130fc8 |
def make_long(n):
|
|
Packit |
130fc8 |
return n
|
|
Packit |
130fc8 |
else:
|
|
Packit |
130fc8 |
def make_long(n):
|
|
Packit |
130fc8 |
return long(n)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
logging.basicConfig()
|
|
Packit |
130fc8 |
logging.getLogger().setLevel(1)
|
|
Packit |
130fc8 |
logger = logging.getLogger('cross-test-client')
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
class Client(SignalTestsImpl):
|
|
Packit |
130fc8 |
fail_id = 0
|
|
Packit |
130fc8 |
expected = set()
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def quit(self):
|
|
Packit |
130fc8 |
for x in self.expected:
|
|
Packit |
130fc8 |
self.fail_id += 1
|
|
Packit |
130fc8 |
print("%s fail %d" % (x, self.fail_id))
|
|
Packit |
130fc8 |
s = "report %d: reply to %s didn't arrive" % (self.fail_id, x)
|
|
Packit |
130fc8 |
print(s)
|
|
Packit |
130fc8 |
logger.error(s)
|
|
Packit |
130fc8 |
logger.info("asking server to Exit")
|
|
Packit |
130fc8 |
Interface(self.obj, INTERFACE_TESTS).Exit(reply_handler=self.quit_reply_handler, error_handler=self.quit_error_handler)
|
|
Packit |
130fc8 |
# if the server doesn't reply we'll just exit anyway
|
|
Packit |
130fc8 |
gobject.timeout_add(1000, lambda: (loop.quit(), False)[1])
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def quit_reply_handler(self):
|
|
Packit |
130fc8 |
logger.info("server says it will exit")
|
|
Packit |
130fc8 |
loop.quit()
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def quit_error_handler(self, e):
|
|
Packit |
130fc8 |
logger.error("error telling server to quit: %s %s",
|
|
Packit |
130fc8 |
e.__class__, e)
|
|
Packit |
130fc8 |
loop.quit()
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
@dbus.service.method(INTERFACE_CALLBACK_TESTS, 'qd')
|
|
Packit |
130fc8 |
def Response(self, input1, input2):
|
|
Packit |
130fc8 |
logger.info("signal/callback: Response received (%r,%r)",
|
|
Packit |
130fc8 |
input1, input2)
|
|
Packit |
130fc8 |
self.expected.discard('%s.Trigger' % INTERFACE_SIGNAL_TESTS)
|
|
Packit |
130fc8 |
if (input1, input2) != (42, 23):
|
|
Packit |
130fc8 |
self.fail_id += 1
|
|
Packit |
130fc8 |
print("%s.Trigger fail %d" %
|
|
Packit |
130fc8 |
(INTERFACE_SIGNAL_TESTS, self.fail_id))
|
|
Packit |
130fc8 |
s = ("report %d: expected (42,23), got %r"
|
|
Packit |
130fc8 |
% (self.fail_id, (input1, input2)))
|
|
Packit |
130fc8 |
logger.error(s)
|
|
Packit |
130fc8 |
print(s)
|
|
Packit |
130fc8 |
else:
|
|
Packit |
130fc8 |
print("%s.Trigger pass" % INTERFACE_SIGNAL_TESTS)
|
|
Packit |
130fc8 |
self.quit()
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def assert_method_matches(self, interface, check_fn, check_arg, member,
|
|
Packit |
130fc8 |
*args):
|
|
Packit |
130fc8 |
if_obj = Interface(self.obj, interface)
|
|
Packit |
130fc8 |
method = getattr(if_obj, member)
|
|
Packit |
130fc8 |
try:
|
|
Packit |
130fc8 |
real_ret = method(*args)
|
|
Packit |
130fc8 |
except Exception as e:
|
|
Packit |
130fc8 |
self.fail_id += 1
|
|
Packit |
130fc8 |
print("%s.%s fail %d" % (interface, member, self.fail_id))
|
|
Packit |
130fc8 |
s = ("report %d: %s.%s%r: raised %r \"%s\""
|
|
Packit |
130fc8 |
% (self.fail_id, interface, member, args, e, e))
|
|
Packit |
130fc8 |
print(s)
|
|
Packit |
130fc8 |
logger.error(s)
|
|
Packit |
130fc8 |
__import__('traceback').print_exc()
|
|
Packit |
130fc8 |
return
|
|
Packit |
130fc8 |
try:
|
|
Packit |
130fc8 |
check_fn(real_ret, check_arg)
|
|
Packit |
130fc8 |
except Exception as e:
|
|
Packit |
130fc8 |
self.fail_id += 1
|
|
Packit |
130fc8 |
print("%s.%s fail %d" % (interface, member, self.fail_id))
|
|
Packit |
130fc8 |
s = ("report %d: %s.%s%r: %s"
|
|
Packit |
130fc8 |
% (self.fail_id, interface, member, args, e))
|
|
Packit |
130fc8 |
print(s)
|
|
Packit |
130fc8 |
logger.error(s)
|
|
Packit |
130fc8 |
return
|
|
Packit |
130fc8 |
print("%s.%s pass" % (interface, member))
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def assert_method_eq(self, interface, ret, member, *args):
|
|
Packit |
130fc8 |
def equals(real_ret, exp):
|
|
Packit |
130fc8 |
if real_ret != exp:
|
|
Packit |
130fc8 |
raise AssertionError('expected %r of class %s, got %r of class %s' % (exp, exp.__class__, real_ret, real_ret.__class__))
|
|
Packit |
130fc8 |
if real_ret != exp:
|
|
Packit |
130fc8 |
raise AssertionError('expected %r, got %r' % (exp, real_ret))
|
|
Packit |
130fc8 |
if not isinstance(exp, (tuple, type(None))):
|
|
Packit |
130fc8 |
if real_ret.variant_level != getattr(exp, 'variant_level', 0):
|
|
Packit |
130fc8 |
raise AssertionError('expected variant_level=%d, got %r with level %d'
|
|
Packit |
130fc8 |
% (getattr(exp, 'variant_level', 0), real_ret,
|
|
Packit |
130fc8 |
real_ret.variant_level))
|
|
Packit |
130fc8 |
if isinstance(exp, list) or isinstance(exp, tuple):
|
|
Packit |
130fc8 |
for i in range(len(exp)):
|
|
Packit |
130fc8 |
try:
|
|
Packit |
130fc8 |
equals(real_ret[i], exp[i])
|
|
Packit |
130fc8 |
except AssertionError as e:
|
|
Packit |
130fc8 |
if not isinstance(e.args, tuple):
|
|
Packit |
130fc8 |
e.args = (e.args,)
|
|
Packit |
130fc8 |
e.args = e.args + ('(at position %d in sequence)' % i,)
|
|
Packit |
130fc8 |
raise e
|
|
Packit |
130fc8 |
elif isinstance(exp, dict):
|
|
Packit |
130fc8 |
for k in exp:
|
|
Packit |
130fc8 |
try:
|
|
Packit |
130fc8 |
equals(real_ret[k], exp[k])
|
|
Packit |
130fc8 |
except AssertionError as e:
|
|
Packit |
130fc8 |
if not isinstance(e.args, tuple):
|
|
Packit |
130fc8 |
e.args = (e.args,)
|
|
Packit |
130fc8 |
e.args = e.args + ('(at key %r in dict)' % k,)
|
|
Packit |
130fc8 |
raise e
|
|
Packit |
130fc8 |
self.assert_method_matches(interface, equals, ret, member, *args)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def assert_InvertMapping_eq(self, interface, expected, member, mapping):
|
|
Packit |
130fc8 |
def check(real_ret, exp):
|
|
Packit |
130fc8 |
for key in exp:
|
|
Packit |
130fc8 |
if key not in real_ret:
|
|
Packit |
130fc8 |
raise AssertionError('missing key %r' % key)
|
|
Packit |
130fc8 |
for key in real_ret:
|
|
Packit |
130fc8 |
if key not in exp:
|
|
Packit |
130fc8 |
raise AssertionError('unexpected key %r' % key)
|
|
Packit |
130fc8 |
got = list(real_ret[key])
|
|
Packit |
130fc8 |
wanted = list(exp[key])
|
|
Packit |
130fc8 |
got.sort()
|
|
Packit |
130fc8 |
wanted.sort()
|
|
Packit |
130fc8 |
if got != wanted:
|
|
Packit |
130fc8 |
raise AssertionError('expected %r => %r, got %r'
|
|
Packit |
130fc8 |
% (key, wanted, got))
|
|
Packit |
130fc8 |
self.assert_method_matches(interface, check, expected, member, mapping)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def triggered_cb(self, param, sender_path):
|
|
Packit |
130fc8 |
logger.info("method/signal: Triggered(%r) by %r",
|
|
Packit |
130fc8 |
param, sender_path)
|
|
Packit |
130fc8 |
self.expected.discard('%s.Trigger' % INTERFACE_TESTS)
|
|
Packit |
130fc8 |
if sender_path != '/Where/Ever':
|
|
Packit |
130fc8 |
self.fail_id += 1
|
|
Packit |
130fc8 |
print("%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id))
|
|
Packit |
130fc8 |
s = ("report %d: expected signal from /Where/Ever, got %r"
|
|
Packit |
130fc8 |
% (self.fail_id, sender_path))
|
|
Packit |
130fc8 |
print(s)
|
|
Packit |
130fc8 |
logger.error(s)
|
|
Packit |
130fc8 |
elif param != 42:
|
|
Packit |
130fc8 |
self.fail_id += 1
|
|
Packit |
130fc8 |
print("%s.Trigger fail %d" % (INTERFACE_TESTS, self.fail_id))
|
|
Packit |
130fc8 |
s = ("report %d: expected signal param 42, got %r"
|
|
Packit |
130fc8 |
% (self.fail_id, param))
|
|
Packit |
130fc8 |
print(s)
|
|
Packit |
130fc8 |
logger.error(s)
|
|
Packit |
130fc8 |
else:
|
|
Packit |
130fc8 |
print("%s.Trigger pass" % INTERFACE_TESTS)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def trigger_returned_cb(self):
|
|
Packit |
130fc8 |
logger.info('method/signal: Trigger() returned')
|
|
Packit |
130fc8 |
# Callback tests
|
|
Packit |
130fc8 |
logger.info("signal/callback: Emitting signal to trigger callback")
|
|
Packit |
130fc8 |
self.expected.add('%s.Trigger' % INTERFACE_SIGNAL_TESTS)
|
|
Packit |
130fc8 |
self.Trigger(UInt16(42), 23.0)
|
|
Packit |
130fc8 |
logger.info("signal/callback: Emitting signal returned")
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def run_client(self):
|
|
Packit |
130fc8 |
bus = SessionBus()
|
|
Packit |
130fc8 |
obj = bus.get_object(CROSS_TEST_BUS_NAME, CROSS_TEST_PATH)
|
|
Packit |
130fc8 |
self.obj = obj
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.run_synchronous_tests(obj)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
# Signal tests
|
|
Packit |
130fc8 |
logger.info("Binding signal handler for Triggered")
|
|
Packit |
130fc8 |
# FIXME: doesn't seem to work when going via the Interface method
|
|
Packit |
130fc8 |
# FIXME: should be possible to ask the proxy object for its
|
|
Packit |
130fc8 |
# bus name
|
|
Packit |
130fc8 |
bus.add_signal_receiver(self.triggered_cb, 'Triggered',
|
|
Packit |
130fc8 |
INTERFACE_SIGNAL_TESTS,
|
|
Packit |
130fc8 |
CROSS_TEST_BUS_NAME,
|
|
Packit |
130fc8 |
path_keyword='sender_path')
|
|
Packit |
130fc8 |
logger.info("method/signal: Triggering signal")
|
|
Packit |
130fc8 |
self.expected.add('%s.Trigger' % INTERFACE_TESTS)
|
|
Packit |
130fc8 |
Interface(obj, INTERFACE_TESTS).Trigger(
|
|
Packit |
130fc8 |
'/Where/Ever', dbus.UInt64(42),
|
|
Packit |
130fc8 |
reply_handler=self.trigger_returned_cb,
|
|
Packit |
130fc8 |
error_handler=self.trigger_error_handler)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def trigger_error_handler(self, e):
|
|
Packit |
130fc8 |
logger.error("method/signal: %s %s", e.__class__, e)
|
|
Packit |
130fc8 |
Interface(self.obj, INTERFACE_TESTS).Exit()
|
|
Packit |
130fc8 |
self.quit()
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
def run_synchronous_tests(self, obj):
|
|
Packit |
130fc8 |
# We can't test that coercion works correctly unless the server has
|
|
Packit |
130fc8 |
# sent us introspection data. Java doesn't :-/
|
|
Packit |
130fc8 |
have_signatures = True
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
# "Single tests"
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', [1, 2, 3])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum',
|
|
Packit |
130fc8 |
[b'\x01', b'\x02', b'\x03'])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', [Byte(1), Byte(2), Byte(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_SINGLE_TESTS, 6, 'Sum', ByteArray(b'\x01\x02\x03'))
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
# Main tests
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', String('foo'))
|
|
Packit |
130fc8 |
if is_py2:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', UTF8String('foo'))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=1), 'Identity', Byte(42))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=23), 'Identity', Byte(42, variant_level=23))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Double(42.5, variant_level=1), 'Identity', 42.5)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Double(-42.5, variant_level=1), 'Identity', -42.5)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, String('foo', variant_level=1), 'Identity', 'foo')
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Byte(42, variant_level=1), 'Identity', Byte(42))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Double(42.5, variant_level=1), 'Identity', Double(42.5))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Double(-42.5, variant_level=1), 'Identity', -42.5)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
for i in (0, 42, 255):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Byte(i), 'IdentityByte', Byte(i))
|
|
Packit |
130fc8 |
for i in (True, False):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityBool', i)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
for i in (-0x8000, 0, 42, 0x7fff):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt16', Int16(i))
|
|
Packit |
130fc8 |
for i in (0, 42, 0xffff):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt16', UInt16(i))
|
|
Packit |
130fc8 |
for i in (-0x7fffffff-1, 0, 42, 0x7fffffff):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt32', Int32(i))
|
|
Packit |
130fc8 |
for i in (0, 42, 0xffffffff):
|
|
Packit |
130fc8 |
i = make_long(i)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt32', UInt32(i))
|
|
Packit |
130fc8 |
MANY = 1
|
|
Packit |
130fc8 |
for n in (0x8000, 0x10000, 0x10000, 0x10000):
|
|
Packit |
130fc8 |
MANY *= make_long(n)
|
|
Packit |
130fc8 |
for i in (-MANY, 0, 42, MANY-1):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityInt64', Int64(i))
|
|
Packit |
130fc8 |
for i in (0, 42, 2*MANY - 1):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityUInt64', UInt64(i))
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42.3, 'IdentityDouble', 42.3)
|
|
Packit |
130fc8 |
for i in ('', 'foo'):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, i, 'IdentityString', i)
|
|
Packit |
130fc8 |
for i in ('\xa9', b'\xc2\xa9'):
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, '\xa9', 'IdentityString', i)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Byte(0x42),
|
|
Packit |
130fc8 |
'IdentityByte', b'\x42')
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, True, 'IdentityBool', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityInt16', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt16', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityInt32', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt32', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityInt64', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42, 'IdentityUInt64', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 42.0, 'IdentityDouble', 42)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [Byte(b'\x01', variant_level=1),
|
|
Packit |
130fc8 |
Byte(b'\x02', variant_level=1),
|
|
Packit |
130fc8 |
Byte(b'\x03', variant_level=1)],
|
|
Packit |
130fc8 |
'IdentityArray',
|
|
Packit |
130fc8 |
Array([Byte(b'\x01'),
|
|
Packit |
130fc8 |
Byte(b'\x02'),
|
|
Packit |
130fc8 |
Byte(b'\x03')],
|
|
Packit |
130fc8 |
signature='v'))
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [Int32(1, variant_level=1),
|
|
Packit |
130fc8 |
Int32(2, variant_level=1),
|
|
Packit |
130fc8 |
Int32(3, variant_level=1)],
|
|
Packit |
130fc8 |
'IdentityArray',
|
|
Packit |
130fc8 |
Array([Int32(1),
|
|
Packit |
130fc8 |
Int32(2),
|
|
Packit |
130fc8 |
Int32(3)],
|
|
Packit |
130fc8 |
signature='v'))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [String('a', variant_level=1),
|
|
Packit |
130fc8 |
String('b', variant_level=1),
|
|
Packit |
130fc8 |
String('c', variant_level=1)],
|
|
Packit |
130fc8 |
'IdentityArray',
|
|
Packit |
130fc8 |
Array([String('a'),
|
|
Packit |
130fc8 |
String('b'),
|
|
Packit |
130fc8 |
String('c')],
|
|
Packit |
130fc8 |
signature='v'))
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [Byte(b'\x01', variant_level=1),
|
|
Packit |
130fc8 |
Byte(b'\x02', variant_level=1),
|
|
Packit |
130fc8 |
Byte(b'\x03', variant_level=1)],
|
|
Packit |
130fc8 |
'IdentityArray',
|
|
Packit |
130fc8 |
ByteArray(b'\x01\x02\x03'))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [Int32(1, variant_level=1),
|
|
Packit |
130fc8 |
Int32(2, variant_level=1),
|
|
Packit |
130fc8 |
Int32(3, variant_level=1)],
|
|
Packit |
130fc8 |
'IdentityArray',
|
|
Packit |
130fc8 |
[Int32(1),
|
|
Packit |
130fc8 |
Int32(2),
|
|
Packit |
130fc8 |
Int32(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [String('a', variant_level=1),
|
|
Packit |
130fc8 |
String('b', variant_level=1),
|
|
Packit |
130fc8 |
String('c', variant_level=1)],
|
|
Packit |
130fc8 |
'IdentityArray',
|
|
Packit |
130fc8 |
['a','b','c'])
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS,
|
|
Packit |
130fc8 |
[Byte(1), Byte(2), Byte(3)],
|
|
Packit |
130fc8 |
'IdentityByteArray',
|
|
Packit |
130fc8 |
ByteArray(b'\x01\x02\x03'))
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3],
|
|
Packit |
130fc8 |
'IdentityByteArray',
|
|
Packit |
130fc8 |
[b'\x01', b'\x02', b'\x03'])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [False,True], 'IdentityBoolArray', [False,True])
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [False,True,True], 'IdentityBoolArray', [0,1,2])
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityInt16Array', [Int16(1),Int16(2),Int16(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityUInt16Array', [UInt16(1),UInt16(2),UInt16(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityInt32Array', [Int32(1),Int32(2),Int32(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityUInt32Array', [UInt32(1),UInt32(2),UInt32(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityInt64Array', [Int64(1),Int64(2),Int64(3)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityUInt64Array', [UInt64(1),UInt64(2),UInt64(3)])
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityInt16Array', [1,2,3])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityUInt16Array', [1,2,3])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityInt32Array', [1,2,3])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityUInt32Array', [1,2,3])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityInt64Array', [1,2,3])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1,2,3], 'IdentityUInt64Array', [1,2,3])
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1.0,2.5,3.1], 'IdentityDoubleArray', [1.0,2.5,3.1])
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, [1.0,2.5,3.1], 'IdentityDoubleArray', [1,2.5,3.1])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, ['a','b','c'], 'IdentityStringArray', ['a','b','c'])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 6, 'Sum', [Int32(1),Int32(2),Int32(3)])
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, 6, 'Sum', [1,2,3])
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_InvertMapping_eq(INTERFACE_TESTS, {'fps': ['unreal', 'quake'], 'rts': ['warcraft']}, 'InvertMapping', {'unreal': 'fps', 'quake': 'fps', 'warcraft': 'rts'})
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, ('a', 1, 2), 'DeStruct', ('a', UInt32(1), Int16(2)))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Array([String('x', variant_level=1)]),
|
|
Packit |
130fc8 |
'Primitize', [String('x', variant_level=1)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Array([String('x', variant_level=1)]),
|
|
Packit |
130fc8 |
'Primitize', [String('x', variant_level=23)])
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS,
|
|
Packit |
130fc8 |
Array([String('x', variant_level=1),
|
|
Packit |
130fc8 |
Byte(1, variant_level=1),
|
|
Packit |
130fc8 |
Byte(2, variant_level=1)]),
|
|
Packit |
130fc8 |
'Primitize',
|
|
Packit |
130fc8 |
Array([String('x'), Byte(1), Byte(2)],
|
|
Packit |
130fc8 |
signature='v'))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS,
|
|
Packit |
130fc8 |
Array([String('x', variant_level=1),
|
|
Packit |
130fc8 |
Byte(1, variant_level=1),
|
|
Packit |
130fc8 |
Byte(2, variant_level=1)]),
|
|
Packit |
130fc8 |
'Primitize',
|
|
Packit |
130fc8 |
Array([String('x'), Array([Byte(1), Byte(2)])],
|
|
Packit |
130fc8 |
signature='v'))
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Boolean(False), 'Invert', True)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Boolean(True), 'Invert', False)
|
|
Packit |
130fc8 |
if have_signatures:
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Boolean(False), 'Invert', 42)
|
|
Packit |
130fc8 |
self.assert_method_eq(INTERFACE_TESTS, Boolean(True), 'Invert', 0)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
if __name__ == '__main__':
|
|
Packit |
130fc8 |
# FIXME: should be possible to export objects without a bus name
|
|
Packit |
130fc8 |
if 0:
|
|
Packit |
130fc8 |
client = Client(dbus.SessionBus(), '/Client')
|
|
Packit |
130fc8 |
else:
|
|
Packit |
130fc8 |
# the Java cross test's interpretation is that the client should be
|
|
Packit |
130fc8 |
# at /Test too
|
|
Packit |
130fc8 |
client = Client(dbus.SessionBus(), '/Test')
|
|
Packit |
130fc8 |
gobject.idle_add(client.run_client)
|
|
Packit |
130fc8 |
|
|
Packit |
130fc8 |
loop = gobject.MainLoop()
|
|
Packit |
130fc8 |
logger.info("running...")
|
|
Packit |
130fc8 |
loop.run()
|
|
Packit |
130fc8 |
logger.info("main loop exited.")
|