| 87 | } |
| 88 | |
| 89 | void KSequentialCompoundJobTest::runOneJob() |
| 90 | { |
| 91 | QPointer slave(new TestJob); |
| 92 | |
| 93 | QPointer master(new KSimpleSequentialCompoundJob); |
| 94 | QVERIFY(master->addSubjob(slave)); |
| 95 | JobSpy masterSpy(master); |
| 96 | |
| 97 | QSignalSpy startedSpy(slave, &TestJob::started); |
| 98 | JobSpy slaveSpy(slave); |
| 99 | |
| 100 | master->start(); |
| 101 | QCOMPARE(startedSpy.count(), 1); |
| 102 | QCOMPARE(slaveSpy.finished.count(), 0); |
| 103 | QCOMPARE(masterSpy.finished.count(), 0); |
| 104 | |
| 105 | QCOMPARE(masterSpy.percentChanged.count(), 0); |
| 106 | QCOMPARE(master->percent(), 0); |
| 107 | |
| 108 | slave->emitResult(); |
| 109 | |
| 110 | QCOMPARE(masterSpy.percentChanged.count(), 1); |
| 111 | QCOMPARE(master->percent(), 100); |
| 112 | |
| 113 | QCOMPARE(masterSpy.finished.count(), 1); |
| 114 | QCOMPARE(masterSpy.result.count(), 1); |
| 115 | |
| 116 | QCOMPARE(startedSpy.count(), 1); |
| 117 | QCOMPARE(slaveSpy.finished.count(), 1); |
| 118 | QCOMPARE(slaveSpy.result.count(), 1); |
| 119 | |
| 120 | QTest::qWait(1); |
| 121 | |
| 122 | QVERIFY(!slave); |
| 123 | QVERIFY(!master); |
| 124 | |
| 125 | QCOMPARE(slaveSpy.percentChanged.count(), 0); |
| 126 | QCOMPARE(masterSpy.percentChanged.count(), 1); |
| 127 | } |
| 128 | |
| 129 | void KSequentialCompoundJobTest::runTwoJobs() |
| 130 | { |