Add a test for ignoring _toggle_sel_translate
This commit is contained in:
parent
592735767f
commit
c048a48b78
|
|
@ -535,6 +535,8 @@ class WebEngineCaret(browsertab.AbstractCaret):
|
|||
# This may happen if the user switches to another mode after
|
||||
# `:toggle-selection` is executed and before this callback function
|
||||
# is asynchronously called.
|
||||
log.misc.debug("Ignoring caret selection callback in {}".format(
|
||||
self._mode_manager.mode))
|
||||
return
|
||||
if state_str is None:
|
||||
message.error("Error toggling caret selection")
|
||||
|
|
|
|||
|
|
@ -99,6 +99,21 @@ def test_toggle(caret, selection, qtbot):
|
|||
assert selection.toggle() == browsertab.SelectionState.none
|
||||
|
||||
|
||||
def test_selection_callback_wrong_mode(qtbot, caplog,
|
||||
webengine_tab, mode_manager):
|
||||
"""Test what calling the selection callback outside of caret mode.
|
||||
|
||||
It should be ignored, as something could have left caret mode while the
|
||||
async callback was happening, so we don't want to mess with the status bar.
|
||||
"""
|
||||
assert mode_manager.mode == usertypes.KeyMode.normal
|
||||
with qtbot.assertNotEmitted(webengine_tab.caret.selection_toggled):
|
||||
webengine_tab.caret._toggle_sel_translate('normal')
|
||||
|
||||
msg = 'Ignoring caret selection callback in KeyMode.normal'
|
||||
assert caplog.messages == [msg]
|
||||
|
||||
|
||||
class TestDocument:
|
||||
|
||||
def test_selecting_entire_document(self, caret, selection):
|
||||
|
|
|
|||
Loading…
Reference in New Issue