Commit e4c1f3ad authored by Lorenz Meier's avatar Lorenz Meier

Merge pull request #131 from jjhall89/airframe_unittest_fix

Airframe unit test fix
parents dcdf3701 70c7c99e
...@@ -163,10 +163,7 @@ void UASUnitTest::getYaw_test() ...@@ -163,10 +163,7 @@ void UASUnitTest::getYaw_test()
void UASUnitTest::getSelected_test() void UASUnitTest::getSelected_test()
{ {
bool test = uas->getSelected(); QCOMPARE(uas->getSelected(), false);
if(test != NULL){
QCOMPARE(test, false);
}
} }
void UASUnitTest::getSystemType_test() void UASUnitTest::getSystemType_test()
...@@ -176,12 +173,24 @@ void UASUnitTest::getSystemType_test() ...@@ -176,12 +173,24 @@ void UASUnitTest::getSystemType_test()
void UASUnitTest::getAirframe_test() void UASUnitTest::getAirframe_test()
{ {
//when uas is constructed, airframe is set to QGC_AIRFRAME_GENERIC which is 0
QCOMPARE(uas->getAirframe(), 0); QCOMPARE(uas->getAirframe(), 0);
uas->setAirframe(25);
QVERIFY(uas->getAirframe() == 25);
} }
void UASUnitTest::setAirframe_test()
{
//check at construction, that airframe=0 (GENERIC)
QVERIFY(uas->getAirframe() == 0);
//check that set airframe works
uas->setAirframe(11);
QVERIFY(uas->getAirframe() == 11);
//check that setAirframe will not assign a number to airframe, that is
//not defined in the enum
uas->setAirframe(12);
QVERIFY(uas->getAirframe() == 11);
}
void UASUnitTest::getWaypointList_test() void UASUnitTest::getWaypointList_test()
{ {
QVector<Waypoint*> kk = uas->getWaypointManager()->getWaypointEditableList(); QVector<Waypoint*> kk = uas->getWaypointManager()->getWaypointEditableList();
......
...@@ -49,6 +49,7 @@ private slots: ...@@ -49,6 +49,7 @@ private slots:
void getSelected_test(); void getSelected_test();
void getSystemType_test(); void getSystemType_test();
void getAirframe_test(); void getAirframe_test();
void setAirframe_test();
void getWaypointList_test(); void getWaypointList_test();
void signalWayPoint_test(); void signalWayPoint_test();
void getWaypoint_test(); void getWaypoint_test();
......
...@@ -86,7 +86,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), ...@@ -86,7 +86,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
receivedRGBDImageTimestamp(0.0), receivedRGBDImageTimestamp(0.0),
#endif #endif
paramsOnceRequested(false), paramsOnceRequested(false),
airframe(QGC_AIRFRAME_EASYSTAR), airframe(QGC_AIRFRAME_GENERIC),
attitudeKnown(false), attitudeKnown(false),
paramManager(NULL), paramManager(NULL),
attitudeStamped(false), attitudeStamped(false),
...@@ -104,7 +104,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), ...@@ -104,7 +104,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
componentID[i] = -1; componentID[i] = -1;
componentMulti[i] = false; componentMulti[i] = false;
} }
color = UASInterface::getNextColor(); color = UASInterface::getNextColor();
setBatterySpecs(QString("9V,9.5V,12.6V")); setBatterySpecs(QString("9V,9.5V,12.6V"));
...@@ -152,9 +152,9 @@ void UAS::readSettings() ...@@ -152,9 +152,9 @@ void UAS::readSettings()
void UAS::deleteSettings() void UAS::deleteSettings()
{ {
this->name = ""; this->name = "";
this->airframe = QGC_AIRFRAME_EASYSTAR; this->airframe = QGC_AIRFRAME_GENERIC;
this->autopilot = -1; this->autopilot = -1;
setBatterySpecs(QString("9V,9.5V,12.6V")); setBatterySpecs(QString("9V,9.5V,12.6V"));
} }
int UAS::getUASID() const int UAS::getUASID() const
......
...@@ -483,15 +483,19 @@ public slots: ...@@ -483,15 +483,19 @@ public slots:
void setAutopilotType(int apType) void setAutopilotType(int apType)
{ {
autopilot = apType; autopilot = apType;
//emit systemSpecsChanged(uasId); emit systemSpecsChanged(uasId);
} }
/** @brief Set the type of airframe */ /** @brief Set the type of airframe */
void setSystemType(int systemType); void setSystemType(int systemType);
/** @brief Set the specific airframe type */ /** @brief Set the specific airframe type */
void setAirframe(int airframe) void setAirframe(int airframe)
{ {
this->airframe = airframe; if((airframe >= 0) && (airframe < 12))
emit systemSpecsChanged(uasId); {
this->airframe = airframe;
emit systemSpecsChanged(uasId);
}
} }
/** @brief Set a new name **/ /** @brief Set a new name **/
void setUASName(const QString& name); void setUASName(const QString& name);
......
...@@ -149,7 +149,8 @@ public: ...@@ -149,7 +149,8 @@ public:
QGC_AIRFRAME_COAXIAL, QGC_AIRFRAME_COAXIAL,
QGC_AIRFRAME_PTERYX, QGC_AIRFRAME_PTERYX,
QGC_AIRFRAME_TRICOPTER, QGC_AIRFRAME_TRICOPTER,
QGC_AIRFRAME_HEXCOPTER QGC_AIRFRAME_HEXCOPTER,
QGC_AIRFRAME_END_OF_ENUM
}; };
/** /**
......
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