32 #include <QtCore/QtCore>
35 #include <private/qcoreapplication_p.h>
36 #include <private/qeventloop_p.h>
37 #include <private/qthread_p.h>
40 #include <QtCore/qt_windows.h>
90 void tst_QCoreApplication::sendEventsOnProcessEvents()
104 void tst_QCoreApplication::getSetCheck()
124 void tst_QCoreApplication::qAppName()
126 #ifdef QT_QGUIAPPLICATIONTEST
127 const char* appName =
"tst_qguiapplication";
129 const char* appName =
"tst_qcoreapplication";
134 char *argv[] = {
const_cast<char*
>(appName) };
144 const QString wantedAppName(
"my app name");
147 char *argv[] = {
const_cast<char*
>(appName) };
160 void tst_QCoreApplication::qAppVersion()
162 #if defined(Q_OS_WIN)
163 const char appVersion[] =
"1.2.3.4";
164 #elif defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID)
165 const char appVersion[] =
"1.2.3";
167 const char appVersion[] =
"";
172 char *argv[] = {
nullptr };
180 const QString wantedAppVersion(
"0.0.1");
183 char *argv[] = {
nullptr };
195 void tst_QCoreApplication::argc()
208 const_cast<char*
>(
"arg1"),
209 const_cast<char*
>(
"arg2"),
210 const_cast<char*
>(
"arg3") };
227 const_cast<char*
>(
"-qmljsdebugger=port:3768,block") };
256 void tst_QCoreApplication::postEvent()
341 void tst_QCoreApplication::removePostedEvents()
417 #if QT_CONFIG(thread)
418 class DeliverInDefinedOrderThread :
public QThread
423 DeliverInDefinedOrderThread()
443 class DeliverInDefinedOrderObject :
public QObject
464 thread =
new DeliverInDefinedOrderThread();
473 void threadProgress(
int v)
481 void threadFinished()
485 thread->deleteLater();
490 void threadDestroyed()
501 switch (
event->type()) {
505 if (loopLevel == 2) {
520 void tst_QCoreApplication::deliverInDefinedOrder()
526 DeliverInDefinedOrderObject
obj(&
app);
536 void tst_QCoreApplication::applicationPid()
560 void tst_QCoreApplication::globalPostedEventsCount()
586 QCOMPARE(
x.globalPostedEventsCount, expected);
606 void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
621 }
while (
t.elapsed() < 1000);
625 void tst_QCoreApplication::sendPostedEventsInNativeLoop()
631 bool signalReceived =
false;
635 signalReceived =
true;
639 elapsedTimer.
start();
644 if (elapsedTimer.hasExpired(3000) || signalReceived)
647 if (!::PeekMessage(&
msg,
NULL, 0, 0, PM_REMOVE)) {
652 ::TranslateMessage(&
msg);
653 ::DispatchMessage(&
msg);
676 void tst_QCoreApplication::quit()
726 void tst_QCoreApplication::reexec()
741 void tst_QCoreApplication::execAfterExit()
752 void tst_QCoreApplication::eventLoopExecAfterExit()
795 void tst_QCoreApplication::customEventDispatcher()
921 void tst_QCoreApplication::testQuitLock()
932 void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock()
934 class MyEvent :
public QEvent
958 void tst_QCoreApplication::applicationEventFilters_mainThread()
973 void tst_QCoreApplication::applicationEventFilters_auxThread()
995 void tst_QCoreApplication::threadedEventDelivery_data()
997 QTest::addColumn<bool>(
"requiresCoreApplication");
998 QTest::addColumn<bool>(
"createCoreApplication");
999 QTest::addColumn<bool>(
"eventsReceived");
1004 QTest::newRow(
"independent-without-coreapp") <<
false <<
false <<
true;
1005 QTest::newRow(
"independent-with-coreapp") <<
false <<
true <<
true;
1009 void tst_QCoreApplication::threadedEventDelivery()
1011 QFETCH(
bool, requiresCoreApplication);
1012 QFETCH(
bool, createCoreApplication);
1013 QFETCH(
bool, eventsReceived);
1020 thread.requiresCoreApplication = requiresCoreApplication;
1031 void tst_QCoreApplication::testTrWithPercantegeAtTheEnd()
1036 #if QT_CONFIG(library)
1037 void tst_QCoreApplication::addRemoveLibPaths()
1040 if (
paths.isEmpty())
1041 QSKIP(
"Cannot add/remove library paths if there are none.");
1044 QCoreApplication::addLibraryPath(currentDir);
1047 QCoreApplication::removeLibraryPath(
paths[0]);
1055 if (
paths.length() != 1 && currentDir !=
paths[0]) {
1062 replace << currentDir <<
paths[0];
1063 QCoreApplication::setLibraryPaths(replace);
1064 QCOMPARE(QCoreApplication::libraryPaths(), replace);
1068 static void createQObjectOnDestruction()
1077 obj.thread()->setProperty(
"testing", 1);
1079 Q_DESTRUCTOR_FUNCTION(createQObjectOnDestruction)
1081 #ifndef QT_QGUIAPPLICATIONTEST
1085 #include "tst_qcoreapplication.moc"
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
int remainingTime(int) override
void registerTimer(int, qint64, Qt::TimerType, QObject *) override
QList< TimerInfo > registeredTimers(QObject *) const override
void registerSocketNotifier(QSocketNotifier *) override
void unregisterSocketNotifier(QSocketNotifier *) override
bool unregisterTimer(int) override
bool unregisterTimers(QObject *) override
bool processEvents(QEventLoop::ProcessEventsFlags) override
void interrupt() override
bool event(QEvent *e) override
QList< int > recordedEvents
bool eventFilter(QObject *, QEvent *event) override
QList< int > globalPostedEventsCount
bool event(QEvent *event) override
JobObject(QEventLoop *loop, QObject *parent=nullptr)
JobObject(QObject *parent=nullptr)
ProcessEventsAlwaysSendsPostedEventsObject()
bool event(QEvent *event) override
The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.
static QAbstractEventDispatcher * instance(QThread *thread=nullptr)
T loadRelaxed() const noexcept
The QCoreApplication class provides an event loop for Qt applications without UI.
static QAbstractEventDispatcher * eventDispatcher()
static void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher)
static void removePostedEvents(QObject *receiver, int eventType=0)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
QString applicationVersion
the version of this application
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
static void setApplicationName(const QString &application)
static qint64 applicationPid() Q_DECL_CONST_FUNCTION
static void setApplicationVersion(const QString &version)
static QStringList arguments()
QString applicationName
the name of this application
static void sendPostedEvents(QObject *receiver=nullptr, int event_type=0)
static void exit(int retcode=0)
The QDir class provides access to directory structures and their contents.
QString absolutePath() const
The QElapsedTimer class provides a fast way to calculate elapsed times.
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QEventLoop class provides a means of entering and leaving an event loop.
int exec(ProcessEventsFlags flags=AllEvents)
The QEventLoopLocker class provides a means to quit an event loop when it is no longer needed.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
bool isEmpty() const noexcept
void append(parameter_type t)
The QObject class is the base class of all Qt objects.
void installEventFilter(QObject *filterObj)
void moveToThread(QThread *thread)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
virtual bool event(QEvent *event)
QVariant property(const char *name) const
void destroyed(QObject *=nullptr)
static QObjectPrivate * get(QObject *o)
The QPointer class is a template class that provides guarded pointers to QObject.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
The QString class provides a Unicode character string.
static QString fromLatin1(QByteArrayView ba)
The QStringList class provides a list of strings.
static Q_AUTOTEST_EXPORT QThreadData * current(bool createIfNecessary=true)
void start(Priority=InheritPriority)
static QThread * currentThread()
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
static void msleep(unsigned long)
bool singleShot
whether the timer is a single-shot timer
The QWinEventNotifier class provides support for the Windows Wait functions.
bool eventFilter(QObject *, QEvent *event) override
QuitTester(QObject *parent=nullptr)
bool requiresCoreApplication
bool event(QEvent *event) override
QList< int > recordedEvents
QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int, QString, double)))
[0]
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_TESTLIB_EXPORT const char * currentAppName()
QT_BEGIN_NAMESPACE bool done
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLenum GLenum GLsizei count
GLbitfield GLuint64 timeout
[4]
GLsizei const GLuint * paths
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
#define QTEST_APPLESS_MAIN(TestObject)
#define QSKIP(statement,...)
#define QFETCH(Type, name)
#define QVERIFY(statement)
QApplication app(argc, argv)
[0]
bool contains(const AT &t) const noexcept
QT_BEGIN_NAMESPACE Q_CORE_EXPORT uint qGlobalPostedEventsCount()
QCoreApplication TestApplication
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent