From 528daea04681eeb012c5bd963463ebeabebdc1bd Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 13 Apr 2020 11:12:43 +0200 Subject: layout: Add test for getText+__call__ identity --- lulua/test_layout.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lulua/test_layout.py b/lulua/test_layout.py index 909b717..45141ae 100644 --- a/lulua/test_layout.py +++ b/lulua/test_layout.py @@ -24,7 +24,7 @@ from itertools import product import pytest from .layout import defaultLayouts, GenericLayout, ButtonCombination -from .keyboard import defaultKeyboards +from .keyboard import defaultKeyboards, LetterButton @pytest.mark.parametrize("layout", defaultLayouts, ids=[l.name for l in defaultLayouts]) def test_atomic (layout): @@ -54,6 +54,21 @@ def test_layout_equality (a, b): else: assert a != b +@pytest.mark.parametrize("layout", defaultLayouts, ids=[l.name for l in defaultLayouts]) +def test_layout_text_identity (layout): + """ Make sure __call__ and getText work for every layout """ + keyboard = defaultKeyboards['ibmpc105'] + layout = layout.specialize (keyboard) + + for match, combinations in layout: + # all combinations produce this match + for comb in combinations: + assert layout.getText (comb) == match + # this match produces all combinations + newmatch, newcombinations = layout (match) + assert newmatch == match + assert set (newcombinations) == set (combinations) + def test_layout_isModifier (): keyboard = defaultKeyboards['ibmpc105'] layout = defaultLayouts['ar-linux'].specialize (keyboard) -- cgit v1.2.3