Add Orca extension for Wine accessibility
Publish the Wine Access protocol on Orca’s service connection and manage helpers per active Wine prefix. Add presentation, dialog capture, documentation, and tests. Preserve the Cthulhu default and shared helper code. Document the single-reader limit and verify Orca cleanup leaves Cthulhu-managed helpers alone. Retain integration artifacts on exceptional failures. Validation: 45 Orca unit tests passed; 11 existing test-environment checks passed; version metadata checks, Python compilation, and staged whitespace checks passed. Full Wine integration and live speech/braille remain unverified here because MinGW, Xvfb, and Orca are unavailable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b57681d159
commit
418f671066
13 files changed
+1913
-3
No files matched your search
@@ -0,0 +1,72 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
"""The published interface matches the signatures wine-access checks."""
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
from xml.etree import ElementTree
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "wine_access"))
|
||||
|
||||
from service import INTERFACE, WineAccessInterface, ssml_status # noqa: E402
|
||||
|
||||
# From wine-access's README: method -> (input signature, output signature).
|
||||
REQUIRED = {
|
||||
"SpeakText": ("sb", "b"),
|
||||
"CancelSpeech": ("", "b"),
|
||||
"BrailleMessage": ("s", "b"),
|
||||
"SpeakSsml": ("ss", "i"),
|
||||
"PresentAccessibleEvent": ("sssssssiis", "b"),
|
||||
# Optional review protocol version 1.
|
||||
"RegisterWineReviewProvider": ("ou", "b"),
|
||||
"PresentWineReviewFocus": ("ssstssb(iiii)", "b"),
|
||||
}
|
||||
|
||||
|
||||
class Backend:
|
||||
def speak_text(self, text, interrupt):
|
||||
return True
|
||||
|
||||
def cancel_speech(self):
|
||||
raise RuntimeError("Orca failed")
|
||||
|
||||
def braille_message(self, text):
|
||||
return text
|
||||
|
||||
def present_event(self, *arguments):
|
||||
self.arguments = arguments
|
||||
return True
|
||||
|
||||
|
||||
class InterfaceTests(unittest.TestCase):
|
||||
def test_signatures_match_helper_contract(self):
|
||||
root = ElementTree.fromstring(WineAccessInterface.__dbus_xml__)
|
||||
interface = root.find(f"interface[@name='{INTERFACE}']")
|
||||
found = {}
|
||||
for method in interface.findall("method"):
|
||||
args = method.findall("arg")
|
||||
found[method.get("name")] = (
|
||||
"".join(a.get("type") for a in args if a.get("direction") == "in"),
|
||||
"".join(a.get("type") for a in args if a.get("direction") == "out"))
|
||||
self.assertEqual(found, REQUIRED)
|
||||
|
||||
def test_backend_errors_answer_false(self):
|
||||
service = WineAccessInterface(Backend())
|
||||
self.assertTrue(service.SpeakText("hi", False))
|
||||
self.assertFalse(service.CancelSpeech())
|
||||
self.assertFalse(service.BrailleMessage(""))
|
||||
|
||||
def test_event_arguments_pass_through_in_order(self):
|
||||
backend = Backend()
|
||||
service = WineAccessInterface(backend)
|
||||
service.PresentAccessibleEvent("s", "focus", "n", "r", "v", "st", "d", 1, 2, "w")
|
||||
self.assertEqual(backend.arguments, ("s", "focus", "n", "r", "v", "st", "d", 1, 2, "w"))
|
||||
|
||||
def test_ssml_status_codes(self):
|
||||
self.assertEqual(ssml_status("<speak>Hi</speak>"), 120)
|
||||
self.assertEqual(ssml_status("<p>Hi</p>"), 87)
|
||||
self.assertEqual(ssml_status("<speak>"), 87)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user