[evolution] tests: when switching tabs make sure required service is running



commit f6d59b3008cb3a41a160ec018761108d042d3159
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Thu Apr 24 13:52:35 2014 +0200

    tests: when switching tabs make sure required service is running

 tests/steps/steps.py |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/tests/steps/steps.py b/tests/steps/steps.py
index 6a600e1..78b19d2 100644
--- a/tests/steps/steps.py
+++ b/tests/steps/steps.py
@@ -5,6 +5,7 @@ from dogtail.tree import root
 from dogtail.rawinput import keyCombo
 from time import sleep
 from os import system
+from gi.repository import Gio
 
 
 @step(u'Help section "{name}" is displayed')
@@ -47,6 +48,28 @@ def open_section_by_name(context, section_name):
     context.app.menu('View').menu('Window').point()
     context.app.menu('View').menu('Window').menuItem(section_name).click()
 
+    # Check that service required for this sections is running
+    required_services = {
+        'Mail': 'org.gnome.evolution.dataserver.Sources',
+        'Calendar': 'org.gnome.evolution.dataserver.Calendar',
+        'Tasks': 'org.gnome.evolution.dataserver.Calendar',
+        'Memos': 'org.gnome.evolution.dataserver.Calendar',
+        'Contacts': 'org.gnome.evolution.dataserver.AddressBook',
+    }
+    required_service = required_services[section_name]
+    bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
+    dbus_proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None,
+                                        'org.freedesktop.DBus',
+                                        '/org/freedesktop/DBus',
+                                        'org.freedesktop.DBus', None)
+    for attempt in xrange(0, 10):
+        result = dbus_proxy.call_sync(
+            'ListNames', None, Gio.DBusCallFlags.NO_AUTO_START, 500, None)
+        sleep(1)
+        if True in [required_service in x for x in result[0]]:
+            return
+    raise RuntimeError("%s service was not found" % required_service)
+
 
 @step(u'"{name}" menu is opened')
 def menu_is_opened(context, name):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]