Commit 89de2ae2 authored by Don Gagne's avatar Don Gagne

Fix constructor ordering bug

parent 91abffc0
......@@ -33,7 +33,6 @@ bool UnitTest::_messageBoxRespondedTo = false;
bool UnitTest::_badResponseButton = false;
QMessageBox::StandardButton UnitTest::_messageBoxResponseButton = QMessageBox::NoButton;
int UnitTest::_missedMessageBoxCount = 0;
UnitTest::UnitTestList_t UnitTest::_tests;
UnitTest::UnitTest(void) :
_unitTestRun(false),
......@@ -58,9 +57,11 @@ UnitTest::~UnitTest()
void UnitTest::_addTest(QObject* test)
{
Q_ASSERT(!_tests.contains(test));
QList<QObject*>& tests = _testList();
Q_ASSERT(!tests.contains(test));
_tests.append(test);
tests.append(test);
}
void UnitTest::_unitTestCalled(void)
......@@ -68,11 +69,18 @@ void UnitTest::_unitTestCalled(void)
_unitTestRun = true;
}
/// @brief Returns the list of unit tests.
QList<QObject*>& UnitTest::_testList(void)
{
static QList<QObject*> tests;
return tests;
}
int UnitTest::run(int argc, char *argv[], QString& singleTest)
{
int ret = 0;
foreach (QObject* test, _tests) {
foreach (QObject* test, _testList()) {
if (singleTest.isEmpty() || singleTest == test->objectName()) {
ret += QTest::qExec(test, argc, argv);
}
......@@ -196,3 +204,4 @@ QMessageBox::StandardButton UnitTest::_messageBox(QMessageBox::Icon icon, const
return retButton;
}
......@@ -79,9 +79,9 @@ public:
// @param Expected failure response flags
void checkExpectedMessageBox(int expectFailFlags = expectFailNoFailure);
// Should only be called by UnitTestWrapper
/// @brief Adds a unit test to the list. Should only be called by UnitTestWrapper.
static void _addTest(QObject* test);
protected slots:
// These are all pure virtuals to force the derived class to implement each one and in turn
......@@ -124,7 +124,8 @@ private:
friend class QGCMessageBox;
void _unitTestCalled(void);
static QList<QObject*>& _testList(void);
static bool _messageBoxRespondedTo; ///< Message box was responded to
static bool _badResponseButton; ///< Attempt to repond to expected message box with button not being displayed
static QMessageBox::StandardButton _messageBoxResponseButton; ///< Response to next message box
......@@ -135,10 +136,6 @@ private:
bool _cleanupTestCaseCalled; ///< true: UnitTest::_cleanupTestCase was called
bool _initCalled; ///< true: UnitTest::_init was called
bool _cleanupCalled; ///< true: UnitTest::_cleanup was called
typedef QList<QObject*> UnitTestList_t;
static UnitTestList_t _tests;
};
template <class T>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment