1
# Copyright (C) 2009 Nokia Corporation
2
# Copyright (C) 2009 Collabora Ltd.
4
# This library is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU Lesser General Public
6
# License as published by the Free Software Foundation; either
7
# version 2.1 of the License, or (at your option) any later version.
9
# This library is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public
15
# License along with this library; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23
from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
25
from mctest import exec_test, create_fakecm_account
26
import constants as cs
29
account_manager = bus.get_object(cs.AM, cs.AM_PATH)
30
account_manager_iface = dbus.Interface(account_manager, cs.AM)
32
params = dbus.Dictionary({"account": "smcv@example.com",
33
"password": "secrecy"}, signature='sv')
34
(cm_name_ref, account) = create_fakecm_account(q, bus, mc, params)
36
account_iface = dbus.Interface(account, cs.ACCOUNT)
37
account_props = dbus.Interface(account, cs.PROPERTIES_IFACE)
39
# Ensure that it's enabled but has offline RP
41
call_async(q, account_props, 'Set', cs.ACCOUNT, 'RequestedPresence',
42
(dbus.UInt32(cs.PRESENCE_TYPE_OFFLINE), 'offline', ''))
43
q.expect('dbus-return', method='Set')
45
call_async(q, account_props, 'Set', cs.ACCOUNT, 'AutomaticPresence',
46
(dbus.UInt32(cs.PRESENCE_TYPE_BUSY), 'busy',
47
'Testing automatic presence'))
48
q.expect('dbus-return', method='Set')
49
q.expect('dbus-signal', signal='AccountPropertyChanged',
51
e.args[0].get('AutomaticPresence', (None, None, None))[1]
54
call_async(q, account_props, 'Set', cs.ACCOUNT, 'Enabled', True)
55
q.expect('dbus-return', method='Set')
56
q.expect('dbus-signal', signal='AccountPropertyChanged',
57
predicate=lambda e: e.args[0].get('Enabled'))
59
# Go online by telling it to connect automatically
60
call_async(q, account_props, 'Set', cs.ACCOUNT, 'ConnectAutomatically',
63
e = q.expect('dbus-method-call', method='RequestConnection',
64
args=['fakeprotocol', params],
65
destination=cs.tp_name_prefix + '.ConnectionManager.fakecm',
66
path=cs.tp_path_prefix + '/ConnectionManager/fakecm',
67
interface=cs.tp_name_prefix + '.ConnectionManager',
70
if __name__ == '__main__':