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.
This commit is contained in:
Norman Feske 2017-03-09 17:17:21 +01:00 committed by Christian Helmuth
parent b9834bc388
commit ec007c0f27

View File

@ -75,11 +75,17 @@ class Test::Input_from_filter
bool _input_expected = false; bool _input_expected = false;
bool _handle_input_in_progress = false;
void _handle_input() void _handle_input()
{ {
_handle_input_in_progress = true;
if (_input_expected) if (_input_expected)
_connection.for_each_event([&] (Input::Event const &event) { _connection.for_each_event([&] (Input::Event const &event) {
_event_handler.handle_event_from_filter(event); }); _event_handler.handle_event_from_filter(event); });
_handle_input_in_progress = false;
} }
Signal_handler<Input_from_filter> _input_handler { Signal_handler<Input_from_filter> _input_handler {
@ -97,6 +103,12 @@ class Test::Input_from_filter
void input_expected(bool expected) void input_expected(bool expected)
{ {
_input_expected = 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(); _handle_input();
} }
}; };