Use shared quick settings and migrate speech values to the SSIP scale
This commit is contained in:
1 parent
679d81a804
commit
09e9570c66
46 files changed
+1053
-554
No files matched your search
@@ -349,10 +349,10 @@ lang = "en"
|
||||
check_output(("Tab",), [("Key echo person", "main", ""), ("Default", "echo-b", "")])
|
||||
check_output(("Down",), [("Echo B (en)", "echo-b", "Echo B")])
|
||||
for control in ("rate", "pitch", "volume"):
|
||||
value = "50.0" if control == "rate" else "5.0"
|
||||
value = {"rate": "2", "pitch": "10", "volume": "40"}[control]
|
||||
check_output(("Tab",), [("Key echo " + control, "main", ""), (value, "echo-b", "Echo B")])
|
||||
for control in ("pitch", "rate", "person", "synthesizer"):
|
||||
value = {"pitch": "5.0", "rate": "50.0", "person": "Echo B (en)", "synthesizer": "echo-b"}[control]
|
||||
value = {"pitch": "10", "rate": "2", "person": "Echo B (en)", "synthesizer": "echo-b"}[control]
|
||||
label = "Key echo speech synthesizer" if control == "synthesizer" else "Key echo " + control
|
||||
check_output(("shift+Tab",), [(label, "main", ""), (value, "echo-b", "Echo B")])
|
||||
print(f"PASS: real reader + GTK + SSIP focus/selection previews, voice completion, no duplicate menu-item speech; evidence: {directory}")
|
||||
|
||||
+18
-21
@@ -142,7 +142,7 @@ def inside():
|
||||
initial["Catalog"]["espeak-ng"] = list(initial["Catalog"]["test-module"])
|
||||
if os.environ.get("CTHULHU_PREFS_NUMBERS_ONLY") == "1":
|
||||
initial["Values"].update(UseCustomEchoVoice=True,
|
||||
EchoVoice={"Rate": 50, "AveragePitch": 5, "Gain": 5})
|
||||
EchoVoice={"Rate": 50, "AveragePitch": 50, "Gain": 50})
|
||||
if os.environ.get("CTHULHU_PREFS_LARGE_CATALOG") == "1":
|
||||
initial["Catalog"]["espeak-ng"].extend(
|
||||
{"Name": f"Test voice {index}", "Language": "en" if index < 100 else "de", "Variant": "none"}
|
||||
@@ -632,17 +632,17 @@ def inside():
|
||||
for name, field in (("Rate", "Rate"), ("Pitch", "Pitch"), ("Volume", "Volume")):
|
||||
slider = next(n for n in nodes if n.getRole() == pyatspi.ROLE_SLIDER and n.name.lower().rstrip(":") == name.lower())
|
||||
focus(slider)
|
||||
assert abs(slider.queryValue().minimumIncrement - 0.1) < 1e-8, (name, "accessible increment")
|
||||
assert abs(slider.queryValue().minimumIncrement - 1) < 1e-8, (name, "accessible increment")
|
||||
startValue = slider.queryValue().currentValue
|
||||
for arrow, delta in (("Right", 0.1), ("Up", 1), ("Left", -0.1), ("Down", -1), ("Left", -0.1)):
|
||||
for arrow, delta in (("Right", 1), ("Up", 10), ("Left", -1), ("Down", -10), ("Left", -1)):
|
||||
expected = startValue + delta
|
||||
key(arrow)
|
||||
values = accept_preview()
|
||||
assert abs(slider.queryValue().currentValue - expected) < 1e-8, (name, arrow, expected)
|
||||
assert abs(values[field] - expected) < 1e-8, (name, arrow, values)
|
||||
assert values[field] == round(values[field], 1), (name, "precision", values)
|
||||
assert values[field] == round(values[field]), (name, "precision", values)
|
||||
startValue = expected
|
||||
for bound, arrows in ((0, ("Left", "Down")),
|
||||
for bound, arrows in ((-100, ("Left", "Down")),
|
||||
(slider.queryValue().maximumValue, ("Right", "Up"))):
|
||||
slider.queryValue().currentValue = bound
|
||||
accept_preview()
|
||||
@@ -662,20 +662,17 @@ def inside():
|
||||
slider = named(name)
|
||||
focus(slider)
|
||||
echoPreview = {"Rate": "rate", "AveragePitch": "pitch", "Gain": "volume"}[field]
|
||||
assert abs(slider.queryValue().minimumIncrement - 0.1) < 1e-8, (name, "accessible increment")
|
||||
for arrow, expected in (("Right", 5.1 if field != "Rate" else 50.1),
|
||||
("Up", 6.1 if field != "Rate" else 51.1),
|
||||
("Left", 6 if field != "Rate" else 51),
|
||||
("Down", 5 if field != "Rate" else 50),
|
||||
("Left", 4.9 if field != "Rate" else 49.9)):
|
||||
assert abs(slider.queryValue().minimumIncrement - 1) < 1e-8, (name, "accessible increment")
|
||||
# Speech Dispatcher's -100..100 scale: Left/Right step 1, Up/Down step 10.
|
||||
for arrow, expected in (("Right", 51), ("Up", 61), ("Left", 60), ("Down", 50), ("Left", 49)):
|
||||
key(arrow)
|
||||
values = accept_preview(echoPreview)
|
||||
wait_for(lambda: abs(slider.queryValue().currentValue - expected) < 1e-8,
|
||||
f"{name}: {arrow} did not produce {expected}")
|
||||
assert abs(values["EchoVoice"][field] - expected) < 1e-8, values
|
||||
assert values["EchoVoice"][field] == round(values["EchoVoice"][field], 1), (name, "precision", values)
|
||||
assert values["EchoVoice"][field] == round(values["EchoVoice"][field]), (name, "precision", values)
|
||||
finalValue = expected
|
||||
for bound, arrows in ((0, ("Left", "Down")),
|
||||
for bound, arrows in ((-100, ("Left", "Down")),
|
||||
(slider.queryValue().maximumValue, ("Right", "Up"))):
|
||||
slider.queryValue().currentValue = bound
|
||||
accept_preview(echoPreview)
|
||||
@@ -686,19 +683,19 @@ def inside():
|
||||
focus(named("Apply")); key("space")
|
||||
applied = request()
|
||||
assert applied["Save"], applied
|
||||
for field, expected in (("Rate", 49.9), ("Pitch", 4.9), ("Volume", 4.9)):
|
||||
for field, expected in (("Rate", 49), ("Pitch", 4), ("Volume", 4)):
|
||||
assert abs(applied["Values"][field] - expected) < 1e-8, applied
|
||||
assert applied["Values"][field] == round(applied["Values"][field], 1), applied
|
||||
for field, expected in (("Rate", 49.9), ("AveragePitch", 4.9), ("Gain", 4.9)):
|
||||
assert applied["Values"][field] == round(applied["Values"][field]), applied
|
||||
for field, expected in (("Rate", 49), ("AveragePitch", 49), ("Gain", 49)):
|
||||
assert abs(applied["Values"]["EchoVoice"][field] - expected) < 1e-8, applied
|
||||
assert applied["Values"]["EchoVoice"][field] == round(applied["Values"]["EchoVoice"][field], 1), applied
|
||||
assert applied["Values"]["EchoVoice"][field] == round(applied["Values"]["EchoVoice"][field]), applied
|
||||
send(dict(initial, Values=applied["Values"], Message="Speech settings saved."))
|
||||
wait_for(lambda: named("Apply").getState().contains(pyatspi.STATE_SENSITIVE), "Apply busy")
|
||||
for name, expected in (("Key echo rate", 49.9), ("Key echo pitch", 4.9), ("Key echo volume", 4.9)):
|
||||
for name, expected in (("Key echo rate", 49), ("Key echo pitch", 49), ("Key echo volume", 49)):
|
||||
assert abs(named(name).queryValue().currentValue - expected) < 1e-8, name
|
||||
focus(named("Cancel")); key("space")
|
||||
assert process.wait(timeout=2) == 0
|
||||
print("PASS: voice and echo sliders, whole/tenth arrow steps, previews, Tab/Shift+Tab, Apply/reload, Cancel")
|
||||
print("PASS: voice and echo sliders, one and ten arrow steps, previews, Tab/Shift+Tab, Apply/reload, Cancel")
|
||||
return
|
||||
if os.environ.get("CTHULHU_PREFS_APPLY_ONLY") == "1":
|
||||
reading_tree = next(node for node in nodes if node.name == "Reading settings"
|
||||
@@ -1596,7 +1593,7 @@ def inside():
|
||||
# Only one preview may be outstanding. Read and acknowledge each
|
||||
# changed value before moving focus, which discards stale previews.
|
||||
for control, field, value in (("rate", "Rate", 83),
|
||||
("pitch", "AveragePitch", 7.5),
|
||||
("pitch", "AveragePitch", 8),
|
||||
("volume", "Gain", 10)):
|
||||
slider = named("Key echo " + control)
|
||||
focus(slider)
|
||||
@@ -1624,7 +1621,7 @@ def inside():
|
||||
assert ev["ProgressBar"] == expectedProgress, ev
|
||||
assert echo_saved["Save"] and echo_saved["Close"] and ev["EnableKeyEcho"], echo_saved
|
||||
assert ev["UseCustomEchoVoice"] and ev["UseCustomEchoForWord"] and ev["KeyEchoInEditFieldsOnly"], ev
|
||||
assert ev["EchoVoice"]["Rate"] == 83 and ev["EchoVoice"]["AveragePitch"] == 7.5 and ev["EchoVoice"]["Gain"] == 10, ev
|
||||
assert ev["EchoVoice"]["Rate"] == 83 and ev["EchoVoice"]["AveragePitch"] == 8 and ev["EchoVoice"]["Gain"] == 10, ev
|
||||
assert ev["EchoVoice"]["Family"]["Name"] == "Test voice", ev
|
||||
send(dict(initial, Values=ev, Message="Echo voice saved."))
|
||||
wait_for(lambda: named("Apply").getState().contains(pyatspi.STATE_SENSITIVE), "OK stayed busy")
|
||||
|
||||
@@ -45,7 +45,8 @@ def check_no_config(window, tabs, server, configPath):
|
||||
controls = controls_for(window)
|
||||
assert not any(name.startswith(("Use server default", "Use Default voice", "Use automatic uppercase"))
|
||||
for name in controls)
|
||||
expected = {"Rate": 59, "Pitch": 4, "Volume": 9} if server.defaultsSupported else {"Rate": 50, "Pitch": 5, "Volume": 5}
|
||||
# Sliders show Speech Dispatcher's own -100..100 values without conversion.
|
||||
expected = {"Rate": 20, "Pitch": -10, "Volume": 100} if server.defaultsSupported else {"Rate": 0, "Pitch": 0, "Volume": 100}
|
||||
for name, value in expected.items():
|
||||
slider = controls[name]
|
||||
assert slider.getRole() == pyatspi.ROLE_SLIDER, (name, slider.getRoleName())
|
||||
@@ -59,7 +60,7 @@ def check_no_config(window, tabs, server, configPath):
|
||||
|
||||
voiceType = controls["Voice type"]
|
||||
assert voiceType.querySelection().selectChild(1)
|
||||
wait_for(lambda: controls["Pitch"].queryValue().currentValue == 7, "automatic uppercase pitch missing")
|
||||
wait_for(lambda: controls["Pitch"].queryValue().currentValue == 50, "automatic uppercase pitch missing")
|
||||
assert voiceType.querySelection().selectChild(0)
|
||||
wait_for(lambda: controls["Pitch"].queryValue().currentValue == expected["Pitch"], "Default pitch did not return")
|
||||
focus(controls["Apply"]); key("space")
|
||||
@@ -70,11 +71,11 @@ def check_no_config(window, tabs, server, configPath):
|
||||
wait_for(lambda: controls["Apply"].getState().contains(pyatspi.STATE_SENSITIVE), "Apply stayed busy")
|
||||
|
||||
expectedRaw = {}
|
||||
for name, scale, offset in (("Rate", 2, 98), ("Pitch", 20, 90), ("Volume", 15, 35)):
|
||||
for name in ("Rate", "Pitch", "Volume"):
|
||||
slider = controls[name]
|
||||
focus(slider); key("Down" if name == "Volume" else "Up")
|
||||
expected[name] += -1 if name == "Volume" else 1
|
||||
expectedRaw[name.upper()] = int(scale * expected[name] - offset)
|
||||
expected[name] += -10 if name == "Volume" else 10
|
||||
expectedRaw[name.upper()] = expected[name]
|
||||
wait_for(lambda: slider.queryValue().currentValue == expected[name], name + " did not change directly")
|
||||
wait_for(lambda: any(all(record["settings"][field] == value for field, value in expectedRaw.items())
|
||||
for record in server.snapshot()), name + " preview did not reach speech backend")
|
||||
@@ -96,11 +97,11 @@ def check_no_config(window, tabs, server, configPath):
|
||||
for name, value in expected.items():
|
||||
assert controls[name].queryValue().currentValue == value, (name, value)
|
||||
assert controls["Voice type"].querySelection().selectChild(1)
|
||||
wait_for(lambda: controls["Pitch"].queryValue().currentValue == max(7, expected["Pitch"] + 2),
|
||||
wait_for(lambda: controls["Pitch"].queryValue().currentValue == min(100, max(50, expected["Pitch"] + 40)),
|
||||
"untouched Uppercase pitch stopped following Default")
|
||||
assert controls["Voice type"].querySelection().selectChild(0)
|
||||
focus(controls["Rate"]); key("Up")
|
||||
changedRaw = dict(expectedRaw, RATE=expectedRaw["RATE"] + 2)
|
||||
changedRaw = dict(expectedRaw, RATE=expectedRaw["RATE"] + 10)
|
||||
wait_for(lambda: any(record["settings"] == changedRaw for record in server.snapshot()), "unsaved preview missing")
|
||||
focus(controls["Cancel"]); key("space")
|
||||
wait_for(lambda: find_window() is None, "Cancel did not close preferences")
|
||||
|
||||
Reference in new issue
Block a user