Web fixes.
This commit is contained in:
@@ -24,6 +24,7 @@ if soundGeneratorModule is not None and not hasattr(soundGeneratorModule, "Sound
|
||||
soundGeneratorModule.SoundGenerator = _StubSoundGenerator
|
||||
|
||||
from cthulhu import messages
|
||||
from cthulhu.ax_utilities_event import AXUtilitiesEvent, TextEventReason
|
||||
from cthulhu.scripts.web import script as web_script
|
||||
from cthulhu.scripts.web import script_utilities as web_script_utilities
|
||||
from cthulhu.scripts.toolkits.Gecko import script_utilities as gecko_script_utilities
|
||||
@@ -336,6 +337,7 @@ class WebFocusSpeechInterruptionRegressionTests(unittest.TestCase):
|
||||
class WebCaretMovedRegressionTests(unittest.TestCase):
|
||||
def _make_script(self):
|
||||
testScript = web_script.Script.__new__(web_script.Script)
|
||||
testScript._inFocusMode = False
|
||||
testScript._lastCommandWasCaretNav = False
|
||||
testScript._lastCommandWasStructNav = False
|
||||
testScript._lastCommandWasMouseButton = False
|
||||
@@ -351,15 +353,87 @@ class WebCaretMovedRegressionTests(unittest.TestCase):
|
||||
def test_matching_char_nav_caret_event_is_consumed_without_duplicate_presentation(self):
|
||||
testScript = self._make_script()
|
||||
source = "source"
|
||||
event = mock.Mock(source=source, detail1=4)
|
||||
event = mock.Mock(type="object:text-caret-moved", source=source, detail1=4)
|
||||
|
||||
with mock.patch.object(web_script.cthulhu, "setLocusOfFocus") as setLocusOfFocus:
|
||||
with (
|
||||
mock.patch.object(
|
||||
AXUtilitiesEvent,
|
||||
"get_text_event_reason",
|
||||
return_value=TextEventReason.NAVIGATION_BY_CHARACTER,
|
||||
),
|
||||
mock.patch.object(web_script.cthulhu, "setLocusOfFocus") as setLocusOfFocus,
|
||||
):
|
||||
result = web_script.Script.onCaretMoved(testScript, event)
|
||||
|
||||
self.assertTrue(result)
|
||||
testScript.utilities.setCaretContext.assert_not_called()
|
||||
setLocusOfFocus.assert_not_called()
|
||||
|
||||
def test_focus_change_caret_event_does_not_replace_real_focus_event(self):
|
||||
testScript = self._make_script()
|
||||
source = object()
|
||||
event = mock.Mock(
|
||||
type="object:text-caret-moved",
|
||||
source=source,
|
||||
detail1=0,
|
||||
)
|
||||
testScript.utilities.getCaretContext.return_value = ("old-focus", 0)
|
||||
testScript.utilities.lastInputEventWasCharNav.return_value = False
|
||||
|
||||
with (
|
||||
mock.patch.object(
|
||||
AXUtilitiesEvent,
|
||||
"get_text_event_reason",
|
||||
return_value=TextEventReason.FOCUS_CHANGE,
|
||||
) as getReason,
|
||||
mock.patch.object(web_script.cthulhu, "setLocusOfFocus") as setLocusOfFocus,
|
||||
):
|
||||
result = web_script.Script.onCaretMoved(testScript, event)
|
||||
|
||||
self.assertTrue(result)
|
||||
getReason.assert_called_once_with(event)
|
||||
testScript.utilities.setCaretContext.assert_not_called()
|
||||
setLocusOfFocus.assert_not_called()
|
||||
|
||||
|
||||
class TextEventReasonRegressionTests(unittest.TestCase):
|
||||
def test_tab_is_classified_as_focus_change_before_editable_state(self):
|
||||
oldFocus = object()
|
||||
source = object()
|
||||
event = mock.Mock(type="object:text-caret-moved", source=source)
|
||||
inputManager = mock.Mock()
|
||||
inputManager.last_event_was_caret_selection.return_value = False
|
||||
inputManager.last_event_was_caret_navigation.return_value = False
|
||||
inputManager.last_event_was_select_all.return_value = False
|
||||
inputManager.last_event_was_primary_click_or_release.return_value = False
|
||||
inputManager.last_event_was_tab_navigation.return_value = True
|
||||
|
||||
with (
|
||||
mock.patch(
|
||||
"cthulhu.input_event_manager.get_manager",
|
||||
return_value=inputManager,
|
||||
),
|
||||
mock.patch(
|
||||
"cthulhu.ax_utilities_event.focus_manager.get_manager"
|
||||
) as getFocusManager,
|
||||
mock.patch(
|
||||
"cthulhu.ax_utilities_event.AXUtilitiesRole.is_text_input_search",
|
||||
return_value=False,
|
||||
),
|
||||
mock.patch(
|
||||
"cthulhu.ax_utilities_event.AXUtilitiesState.is_editable",
|
||||
return_value=True,
|
||||
) as isEditable,
|
||||
):
|
||||
getFocusManager.return_value.get_active_mode_and_object_of_interest.return_value = (
|
||||
None,
|
||||
oldFocus,
|
||||
)
|
||||
reason = AXUtilitiesEvent._get_caret_moved_event_reason(event)
|
||||
|
||||
self.assertEqual(reason, TextEventReason.FOCUS_CHANGE)
|
||||
isEditable.assert_not_called()
|
||||
|
||||
|
||||
class WebDescriptionChangeRegressionTests(unittest.TestCase):
|
||||
def _make_script(self):
|
||||
@@ -610,7 +684,11 @@ class WebSelectionRegressionTests(unittest.TestCase):
|
||||
testScript = self._make_script()
|
||||
document = object()
|
||||
section = object()
|
||||
event = mock.Mock(source=section, detail1=-1)
|
||||
event = mock.Mock(
|
||||
type="object:text-caret-moved",
|
||||
source=section,
|
||||
detail1=-1,
|
||||
)
|
||||
manager = mock.Mock()
|
||||
manager.last_event_was_forward_caret_selection.return_value = True
|
||||
manager.last_event_was_backward_caret_selection.return_value = False
|
||||
|
||||
Reference in New Issue
Block a user