File: testobject.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 (32 lines) | stat: -rw-r--r-- 804 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
23
24
25
26
27
28
29
30
31
32
// SPDX-FileCopyrightText: 2021 Daniel Vrátil <dvratil@kde.org>
//
// SPDX-License-Identifier: MIT

#include "testobject.h"

using namespace QCoro;

TestContext::TestContext(QEventLoop &el) : mEventLoop(&el) {
    mEventLoop->setProperty("testFinished", false);
    mEventLoop->setProperty("shouldNotSuspend", false);
}

TestContext::TestContext(TestContext &&other) noexcept {
    std::swap(mEventLoop, other.mEventLoop);
}

TestContext::~TestContext() {
    if (mEventLoop) {
        mEventLoop->setProperty("testFinished", true);
        mEventLoop->quit();
    }
}

TestContext &TestContext::operator=(TestContext &&other) noexcept {
    std::swap(mEventLoop, other.mEventLoop);
    return *this;
}

void TestContext::setShouldNotSuspend() {
    mEventLoop->setProperty("shouldNotSuspend", true);
}