summaryrefslogtreecommitdiffstats
path: root/tests/basic.py
blob: 1006ecff2c6c62bb30a723e5b07a13a8fdeeb4f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#! /usr/bin/python

# This a simple test, using the dogtail framework:
#
# Click on All, Installed, Updates and check that the button state
# and the main page content update as expected. Type a few characters
# on the overview page, hit Enter, and verify that we end up on the
# search page. Hit Escape and verify that we go back to the overview
# page.

from gi.repository import Gio

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

import os
from dogtail.tree import *
from dogtail.utils import *
from dogtail.procedural import *

try:
    run('gnome-software')

    app_name = 'gnome-software'
    app = root.application(app_name)

    all_button = app.child('All')
    installed_button = app.child('Installed')
    updates_button = app.child('Updates')
    back_button = app.child('Go back')

    overview_page = app.child('Overview page')
    installed_page = app.child('Installed page')
    updates_page = app.child('Updates page')
    search_page = app.child('Search page')
    details_page = app.child('Details page')
    install_button = details_page.child('Install')
    uninstall_button = details_page.child('Uninstall')

    search_page_listbox = search_page.child(roleName='list box')

    all_button.click()
    assert (all_button.checked)
    assert (not installed_button.checked)
    assert (not updates_button.checked)
    assert (overview_page.showing)
    assert (not installed_page.showing)
    assert (not updates_page.showing)
    assert (not search_page.showing)

    installed_button.click()
    assert (not all_button.checked)
    assert (installed_button.checked)
    assert (not updates_button.checked)
    assert (not overview_page.showing)
    assert (installed_page.showing)
    assert (not updates_page.showing)
    assert (not search_page.showing)

    updates_button.click()
    assert (not all_button.checked)
    assert (not installed_button.checked)
    assert (updates_button.checked)
    assert (not overview_page.showing)
    assert (not installed_page.showing)
    assert (updates_page.showing)
    assert (not search_page.showing)

    installed_button.click()
    assert (not all_button.checked)
    assert (installed_button.checked)
    assert (not updates_button.checked)
    assert (not overview_page.showing)
    assert (installed_page.showing)
    assert (not updates_page.showing)
    assert (not search_page.showing)

    all_button.click()
    assert (all_button.checked)
    assert (not installed_button.checked)
    assert (not updates_button.checked)
    assert (overview_page.showing)
    assert (not installed_page.showing)
    assert (not updates_page.showing)
    assert (not search_page.showing)

    type("archive\n")
    doDelay(2)
    assert (not all_button.checked)
    assert (not installed_button.checked)
    assert (not updates_button.checked)
    assert (not overview_page.showing)
    assert (not installed_page.showing)
    assert (not updates_page.showing)
    assert (search_page.showing)

    """Details page test section"""
    search_page_listbox.child(roleName='label', name='Archive Manager').click()
    doDelay(4)
    assert (not overview_page.showing)
    assert (not installed_page.showing)
    assert (not updates_page.showing)
    assert (not search_page.showing)
    assert (details_page.showing)
    assert (install_button.showing or uninstall_button.showing)
    assert (back_button.showing)
    assert (root.application(app_name).child('Details page')
            .child(roleName='push button', name='History')
            .states.contains(pyatspi.STATE_VISIBLE))
    assert (root.application(app_name).child('Details page')
            .child(roleName='push button', name='Website')
            .states.contains(pyatspi.STATE_VISIBLE))

    if install_button.showing:
        assert (not root.application(app_name).child('Details page')
                    .child(roleName='push button', name='Launch')
                    .states.contains(pyatspi.STATE_VISIBLE))
    else:
        assert (root.application(app_name).child('Details page')
                .child(roleName='push button', name='Launch')
                .states.contains(pyatspi.STATE_VISIBLE))

    back_button.click()
    assert (not all_button.checked)
    assert (not installed_button.checked)
    assert (not updates_button.checked)
    assert (not overview_page.showing)
    assert (not installed_page.showing)
    assert (not updates_page.showing)
    assert (search_page.showing)
    assert (not install_button.showing)
    assert (not uninstall_button.showing)
    assert (not back_button.showing)

    keyCombo("Escape")
    assert (all_button.checked)
    assert (not installed_button.checked)
    assert (not updates_button.checked)
    assert (overview_page.showing)
    assert (not installed_page.showing)
    assert (not updates_page.showing)
    assert (not search_page.showing)

    super_menu = root.application('gnome-shell').child(roleName='menu', name='Software')
    super_menu.click()
    root.application('gnome-shell').child(roleName='label', name='Software Sources').click()
    assert (len(app.children) == 2)
    sources_dialog = app.children[-1]
    assert (sources_dialog.child(roleName='label', name='Software Sources'))
finally:
    os.system("killall gnome-software")