diff --git a/UnitTest.qrc b/UnitTest.qrc
index 599007da62aa4d0d25999b4d9454f1560d72c4ee..3332cf87698fa45ef6d3034f368cea05b7861e57 100644
--- a/UnitTest.qrc
+++ b/UnitTest.qrc
@@ -6,5 +6,7 @@
src/MissionManager/UnitTest/MavCmdInfoRover.json
src/MissionManager/UnitTest/MavCmdInfoSub.json
src/MissionManager/UnitTest/MavCmdInfoVTOL.json
+ src/MissionManager/UnitTest/MissionPlanner.waypoints
+ src/MissionManager/UnitTest/OldFileFormat.mission
diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index d4926a7890788219bdbf1326487748514c4cd737..82cf18446bf27c103f93747f5044967c92a4116d 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -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 \
diff --git a/src/MissionManager/PlanMasterControllerTest.cc b/src/MissionManager/PlanMasterControllerTest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f52b5340083f1635a9c4ef4572ed9d14906de9ff
--- /dev/null
+++ b/src/MissionManager/PlanMasterControllerTest.cc
@@ -0,0 +1,52 @@
+/****************************************************************************
+ *
+ * (c) 2009-2016 QGROUNDCONTROL PROJECT
+ *
+ * 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);
+}
diff --git a/src/MissionManager/PlanMasterControllerTest.h b/src/MissionManager/PlanMasterControllerTest.h
new file mode 100644
index 0000000000000000000000000000000000000000..05f647adf1176891df69635ba0de52149578264d
--- /dev/null
+++ b/src/MissionManager/PlanMasterControllerTest.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+ *
+ * (c) 2009-2016 QGROUNDCONTROL PROJECT
+ *
+ * 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
+
+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;
+};
diff --git a/src/MissionManager/UnitTest/MissionPlanner.waypoints b/src/MissionManager/UnitTest/MissionPlanner.waypoints
new file mode 100644
index 0000000000000000000000000000000000000000..40c3175ee2eb5fd20700bcb83aa127b40c787ac1
--- /dev/null
+++ b/src/MissionManager/UnitTest/MissionPlanner.waypoints
@@ -0,0 +1,7 @@
+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
diff --git a/src/MissionManager/UnitTest/OldFileFormat.mission b/src/MissionManager/UnitTest/OldFileFormat.mission
new file mode 100644
index 0000000000000000000000000000000000000000..e2b1be92865d9269a30a64034d94a6d5f84701a1
--- /dev/null
+++ b/src/MissionManager/UnitTest/OldFileFormat.mission
@@ -0,0 +1,120 @@
+{
+ "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
+}
diff --git a/src/qgcunittest/UnitTest.h b/src/qgcunittest/UnitTest.h
index fc06f287db325d505a6ff46072971c004b33b739..8e2b9cd4ab536778ca0926ea25ae50659d9f6eb0 100644
--- a/src/qgcunittest/UnitTest.h
+++ b/src/qgcunittest/UnitTest.h
@@ -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:
diff --git a/src/qgcunittest/UnitTestList.cc b/src/qgcunittest/UnitTestList.cc
index 7c6eb906d5d4d41481fc62502fc8d08d575de288..3fc648abf29f5575033b31927e81f0abc7a4d085 100644
--- a/src/qgcunittest/UnitTestList.cc
+++ b/src/qgcunittest/UnitTestList.cc
@@ -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.