File indexing completed on 2024-05-19 04:39:57
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2013 Kevin Funk <kevin@kfunk.org> 0004 SPDX-FileCopyrightText: 2023 Igor Kushnir <igorkuo@gmail.com> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef KCOMPOUNDJOBTEST_H 0010 #define KCOMPOUNDJOBTEST_H 0011 0012 #include <QObject> 0013 0014 #include "kcompoundjob.h" 0015 0016 using namespace KDevCoreAddons; 0017 0018 class TestJob : public KJob 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 explicit TestJob(QObject *parent = nullptr); 0024 0025 /// Takes 1 second to finish 0026 void start() override; 0027 0028 using KJob::emitResult; 0029 }; 0030 0031 class KillableTestJob : public TestJob 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 explicit KillableTestJob(QObject *parent = nullptr); 0037 0038 protected: 0039 bool doKill() override; 0040 }; 0041 0042 class TestCompoundJob : public KCompoundJob 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 explicit TestCompoundJob(QObject *parent = nullptr) 0048 : KCompoundJob(parent) 0049 { 0050 } 0051 0052 void start() override; 0053 0054 using KCompoundJob::addSubjob; 0055 using KCompoundJob::clearSubjobs; 0056 0057 protected Q_SLOTS: 0058 void subjobFinished(KJob *job) override; 0059 }; 0060 0061 class KCompoundJobTest : public QObject 0062 { 0063 Q_OBJECT 0064 0065 public: 0066 enum class Action { Finish, KillVerbosely, KillQuietly, Destroy }; 0067 Q_ENUM(Action) 0068 0069 KCompoundJobTest(); 0070 0071 private Q_SLOTS: 0072 void initTestCase(); 0073 0074 void testDeletionDuringExecution_data(); 0075 void testDeletionDuringExecution(); 0076 0077 void testFinishingSubjob_data(); 0078 void testFinishingSubjob(); 0079 }; 0080 0081 #endif // KCOMPOUNDJOBTEST_H