tst_qeventdispatcher: avoid influence between test functions
When some test function fails (even as expected), it can leave the event dispatcher in an inconsistent state where the posted events queue might not be empty. As a result, this may break the internal logic of the next test function that is run. So, calling eventDispatcher->processEvents() after each completed function resets the event dispatcher to its initial state, which fixes the problem. Pick-to: 6.2 6.3 Change-Id: I5a54f892d09a6eca73c8fc82875ce3b9ce4a3242 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
552d1c9166
commit
9f6f3da8eb
@ -65,6 +65,8 @@ public:
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanup();
|
||||
|
||||
void registerTimer();
|
||||
|
||||
/* void registerSocketNotifier(); */ // Not implemented here, see tst_QSocketNotifier instead
|
||||
@ -111,6 +113,12 @@ void tst_QEventDispatcher::initTestCase()
|
||||
}
|
||||
}
|
||||
|
||||
// consume pending posted events to avoid impact on the next test function
|
||||
void tst_QEventDispatcher::cleanup()
|
||||
{
|
||||
eventDispatcher->processEvents(QEventLoop::AllEvents);
|
||||
}
|
||||
|
||||
class TimerManager {
|
||||
Q_DISABLE_COPY(TimerManager)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user