summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2018-03-09 07:38:16 +0100
committerFlorian Bruhin <git@the-compiler.org>2018-03-09 07:38:16 +0100
commit66b06ed84ce3b383f03d70b7244b3b02726981b5 (patch)
tree8d7a77a7399b9198c6d3fe657dcb8bf76d3dd097
parentb789e436b8634951d46684517fb762df5f95cd29 (diff)
downloadqutebrowser-66b06ed84ce3b383f03d70b7244b3b02726981b5.tar.gz
qutebrowser-66b06ed84ce3b383f03d70b7244b3b02726981b5.zip
Add first tests for HintKeyParser
-rw-r--r--tests/unit/keyinput/test_modeparsers.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/tests/unit/keyinput/test_modeparsers.py b/tests/unit/keyinput/test_modeparsers.py
index c3be9d70f..cd1f110bc 100644
--- a/tests/unit/keyinput/test_modeparsers.py
+++ b/tests/unit/keyinput/test_modeparsers.py
@@ -22,6 +22,7 @@
from unittest import mock
from PyQt5.QtCore import Qt
+from PyQt5.QtGui import QKeySequence
import pytest
@@ -30,12 +31,6 @@ from qutebrowser.keyinput import modeparsers, keyutils
class TestsNormalKeyParser:
- """Tests for NormalKeyParser.
-
- Attributes:
- kp: The NormalKeyParser to be tested.
- """
-
@pytest.fixture(autouse=True)
def patch_stuff(self, monkeypatch, stubs, keyinput_bindings):
"""Set up mocks and read the test config."""
@@ -81,3 +76,23 @@ class TestsNormalKeyParser:
assert not keyparser.execute.called
assert not keyparser._sequence
keystring_updated_mock.assert_called_once_with('')
+
+
+class TestHintKeyParser:
+
+ @pytest.fixture
+ def keyparser(self, config_stub, key_config_stub):
+ kp = modeparsers.HintKeyParser(0)
+ kp.execute = mock.Mock()
+ kp.keystring_updated.disconnect() # Don't try to update HintManager
+ return kp
+
+ def test_simple_hint_match(self, keyparser, fake_keyevent):
+ keyparser.update_bindings(['aa', 'as'])
+
+ match = keyparser.handle(fake_keyevent(Qt.Key_A))
+ assert match == QKeySequence.PartialMatch
+ match = keyparser.handle(fake_keyevent(Qt.Key_S))
+ assert match == QKeySequence.ExactMatch
+
+ keyparser.execute.assert_called_with('follow-hint -s as', None)