Fixed status announcements interrupting page information for the web navigation.

This commit is contained in:
Storm Dragon committed 2026-05-15 01:54:17 -04:00
1 parent 922ba60445
commit b224d699c0
4 files changed
+109 -4

No files matched your search

@@ -42,6 +42,46 @@ class StructuralNavigationTableRegressionTests(unittest.TestCase):
interrupt=False,
)
def test_wrapping_announcement_does_not_interrupt_wrapped_object(self):
navigator = structural_navigation.StructuralNavigation.__new__(
structural_navigation.StructuralNavigation
)
script = mock.Mock()
script.utilities.isZombie.return_value = False
script.utilities.isHidden.return_value = False
script.utilities.isEmpty.return_value = False
script.utilities.pathComparison.return_value = 0
navigator._script = script
first = object()
current = object()
structuralNavigationObject = mock.Mock()
structuralNavigationObject.predicate = None
events = []
structuralNavigationObject.present.side_effect = lambda obj, arg=None: events.append(
("present", obj, arg)
)
script.presentMessage.side_effect = lambda message, **kwargs: events.append(
("message", message, kwargs)
)
navigator._getAll = mock.Mock(return_value=[first, current])
with (
mock.patch.object(structural_navigation.settings, "wrappedStructuralNavigation", True),
mock.patch.object(structural_navigation.AXObject, "is_dead", return_value=False),
mock.patch.object(structural_navigation.AXObject, "get_parent", return_value=None),
mock.patch.object(structural_navigation.AXObject, "get_path", side_effect=lambda obj: [id(obj)]),
):
navigator.goObject(structuralNavigationObject, True, current, "arg")
self.assertEqual(
events,
[
("present", first, "arg"),
("message", messages.WRAPPING_TO_TOP, {"interrupt": False}),
],
)
if __name__ == "__main__":
unittest.main()
+63
View File
@@ -100,6 +100,69 @@ class WebKeyGrabRegressionTests(unittest.TestCase):
testScript.refreshKeyGrabs.assert_called_once_with()
class WebPresentationModeSpeechRegressionTests(unittest.TestCase):
def _make_script(self, inFocusMode):
testScript = web_script.Script.__new__(web_script.Script)
testScript._inFocusMode = inFocusMode
testScript._focusModeIsSticky = True
testScript._browseModeIsSticky = True
testScript._loadingDocumentContent = False
testScript._lastCommandWasCaretNav = False
testScript._lastCommandWasStructNav = False
testScript.utilities = mock.Mock()
testScript.utilities.getCaretContext.return_value = ("button", 0)
testScript.utilities.grabFocusWhenSettingCaret.return_value = True
testScript.presentMessage = mock.Mock()
testScript.refreshKeyGrabs = mock.Mock()
testScript._shouldSuppressBrowseModeSound = mock.Mock(return_value=False)
return testScript
def test_automatic_browse_mode_announcement_does_not_interrupt_focus_presentation(self):
testScript = self._make_script(inFocusMode=True)
soundManager = mock.Mock()
with (
mock.patch.object(web_script.AXObject, "get_parent", return_value=None),
mock.patch.object(web_script.AXUtilities, "is_list_box", return_value=False),
mock.patch.object(web_script.AXUtilities, "is_menu", return_value=False),
mock.patch.object(web_script.sound_theme_manager, "getManager", return_value=soundManager),
):
web_script.Script.togglePresentationMode(testScript, None, "document")
testScript.presentMessage.assert_called_once_with(messages.MODE_BROWSE, interrupt=False)
soundManager.playBrowseModeSound.assert_called_once_with()
self.assertFalse(testScript._inFocusMode)
self.assertFalse(testScript._focusModeIsSticky)
self.assertFalse(testScript._browseModeIsSticky)
testScript.refreshKeyGrabs.assert_called_once_with()
def test_automatic_focus_mode_announcement_does_not_interrupt_focus_presentation(self):
testScript = self._make_script(inFocusMode=False)
soundManager = mock.Mock()
with mock.patch.object(
web_script.sound_theme_manager,
"getManager",
return_value=soundManager,
):
web_script.Script.togglePresentationMode(testScript, None, "document")
testScript.presentMessage.assert_called_once_with(messages.MODE_FOCUS, interrupt=False)
soundManager.playFocusModeSound.assert_called_once_with()
self.assertTrue(testScript._inFocusMode)
self.assertFalse(testScript._focusModeIsSticky)
self.assertFalse(testScript._browseModeIsSticky)
testScript.refreshKeyGrabs.assert_called_once_with()
def test_manual_presentation_mode_toggle_still_interrupts(self):
testScript = self._make_script(inFocusMode=False)
with mock.patch.object(web_script.sound_theme_manager, "getManager", return_value=mock.Mock()):
web_script.Script.togglePresentationMode(testScript, object(), "document")
testScript.presentMessage.assert_called_once_with(messages.MODE_FOCUS, interrupt=True)
if __name__ == "__main__":
unittest.main()