Hopefully fix some wayland keyboard stuff.

This commit is contained in:
Storm Dragon
2026-04-08 03:37:50 -04:00
parent 2d9790de88
commit eeb7bd046f
6 changed files with 124 additions and 12 deletions
+44
View File
@@ -0,0 +1,44 @@
import sys
import unittest
from pathlib import Path
from unittest import mock
import gi
gi.require_version("Gdk", "3.0")
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from gi.repository import Gdk
from cthulhu import cthulhu_state
from cthulhu import input_event
from cthulhu import learn_mode_presenter
class LearnModePresenterRegressionTests(unittest.TestCase):
def test_escape_keyval_exits_learn_mode_when_event_string_is_control_character(self):
presenter = learn_mode_presenter.LearnModePresenter(mock.Mock())
presenter._is_active = True
keyboardEvent = input_event.KeyboardEvent(
True,
9,
Gdk.KEY_Escape,
0,
"\x1b",
)
activeScript = mock.Mock()
with mock.patch.object(cthulhu_state, "activeScript", activeScript):
result = presenter.handle_event(keyboardEvent)
self.assertTrue(result)
self.assertFalse(presenter.is_active())
activeScript.speakKeyEvent.assert_called_once_with(keyboardEvent)
activeScript.presentMessage.assert_called_once()
if __name__ == "__main__":
unittest.main()