File: interact

package info (click to toggle)
liferea 1.15.8-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,652 kB
  • sloc: ansic: 27,425; javascript: 1,646; python: 1,123; makefile: 657; sh: 115; xml: 13
file content (170 lines) | stat: -rwxr-xr-x 4,453 bytes parent folder | download
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#! /usr/bin/python3

# Wrapping copied from:
# https://salsa.debian.org/ci-team/autopkgtest-help/-/issues/6
# So thanks to josch

import atexit
import os
import shutil
import signal
import subprocess
import sys
import tempfile
import time

from gi.repository.GLib import GError
from time import sleep


def start_dbus():
    pid_r, pid_w = os.pipe()
    addr_r, addr_w = os.pipe()
    os.set_inheritable(pid_w, True)
    os.set_inheritable(addr_w, True)
    subprocess.check_call(
        [
            "dbus-daemon",
            "--fork",
            "--session",
            "--print-address=%d" % addr_w,
            "--print-pid=%d" % pid_w,
        ],
        close_fds=False,
    )
    os.close(pid_w)
    os.close(addr_w)
    dbuspid = int(os.read(pid_r, 4096).decode("ascii").strip())
 #   atexit.register(os.kill, dbuspid, signal.SIGTERM)
    dbusaddr = os.read(addr_r, 4096).decode("ascii").strip()
    os.close(pid_r)
    os.close(addr_r)
    os.environ["DBUS_SESSION_BUS_ADDRESS"] = dbusaddr


def setup_dirs():
    if "AUTOPKGTEST_TMP" not in os.environ:
        tmpdir = tempfile.mkdtemp()
#        atexit.register(shutil.rmtree, tmpdir)
        os.environ["AUTOPKGTEST_TMP"] = tmpdir
    home = os.environ["AUTOPKGTEST_TMP"] + "/home"
    for v, p in [
        ("HOME", home),
        ("XDG_CONFIG_HOME", home + "/.config"),
        ("XDG_DATA_HOME", home + "/.local/share"),
        ("XDG_CACHE_HOME", home + "/.cache"),
        ("XDG_RUNTIME_DIR", home + "/runtime"),
    ]:
        os.environ[v] = p
        os.makedirs(p, exist_ok=True)


def enable_a11y():
    subprocess.check_call(
        [
            "gsettings",
            "set",
            "org.gnome.desktop.interface",
            "toolkit-accessibility",
            "true",
        ]
    )


def main():
    os.environ["LC_ALL"] = 'C.UTF-8'
    os.environ['LANG'] = 'en_US.UTF-8'
    os.environ['QT_ACCESSIBILITY'] = '1'

    # This test needs a DISPLAY, so if we don't have one, run ourselves via
    # xvfb-run
    if "DISPLAY" not in os.environ:
        os.environ["XAUTHORITY"] = "/dev/null"
        subprocess.check_call(
            ["xvfb-run", "--auto-servernum"] + sys.argv, env=os.environ
        )
        exit()

    setup_dirs()
    start_dbus()
    enable_a11y()

    # Dogtail requires that Assistive Technology support be enabled before it
    # can be imported, hence we do it here after enable_a11y()
    from dogtail.config import config
    from dogtail.procedural import focus, click
    from dogtail.tree import root
    from dogtail.utils import run
    from dogtail.utils import screenshot

    config.debugSearching = True
    config.debugTranslation = False
    config.logDebugToFile = False
    if "AUTOPKGTEST_ARTIFACTS" in os.environ:
        config.scratchDir = os.environ["AUTOPKGTEST_ARTIFACTS"]

    run('liferea', timeout=10)
    focus.application('net.sourceforge.liferea')

    screenshot("010_after_startup.png")
    click('View')
    click('Fullscreen')
    screenshot("020_after_fullscreen.png")

    click('Help')
    click('Contents')

    click('Help')
    click('Quick Reference')

    click('Help')
    click('FAQ')

    click('Help')
    click('About')
    click('Credits')
    screenshot("030_credits.png")
    click('Close')

    click('Item')
    click('Next Unread Item')

    click('Planet Debian')
    click('Feed')
    click('Properties')
    click('Source')
    screenshot("040_planet-debian-source.png")
    focus.text()
    screenshot("050_planet-debian-source-focussed.png")
    click('OK')

    liferea = root.application('net.sourceforge.liferea')
    try:
        # Crashes on s390x (but who would be using liferea on s390x anyways)
        liferea.dump()
    except GError:
        pass

    # Somehow since liferea 1.15.5 dogtail get confused otherwise after the previous call
    focus.application('net.sourceforge.liferea')
    liferea.keyCombo('F11')
    try:
        click('Help Contents')
    except AttributeError:
        # Why does s390x have another title? The tab is called "Help Topics"
        # while the html title says "Help Contents"
        click('Help Topics')
    screenshot("060_help_focussed.png")
    liferea.keyCombo('<Control>w')
    liferea.keyCombo('<Control>w')
    liferea.keyCombo('<Control>w')

    # Quit
    focus.application('net.sourceforge.liferea')
    click('Subscriptions')
    screenshot("070_before-quit.png")
    click('Quit')


if __name__ == "__main__":
    main()