update combo unit tests

This commit is contained in:
xs5871 2022-06-05 20:58:01 +00:00 committed by Kyle Brown
parent 400042f799
commit 35b1a5843f

View File

@ -7,7 +7,7 @@ from tests.keyboard_test import KeyboardTest
class TestCombo(unittest.TestCase):
def test_basic_kmk_keyboard(self):
def setUp(self):
combos = Combos()
layers = Layers()
KCMO = KC.MO(1)
@ -20,9 +20,10 @@ class TestCombo(unittest.TestCase):
Sequence((KC.N1, KC.N2), KC.X, timeout=50),
Sequence((KC.N3, KC.N4), KC.Z, timeout=100),
Sequence((KC.N1, KC.N1, KC.N1), KC.W, timeout=50),
Sequence((KC.N3, KC.N2, KC.N1), KC.Y, timeout=50, fast_reset=False),
Sequence((KC.LEADER, KC.N1), KC.V, timeout=50),
]
keyboard = KeyboardTest(
self.keyboard = KeyboardTest(
[combos, layers],
[
[KC.A, KC.B, KC.C, KC.D, KC.E, KCMO],
@ -31,10 +32,14 @@ class TestCombo(unittest.TestCase):
debug_enabled=False,
)
t_within = 40
t_after = 60
self.t_within = 40
self.t_after = 60
def test_chord(self):
keyboard = self.keyboard
t_within = self.t_within
t_after = self.t_after
# test combos
keyboard.test(
'match: 2 combo, within timeout',
[(0, True), t_within, (1, True), (0, False), (1, False), t_after],
@ -42,12 +47,11 @@ class TestCombo(unittest.TestCase):
)
keyboard.test(
'match: 3 combo, within timout, shuffled',
'match: 3 combo, within timeout, shuffled',
[
(0, True),
(2, True),
(1, True),
t_within,
(1, False),
(0, False),
(2, False),
@ -66,7 +70,7 @@ class TestCombo(unittest.TestCase):
t_after,
(2, True),
(2, False),
2 * t_after,
t_after,
],
[{KC.X}, {}, {KC.C}, {}],
)
@ -149,7 +153,42 @@ class TestCombo(unittest.TestCase):
[{KC.X}, {KC.E, KC.X}, {KC.E}, {}],
)
#
keyboard.test(
'match: 2 combo, partial release and repeat',
[
(0, True),
(1, True),
t_after,
(1, False),
t_after,
(1, True),
(1, False),
(0, False),
t_after,
],
[{KC.X}, {}, {KC.X}, {}],
)
keyboard.test(
'match: 2 combo, partial release and repeat',
[
(0, True),
(2, True),
(1, True),
t_after,
(1, False),
(0, False),
t_after,
(1, True),
(0, True),
(1, False),
(0, False),
(2, False),
t_after,
],
[{KC.Y}, {}, {KC.Y}, {}],
)
keyboard.test(
'match: 2 combo + 2 combo, after timeout',
[
@ -158,7 +197,6 @@ class TestCombo(unittest.TestCase):
t_after,
(2, True),
(3, True),
2 * t_after,
(0, False),
(1, False),
(2, False),
@ -176,7 +214,6 @@ class TestCombo(unittest.TestCase):
t_after,
(2, True),
(3, True),
2 * t_after,
(2, False),
(3, False),
t_after,
@ -188,7 +225,7 @@ class TestCombo(unittest.TestCase):
)
keyboard.test(
'no match: partial combor, after timeout',
'no match: partial combo, after timeout',
[(0, True), (0, False), t_after],
[{KC.A}, {}],
)
@ -212,7 +249,6 @@ class TestCombo(unittest.TestCase):
keyboard.test(
'no match: partial combo, repeated',
[
t_after,
(0, True),
(0, False),
(1, True),
@ -258,7 +294,7 @@ class TestCombo(unittest.TestCase):
)
keyboard.test(
'no match: 2 + other combo within timeout',
'no match: 2 combo + other within timeout',
[
(0, True),
t_within,
@ -274,7 +310,7 @@ class TestCombo(unittest.TestCase):
)
keyboard.test(
'no match: 2 Combo after timeout',
'no match: 2 combo after timeout',
[(0, True), (0, False), t_after, (1, True), (1, False), t_after],
[{KC.A}, {}, {KC.B}, {}],
)
@ -313,7 +349,6 @@ class TestCombo(unittest.TestCase):
[
(5, True),
(2, True),
t_within,
(2, False),
(5, False),
t_after,
@ -333,8 +368,13 @@ class TestCombo(unittest.TestCase):
[{KC.N1}, {}],
)
# test sequences
def test_sequence(self):
keyboard = self.keyboard
t_within = self.t_within
t_after = self.t_after
keyboard.keyboard.active_layers = [1]
keyboard.test(
'match: leader sequence, within timeout',
[(5, True), (5, False), t_within, (0, True), (0, False), t_after],
@ -380,12 +420,46 @@ class TestCombo(unittest.TestCase):
t_within,
(0, True),
(0, False),
t_within,
t_after,
],
[{KC.W}, {}],
)
keyboard.test(
'match: 3 sequence hold + other, within timeout',
[
(0, True),
(0, False),
(0, True),
(0, False),
(0, True),
t_after,
(4, True),
(0, False),
(4, False),
t_after,
],
[{KC.W}, {KC.W, KC.N5}, {KC.N5}, {}],
)
keyboard.test(
'match: 3 sequence, partial release and repeat',
[
(2, True),
(1, True),
(0, True),
(0, False),
(1, False),
(1, True),
(0, True),
(1, False),
(2, False),
(0, False),
t_after,
],
[{KC.Y}, {}, {KC.Y}, {}],
)
keyboard.test(
'no match: 2 sequence, after timeout',
[(0, True), (0, False), t_after, (1, True), (1, False), t_after],