tst_QApplication::testDeleteLaterProcessEvents(): Split the test
The test can trigger timeouts in COIN, split into subtests. Change-Id: I1fa5d52422275f89b2858d90c5979632aa7058e2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
d934fd7f54
commit
ae653fc08b
@ -93,7 +93,11 @@ private slots:
|
|||||||
void quitOnLastWindowClosed();
|
void quitOnLastWindowClosed();
|
||||||
void closeAllWindows();
|
void closeAllWindows();
|
||||||
void testDeleteLater();
|
void testDeleteLater();
|
||||||
void testDeleteLaterProcessEvents();
|
void testDeleteLaterProcessEvents1();
|
||||||
|
void testDeleteLaterProcessEvents2();
|
||||||
|
void testDeleteLaterProcessEvents3();
|
||||||
|
void testDeleteLaterProcessEvents4();
|
||||||
|
void testDeleteLaterProcessEvents5();
|
||||||
|
|
||||||
#if QT_CONFIG(library)
|
#if QT_CONFIG(library)
|
||||||
void libraryPaths();
|
void libraryPaths();
|
||||||
@ -1333,10 +1337,8 @@ public slots:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QApplication::testDeleteLaterProcessEvents()
|
void tst_QApplication::testDeleteLaterProcessEvents1()
|
||||||
{
|
{
|
||||||
int argc = 0;
|
|
||||||
|
|
||||||
// Calling processEvents() with no event dispatcher does nothing.
|
// Calling processEvents() with no event dispatcher does nothing.
|
||||||
QObject *object = new QObject;
|
QObject *object = new QObject;
|
||||||
QPointer<QObject> p(object);
|
QPointer<QObject> p(object);
|
||||||
@ -1344,14 +1346,17 @@ void tst_QApplication::testDeleteLaterProcessEvents()
|
|||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
QVERIFY(p);
|
QVERIFY(p);
|
||||||
delete object;
|
delete object;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QApplication::testDeleteLaterProcessEvents2()
|
||||||
{
|
{
|
||||||
|
int argc = 0;
|
||||||
QApplication app(argc, nullptr);
|
QApplication app(argc, nullptr);
|
||||||
// If you call processEvents() with an event dispatcher present, but
|
// If you call processEvents() with an event dispatcher present, but
|
||||||
// outside any event loops, deferred deletes are not processed unless
|
// outside any event loops, deferred deletes are not processed unless
|
||||||
// sendPostedEvents(0, DeferredDelete) is called.
|
// sendPostedEvents(0, DeferredDelete) is called.
|
||||||
object = new QObject;
|
auto object = new QObject;
|
||||||
p = object;
|
QPointer<QObject> p(object);
|
||||||
object->deleteLater();
|
object->deleteLater();
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
QVERIFY(p);
|
QVERIFY(p);
|
||||||
@ -1369,14 +1374,17 @@ void tst_QApplication::testDeleteLaterProcessEvents()
|
|||||||
loop.exec();
|
loop.exec();
|
||||||
QVERIFY(!p);
|
QVERIFY(!p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QApplication::testDeleteLaterProcessEvents3()
|
||||||
{
|
{
|
||||||
|
int argc = 0;
|
||||||
// When an object is in an event loop, then calls deleteLater() and enters
|
// When an object is in an event loop, then calls deleteLater() and enters
|
||||||
// an event loop recursively, it should not die until the parent event
|
// an event loop recursively, it should not die until the parent event
|
||||||
// loop continues.
|
// loop continues.
|
||||||
QApplication app(argc, nullptr);
|
QApplication app(argc, nullptr);
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
EventLoopNester *nester = new EventLoopNester;
|
EventLoopNester *nester = new EventLoopNester;
|
||||||
p = nester;
|
QPointer<QObject> p(nester);
|
||||||
QTimer::singleShot(3000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(3000, &loop, &QEventLoop::quit);
|
||||||
QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndEnterLoop);
|
QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndEnterLoop);
|
||||||
|
|
||||||
@ -1384,14 +1392,16 @@ void tst_QApplication::testDeleteLaterProcessEvents()
|
|||||||
QVERIFY(!p);
|
QVERIFY(!p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QApplication::testDeleteLaterProcessEvents4()
|
||||||
{
|
{
|
||||||
|
int argc = 0;
|
||||||
// When the event loop that calls deleteLater() is exited
|
// When the event loop that calls deleteLater() is exited
|
||||||
// immediately, the object should die when returning to the
|
// immediately, the object should die when returning to the
|
||||||
// parent event loop
|
// parent event loop
|
||||||
QApplication app(argc, nullptr);
|
QApplication app(argc, nullptr);
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
EventLoopNester *nester = new EventLoopNester;
|
EventLoopNester *nester = new EventLoopNester;
|
||||||
p = nester;
|
QPointer<QObject> p(nester);
|
||||||
QTimer::singleShot(3000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(3000, &loop, &QEventLoop::quit);
|
||||||
QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndExitLoop);
|
QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndExitLoop);
|
||||||
|
|
||||||
@ -1399,21 +1409,22 @@ void tst_QApplication::testDeleteLaterProcessEvents()
|
|||||||
QVERIFY(!p);
|
QVERIFY(!p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QApplication::testDeleteLaterProcessEvents5()
|
||||||
{
|
{
|
||||||
// when the event loop that calls deleteLater() also calls
|
// when the event loop that calls deleteLater() also calls
|
||||||
// processEvents() immediately afterwards, the object should
|
// processEvents() immediately afterwards, the object should
|
||||||
// not die until the parent loop continues
|
// not die until the parent loop continues
|
||||||
|
int argc = 0;
|
||||||
QApplication app(argc, nullptr);
|
QApplication app(argc, nullptr);
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
EventLoopNester *nester = new EventLoopNester();
|
EventLoopNester *nester = new EventLoopNester();
|
||||||
p = nester;
|
QPointer<QObject> p(nester);
|
||||||
QTimer::singleShot(3000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(3000, &loop, &QEventLoop::quit);
|
||||||
QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndProcessEvents);
|
QTimer::singleShot(0, nester, &EventLoopNester::deleteLaterAndProcessEvents);
|
||||||
|
|
||||||
loop.exec();
|
loop.exec();
|
||||||
QVERIFY(!p);
|
QVERIFY(!p);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Test for crash with QApplication::setDesktopSettingsAware(false).
|
Test for crash with QApplication::setDesktopSettingsAware(false).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user