Commit 30d65882 authored by Don Gagne's avatar Don Gagne

Unit tests for .waypoints and .mission file format load

parent bf761e36
......@@ -6,5 +6,7 @@
<file alias="MavCmdInfoRover.json">src/MissionManager/UnitTest/MavCmdInfoRover.json</file>
<file alias="MavCmdInfoSub.json">src/MissionManager/UnitTest/MavCmdInfoSub.json</file>
<file alias="MavCmdInfoVTOL.json">src/MissionManager/UnitTest/MavCmdInfoVTOL.json</file>
<file alias="MissionPlanner.waypoints">src/MissionManager/UnitTest/MissionPlanner.waypoints</file>
<file alias="OldFileFormat.mission">src/MissionManager/UnitTest/OldFileFormat.mission</file>
</qresource>
</RCC>
......@@ -390,6 +390,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src/MissionManager/MissionControllerTest.h \
src/MissionManager/MissionItemTest.h \
src/MissionManager/MissionManagerTest.h \
src/MissionManager/PlanMasterControllerTest.h \
src/MissionManager/SectionTest.h \
src/MissionManager/SimpleMissionItemTest.h \
src/MissionManager/SpeedSectionTest.h \
......@@ -422,6 +423,7 @@ DebugBuild { PX4FirmwarePlugin { PX4FirmwarePluginFactory { APMFirmwarePlugin {
src/MissionManager/MissionControllerTest.cc \
src/MissionManager/MissionItemTest.cc \
src/MissionManager/MissionManagerTest.cc \
src/MissionManager/PlanMasterControllerTest.cc \
src/MissionManager/SectionTest.cc \
src/MissionManager/SimpleMissionItemTest.cc \
src/MissionManager/SpeedSectionTest.cc \
......
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "PlanMasterControllerTest.h"
#include "LinkManager.h"
#include "MultiVehicleManager.h"
#include "SimpleMissionItem.h"
#include "MissionSettingsItem.h"
#include "QGCApplication.h"
#include "SettingsManager.h"
#include "AppSettings.h"
PlanMasterControllerTest::PlanMasterControllerTest(void)
: _masterController(NULL)
{
}
void PlanMasterControllerTest::init(void)
{
UnitTest::init();
_masterController = new PlanMasterController(this);
_masterController->start(true /* editMode */);
}
void PlanMasterControllerTest::cleanup(void)
{
delete _masterController;
_masterController = NULL;
UnitTest::cleanup();
}
void PlanMasterControllerTest::_testMissionFileLoad(void)
{
_masterController->loadFromFile(":/json/unittest/OldFileFormat.mission");
QCOMPARE(_masterController->missionController()->visualItems()->count(), 7);
}
void PlanMasterControllerTest::_testMissionPlannerFileLoad(void)
{
_masterController->loadFromFile(":/json/unittest/MissionPlanner.waypoints");
QCOMPARE(_masterController->missionController()->visualItems()->count(), 6);
}
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#pragma once
#include "UnitTest.h"
#include "MockLink.h"
#include "MissionManager.h"
#include "MultiSignalSpy.h"
#include "MissionControllerManagerTest.h"
#include "PlanMasterController.h"
#include "MissionController.h"
#include "SimpleMissionItem.h"
#include <QGeoCoordinate>
class PlanMasterControllerTest : public UnitTest
{
Q_OBJECT
public:
PlanMasterControllerTest(void);
private slots:
void init(void) final;
void cleanup(void) final;
void _testMissionFileLoad(void);
void _testMissionPlannerFileLoad(void);
private:
PlanMasterController* _masterController;
};
QGC WPL 110
0 1 0 16 0 0 0 0 47.660459 -122.103167 5.210000 1
1 0 3 16 0.000000 0.000000 0.000000 0.000000 47.661298 -122.103274 100.000000 1
2 0 3 16 0.000000 0.000000 0.000000 0.000000 47.661030 -122.101858 100.000000 1
3 0 3 16 0.000000 0.000000 0.000000 0.000000 47.659961 -122.101525 100.000000 1
4 0 3 16 0.000000 0.000000 0.000000 0.000000 47.659195 -122.103370 100.000000 1
5 0 3 16 0.000000 0.000000 0.000000 0.000000 47.660459 -122.105538 100.000000 1
{
"firmwareType": 3,
"groundStation": "QGroundControl",
"items": [
{
"autoContinue": true,
"command": 22,
"coordinate": [
47.660137763851573,
-122.29411931627152,
50
],
"doJumpId": 1,
"frame": 2,
"params": [
0,
0,
0,
0
],
"type": "SimpleItem"
},
{
"autoContinue": true,
"command": 18,
"coordinate": [
47.660316610000002,
-122.29423867,
10
],
"doJumpId": 2,
"frame": 3,
"params": [
1,
0,
0,
0
],
"type": "SimpleItem"
},
{
"autoContinue": true,
"command": 18,
"coordinate": [
47.660299945473923,
-122.29402946102036,
20
],
"doJumpId": 3,
"frame": 3,
"params": [
3,
0,
0,
0
],
"type": "SimpleItem"
},
{
"autoContinue": true,
"command": 16,
"coordinate": [
47.660239429999997,
-122.29371564,
5
],
"doJumpId": 4,
"frame": 3,
"params": [
0,
0,
0,
0
],
"type": "SimpleItem"
},
{
"autoContinue": true,
"command": 16,
"coordinate": [
47.660368599999998,
-122.29426013,
5
],
"doJumpId": 5,
"frame": 3,
"params": [
0,
0,
0,
0
],
"type": "SimpleItem"
},
{
"autoContinue": true,
"command": 21,
"coordinate": [
47.660153620000003,
-122.29410455999999,
3
],
"doJumpId": 6,
"frame": 3,
"params": [
0,
0,
0,
0
],
"type": "SimpleItem"
}
],
"plannedHomePosition": [
47.660137763851573,
-122.29411931627152,
0
],
"version": 2
}
......@@ -98,11 +98,11 @@ protected slots:
// call the UnitTest private implementation.
/// @brief Called before each test.
/// Make sure to call _init first in your derived class.
/// Make sure to call UnitTest::init first in your derived class.
virtual void init(void);
/// @brief Called after each test.
/// Make sure to call _cleanup first in your derived class.
/// Make sure to call UnitTest::cleanup last in your derived class.
virtual void cleanup(void);
protected:
......
......@@ -35,6 +35,7 @@
#include "VisualMissionItemTest.h"
#include "CameraSectionTest.h"
#include "SpeedSectionTest.h"
#include "PlanMasterControllerTest.h"
UT_REGISTER_TEST(FactSystemTestGeneric)
UT_REGISTER_TEST(FactSystemTestPX4)
......@@ -56,6 +57,7 @@ UT_REGISTER_TEST(SendMavCommandTest)
UT_REGISTER_TEST(SurveyMissionItemTest)
UT_REGISTER_TEST(CameraSectionTest)
UT_REGISTER_TEST(SpeedSectionTest)
UT_REGISTER_TEST(PlanMasterControllerTest)
// List of unit test which are currently disabled.
// If disabling a new test, include reason in comment.
......
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