actions.py 2.19 KB
Newer Older
Matthias Clasen's avatar
Matthias Clasen committed
1 2 3 4 5 6 7 8
#! /usr/bin/python

# This a simple test, using the dogtail framework:
#
# Activate the app via the org.gtk.Application bus interface.
# Check that the expected actions are exported on the session bus.
# Activate each action and verify the result.

9
import os
10 11 12 13 14
from gi.repository import Gio

settings = Gio.Settings.new("org.gnome.desktop.interface")
settings.set_boolean ("toolkit-accessibility", True)

Matthias Clasen's avatar
Matthias Clasen committed
15 16 17
from dogtail.tree import *
from dogtail.utils import *
from dogtail.procedural import *
18
from dogtail.rawinput import keyCombo
Matthias Clasen's avatar
Matthias Clasen committed
19

20 21 22
try:
    run('gnome-software')

23
    app = root.application('gnome-software')
24 25 26 27 28 29 30 31 32

    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)

33 34 35 36 37 38 39
    doDelay(1)
    try:
        shopping_button = app.child(name=u'Let\u2019s Go Shopping', retry=False)
        shopping_button.click()
    except tree.SearchError:
        print "not first-run, moving on"

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    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)
59
    keyCombo("<Esc>")
60 61 62 63 64 65 66 67 68
    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")