File indexing completed on 2024-04-28 15:34:48
0001 /* -*- C++ -*- 0002 This file contains a testsuite for the queueing behaviour in ThreadWeaver. 0003 0004 SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef QUEUETESTS_H 0010 #define QUEUETESTS_H 0011 0012 #include <QThread> 0013 0014 #include "AppendCharacterJob.h" 0015 0016 class LowPriorityAppendCharacterJob : public AppendCharacterJob 0017 { 0018 public: 0019 LowPriorityAppendCharacterJob(QChar character = QChar(), QString *stringref = nullptr); 0020 0021 int priority() const override; 0022 }; 0023 0024 class HighPriorityAppendCharacterJob : public AppendCharacterJob 0025 { 0026 public: 0027 HighPriorityAppendCharacterJob(QChar character = QChar(), QString *stringref = nullptr); 0028 0029 int priority() const override; 0030 }; 0031 0032 namespace ThreadWeaver 0033 { 0034 class Job; 0035 class Collection; 0036 class QObjectDecorator; 0037 } 0038 0039 using ThreadWeaver::Job; 0040 0041 class SecondThreadThatQueues : public QThread 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 SecondThreadThatQueues(); 0047 0048 protected: 0049 void run() override; 0050 }; 0051 0052 class QueueTests : public QObject 0053 { 0054 Q_OBJECT 0055 0056 public: 0057 explicit QueueTests(QObject *parent = nullptr); 0058 0059 public Q_SLOTS: 0060 // this slot (which is not a test) is part of 0061 // DeleteDoneJobsFromSequenceTest 0062 void deleteJob(ThreadWeaver::JobPointer); 0063 // this slot is part of DeleteCollectionOnDoneTest 0064 void deleteCollection(ThreadWeaver::JobPointer); 0065 0066 private: 0067 // this is also part of DeleteDoneJobsFromSequenceTest 0068 ThreadWeaver::QObjectDecorator *autoDeleteJob; 0069 // this is part of DeleteCollectionOnDoneTest 0070 ThreadWeaver::QObjectDecorator *autoDeleteCollection; 0071 0072 private Q_SLOTS: 0073 0074 void initTestCase(); 0075 0076 void SimpleQueuePrioritiesTest(); 0077 void WeaverInitializationTest(); 0078 void QueueFromSecondThreadTest(); 0079 void DeleteDoneJobsFromSequenceTest(); 0080 void DeleteCollectionOnDoneTest(); 0081 }; 0082 0083 #endif