Commit 95e74729 authored by Don Gagne's avatar Don Gagne

Merge pull request #786 from DonLakeFlyer/FileManagerUT

File manager Unit Test back on
parents e4977186 2076d3d4
......@@ -14,6 +14,7 @@ bin/*.exe
bin/*.txt
bin/mac
*pro.user*
.qmake.stash
qrc_*.cpp
*.Debug
*.Release
......
......@@ -767,7 +767,8 @@ HEADERS += \
src/qgcunittest/FlightModeConfigTest.h \
src/qgcunittest/FlightGearTest.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h
src/qgcunittest/TCPLoopBackServer.h \
src/qgcunittest/QGCUASFileManagerTest.h
SOURCES += \
src/qgcunittest/UASUnitTest.cc \
......@@ -779,4 +780,5 @@ SOURCES += \
src/qgcunittest/FlightModeConfigTest.cc \
src/qgcunittest/FlightGearTest.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc
src/qgcunittest/TCPLoopBackServer.cc \
src/qgcunittest/QGCUASFileManagerTest.cc
......@@ -281,7 +281,7 @@ void MockMavlinkFileServer::_emitResponse(QGCUASFileManager::Request* request)
request->hdr.crc32 = QGCUASFileManager::crc32(request);
mavlink_msg_encapsulated_data_pack(250, 0, &mavlinkMessage, 0 /*_encdata_seq*/, (uint8_t*)request);
mavlink_msg_encapsulated_data_pack(250, MAV_COMP_ID_IMU, &mavlinkMessage, 0 /*_encdata_seq*/, (uint8_t*)request);
emit messageReceived(NULL, mavlinkMessage);
}
......@@ -96,6 +96,7 @@ bool MultiSignalSpy::checkSignalByMask(quint16 mask)
Q_ASSERT(spy != NULL);
if (spy->count() != 1) {
_printSignalState();
return false;
}
}
......@@ -114,10 +115,12 @@ bool MultiSignalSpy::checkOnlySignalByMask(quint16 mask)
if ((1 << i) & mask) {
if (spy->count() != 1) {
_printSignalState();
return false;
}
} else {
if (spy->count() != 0) {
_printSignalState();
return false;
}
}
......@@ -135,6 +138,7 @@ bool MultiSignalSpy::checkNoSignalByMask(quint16 mask)
Q_ASSERT(spy != NULL);
if (spy->count() != 0) {
_printSignalState();
return false;
}
}
......@@ -232,3 +236,12 @@ bool MultiSignalSpy::waitForSignalByIndex(
return spy->count() != 0;
}
void MultiSignalSpy::_printSignalState(void)
{
for (size_t i=0; i<_cSignals; i++) {
QSignalSpy* spy = _rgSpys[i];
Q_ASSERT(spy != NULL);
qDebug() << "Signal index:" << i << "count:" << spy->count();
}
}
......@@ -59,6 +59,8 @@ public:
private:
// QObject overrides
void timerEvent(QTimerEvent * event);
void _printSignalState(void);
QObject* _signalEmitter;
const char** _rgSignals;
......
......@@ -53,6 +53,7 @@ void QGCUASFileManagerUnitTest::init(void)
bool connected = connect(&_mockFileServer, SIGNAL(messageReceived(LinkInterface*, mavlink_message_t)), _fileManager, SLOT(receiveMessage(LinkInterface*, mavlink_message_t)));
Q_ASSERT(connected);
Q_UNUSED(connected); // Silent release build compiler warning
connected = connect(_fileManager, SIGNAL(statusMessage(const QString&)), this, SLOT(statusMessage(const QString&)));
Q_ASSERT(connected);
......
......@@ -150,7 +150,7 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
QCOMPARE(_link->connect(), true);
// Make sure we get the two different connected signals
QCOMPARE(_multiSpy->waitForSignalByIndex(connectedSignalIndex, 1000), true);
QCOMPARE(_multiSpy->waitForSignalByIndex(connectedSignalIndex, 10000), true);
QCOMPARE(_multiSpy->checkOnlySignalByMask(connectedSignalMask | connected2SignalMask), true);
QList<QVariant> arguments = _multiSpy->getSpyByIndex(connected2SignalIndex)->takeFirst();
QCOMPARE(arguments.at(0).toBool(), true);
......
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