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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user