Preview voice profile edits and restore parent speech
This commit is contained in:
1 parent
1b42dde756
commit
b21fceb311
7 files changed
+175
-11
No files matched your search
@@ -53,13 +53,40 @@ def check_profiles(window, initial, send, request, windowNodes):
|
||||
def choose(editor, label, index):
|
||||
assert named(editor, label, pyatspi.ROLE_COMBO_BOX).querySelection().selectChild(index), label
|
||||
|
||||
def preview_until(matches, description, acknowledge=True):
|
||||
for _ in range(30):
|
||||
preview = request()
|
||||
assert preview.get("Preview"), (description, preview)
|
||||
values = preview["Values"]
|
||||
assert values["EchoVoice"] == initial["Values"]["EchoVoice"], values
|
||||
assert values["SystemVoice"] == initial["Values"]["SystemVoice"], values
|
||||
if matches(values):
|
||||
if acknowledge:
|
||||
send({"Preview": True, "Accepted": True})
|
||||
return values
|
||||
send({"Preview": True, "Accepted": True})
|
||||
raise AssertionError(description)
|
||||
|
||||
def parent_voice(values):
|
||||
return (values["Rate"] == initial["Values"]["Rate"]
|
||||
and values["SpeechOutputModule"] == initial["Values"].get("SpeechOutputModule", ""))
|
||||
|
||||
tabs = next(node for node in windowNodes if node.getRole() == pyatspi.ROLE_PAGE_TAB_LIST)
|
||||
index = next(i for i, child in enumerate(tabs) if child.name == "Voice Profiles")
|
||||
assert tabs.querySelection().selectChild(index)
|
||||
editor = open_editor("Add Voice Profile")
|
||||
preview_until(parent_voice, "new editor did not preview its initial voice")
|
||||
named(editor, "Rate", pyatspi.ROLE_SPIN_BUTTON).queryValue().currentValue = 25
|
||||
preview_until(lambda values: values["Rate"] == 25, "profile rate was not previewed", acknowledge=False)
|
||||
# Keep that preview in flight, then supersede it and cancel the child.
|
||||
rate = named(editor, "Rate", pyatspi.ROLE_SPIN_BUTTON)
|
||||
rate.queryValue().currentValue = 35
|
||||
wait_for(lambda: rate.queryValue().currentValue == 35, "newer profile rate missing")
|
||||
named(editor, "Voice Profile Name", pyatspi.ROLE_ENTRY).queryEditableText().setTextContents("Discarded")
|
||||
activate(editor, "Cancel")
|
||||
wait_for(lambda: dialog() is None, "Cancel did not close child")
|
||||
send({"Preview": True, "Accepted": True})
|
||||
preview_until(parent_voice, "Cancel did not restore the parent voice")
|
||||
assert not any(n.name == "Discarded" for n in walk(window)), "cancelled profile retained"
|
||||
|
||||
editor = open_editor("Add Voice Profile")
|
||||
@@ -69,6 +96,7 @@ def check_profiles(window, initial, send, request, windowNodes):
|
||||
device.queryEditableText().setTextContents("/dev/fixture-synth")
|
||||
activate(editor, "Save Voice Profile")
|
||||
wait_for(lambda: dialog() is None, "hardware profile did not save")
|
||||
preview_until(parent_voice, "Save did not restore the parent voice")
|
||||
|
||||
editor = open_editor("Add Voice Profile")
|
||||
choose(editor, "Module", 1)
|
||||
@@ -80,20 +108,27 @@ def check_profiles(window, initial, send, request, windowNodes):
|
||||
wait_for(lambda: any(n.name.startswith("Spanish test voice") for n in walk(voice)), "Spanish voice missing")
|
||||
choose(editor, "Voice", 1)
|
||||
named(editor, "Rate", pyatspi.ROLE_SPIN_BUTTON).queryValue().currentValue = 20
|
||||
preview_until(lambda values: values["Rate"] == 20 and values["SpeechOutputModule"] == "test-module"
|
||||
and values.get("SpeechVoiceFamily", {}).get("Name") == "Spanish test voice",
|
||||
"module, language, voice and rate were not previewed in the child editor")
|
||||
activate(editor, "Save Voice Profile")
|
||||
wait_for(lambda: dialog() is None, "software profile did not save")
|
||||
preview_until(parent_voice, "saving a software profile did not restore the parent voice")
|
||||
|
||||
profilesControl = named(window, "Voice Profiles", pyatspi.ROLE_COMBO_BOX)
|
||||
assert profilesControl.querySelection().selectChild(1)
|
||||
editor = open_editor("Edit Voice Profile")
|
||||
preview_until(lambda values: values["Rate"] == 20, "Edit did not preview the saved profile")
|
||||
assert named(editor, "Voice Profile Name", pyatspi.ROLE_ENTRY).queryText().getText(0, -1) == "test-module Spanish test voice"
|
||||
named(editor, "Voice Profile Name", pyatspi.ROLE_ENTRY).queryEditableText().setTextContents("DECtalk")
|
||||
activate(editor, "Save Voice Profile")
|
||||
wait_for(lambda: any("already exists" in n.name for n in walk(editor)), "duplicate name not rejected")
|
||||
activate(editor, "Cancel")
|
||||
wait_for(lambda: dialog() is None, "duplicate cancellation failed")
|
||||
preview_until(parent_voice, "Edit cancellation did not restore the parent voice")
|
||||
activate(window, "Use Voice Profile")
|
||||
wait_for(lambda: named(window,"Rate",pyatspi.ROLE_SLIDER).queryValue().currentValue==20, "Use did not load primary controls")
|
||||
preview_until(lambda values: values["Rate"] == 20, "Use did not preview the selected profile")
|
||||
activate(window, "Apply")
|
||||
while True:
|
||||
applied = request()
|
||||
@@ -117,4 +152,4 @@ def check_profiles(window, initial, send, request, windowNodes):
|
||||
send({"Preview": True, "Accepted": True})
|
||||
applied = request()
|
||||
assert len(applied["Values"]["VoiceProfiles"]["Profiles"]) == 1, applied
|
||||
print("PASS: GTK profile name focus, Tab traversal, hardware/software settings, naming, duplicates, cancel, use, remove, and auxiliary voices")
|
||||
print("PASS: GTK profile previews, parent restoration, Tab traversal, naming, duplicates, cancel, use, remove, and auxiliary voices")
|
||||
Reference in new issue
Block a user