Patronum/Tests/testutils.cpp

30 lines
741 B
C++
Raw Normal View History

2020-05-06 23:23:46 +03:00
#include "testutils.h"
#include <QCoreApplication>
#include <QDateTime>
#include <QVariantMap>
TestUtils::TestUtils()
{
}
bool TestUtils::wait(const bool &forWait, int msec) {
auto curmsec = QDateTime::currentMSecsSinceEpoch() + msec;
while (curmsec > QDateTime::currentMSecsSinceEpoch() && !forWait) {
QCoreApplication::processEvents();
}
QCoreApplication::processEvents();
return forWait;
}
2021-04-28 18:38:39 +03:00
bool TestUtils::wait(std::function<bool ()> forWait, int msec) {
auto curmsec = QDateTime::currentMSecsSinceEpoch() + msec;
while (curmsec > QDateTime::currentMSecsSinceEpoch() && !forWait()) {
QCoreApplication::processEvents();
}
QCoreApplication::processEvents();
return forWait();
}