diff options
author | Florian Bruhin <me@the-compiler.org> | 2019-09-11 12:14:31 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2019-09-11 12:14:31 +0200 |
commit | 2df9bf8e537c0196d9768e5d38d601c79c3aef3e (patch) | |
tree | 8aad4f26db1a3ad317dd25822c70fd8ce10b2e34 /tests/unit/keyinput/test_keyutils.py | |
parent | 1c25bd11c141900de66dd9fea52dbbc45bc0cbe1 (diff) | |
parent | a86a47406157e4e09afea8a912dc983d2831b15c (diff) | |
download | qutebrowser-2df9bf8e537c0196d9768e5d38d601c79c3aef3e.tar.gz qutebrowser-2df9bf8e537c0196d9768e5d38d601c79c3aef3e.zip |
Merge remote-tracking branch 'origin/pr/4492'
Diffstat (limited to 'tests/unit/keyinput/test_keyutils.py')
-rw-r--r-- | tests/unit/keyinput/test_keyutils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit/keyinput/test_keyutils.py b/tests/unit/keyinput/test_keyutils.py index e0eb2bec2..44821344d 100644 --- a/tests/unit/keyinput/test_keyutils.py +++ b/tests/unit/keyinput/test_keyutils.py @@ -173,6 +173,34 @@ def test_key_info_str(key, modifiers, expected): assert str(keyutils.KeyInfo(key, modifiers)) == expected +@pytest.mark.parametrize('key, modifiers, text, expected', [ + (0xd83c, Qt.NoModifier, '🏻', '<🏻>'), + (0xd867, Qt.NoModifier, '𩷶', '<𩷶>'), + (0xd867, Qt.ShiftModifier, '𩷶', '<Shift+𩷶>'), +]) +def test_surrogates(key, modifiers, text, expected): + evt = QKeyEvent(QKeyEvent.KeyPress, key, modifiers, text) + assert str(keyutils.KeyInfo.from_event(evt)) == expected + + +@pytest.mark.parametrize('keys, expected', [ + ([0x1f3fb], '<🏻>'), + ([0x29df6], '<𩷶>'), + ([Qt.Key_Shift, 0x29df6], '<Shift><𩷶>'), + ([0x1f468, 0x200d, 0x1f468, 0x200d, 0x1f466], '<👨><><👨><><👦>'), +]) +def test_surrogate_sequences(keys, expected): + seq = keyutils.KeySequence(*keys) + assert str(seq) == expected + + +# This shouldn't happen, but if it does we should handle it well +def test_surrogate_error(): + evt = QKeyEvent(QKeyEvent.KeyPress, 0xd83e, Qt.NoModifier, '🤞🏻') + with pytest.raises(keyutils.KeyParseError): + keyutils.KeyInfo.from_event(evt) + + @pytest.mark.parametrize('keystr, expected', [ ('foo', "Could not parse 'foo': error"), (None, "Could not parse keystring: error"), |