QThread: check various ways users may use start(Priority)
Some of these would break if we changed the start(Priority) to say start(QThread::Priority) instead. Manual conflict resolution: - added <chrono> include and std:chrono_literals using declaration which 6.7 already had in tst_qthread.cpp Pick-to: 6.2 Task-number: QTBUG-124723 Change-Id: Id3ebe73718c8acbc54a2c88158f4062fd0dd5be1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit cf19105e018314d1fb05bc91959f233d3d6747ba) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit a4c271007743719dc74aa333b37bd1ec78831c94) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
f51b799fe5
commit
9ea2ff075e
@ -38,6 +38,10 @@
|
|||||||
|
|
||||||
#include <QtTest/private/qemulationdetector_p.h>
|
#include <QtTest/private/qemulationdetector_p.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
class tst_QThread : public QObject
|
class tst_QThread : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -51,6 +55,7 @@ private slots:
|
|||||||
void setStackSize();
|
void setStackSize();
|
||||||
void exit();
|
void exit();
|
||||||
void start();
|
void start();
|
||||||
|
void startSlotUsedInStringBasedLookups();
|
||||||
void terminate();
|
void terminate();
|
||||||
void quit();
|
void quit();
|
||||||
void started();
|
void started();
|
||||||
@ -462,6 +467,56 @@ void tst_QThread::start()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QThreadStarter : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using QObject::QObject;
|
||||||
|
Q_SIGNALS:
|
||||||
|
void start(QThread::Priority);
|
||||||
|
};
|
||||||
|
|
||||||
|
class QThreadSelfStarter : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
using QThread::QThread;
|
||||||
|
|
||||||
|
void check()
|
||||||
|
{
|
||||||
|
QVERIFY(connect(this, SIGNAL(starting(Priority)),
|
||||||
|
this, SLOT(start(Priority))));
|
||||||
|
QVERIFY(QMetaObject::invokeMethod(this, "start", Q_ARG(Priority, IdlePriority)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void starting(Priority);
|
||||||
|
};
|
||||||
|
|
||||||
|
void tst_QThread::startSlotUsedInStringBasedLookups()
|
||||||
|
{
|
||||||
|
// QTBUG-124723
|
||||||
|
|
||||||
|
QThread thread;
|
||||||
|
{
|
||||||
|
QThreadStarter starter;
|
||||||
|
QVERIFY(QObject::connect(&starter, SIGNAL(start(QThread::Priority)),
|
||||||
|
&thread, SLOT(start(QThread::Priority))));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QThreadSelfStarter selfStarter;
|
||||||
|
selfStarter.check();
|
||||||
|
if (QTest::currentTestFailed())
|
||||||
|
return;
|
||||||
|
selfStarter.exit();
|
||||||
|
selfStarter.wait(30s);
|
||||||
|
}
|
||||||
|
QVERIFY(QMetaObject::invokeMethod(&thread, "start",
|
||||||
|
Q_ARG(QThread::Priority, QThread::IdlePriority)));
|
||||||
|
thread.exit();
|
||||||
|
thread.wait(30s);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QThread::terminate()
|
void tst_QThread::terminate()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user