swift
Loading...
Searching...
No Matches
testworker.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
10
11#include <QObject>
12#include <QTest>
13
14#include "misc/eventloop.h"
15#include "misc/worker.h"
16
17using namespace swift::misc;
18
19namespace MiscTest
20{
22 class CTestWorker : public QObject
23 {
25
26 public:
28 explicit CTestWorker(QObject *parent = nullptr);
29
30 private slots:
32 void singleShot();
33 };
34
39
40 void CTestWorker::singleShot()
41 {
42 QFuture<int> future = swift::misc::singleShot(0, this, []() { return 123; });
43 CEventLoop::processEventsFor(0);
44 QVERIFY2(future.isFinished(), "Future is finished after slot has returned");
45 QVERIFY2(future.result() == 123, "Future provides access to slot's return value");
46 }
47
48} // namespace MiscTest
49
52
53#include "testworker.moc"
54
Aviation classes basic tests.
CTestWorker(QObject *parent=nullptr)
Standard test case constructor.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...
Definition threadutils.h:30
bool isFinished() const const
T result() const const
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
#define SWIFTTEST_APPLESS_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject without instantiating a QApplicati...
Definition test.h:39