[telepathy-glib/master] Don't let MC5 activate itself during AM tests.

David Laban david.laban at collabora.co.uk
Tue Nov 24 08:56:56 PST 2009


This sets up dbus to use a session.conf which doesn't include the
standard services.
This is the same trick that gabble's twisted tests use.

I'm not really sure whether tests/dbus/dbus-1/session.conf.in is the
best place to put the new file. If anyone thinks there is a better
place for it, shout.
---
 .gitignore                        |    1 +
 tests/dbus/Makefile.am            |    7 ++++++-
 tests/dbus/account-manager.c      |   33 +++++++++++++++++++++++++++++++++
 tests/dbus/dbus-1/session.conf.in |   30 ++++++++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 1 deletions(-)
 create mode 100644 tests/dbus/dbus-1/session.conf.in

diff --git a/.gitignore b/.gitignore
index f5e676d..f14a250 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,6 +65,7 @@ missing
 stamp-h1
 tags
 /telepathy-glib-0.7.*
+tests/dbus/dbus-1/session.conf
 tests/dbus/test-*
 tests/test-*
 tests/tools/actual.h
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 7fc5d4b..026a78a 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -169,7 +169,8 @@ TESTS_ENVIRONMENT = \
     XDG_DATA_HOME=@abs_builddir@ \
     XDG_DATA_DIRS=@abs_srcdir@ \
     G_DEBUG=fatal_warnings,fatal_criticals \
-    sh $(top_srcdir)/tools/with-session-bus.sh --session --
+    sh $(top_srcdir)/tools/with-session-bus.sh \
+	--config-file=dbus-1/session.conf --
 
 check-valgrind:
 	$(MAKE) check-TESTS \
@@ -186,6 +187,7 @@ VALGRIND_TESTS_ENVIRONMENT = \
         $(VALGRIND_FLAGS)
 
 BUILT_SOURCES = \
+	dbus-1/session.conf \
 	_gen/errors-check.h \
 	_gen/svc.h \
 	_gen/svc.c
@@ -203,6 +205,9 @@ EXTRA_DIST = \
     telepathy/managers/test_manager_file_invalid.manager \
     with-properties.xml
 
+dbus-1/%.conf: dbus-1/%.conf.in
+	sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@
+
 _gen/svc.c _gen/svc.h: with-properties.xml \
 	$(top_srcdir)/tools/glib-ginterface-gen.py \
 	Makefile.am
diff --git a/tests/dbus/account-manager.c b/tests/dbus/account-manager.c
index 2d13148..79b8ffd 100644
--- a/tests/dbus/account-manager.c
+++ b/tests/dbus/account-manager.c
@@ -241,6 +241,7 @@ finish_prepare_action (GObject *source_object,
   Test *test = (Test *) user_data;
   gboolean is_prepared_reply;
   TpAccountManager *am = TP_ACCOUNT_MANAGER (source_object);
+
   g_assert (test->am == am);
   test->prepared = tp_account_manager_prepare_finish (am, res, &test->error);
   is_prepared_reply = tp_account_manager_is_prepared (test->am,
@@ -259,6 +260,36 @@ prepare_action (gpointer script_data,
   tp_account_manager_prepare_async (test->am, NULL, finish_prepare_action, test);
 }
 
+/* We really don't want to have MC being launched during this test */
+static void
+finish_assert_am_not_activatable_action (TpDBusDaemon *proxy,
+    const gchar * const *names,
+    const GError *error,
+    gpointer user_data,
+    GObject *weak_object)
+{
+  guint i;
+
+  g_assert (error == NULL);
+
+  for (i=0; names[i] != NULL; i++)
+    {
+      g_assert_cmpstr (names[i], !=, TP_ACCOUNT_MANAGER_BUS_NAME);
+      g_assert_cmpstr (names[i], !=, "org.freedesktop.Telepathy.MissionControl5");
+    }
+
+  script_continue (user_data);
+}
+
+static void
+assert_am_not_activatable_action (gpointer script_data,
+    gpointer user_data)
+{
+  Test *test = (Test *) script_data;
+
+  tp_dbus_daemon_list_activatable_names (test->dbus, 500,
+      finish_assert_am_not_activatable_action, test, NULL, NULL);
+}
 
 static void
 assert_ok_action (gpointer script_data,
@@ -321,6 +352,7 @@ finish_account_prepare_action (GObject *source_object,
 {
   Test *test = (Test *) user_data;
   TpAccount *account = TP_ACCOUNT (source_object);
+
   g_assert (test->account == account);
   test->prepared = tp_account_prepare_finish (account, res, &test->error);
   g_assert (test->prepared == tp_account_is_prepared (account, TP_ACCOUNT_FEATURE_CORE));
@@ -362,6 +394,7 @@ static void
 test_prepare (Test *test,
     gconstpointer data G_GNUC_UNUSED)
 {
+  script_append_action (test, assert_am_not_activatable_action, NULL);
   script_append_action (test, prepare_action, NULL);
   script_append_action (test, noop_action, NULL);
 }
diff --git a/tests/dbus/dbus-1/session.conf.in b/tests/dbus/dbus-1/session.conf.in
new file mode 100644
index 0000000..52fe180
--- /dev/null
+++ b/tests/dbus/dbus-1/session.conf.in
@@ -0,0 +1,30 @@
+<!-- Copied from telepathy-gabble (which doubtless copied it from somewhere
+     else) and modified.
+     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/dbus/dbus-1/services/</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>
-- 
1.5.6.5




More information about the telepathy-commits mailing list