summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-03-20 09:29:10 +0100
committerStef Walter <stefw@collabora.co.uk>2011-03-22 11:32:28 +0100
commit3b85364606beb5592fd456990e7fb14b4b6a9689 (patch)
tree112681f67253e46473c3e1a5ee473dbf54449051
parent150140a2a28b8112e3eaba5ebf66b928f0a1288e (diff)
Add ytstenut test.
Register local-ytstenut property and salut properly in test environment.
-rw-r--r--.gitignore1
-rw-r--r--configure.ac10
-rw-r--r--mission-control/mcp-account-manager-ytstenut.c2
-rw-r--r--tests/twisted/Makefile.am3
-rw-r--r--tests/twisted/mctest.py2
-rw-r--r--tests/twisted/servicetest.py2
-rw-r--r--tests/twisted/telepathy/managers/salut.manager8
-rw-r--r--tests/twisted/tools/Makefile.am3
-rw-r--r--tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.salut.service.in3
-rwxr-xr-xtests/twisted/ytstenut/account.py102
10 files changed, 132 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index e1f15c8..a57ee3f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ stamp-h1
/tests/twisted/tools/exec-with-log.sh
/tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service
/tests/twisted/tools/org.freedesktop.Telepathy.MissionControl5.service
+/tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.salut.service
/tests/twisted/tools/tmp-session-bus.conf
/tests/twisted/tools/missioncontrol*.log
/tests/twisted/tmp-*/
diff --git a/configure.ac b/configure.ac
index 7000cea..83628a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,15 @@ AC_SUBST(SALUT_CFLAGS)
salutplugindir=`pkg-config --variable=plugindir telepathy-salut`
AC_SUBST(salutplugindir)
+AC_MSG_CHECKING([telepathy-salut executable])
+SALUT_EXECUTABLE=`pkg-config --variable=salutpath telepathy-salut`
+if test "$SALUT_EXECUTABLE" = ""; then
+ AC_MSG_ERROR([could not determine location of telepathy-salut executable])
+else
+ AC_MSG_RESULT([$SALUT_EXECUTABLE])
+fi
+AC_SUBST(SALUT_EXECUTABLE)
+
# ------------------------------------------------------------------------------
AC_ARG_ENABLE(debug,
@@ -97,4 +106,5 @@ AC_OUTPUT([
tests/twisted/tools/tmp-session-bus.conf
tests/twisted/tools/org.freedesktop.Telepathy.MissionControl5.service
tests/twisted/tools/org.freedesktop.Telepathy.Client.Logger.service
+ tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.salut.service
])
diff --git a/mission-control/mcp-account-manager-ytstenut.c b/mission-control/mcp-account-manager-ytstenut.c
index 1e70957..e7c786e 100644
--- a/mission-control/mcp-account-manager-ytstenut.c
+++ b/mission-control/mcp-account-manager-ytstenut.c
@@ -78,6 +78,8 @@ static const Parameter account_parameters[] = {
{ "ConnectAutomatically", "true" },
{ "Hidden", "true" },
{ "Enabled", "true" },
+
+ { "param-account", "automatic" },
};
static const Parameter account_translated_parameters[] = {
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 2d00747..89d8847 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -1,6 +1,7 @@
TWISTED_TESTS =
-TWISTED_BASIC_TESTS =
+TWISTED_BASIC_TESTS = \
+ ytstenut/account.py
config.py: Makefile
$(AM_V_GEN) { \
diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py
index d1a966d..58af3cb 100644
--- a/tests/twisted/mctest.py
+++ b/tests/twisted/mctest.py
@@ -114,7 +114,7 @@ def exec_test_deferred (fun, params, protocol=None, timeout=None,
queue.cleanup()
if error is None:
- reactor.callLater(0, reactor.stop)
+ reactor.callLater(0, reactor.crash)
else:
# please ignore the POSIX behind the curtain
os._exit(1)
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py
index 45a5c76..e8a93ef 100644
--- a/tests/twisted/servicetest.py
+++ b/tests/twisted/servicetest.py
@@ -84,7 +84,7 @@ class EventPattern:
except AttributeError:
return False
- if self.predicate(event):
+ if self.predicate is None or self.predicate(event):
return True
return False
diff --git a/tests/twisted/telepathy/managers/salut.manager b/tests/twisted/telepathy/managers/salut.manager
new file mode 100644
index 0000000..d634f50
--- /dev/null
+++ b/tests/twisted/telepathy/managers/salut.manager
@@ -0,0 +1,8 @@
+
+[ConnectionManager]
+BusName=org.freedesktop.Telepathy.ConnectionManager.salut
+ObjectPath=/org/freedesktop/Telepathy/ConnectionManager/salut
+Interfaces=
+
+[Protocol local-ytstenut]
+param-account=s
diff --git a/tests/twisted/tools/Makefile.am b/tests/twisted/tools/Makefile.am
index b39b15b..faa58bb 100644
--- a/tests/twisted/tools/Makefile.am
+++ b/tests/twisted/tools/Makefile.am
@@ -1,7 +1,8 @@
# D-Bus service file for testing
service_in_files = \
org.freedesktop.Telepathy.MissionControl5.service.in \
- org.freedesktop.Telepathy.Client.Logger.service.in
+ org.freedesktop.Telepathy.Client.Logger.service.in \
+ org.freedesktop.Telepathy.ConnectionManager.salut.service.in
service_files = $(service_in_files:.conf.in=.conf)
# D-Bus config file for testing
diff --git a/tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.salut.service.in b/tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.salut.service.in
new file mode 100644
index 0000000..e9a6edf
--- /dev/null
+++ b/tests/twisted/tools/org.freedesktop.Telepathy.ConnectionManager.salut.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.freedesktop.Telepathy.ConnectionManager.salut
+Exec=@SALUT_EXECUTABLE@
diff --git a/tests/twisted/ytstenut/account.py b/tests/twisted/ytstenut/account.py
new file mode 100755
index 0000000..920e92e
--- /dev/null
+++ b/tests/twisted/ytstenut/account.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2011 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
+
+import dbus
+import dbus
+import dbus.service
+
+from servicetest import assertContains, assertEquals, assertSameSets
+from servicetest import unwrap, ProxyWrapper, EventPattern, TimeoutError
+from mctest import exec_test, create_fakecm_account
+import constants as cs
+
+YTST_ACCOUNT_MANAGER_PATH = "/com/meego/xpmn/ytstenut/AccountManager"
+YTST_ACCOUNT_MANAGER_IFACE = "com.meego.xpmn.ytstenut.AccountManager"
+YTST_ACCOUNT_PATH = "/org/freedesktop/Telepathy/Account/salut/local_ytstenut/automatic_account"
+
+def is_account_going_online(event):
+ presence = event.args[0].get("RequestedPresence")
+ if presence and presence[0] == cs.PRESENCE_TYPE_AVAILABLE:
+ return True
+ return False
+
+def is_account_going_offline(event):
+ presence = event.args[0].get("RequestedPresence")
+ if presence and presence[0] == cs.PRESENCE_TYPE_OFFLINE:
+ return True
+ return False
+
+def test_account_exists(q, bus, mc):
+ manager = bus.get_object(cs.MC, YTST_ACCOUNT_MANAGER_PATH)
+ manager_props = dbus.Interface (manager, dbus.PROPERTIES_IFACE)
+
+ account_path = manager_props.Get (YTST_ACCOUNT_MANAGER_IFACE, "Account")
+ assertEquals (account_path, YTST_ACCOUNT_PATH)
+
+ account = bus.get_object(cs.MC, account_path)
+ account_props = dbus.Interface (account, dbus.PROPERTIES_IFACE)
+
+ enabled = account_props.Get (cs.ACCOUNT, "Enabled")
+ assertEquals(enabled, True)
+
+def test_hold_and_release(q, bus, mc):
+ q.timeout = 6 # Just longer than Release() timeout
+
+ # Create an object that will proxy for a particular remote object.
+ manager = bus.get_object(cs.MC, YTST_ACCOUNT_MANAGER_PATH)
+ manager_ytst = dbus.Interface (manager, YTST_ACCOUNT_MANAGER_IFACE)
+
+ manager_ytst.Hold()
+
+ q.expect('dbus-signal', signal='AccountPropertyChanged',
+ path=YTST_ACCOUNT_PATH, predicate=is_account_going_online)
+
+ manager_ytst.Release()
+
+ q.expect('dbus-signal', signal='AccountPropertyChanged',
+ path=YTST_ACCOUNT_PATH, predicate=is_account_going_offline)
+
+def test_hold_and_no_release(q, bus, mc):
+ q.timeout = 6 # Just longer than Release() timeout
+
+ # Create an object that will proxy for a particular remote object.
+ manager = bus.get_object(cs.MC, YTST_ACCOUNT_MANAGER_PATH)
+ manager_ytst = dbus.Interface (manager, YTST_ACCOUNT_MANAGER_IFACE)
+
+ manager_ytst.Hold()
+
+ q.expect('dbus-signal', signal='AccountPropertyChanged',
+ path=YTST_ACCOUNT_PATH, predicate=is_account_going_online)
+
+ # This second hold should cancel the release
+ manager_ytst.Release()
+ manager_ytst.Hold()
+
+ try:
+ q.expect('dbus-signal', signal='AccountPropertyChanged',
+ path=YTST_ACCOUNT_PATH, predicate=is_account_going_offline)
+ except TimeoutError:
+ pass
+ else:
+ assert False
+
+if __name__ == '__main__':
+ exec_test(test_account_exists, {})
+ exec_test(test_hold_and_release, {})
+ exec_test(test_hold_and_no_release, {})