Commit 651fdd26 authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #430 from DonLakeFlyer/UnitTestFixes

Unit Tests would not compile, once they compiled, they didn't work correctly, once working correctly they found a couple bugs
parents bcff0d52 b588e69e
This diff is collapsed.
This diff is collapsed.
......@@ -32,8 +32,15 @@ QT += network \
sql \
declarative
TEMPLATE = app
TARGET = qgroundcontrol
# Setting this variable allows you to include this .pro file in another such that
# you can set your own TARGET and main() function. This is used by the unit test
# build files to build unit test using all built parts of QGCS except for main.
isEmpty(QGCS_UNITTEST_OVERRIDE) {
TEMPLATE = app
TARGET = qgroundcontrol
SOURCES += src/main.cc
}
BASEDIR = $${IN_PWD}
linux-g++|linux-g++-64{
debug {
......@@ -556,7 +563,7 @@ contains(DEPENDENCIES_PRESENT, libfreenect) {
# Enable only if libfreenect is available
HEADERS += src/input/Freenect.h
}
SOURCES += src/main.cc \
SOURCES += \
src/QGCCore.cc \
src/uas/UASManager.cc \
src/uas/UAS.cc \
......
......@@ -178,28 +178,28 @@ void UASUnitTest::getSystemType_test()
void UASUnitTest::getAirframe_test()
{
//when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC which is 0
QCOMPARE(uas->getAirframe(), 0);
//when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC
QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_GENERIC);
}
void UASUnitTest::setAirframe_test()
{
//check at construction, that airframe=0 (GENERIC)
QVERIFY(uas->getAirframe() == 0);
QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_GENERIC);
//check that set airframe works
uas->setAirframe(11);
QVERIFY(uas->getAirframe() == 11);
uas->setAirframe(UASInterface::QGC_AIRFRAME_HEXCOPTER);
QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_HEXCOPTER);
//check that setAirframe will not assign a number to airframe, that is
//not defined in the enum
uas->setAirframe(12);
QVERIFY(uas->getAirframe() == 11);
uas->setAirframe(UASInterface::QGC_AIRFRAME_END_OF_ENUM);
QVERIFY(uas->getAirframe() == UASInterface::QGC_AIRFRAME_HEXCOPTER);
}
void UASUnitTest::getWaypointList_test()
{
QVector<Waypoint*> kk = uas->getWaypointManager()->getWaypointEditableList();
QList<Waypoint*> kk = uas->getWaypointManager()->getWaypointEditableList();
QCOMPARE(kk.count(), 0);
Waypoint* wp = new Waypoint(0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,false, false, MAV_FRAME_GLOBAL, MAV_CMD_MISSION_START, "blah");
......@@ -232,7 +232,7 @@ void UASUnitTest::getWaypoint_test()
uas->getWaypointManager()->addWaypointEditable(wp, true);
QVector<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList();
QList<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList();
QCOMPARE(wpList.count(), 1);
QCOMPARE(static_cast<quint16>(0), static_cast<Waypoint*>(wpList.at(0))->getId());
......@@ -281,7 +281,7 @@ void UASUnitTest::signalWayPoint_test()
QCOMPARE(spy2.count(), 1);
uas->getWaypointManager()->clearWaypointList();
QVector<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList();
QList<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList();
QCOMPARE(wpList.count(), 1);
delete uas;
uas = NULL;
......@@ -292,7 +292,7 @@ void UASUnitTest::signalUASLink_test()
{
QSignalSpy spy(uas, SIGNAL(modeChanged(int,QString,QString)));
uas->setMode(2);
uas->setMode(2, 0);
QCOMPARE(spy.count(), 0);// not solve for UAS not receiving message from UAS
QSignalSpy spyS(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)));
......@@ -391,10 +391,10 @@ void UASUnitTest::signalIdUASLink_test()
LinkInterface* b = static_cast<LinkInterface*>(links.at(1));
LinkInterface* c = static_cast<LinkInterface*>(links.at(2));
LinkInterface* d = static_cast<LinkInterface*>(links.at(3));
QCOMPARE(a->getName(), QString("serial port COM 17"));
QCOMPARE(b->getName(), QString("serial port COM 18"));
QCOMPARE(c->getName(), QString("serial port COM 19"));
QCOMPARE(d->getName(), QString("serial port COM 20"));
QCOMPARE(a->getName(), QString("COM 17"));
QCOMPARE(b->getName(), QString("COM 18"));
QCOMPARE(c->getName(), QString("COM 19"));
QCOMPARE(d->getName(), QString("COM 20"));
LinkManager::instance()->removeLink(myLink4);
delete myLink4;
......
......@@ -109,6 +109,11 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
localX(0.0),
localY(0.0),
localZ(0.0),
latitude(0.0),
longitude(0.0),
altitude(0.0),
globalEstimatorActive(false),
latitude_gps(0.0),
longitude_gps(0.0),
......@@ -131,6 +136,10 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
attitudeStamped(false),
lastAttitude(0),
roll(0.0),
pitch(0.0),
yaw(0.0),
paramsOnceRequested(false),
simulation(0),
......
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