Found more weird breakage on Slint. Fixed now.

This commit is contained in:
Storm Dragon committed 2026-11-02 17:28:31 +00:00
1 parent 6df27c88de
commit 7918fc02c4
14 files changed
+502 -6

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
# Copyright (c) 2026 Storm Dragon
# Authors: Storm Dragon, Angus Kola
# SPDX-License-Identifier: GPL-3.0-or-later
"""Exercise Toby's editable read-only combo under a private AT-SPI session."""
import os
from pathlib import Path
import site
import subprocess
import sys
import tempfile
import time
from native_test_session import run_private_session
def wait_for_window():
deadline = time.monotonic() + 5
while time.monotonic() < deadline:
result = subprocess.run(
["xdotool", "search", "--onlyvisible", "--name", "^Toby combo probe$"],
capture_output=True, text=True,
)
if result.stdout.strip():
return result.stdout.strip().splitlines()[0]
time.sleep(0.05)
raise RuntimeError("Toby combo fixture window missing")
def run_inside():
root = Path(__file__).resolve().parents[1]
diagnostics = tempfile.NamedTemporaryFile(prefix="cthulhu-combo-qt-", suffix=".log", delete=False)
print("Qt fixture diagnostics:", diagnostics.name, flush=True)
fixture = subprocess.Popen(
[sys.executable, root / "tests" / "toby_combo_fixture.py"],
stderr=diagnostics,
stdout=diagnostics,
)
try:
window = wait_for_window()
subprocess.run(["xdotool", "windowfocus", "--sync", window], check=True)
from native_x11 import set_active_window
set_active_window(int(window))
subprocess.run(
["go", "test", "./internal/atspi", "-run", "^TestNativeTobyComboPopupLifetime$",
"-count=1", "-v", "-timeout=45s"],
cwd=root, check=True, timeout=60,
env=dict(os.environ, CTHULHU_NATIVE_TOBY_COMBO="1", GOCACHE="/tmp/cthulhu-cache"),
)
finally:
exited = fixture.poll() is not None
if not exited:
fixture.terminate()
fixture.wait(timeout=5)
diagnostics.close()
if exited:
raise RuntimeError(f"Qt fixture exited with status {fixture.returncode}; see {diagnostics.name}")
if __name__ == "__main__":
if "--inside" in sys.argv:
run_inside()
else:
with tempfile.TemporaryDirectory(prefix="cthulhu-toby-combo-") as temporary:
environment = dict(
os.environ,
HOME=temporary,
XDG_CONFIG_HOME=temporary,
XDG_CACHE_HOME=temporary,
XDG_DATA_HOME=temporary,
QT_QPA_PLATFORM="xcb",
QT_LINUX_ACCESSIBILITY_ALWAYS_ON="1",
NO_AT_BRIDGE="0",
PYTHONPATH=site.getusersitepackages(),
GOMODCACHE=subprocess.check_output(
["go", "env", "GOMODCACHE"], text=True
).strip(),
)
environment.pop("AT_SPI_BUS_ADDRESS", None)
run_private_session(
["xvfb-run", "-a", "-s", "-screen 0 1024x768x24", "dbus-run-session", "--", sys.executable,
__file__, "--inside"],
env=environment, check=True,
)
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env python3
# Copyright (c) 2026 Storm Dragon
# Authors: Storm Dragon, Angus Kola
# SPDX-License-Identifier: GPL-3.0-or-later
"""Minimal Toby Doom Launcher combo-box fixture for native diagnostics."""
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QComboBox, QLabel, QLineEdit, QPushButton, QVBoxLayout, QWidget
class AccessibleComboBox(QComboBox):
def __init__(self, parent=None):
super().__init__(parent)
self.setEditable(True)
self.lineEdit().setReadOnly(True)
self.pageStep = 5
def keyPressEvent(self, event):
current_index = self.currentIndex()
item_count = self.count()
if event.key() == Qt.Key_PageUp:
self.setCurrentIndex(max(0, current_index - self.pageStep))
elif event.key() == Qt.Key_PageDown:
self.setCurrentIndex(min(item_count - 1, current_index + self.pageStep))
elif event.key() == Qt.Key_Home:
self.setCurrentIndex(0)
self.setFocus()
self.currentIndexChanged.emit(0)
self.activated.emit(0)
elif event.key() == Qt.Key_End:
last_index = item_count - 1
self.setCurrentIndex(last_index)
self.setFocus()
self.currentIndexChanged.emit(last_index)
self.activated.emit(last_index)
else:
super().keyPressEvent(event)
application = QApplication([])
window = QWidget()
window.setWindowTitle("Toby combo probe")
layout = QVBoxLayout(window)
label = QLabel("Game")
combo = AccessibleComboBox()
combo.setAccessibleName("Game")
combo.addItems(("Classic Doom", "Bring Back the 90s", "Funny Pack - Toby Doom"))
label.setBuddy(combo)
layout.addWidget(label)
layout.addWidget(combo)
button = QPushButton("Launch")
layout.addWidget(button)
editor = QLineEdit("alpha beta")
editor.setAccessibleName("Plain editor")
layout.addWidget(editor)
read_only = QLineEdit("alpha beta")
read_only.setReadOnly(True)
read_only.setAccessibleName("Read-only text")
layout.addWidget(read_only)
writable_combo = QComboBox()
writable_combo.setEditable(True)
writable_combo.addItems(("alpha beta", "gamma delta"))
layout.addWidget(writable_combo)
window.resize(420, 300)
window.show()
combo.setFocus()
application.exec()