Add WaitFor() helper and use it in Button::Click unit test
This test also sporadically happens under AppVeyor, check if it happens because we need to wait for some time before the event is processed.
This commit is contained in:
parent
55e074f5bc
commit
1237322404
2 changed files with 30 additions and 1 deletions
|
|
@ -12,6 +12,31 @@
|
|||
#include "wx/stopwatch.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
// Function used to wait until the given predicate becomes true or timeout
|
||||
// expires.
|
||||
inline bool
|
||||
WaitFor(const char* what, const std::function<bool ()>& pred, int timeout = 500)
|
||||
{
|
||||
wxStopWatch sw;
|
||||
for ( ;; )
|
||||
{
|
||||
wxYield();
|
||||
|
||||
if ( pred() )
|
||||
break;
|
||||
|
||||
if ( sw.Time() > timeout )
|
||||
{
|
||||
WARN("Timed out waiting for " << what);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Class used to check if we received the (first) paint event: this is
|
||||
// currently used under GTK only, as MSW doesn't seem to need to wait for the
|
||||
// things to work, while under Mac nothing works anyhow.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue