Browse Source

`UnitTest::cleanup()` shall drain any remaining signals or events.

Any signals or events which do significant work (including deleting objects marked with `deleteLater()`) may cause segmentation faults or use-after-free errors.
QGC4.4
Keith Bennett 4 years ago committed by Don Gagne
parent
commit
c34f58885c
  1. 8
      src/qgcunittest/UnitTest.cc

8
src/qgcunittest/UnitTest.cc

@ -63,7 +63,7 @@ void UnitTest::_unitTestCalled(void)
QList<UnitTest*>& UnitTest::_testList(void) QList<UnitTest*>& UnitTest::_testList(void)
{ {
static QList<UnitTest*> tests; static QList<UnitTest*> tests;
return tests; return tests;
} }
int UnitTest::run(QString& singleTest) int UnitTest::run(QString& singleTest)
@ -134,6 +134,12 @@ void UnitTest::cleanup(void)
QEXPECT_FAIL("", "Expecting failure due internal testing", Continue); QEXPECT_FAIL("", "Expecting failure due internal testing", Continue);
} }
QCOMPARE(_missedFileDialogCount, 0); QCOMPARE(_missedFileDialogCount, 0);
// Don't let any lingering signals or events cross to the next unit test.
// If you have a failure whose stack trace points to this then
// your test is leaking signals or events. It could cause use-after-free or
// segmentation faults from wild pointers.
qgcApp()->processEvents();
} }
void UnitTest::setExpectedMessageBox(QMessageBox::StandardButton response) void UnitTest::setExpectedMessageBox(QMessageBox::StandardButton response)

Loading…
Cancel
Save