File: testloop.cpp

package info (click to toggle)
qcoro 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,700 kB
  • sloc: cpp: 8,573; python: 32; xml: 26; makefile: 23; sh: 15
file content (22 lines) | stat: -rw-r--r-- 413 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "testloop.h"

#include <QTest>

TestLoop::TestLoop(QObject *parent)
    : QObject(parent)
{
    mTimer.setSingleShot(true);
    connect(&mTimer, &QTimer::timeout, this, [this]() {
        mEventLoop.quit();
        QFAIL("Test timeout!");
    });
}

void TestLoop::exec() {
    mEventLoop.exec();
}

void TestLoop::quit() {
    mTimer.stop();
    QTimer::singleShot(0, &mEventLoop, &QEventLoop::quit);
}