diff --git a/tools/test_webui.py b/tools/test_webui.py index 4a42641..af205aa 100644 --- a/tools/test_webui.py +++ b/tools/test_webui.py @@ -137,16 +137,6 @@ class TestFrontEnd(unittest.TestCase): for key in webui.KEYS: self.assertIn(f'data-key="{key}"', self.body) - def test_sends_down_and_up_not_just_tap(self): - """Real press duration must come from the browser. - - The firmware distinguishes a short press from a held key at 400 ms, so - the front end has to send the two edges separately rather than asking the - server for a fixed-length tap. - """ - self.assertIn("send(key, 'down')", self.body) - self.assertIn("send(key, 'up')", self.body) - def test_binds_pointer_and_keyboard_input(self): self.assertIn("pointerdown", self.body) self.assertIn("keydown", self.body) @@ -207,5 +197,28 @@ class TestHoldMs(unittest.TestCase): self.assertEqual(resp.get_json()["hold_ms"], 900) +class TestFrontEndHoldMs(unittest.TestCase): + """The page must send one request per key, carrying a measured duration.""" + + def setUp(self): + _, http = make_app() + self.body = http.get("/").get_data(as_text=True) + + def test_sends_hold_ms(self): + self.assertIn("hold_ms", self.body) + + def test_measures_press_duration_in_the_browser(self): + self.assertIn("performance.now()", self.body) + + def test_does_not_send_separate_down_and_up_for_taps(self): + """Two requests per key double the latency and break at 400 ms RTT.""" + self.assertNotIn("send(key, 'down')", self.body) + self.assertNotIn("send(key, 'up')", self.body) + + def test_enforces_a_minimum_hold(self): + """A very fast click still has to clear the 20 ms debounce.""" + self.assertIn("MIN_HOLD_MS", self.body) + + if __name__ == "__main__": unittest.main() diff --git a/tools/webui.py b/tools/webui.py index 9b2885d..0cbba22 100644 --- a/tools/webui.py +++ b/tools/webui.py @@ -218,21 +218,23 @@ def render_index(scale: int) -> str:
{grid}
connecting...
-

Hold a key to send a long press: over 400 ms the firmware +

How long you hold a key is measured here and sent as a number, + so a slow link cannot turn a tap into a long press. Over 400 ms the firmware treats it as held, which is a different event. Arrows move, Enter is MENU, Esc is EXIT, digits map straight through. No PTT button -- the keypad model has no PTT line.