Refactor code waiting for events in the test suite

We already had WX_ASSERT_EVENT_OCCURS_IN macro and a recent commit also
added code doing almost the same thing manually in wxTopLevelWindow unit
test, which was one version too many.

Replace both of them with the new EventCounter::WaitEvent().

No real changes, this is just a refactoring.
This commit is contained in:
Vadim Zeitlin
2019-01-24 14:04:10 +01:00
parent f4ea128007
commit 5811d541da
6 changed files with 33 additions and 39 deletions

View File

@@ -63,3 +63,26 @@ EventCounter::~EventCounter()
m_frame = NULL;
m_win = NULL;
}
bool EventCounter::WaitEvent(int timeInMs)
{
static const int SINGLE_WAIT_DURATION = 50;
for ( int i = 0; i < timeInMs / SINGLE_WAIT_DURATION; ++i )
{
wxYield();
const int count = GetCount();
if ( count )
{
CHECK( count == 1 );
Clear();
return true;
}
wxMilliSleep(SINGLE_WAIT_DURATION);
}
return false;
}