Commit c7c7a058 authored by Jessica's avatar Jessica

Colors list in UASInterface.h corrected which got rid of segfault in unit tests.

parent 4fc0a05d
...@@ -51,7 +51,7 @@ namespace AutoTest ...@@ -51,7 +51,7 @@ namespace AutoTest
inline int run(int argc, char *argv[]) inline int run(int argc, char *argv[])
{ {
int ret = 0; int ret = 0;
QCoreApplication t(argc, argv);
foreach (QObject* test, testList()) foreach (QObject* test, testList())
{ {
ret += QTest::qExec(test, argc, argv); ret += QTest::qExec(test, argc, argv);
......
#include "UASUnitTest.h" #include "UASUnitTest.h"
#include <stdio.h>
UASUnitTest::UASUnitTest() UASUnitTest::UASUnitTest()
{ {
} }
//This function is called after every test
void UASUnitTest::initTestCase() void UASUnitTest::init()
{ {
mav = new MAVLinkProtocol(); mav = new MAVLinkProtocol();
uas = new UAS(mav,UASID); uas = new UAS(mav, UASID);
uas->deleteSettings();
} }
//this function is called after every test
void UASUnitTest::cleanupTestCase() void UASUnitTest::cleanup()
{ {
delete uas;
delete mav; delete mav;
mav = NULL;
delete uas;
uas = NULL;
} }
void UASUnitTest::getUASID_test() void UASUnitTest::getUASID_test()
...@@ -32,6 +35,7 @@ void UASUnitTest::getUASID_test() ...@@ -32,6 +35,7 @@ void UASUnitTest::getUASID_test()
// Make sure that ID >= 0 // Make sure that ID >= 0
QCOMPARE(uas->getUASID(), 100); QCOMPARE(uas->getUASID(), 100);
} }
void UASUnitTest::getUASName_test() void UASUnitTest::getUASName_test()
...@@ -118,6 +122,7 @@ void UASUnitTest::getStatusForCode_test() ...@@ -118,6 +122,7 @@ void UASUnitTest::getStatusForCode_test()
uas->getStatusForCode(5325, state, desc); uas->getStatusForCode(5325, state, desc);
QVERIFY(state == "UNKNOWN"); QVERIFY(state == "UNKNOWN");
} }
void UASUnitTest::getLocalX_test() void UASUnitTest::getLocalX_test()
...@@ -158,7 +163,10 @@ void UASUnitTest::getYaw_test() ...@@ -158,7 +163,10 @@ void UASUnitTest::getYaw_test()
void UASUnitTest::getSelected_test() void UASUnitTest::getSelected_test()
{ {
QCOMPARE(uas->getSelected(), false); bool test = uas->getSelected();
if(test != NULL){
QCOMPARE(test, false);
}
} }
void UASUnitTest::getSystemType_test() void UASUnitTest::getSystemType_test()
...@@ -200,6 +208,7 @@ void UASUnitTest::getWaypointList_test() ...@@ -200,6 +208,7 @@ void UASUnitTest::getWaypointList_test()
QCOMPARE(kk.count(), 0); QCOMPARE(kk.count(), 0);
qDebug()<<"disconnect SIGNAL waypointListChanged"; qDebug()<<"disconnect SIGNAL waypointListChanged";
} }
void UASUnitTest::getWaypoint_test() void UASUnitTest::getWaypoint_test()
...@@ -220,6 +229,7 @@ void UASUnitTest::getWaypoint_test() ...@@ -220,6 +229,7 @@ void UASUnitTest::getWaypoint_test()
QCOMPARE(wp->getX(), wp2->getX()); QCOMPARE(wp->getX(), wp2->getX());
QCOMPARE(wp->getFrame(), MAV_FRAME_GLOBAL); QCOMPARE(wp->getFrame(), MAV_FRAME_GLOBAL);
QCOMPARE(wp->getFrame(), wp2->getFrame()); QCOMPARE(wp->getFrame(), wp2->getFrame());
} }
void UASUnitTest::signalWayPoint_test() void UASUnitTest::signalWayPoint_test()
...@@ -250,6 +260,7 @@ void UASUnitTest::signalWayPoint_test() ...@@ -250,6 +260,7 @@ void UASUnitTest::signalWayPoint_test()
uas->getWaypointManager()->clearWaypointList(); uas->getWaypointManager()->clearWaypointList();
QVector<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList(); QVector<Waypoint*> wpList = uas->getWaypointManager()->getWaypointEditableList();
QCOMPARE(wpList.count(), 1); QCOMPARE(wpList.count(), 1);
} }
void UASUnitTest::signalUASLink_test() void UASUnitTest::signalUASLink_test()
...@@ -308,6 +319,7 @@ void UASUnitTest::signalUASLink_test() ...@@ -308,6 +319,7 @@ void UASUnitTest::signalUASLink_test()
LinkManager::instance()->add(link); LinkManager::instance()->add(link);
LinkManager::instance()->addProtocol(link, mav); LinkManager::instance()->addProtocol(link, mav);
QCOMPARE(spyS.count(), 3); QCOMPARE(spyS.count(), 3);
} }
void UASUnitTest::signalIdUASLink_test() void UASUnitTest::signalIdUASLink_test()
...@@ -331,4 +343,5 @@ void UASUnitTest::signalIdUASLink_test() ...@@ -331,4 +343,5 @@ void UASUnitTest::signalIdUASLink_test()
QCOMPARE(a->getName(), QString("serial port COM 17")); QCOMPARE(a->getName(), QString("serial port COM 17"));
QCOMPARE(b->getName(), QString("serial port COM 18")); QCOMPARE(b->getName(), QString("serial port COM 18"));
} }
...@@ -26,9 +26,8 @@ public: ...@@ -26,9 +26,8 @@ public:
UASUnitTest(); UASUnitTest();
private slots: private slots:
void initTestCase(); void init();
void cleanupTestCase(); void cleanup();
void getUASID_test(); void getUASID_test();
void getUASName_test(); void getUASName_test();
...@@ -47,16 +46,12 @@ private slots: ...@@ -47,16 +46,12 @@ private slots:
void getRoll_test(); void getRoll_test();
void getPitch_test(); void getPitch_test();
void getYaw_test(); void getYaw_test();
void getSelected_test(); void getSelected_test();
void getSystemType_test(); void getSystemType_test();
void getAirframe_test(); void getAirframe_test();
void getWaypointList_test(); void getWaypointList_test();
void getWaypoint_test();
void signalWayPoint_test(); void signalWayPoint_test();
void getWaypoint_test();
void signalUASLink_test(); void signalUASLink_test();
void signalIdUASLink_test(); void signalIdUASLink_test();
}; };
......
...@@ -97,6 +97,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), ...@@ -97,6 +97,7 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
systemIsArmed(false), systemIsArmed(false),
nedPosGlobalOffset(0,0,0), nedPosGlobalOffset(0,0,0),
nedAttGlobalOffset(0,0,0) nedAttGlobalOffset(0,0,0)
{ {
for (unsigned int i = 0; i<255;++i) for (unsigned int i = 0; i<255;++i)
{ {
...@@ -105,12 +106,13 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(), ...@@ -105,12 +106,13 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : UASInterface(),
} }
color = UASInterface::getNextColor(); color = UASInterface::getNextColor();
setBatterySpecs(QString("9V,9.5V,12.6V")); setBatterySpecs(QString("9V,9.5V,12.6V"));
connect(statusTimeout, SIGNAL(timeout()), this, SLOT(updateState())); connect(statusTimeout, SIGNAL(timeout()), this, SLOT(updateState()));
connect(this, SIGNAL(systemSpecsChanged(int)), this, SLOT(writeSettings())); connect(this, SIGNAL(systemSpecsChanged(int)), this, SLOT(writeSettings()));
statusTimeout->start(500); statusTimeout->start(500);
readSettings(); readSettings();
// autopilot = 11;
// Initial signals // Initial signals
emit disarmed(); emit disarmed();
emit armingChanged(false); emit armingChanged(false);
...@@ -121,8 +123,15 @@ UAS::~UAS() ...@@ -121,8 +123,15 @@ UAS::~UAS()
writeSettings(); writeSettings();
delete links; delete links;
links=NULL; links=NULL;
} //if(statusTimeout != NULL){
// delete statusTimeout;
// statusTimeout = NULL;//}
// if(simulation != NULL){
// delete simulation;
// simulation = NULL;
// }
}
void UAS::writeSettings() void UAS::writeSettings()
{ {
QSettings settings; QSettings settings;
...@@ -149,6 +158,14 @@ void UAS::readSettings() ...@@ -149,6 +158,14 @@ void UAS::readSettings()
settings.endGroup(); settings.endGroup();
} }
void UAS::deleteSettings()
{
this->name = "";
this->airframe = QGC_AIRFRAME_EASYSTAR,
this->autopilot = -1;
setBatterySpecs(QString("9V,9.5V,12.6V"));
}
int UAS::getUASID() const int UAS::getUASID() const
{ {
return uasId; return uasId;
......
...@@ -143,7 +143,6 @@ public: ...@@ -143,7 +143,6 @@ public:
return yaw; return yaw;
} }
bool getSelected() const; bool getSelected() const;
QVector3D getNedPosGlobalOffset() const QVector3D getNedPosGlobalOffset() const
{ {
return nedPosGlobalOffset; return nedPosGlobalOffset;
...@@ -430,7 +429,7 @@ public: ...@@ -430,7 +429,7 @@ public:
QImage getImage(); QImage getImage();
void requestImage(); void requestImage();
int getAutopilotType() { int getAutopilotType(){
return autopilot; return autopilot;
} }
QString getAutopilotTypeName() QString getAutopilotTypeName()
...@@ -484,7 +483,7 @@ public slots: ...@@ -484,7 +483,7 @@ 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);
...@@ -638,7 +637,7 @@ public slots: ...@@ -638,7 +637,7 @@ public slots:
void startDataRecording(); void startDataRecording();
void stopDataRecording(); void stopDataRecording();
void deleteSettings();
signals: signals:
/** @brief The main/battery voltage has changed/was updated */ /** @brief The main/battery voltage has changed/was updated */
......
...@@ -171,35 +171,33 @@ public: ...@@ -171,35 +171,33 @@ public:
*/ */
static QColor getNextColor() { static QColor getNextColor() {
/* Create color map */ /* Create color map */
static QList<QColor> colors = QList<QColor>(); static QList<QColor> colors = QList<QColor>()
static int nextColor = -1; << QColor(231,72,28)
<< QColor(104,64,240)
<< QColor(203,254,121)
<< QColor(161,252,116)
<< QColor(232,33,47)
<< QColor(116,251,110)
<< QColor(234,38,107)
<< QColor(104,250,138)
<< QColor(235,43,165)
<< QColor(98,248,176)
<< QColor(236,48,221)
<< QColor(92,247,217)
<< QColor(200,54,238)
<< QColor(87,231,246)
<< QColor(151,59,239)
<< QColor(81,183,244)
<< QColor(75,133,243)
<< QColor(242,255,128)
<< QColor(230,126,23);
if (nextColor == -1) { static int nextColor = -1;
///> Color map for plots, includes 20 colors if(nextColor == 18){//if at the end of the list
///> Map will start from beginning when the first 20 colors are exceeded nextColor = -1;//go back to the beginning
colors.append(QColor(231,72,28));
colors.append(QColor(104,64,240));
colors.append(QColor(203,254,121));
colors.append(QColor(161,252,116));
colors.append(QColor(232,33,47));
colors.append(QColor(116,251,110));
colors.append(QColor(234,38,107));
colors.append(QColor(104,250,138));
colors.append(QColor(235,43,165));
colors.append(QColor(98,248,176));
colors.append(QColor(236,48,221));
colors.append(QColor(92,247,217));
colors.append(QColor(200,54,238));
colors.append(QColor(87,231,246));
colors.append(QColor(151,59,239));
colors.append(QColor(81,183,244));
colors.append(QColor(75,133,243));
colors.append(QColor(242,255,128));
colors.append(QColor(230,126,23));
nextColor = 0;
} }
return colors[nextColor++]; nextColor++;
return colors[nextColor];//return the next color
} }
/** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/ /** @brief Get the type of the system (airplane, quadrotor, helicopter,..)*/
......
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