Changeset View
Changeset View
Standalone View
Standalone View
tests/units/utils/compositejobtest.cpp
Show All 23 Lines | |||||
24 | #include <testlib/qtest_zanshin.h> | 24 | #include <testlib/qtest_zanshin.h> | ||
25 | 25 | | |||
26 | #include "utils/compositejob.h" | 26 | #include "utils/compositejob.h" | ||
27 | 27 | | |||
28 | #include "testlib/fakejob.h" | 28 | #include "testlib/fakejob.h" | ||
29 | 29 | | |||
30 | using namespace Utils; | 30 | using namespace Utils; | ||
31 | 31 | | |||
32 | namespace | ||||
33 | { | ||||
34 | template<typename T> | ||||
35 | QSet<T> listToSet(const QList<T> &list) | ||||
36 | { | ||||
37 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | ||||
38 | return list.toSet(); | ||||
39 | #else | ||||
40 | return {list.cbegin(), list.cend()}; | ||||
41 | #endif | ||||
42 | } | ||||
43 | } | ||||
44 | | ||||
32 | class CompositeJobTest : public QObject | 45 | class CompositeJobTest : public QObject | ||
33 | { | 46 | { | ||
34 | Q_OBJECT | 47 | Q_OBJECT | ||
35 | public: | 48 | public: | ||
36 | explicit CompositeJobTest(QObject *parent = nullptr) | 49 | explicit CompositeJobTest(QObject *parent = nullptr) | ||
37 | : QObject(parent) | 50 | : QObject(parent) | ||
38 | , m_callCount(0) | 51 | , m_callCount(0) | ||
39 | { | 52 | { | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 86 | { | |||
88 | QVERIFY(compositeJob->install(job2, handlerWithJob)); | 101 | QVERIFY(compositeJob->install(job2, handlerWithJob)); | ||
89 | 102 | | |||
90 | // WHEN | 103 | // WHEN | ||
91 | compositeJob->start(); | 104 | compositeJob->start(); | ||
92 | QTest::qWait(FakeJob::DURATION + 10); | 105 | QTest::qWait(FakeJob::DURATION + 10); | ||
93 | 106 | | |||
94 | // THEN | 107 | // THEN | ||
95 | QCOMPARE(callCount, 2); | 108 | QCOMPARE(callCount, 2); | ||
96 | QCOMPARE(seenJobs.toSet(), QSet<KJob*>() << job1 << job2); | 109 | QCOMPARE(listToSet(seenJobs), QSet<KJob*>() << job1 << job2); | ||
97 | QVERIFY(!compositeJob->error()); | 110 | QVERIFY(!compositeJob->error()); | ||
98 | delete compositeJob; | 111 | delete compositeJob; | ||
99 | } | 112 | } | ||
100 | 113 | | |||
101 | void handleJobResult(KJob*) | 114 | void handleJobResult(KJob*) | ||
102 | { | 115 | { | ||
103 | m_callCount++; | 116 | m_callCount++; | ||
104 | } | 117 | } | ||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |