Skip to content

Commit

Permalink
Attempt to stabilize EventLoopChecker on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
danvratil committed May 6, 2022
1 parent c8dcad4 commit 0ffd99a
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/testobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ class TestContext {
class EventLoopChecker : public QTimer {
Q_OBJECT
public:
explicit EventLoopChecker(int minTicks = 10, std::chrono::milliseconds interval = 10ms)
explicit EventLoopChecker(int minTicks = 10, std::chrono::milliseconds interval = 5ms)
: mMinTicks{minTicks} {
connect(this, &EventLoopChecker::timeout, this, &EventLoopChecker::timeoutCheck);
connect(this, &EventLoopChecker::timeout, this, [this]() { ++mTick; });
setInterval(interval);
start();
}

operator bool() const {
return mTick > mMinTicks;
}

private Q_SLOTS:
void timeoutCheck() {
++mTick;
if (mTick < mMinTicks) {
qDebug() << "EventLoopChecker failed: ticks=" << mTick << ", minTicks=" << mMinTicks;
}
return mTick >= mMinTicks;
}

private:
Expand Down

0 comments on commit 0ffd99a

Please sign in to comment.