[gnome-software] tests: kill gnome-software after each test



commit 4a957801ac73d7a8db763cd90c53b64c6bfcbe9a
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Wed Feb 26 13:36:52 2014 +0100

    tests: kill gnome-software after each test
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725219

 tests/actions.py |   81 +++++++++++++++++----------------
 tests/basic.py   |  135 +++++++++++++++++++++++++++--------------------------
 2 files changed, 111 insertions(+), 105 deletions(-)
---
diff --git a/tests/actions.py b/tests/actions.py
index 9df2b7f..c43a8d0 100755
--- a/tests/actions.py
+++ b/tests/actions.py
@@ -16,42 +16,45 @@ from dogtail.tree import *
 from dogtail.utils import *
 from dogtail.procedural import *
 
-run('gnome-software')
-
-app = root.application('gnome-software');
-
-bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
-proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE,
-                               None,
-                               'org.gnome.Software',
-                               '/org/gnome/Software',
-                               'org.gtk.Application')
-proxy.call_sync('Activate', GLib.Variant('(a{sv})', ({},)), 0, -1, None)
-
-doDelay(1)
-assert (len(app.children) == 1)
-
-dbus_actions = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE,
-                                      None,
-                                      'org.gnome.Software',
-                                      '/org/gnome/Software',
-                                      'org.gtk.Actions')
-
-names = dbus_actions.call_sync('List', None, 0, -1, None).unpack()[0]
-assert (u'quit' in names)
-assert (u'about' in names)
-
-dbus_actions.call_sync('Activate',
-                       GLib.Variant('(sava{sv})', (u'about', [], {})),
-                       0, -1, None)
-
-doDelay (1)
-assert (len(app.children) == 2)
-app.dialog('About Software').child('Close').click()
-doDelay (1)
-assert (len(app.children) == 1)
-
-dbus_actions.call_sync('Activate',
-                       GLib.Variant('(sava{sv})', (u'quit', [], {})),
-                       0, -1, None)
-assert (len(app.children) == 0)
+try:
+    run('gnome-software')
+
+    app = root.application('gnome-software');
+
+    bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
+    proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE,
+                                   None,
+                                   'org.gnome.Software',
+                                   '/org/gnome/Software',
+                                   'org.gtk.Application')
+    proxy.call_sync('Activate', GLib.Variant('(a{sv})', ({},)), 0, -1, None)
+
+    doDelay(1)
+    assert (len(app.children) == 1)
+
+    dbus_actions = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE,
+                                          None,
+                                          'org.gnome.Software',
+                                          '/org/gnome/Software',
+                                          'org.gtk.Actions')
+
+    names = dbus_actions.call_sync('List', None, 0, -1, None).unpack()[0]
+    assert (u'quit' in names)
+    assert (u'about' in names)
+
+    dbus_actions.call_sync('Activate',
+                           GLib.Variant('(sava{sv})', (u'about', [], {})),
+                           0, -1, None)
+
+    doDelay (1)
+    assert (len(app.children) == 2)
+    app.dialog('About Software').child('Close').click()
+    doDelay (1)
+    assert (len(app.children) == 1)
+
+    dbus_actions.call_sync('Activate',
+                           GLib.Variant('(sava{sv})', (u'quit', [], {})),
+                           0, -1, None)
+    assert (len(app.children) == 0)
+finally:
+    os.system("killall gnome-software")
diff --git a/tests/basic.py b/tests/basic.py
index 86c2b89..f8a7fc0 100755
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -18,79 +18,82 @@ from dogtail.tree import *
 from dogtail.utils import *
 from dogtail.procedural import *
 
-run('gnome-software')
+try:
+    run('gnome-software')
 
-app = root.application('gnome-software');
+    app = root.application('gnome-software');
 
-all_button = app.child('All')
-installed_button = app.child('Installed')
-updates_button = app.child('Updates')
+    all_button = app.child('All')
+    installed_button = app.child('Installed')
+    updates_button = app.child('Updates')
 
-overview_page = app.child('Overview page')
-installed_page = app.child('Installed page')
-updates_page = app.child('Updates page')
-search_page = app.child('Search page')
+    overview_page = app.child('Overview page')
+    installed_page = app.child('Installed page')
+    updates_page = app.child('Updates page')
+    search_page = app.child('Search page')
 
-all_button.click()
-assert (all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+    all_button.click()
+    assert (all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
 
-installed_button.click()
-assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+    installed_button.click()
+    assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
 
-updates_button.click()
-assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+    updates_button.click()
+    assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
 
-installed_button.click()
-assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+    installed_button.click()
+    assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
 
-all_button.click()
-assert (all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+    all_button.click()
+    assert (all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
 
-type("gimp\n")
-doDelay(2)
-assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (search_page.getState().contains(pyatspi.STATE_SHOWING))
+    type("gimp\n")
+    doDelay(2)
+    assert (not all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (search_page.getState().contains(pyatspi.STATE_SHOWING))
 
-keyCombo("Escape")
-assert (all_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
-assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
-assert (overview_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
-assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+    keyCombo("Escape")
+    assert (all_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not installed_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (not updates_button.getState().contains(pyatspi.STATE_ARMED))
+    assert (overview_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not installed_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not updates_page.getState().contains(pyatspi.STATE_SHOWING))
+    assert (not search_page.getState().contains(pyatspi.STATE_SHOWING))
+finally:
+    os.system("killall gnome-software")


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