Attempt to fix the rest of speech interrupting when it shouldn't. Also play radio buttons after the ui after they figure out if they are checked or not.
This commit is contained in:
1 parent
2c6ab2ce76
commit
82887b3897
64 files changed
+501
-225
No files matched your search
@@ -111,7 +111,36 @@ class PreviewSpeechServer:
|
||||
client["socket"].close()
|
||||
|
||||
|
||||
def check_runtime():
|
||||
def check_radio_buttons(controls, tabs, server, readerLog):
|
||||
import pyatspi
|
||||
|
||||
def radio_cues():
|
||||
records = [json.loads(line) for line in readerLog.read_text().splitlines() if line.startswith("{")]
|
||||
return [record["cue"] for record in records if record.get("message") == "playing object sound"
|
||||
and record.get("cue", "").startswith("radiobutton_")]
|
||||
|
||||
assert tabs.querySelection().selectChild(0)
|
||||
assert controls["Desktop"].queryComponent().grabFocus()
|
||||
wait_for(lambda: radio_cues(), "initial radio sound did not play")
|
||||
time.sleep(0.35)
|
||||
for keyName, target in (("Right", "Laptop"), ("Left", "Desktop"), ("Right", "Laptop")):
|
||||
cueOffset = len(radio_cues())
|
||||
speechOffset = len(server.snapshot())
|
||||
subprocess.run(["xdotool", "key", "--clearmodifiers", keyName], check=True)
|
||||
wait_for(lambda: controls[target].getState().contains(pyatspi.STATE_CHECKED), target + " was not selected")
|
||||
wait_for(lambda: len(radio_cues()) > cueOffset, target + " selection sound did not play")
|
||||
# Cover the deferred focus cue and duplicate focus event after checking.
|
||||
time.sleep(0.35)
|
||||
cues = radio_cues()[cueOffset:]
|
||||
assert cues == ["radiobutton_checked"], (keyName, target, cues)
|
||||
assert any(target in record["text"] for record in server.snapshot()[speechOffset:]), target + " label was lost"
|
||||
records = [json.loads(line) for line in readerLog.read_text().splitlines() if line.startswith("{")]
|
||||
errors = [record for record in records if record.get("message") == "play sound"
|
||||
and record.get("cue", "").startswith("radiobutton_") and record.get("error") != "context canceled"]
|
||||
assert not errors, errors
|
||||
|
||||
|
||||
def check_runtime(radioOnly=False):
|
||||
import pyatspi
|
||||
directory = Path(tempfile.mkdtemp(prefix="cthulhu-echo-runtime-"))
|
||||
binary = os.environ["CTHULHU_BINARY"]
|
||||
@@ -144,10 +173,30 @@ gain = 5
|
||||
name = "Echo A"
|
||||
lang = "en"
|
||||
''')
|
||||
if radioOnly:
|
||||
configPath.write_text(configPath.read_text().replace(
|
||||
"[profiles.default.sound]\nenabled = false",
|
||||
'[profiles.default.sound]\nenabled = true\nsink = "auto"\nplay-for-state = true\nrole-presentation-strategy = "sound_only"'))
|
||||
readerEnv = os.environ.copy()
|
||||
if radioOnly:
|
||||
import gi
|
||||
gi.require_version("Gst", "1.0")
|
||||
from gi.repository import Gst
|
||||
Gst.init(None)
|
||||
assert Gst.ElementFactory.find("fakeaudiosink"), "silent GStreamer audio sink is unavailable"
|
||||
# Only the child reader sees these ranks. Auto audio can choose
|
||||
# the fake sink; every real audio sink is excluded from discovery.
|
||||
ranks = []
|
||||
for factory in Gst.Registry.get().get_feature_list(Gst.ElementFactory):
|
||||
kind = factory.get_metadata("klass") or ""
|
||||
if "Audio" in kind and "Sink" in kind:
|
||||
rank = "MAX" if factory.get_name() == "fakeaudiosink" else "0"
|
||||
ranks.append(factory.get_name() + ":" + rank)
|
||||
readerEnv["GST_PLUGIN_FEATURE_RANK"] = ",".join(ranks)
|
||||
reader = subprocess.Popen([binary, "--config", str(configPath), "--settings", "--no-tentacles",
|
||||
"--speech-socket", str(directory / "speech.sock"),
|
||||
"--debug-file", str(directory / "reader.log")],
|
||||
stdout=subprocess.DEVNULL, stderr=(directory / "stderr.log").open("w"))
|
||||
env=readerEnv, stdout=subprocess.DEVNULL, stderr=(directory / "stderr.log").open("w"))
|
||||
def find_window():
|
||||
for application in pyatspi.Registry.getDesktop(0):
|
||||
for window in application:
|
||||
@@ -163,6 +212,10 @@ lang = "en"
|
||||
xid = subprocess.check_output(["xdotool", "search", "--onlyvisible", "--name", "^Cthulhu Preferences$"], text=True).splitlines()[0]
|
||||
subprocess.run(["xdotool", "windowactivate", "--sync", xid], check=True)
|
||||
tabs = next(node for node in walk(window) if node.getRole() == pyatspi.ROLE_PAGE_TAB_LIST)
|
||||
if radioOnly:
|
||||
check_radio_buttons(controls, tabs, server, directory / "reader.log")
|
||||
print(f"PASS: real GTK Desktop/Laptop arrows play only the final selected sound and retain labels; evidence: {directory}")
|
||||
return
|
||||
assert tabs.querySelection().selectChild(4)
|
||||
assert controls["Use custom echo voice"].queryComponent().grabFocus()
|
||||
wait_for(lambda: any(record["text"] == "checked" and record["finished"]
|
||||
|
||||
Reference in new issue
Block a user