From 70c7c99e27d0a7f848e9e7e7458c6554bf10e096 Mon Sep 17 00:00:00 2001 From: Jessica Date: Wed, 18 Jul 2012 14:31:16 -0700 Subject: [PATCH] Added a unit test, setAirframeTest. Changed setAirframe function. Added an end_of_enum to the airframe enum. --- qgcunittest/UASUnitTest.cc | 13 +++++++++++-- src/uas/UAS.h | 10 +++++++--- src/uas/UASInterface.h | 3 ++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/qgcunittest/UASUnitTest.cc b/qgcunittest/UASUnitTest.cc index f67144d..650ec84 100644 --- a/qgcunittest/UASUnitTest.cc +++ b/qgcunittest/UASUnitTest.cc @@ -179,8 +179,17 @@ void UASUnitTest::getAirframe_test() void UASUnitTest::setAirframe_test() { - uas->setAirframe(25); - QVERIFY(uas->getAirframe() == 25); + //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() { diff --git a/src/uas/UAS.h b/src/uas/UAS.h index 919d798..bab9d55 100644 --- a/src/uas/UAS.h +++ b/src/uas/UAS.h @@ -483,15 +483,19 @@ public slots: void setAutopilotType(int apType) { autopilot = apType; - //emit systemSpecsChanged(uasId); + emit systemSpecsChanged(uasId); } /** @brief Set the type of airframe */ void setSystemType(int systemType); /** @brief Set the specific airframe type */ void setAirframe(int airframe) { - this->airframe = airframe; - emit systemSpecsChanged(uasId); + if((airframe >= 0) && (airframe < 12)) + { + this->airframe = airframe; + emit systemSpecsChanged(uasId); + } + } /** @brief Set a new name **/ void setUASName(const QString& name); diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index 47cc7bf..034d77b 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -149,7 +149,8 @@ public: QGC_AIRFRAME_COAXIAL, QGC_AIRFRAME_PTERYX, QGC_AIRFRAME_TRICOPTER, - QGC_AIRFRAME_HEXCOPTER + QGC_AIRFRAME_HEXCOPTER, + QGC_AIRFRAME_END_OF_ENUM }; /**