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

@@ -2,7 +2,6 @@
#define WX_TESTPREC_INCLUDED 1
#include "wx/wxprec.h"
#include "wx/stopwatch.h"
#include "wx/evtloop.h"
// This needs to be included before catch.hpp to be taken into account.
@@ -108,27 +107,6 @@ public:
#define WX_ASSERT_FAILS_WITH_ASSERT(cond)
#endif
#define WX_ASSERT_EVENT_OCCURS_IN(eventcounter, count, ms) \
{\
wxStopWatch sw; \
wxEventLoopBase* loop = wxEventLoopBase::GetActive(); \
while(eventcounter.GetCount() < count) \
{ \
if(sw.Time() < ms) \
loop->Dispatch(); \
else \
{ \
CPPUNIT_FAIL(wxString::Format("timeout reached with %d " \
"events received, %d expected", \
eventcounter.GetCount(), count).ToStdString()); \
break; \
} \
} \
eventcounter.Clear(); \
}
#define WX_ASSERT_EVENT_OCCURS(eventcounter,count) WX_ASSERT_EVENT_OCCURS_IN(eventcounter, count, 100)
// these functions can be used to hook into wxApp event processing and are
// currently used by the events propagation test
class WXDLLIMPEXP_FWD_BASE wxEvent;