Files
cthulhu/tests/native_tentacle_settings.py

48 lines
2.6 KiB
Python

"""Focused private GTK/AT-SPI checks for Tentacle settings and shortcut labels."""
from native_x11 import wait_for
def check_page(pyatspi, window, nodes, named, walk, focus, key, request, send, initial):
tabs = next(n for n in nodes if n.getRole() == pyatspi.ROLE_PAGE_TAB_LIST)
index = next(i for i, n in enumerate(tabs) if n.name == "Tentacles")
assert tabs.querySelection().selectChild(index)
wait_for(lambda: tabs[index].getState().contains(pyatspi.STATE_SELECTED), "Tentacles page missing")
tree = next(n for n in nodes if n.name == "Tentacles" and
n.getRole() in (pyatspi.ROLE_TABLE, pyatspi.ROLE_TREE_TABLE))
focus(tree)
key("Home")
shortcut = "Desktop: Cthulhu+Ctrl+Shift+W (Probe menu)"
wait_for(lambda: any(n.name == shortcut for n in walk(tree)), "acknowledged shortcut missing")
settings = named("Settings")
status = named(initial["Message"])
wait_for(lambda: settings.getState().contains(pyatspi.STATE_SENSITIVE), "Settings is disabled")
focus(settings)
key("Tab")
wait_for(lambda: named("Retry").getState().contains(pyatspi.STATE_FOCUSED), "Tab trapped after Settings")
key("shift+Tab")
wait_for(lambda: settings.getState().contains(pyatspi.STATE_FOCUSED), "Shift+Tab did not return to Settings")
key("Return")
sent = request()
assert sent["Tentacle"]["Action"] == "settings" and sent["Tentacle"]["ID"] == "probe", sent
send({"Accepted": False, "Message": "No settings for this tentacle."})
wait_for(lambda: status.name == "No settings for this tentacle." and
status.getState().contains(pyatspi.STATE_FOCUSED),
"no-settings status missing")
focus(settings)
key("Return")
assert request()["Tentacle"]["Action"] == "settings"
send({"Accepted": True})
wait_for(lambda: settings.getState().contains(pyatspi.STATE_FOCUSED), "settings response moved focus")
# A following refresh response must retain the selected tentacle and controls.
focus(named("Refresh status"))
key("Return")
assert request()["Tentacle"]["Action"] == "list"
send({"Accepted": True, "Tentacles": initial["Tentacles"], "Message": "Tentacle status."})
wait_for(lambda: status.name == "Tentacle status.", "refresh response missing")
focus(settings)
key("Return")
assert request()["Tentacle"]["ID"] == "probe"
send({"Accepted": False, "Message": "No settings for this tentacle."})
wait_for(lambda: status.name == "No settings for this tentacle.", "status missing")
print("PASS: Settings request, no-settings status, shortcut label, Tab/Shift+Tab and selected-row retention", flush=True)