Better handle some gtk tables that report themselves as lists.
This commit is contained in:
1 parent
824a4d2369
commit
3df96145f2
12 files changed
+382
-14
No files matched your search
+23
-5
@@ -5,7 +5,9 @@ import gi
|
||||
import os
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
gi.require_version("Gdk", "3.0")
|
||||
gi.require_version("Atk", "1.0")
|
||||
from gi.repository import Atk, Gdk, Gtk
|
||||
|
||||
|
||||
window = Gtk.Window(title="Table presentation probe")
|
||||
@@ -27,21 +29,37 @@ view.append_column(name_column)
|
||||
kind_renderer = Gtk.CellRendererText()
|
||||
view.append_column(Gtk.TreeViewColumn("Kind", kind_renderer, text=1))
|
||||
multi = os.environ.get("CTHULHU_GTK_TABLE_MULTI") == "1"
|
||||
listRole = os.environ.get("CTHULHU_GTK_TABLE_LIST") == "1"
|
||||
if multi:
|
||||
view.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||
if multi or listRole:
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
button = Gtk.Button(label="Before table")
|
||||
box.pack_start(button, False, False, 0)
|
||||
before = Gtk.Entry() if listRole else Gtk.Button(label="Before table")
|
||||
if listRole:
|
||||
before.get_accessible().set_name("Command")
|
||||
view.get_accessible().set_role(Atk.Role.LIST)
|
||||
|
||||
def on_entry_key_press(_entry, event):
|
||||
if event.keyval == Gdk.KEY_Down:
|
||||
view.grab_focus()
|
||||
view.get_selection().select_path(0)
|
||||
return True
|
||||
return False
|
||||
|
||||
before.connect("key-press-event", on_entry_key_press)
|
||||
box.pack_start(before, False, False, 0)
|
||||
box.pack_start(view, True, True, 0)
|
||||
window.add(box)
|
||||
else:
|
||||
window.add(view)
|
||||
view.get_selection().select_path(0)
|
||||
if listRole and not multi:
|
||||
view.get_selection().unselect_all()
|
||||
if multi:
|
||||
view.get_selection().select_path(1)
|
||||
window.show_all()
|
||||
if multi:
|
||||
button.grab_focus()
|
||||
if multi or listRole:
|
||||
before.grab_focus()
|
||||
else:
|
||||
view.grab_focus()
|
||||
Gtk.main()
|
||||
+14
-2
@@ -35,6 +35,9 @@ def run_inside():
|
||||
run_probe("box", flat=True, terminal=True, terminal_mode="prompt")
|
||||
run_table_probe()
|
||||
run_table_probe(multi=True)
|
||||
run_table_probe(list_role=True)
|
||||
run_table_probe(multi=True, list_role=True)
|
||||
run_table_probe(list_role=True, speech=True)
|
||||
if os.environ.get("CTHULHU_TEST_THUNAR") == "1":
|
||||
run_thunar_probe()
|
||||
|
||||
@@ -71,10 +74,12 @@ def run_thunar_probe():
|
||||
fixture.wait(timeout=3)
|
||||
|
||||
|
||||
def run_table_probe(multi: bool = False, screen_lock: bool = False) -> None:
|
||||
def run_table_probe(multi: bool = False, screen_lock: bool = False, list_role: bool = False, speech: bool = False) -> None:
|
||||
fixture_env = dict(os.environ)
|
||||
if multi:
|
||||
fixture_env["CTHULHU_GTK_TABLE_MULTI"] = "1"
|
||||
if list_role:
|
||||
fixture_env["CTHULHU_GTK_TABLE_LIST"] = "1"
|
||||
fixture = subprocess.Popen([sys.executable, str(Path(__file__).with_name("gtk_table.py"))], env=fixture_env)
|
||||
try:
|
||||
def find_window():
|
||||
@@ -87,6 +92,8 @@ def run_table_probe(multi: bool = False, screen_lock: bool = False) -> None:
|
||||
window = wait_for(find_window, "GTK table probe window missing")
|
||||
subprocess.run(["xdotool", "windowfocus", window], check=True)
|
||||
environment = dict(os.environ, CTHULHU_NATIVE_GUI_TABLE="1", CTHULHU_GUI_TABLE_WINDOW=window)
|
||||
if list_role:
|
||||
environment["CTHULHU_NATIVE_GUI_LIST_TABLE"] = "1"
|
||||
if multi:
|
||||
environment["CTHULHU_NATIVE_GUI_TABLE_MULTI"] = "1"
|
||||
environment.setdefault("GOCACHE", "/tmp/cthulhu-cache")
|
||||
@@ -95,8 +102,10 @@ def run_table_probe(multi: bool = False, screen_lock: bool = False) -> None:
|
||||
test_name = "^TestNativeGUITableScreenLockRecovery$"
|
||||
elif multi:
|
||||
test_name = "^TestNativeGUITableMultiselectionFocus$"
|
||||
elif list_role:
|
||||
test_name = "^TestNativeGUIListTableSpeech$" if speech else "^TestNativeGUIListTableFocus$"
|
||||
subprocess.run(
|
||||
["go", "test", "./internal/atspi", "-run", test_name, "-count=1", "-timeout=20s"],
|
||||
["go", "test", "./internal/app" if speech else "./internal/atspi", "-v", "-run", test_name, "-count=1", "-timeout=20s"],
|
||||
cwd=Path(__file__).resolve().parents[1], env=environment, check=True, timeout=25,
|
||||
)
|
||||
finally:
|
||||
@@ -165,6 +174,9 @@ def main() -> None:
|
||||
if len(sys.argv) == 2 and sys.argv[1] == "--inside-table":
|
||||
run_table_probe()
|
||||
run_table_probe(multi=True)
|
||||
run_table_probe(list_role=True)
|
||||
run_table_probe(multi=True, list_role=True)
|
||||
run_table_probe(list_role=True, speech=True)
|
||||
return
|
||||
with tempfile.TemporaryDirectory(prefix="cthulhu-atspi-"):
|
||||
read_fd, write_fd = os.pipe()
|
||||
|
||||
Reference in new issue
Block a user