From ec007c0f2774731e9641a21b620794fccab5fec0 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 9 Mar 2017 17:17:21 +0100 Subject: [PATCH] input_filter.run: stabilize key-repeat test Under certain timing conditions, the test would end up flushing the input from the input filter in a nested way, which ultimately resulted in lost input events of the outer nesting level. This patch eliminates this corner case and thereby stabilizes the key-repeat test. --- repos/os/src/test/input_filter/main.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/repos/os/src/test/input_filter/main.cc b/repos/os/src/test/input_filter/main.cc index 73645e8c8a..853d020135 100644 --- a/repos/os/src/test/input_filter/main.cc +++ b/repos/os/src/test/input_filter/main.cc @@ -75,11 +75,17 @@ class Test::Input_from_filter bool _input_expected = false; + bool _handle_input_in_progress = false; + void _handle_input() { + _handle_input_in_progress = true; + if (_input_expected) _connection.for_each_event([&] (Input::Event const &event) { _event_handler.handle_event_from_filter(event); }); + + _handle_input_in_progress = false; } Signal_handler _input_handler { @@ -97,6 +103,12 @@ class Test::Input_from_filter void input_expected(bool expected) { _input_expected = expected; + + /* prevent nested call of '_handle_input' */ + if (!_input_expected || _handle_input_in_progress) + return; + + /* if new step expects input, process currently pending events */ _handle_input(); } };