Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
e68c93dc
Commit
e68c93dc
authored
Apr 03, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3133 from DonLakeFlyer/MissionItemFixes
Mission item fixes
parents
99126254
246de5bc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
22 deletions
+65
-22
MissionItem.cc
src/MissionManager/MissionItem.cc
+4
-2
MissionItemTest.cc
src/MissionManager/MissionItemTest.cc
+55
-20
MissionItemTest.h
src/MissionManager/MissionItemTest.h
+6
-0
No files found.
src/MissionManager/MissionItem.cc
View file @
e68c93dc
...
...
@@ -203,6 +203,10 @@ bool MissionItem::load(const QJsonObject& json, QString& errorString)
return
false
;
}
// Make sure to set these first since they can signal other changes
setFrame
((
MAV_FRAME
)
json
[
_jsonFrameKey
].
toInt
());
setCommand
((
MAV_CMD
)
json
[
_jsonCommandKey
].
toInt
());
QGeoCoordinate
coordinate
;
if
(
!
JsonHelper
::
toQGeoCoordinate
(
json
[
_jsonCoordinateKey
],
coordinate
,
true
/* altitudeRequired */
,
errorString
))
{
return
false
;
...
...
@@ -213,8 +217,6 @@ bool MissionItem::load(const QJsonObject& json, QString& errorString)
setIsCurrentItem
(
false
);
setSequenceNumber
(
json
[
_jsonIdKey
].
toInt
());
setFrame
((
MAV_FRAME
)
json
[
_jsonFrameKey
].
toInt
());
setCommand
((
MAV_CMD
)
json
[
_jsonCommandKey
].
toInt
());
setParam1
(
json
[
_jsonParam1Key
].
toDouble
());
setParam2
(
json
[
_jsonParam2Key
].
toDouble
());
setParam3
(
json
[
_jsonParam3Key
].
toDouble
());
...
...
src/MissionManager/MissionItemTest.cc
View file @
e68c93dc
...
...
@@ -25,6 +25,7 @@
#include "LinkManager.h"
#include "MultiVehicleManager.h"
#include "MissionItem.h"
#include "SimpleMissionItem.h"
#if 0
const MissionItemTest::TestCase_t MissionItemTest::_rgTestCases[] = {
...
...
@@ -236,16 +237,10 @@ void MissionItemTest::_testFactSignals(void)
QCOMPARE
(
arguments
.
at
(
0
).
toDouble
(),
8.0
);
}
void
MissionItemTest
::
_
testLoadFromStream
(
void
)
void
MissionItemTest
::
_
checkExpectedMissionItem
(
const
MissionItem
&
missionItem
)
{
MissionItem
missionItem
;
QString
testString
(
"10
\t
1
\t
3
\t
80
\t
10
\t
20
\t
30
\t
40
\t
-10
\t
-20
\t
-30
\t
1
\r\n
"
);
QTextStream
testStream
(
&
testString
,
QIODevice
::
ReadOnly
);
QVERIFY
(
missionItem
.
load
(
testStream
));
QCOMPARE
(
missionItem
.
sequenceNumber
(),
10
);
QCOMPARE
(
missionItem
.
isCurrentItem
(),
tru
e
);
QCOMPARE
(
missionItem
.
isCurrentItem
(),
fals
e
);
QCOMPARE
(
missionItem
.
frame
(),
(
MAV_FRAME
)
3
);
QCOMPARE
(
missionItem
.
command
(),
(
MAV_CMD
)
80
);
QCOMPARE
(
missionItem
.
param1
(),
10.0
);
...
...
@@ -258,6 +253,30 @@ void MissionItemTest::_testLoadFromStream(void)
QCOMPARE
(
missionItem
.
autoContinue
(),
true
);
}
void
MissionItemTest
::
_testLoadFromStream
(
void
)
{
MissionItem
missionItem
;
QString
testString
(
"10
\t
0
\t
3
\t
80
\t
10
\t
20
\t
30
\t
40
\t
-10
\t
-20
\t
-30
\t
1
\r\n
"
);
QTextStream
testStream
(
&
testString
,
QIODevice
::
ReadOnly
);
QVERIFY
(
missionItem
.
load
(
testStream
));
_checkExpectedMissionItem
(
missionItem
);
}
void
MissionItemTest
::
_testSimpleLoadFromStream
(
void
)
{
// We specifically test SimpleMissionItem loading as well since it has additional
// signalling which can affect values.
SimpleMissionItem
simpleMissionItem
(
NULL
);
QString
testString
(
"10
\t
0
\t
3
\t
80
\t
10
\t
20
\t
30
\t
40
\t
-10
\t
-20
\t
-30
\t
1
\r\n
"
);
QTextStream
testStream
(
&
testString
,
QIODevice
::
ReadOnly
);
QVERIFY
(
simpleMissionItem
.
load
(
testStream
));
_checkExpectedMissionItem
(
simpleMissionItem
.
missionItem
());
}
void
MissionItemTest
::
_testLoadFromJson
(
void
)
{
MissionItem
missionItem
;
...
...
@@ -335,18 +354,34 @@ void MissionItemTest::_testLoadFromJson(void)
// Test good load
QVERIFY
(
missionItem
.
load
(
jsonObject
,
errorString
));
QCOMPARE
(
missionItem
.
sequenceNumber
(),
10
);
QCOMPARE
(
missionItem
.
isCurrentItem
(),
false
);
QCOMPARE
(
missionItem
.
frame
(),
(
MAV_FRAME
)
3
);
QCOMPARE
(
missionItem
.
command
(),
(
MAV_CMD
)
80
);
QCOMPARE
(
missionItem
.
param1
(),
10.0
);
QCOMPARE
(
missionItem
.
param2
(),
20.0
);
QCOMPARE
(
missionItem
.
param3
(),
30.0
);
QCOMPARE
(
missionItem
.
param4
(),
40.0
);
QCOMPARE
(
missionItem
.
param5
(),
-
10.0
);
QCOMPARE
(
missionItem
.
param6
(),
-
20.0
);
QCOMPARE
(
missionItem
.
param7
(),
-
30.0
);
QCOMPARE
(
missionItem
.
autoContinue
(),
true
);
_checkExpectedMissionItem
(
missionItem
);
}
void
MissionItemTest
::
_testSimpleLoadFromJson
(
void
)
{
// We specifically test SimpleMissionItem loading as well since it has additional
// signalling which can affect values.
SimpleMissionItem
simpleMissionItem
(
NULL
);
QString
errorString
;
QJsonArray
coordinateArray
=
{
-
10.0
,
-
20.0
,
-
30.0
};
QJsonObject
jsonObject
{
{
"autoContinue"
,
true
},
{
"command"
,
80
},
{
"frame"
,
3
},
{
"id"
,
10
},
{
"param1"
,
10
},
{
"param2"
,
20
},
{
"param3"
,
30
},
{
"param4"
,
40
},
{
"type"
,
"missionItem"
},
{
"coordinate"
,
coordinateArray
},
};
QVERIFY
(
simpleMissionItem
.
load
(
jsonObject
,
errorString
));
_checkExpectedMissionItem
(
simpleMissionItem
.
missionItem
());
}
void
MissionItemTest
::
_testSaveToJson
(
void
)
...
...
src/MissionManager/MissionItemTest.h
View file @
e68c93dc
...
...
@@ -26,6 +26,7 @@
#include "UnitTest.h"
#include "MultiSignalSpy.h"
#include "MissionItem.h"
/// Unit test for the MissionItem Object
class
MissionItemTest
:
public
UnitTest
...
...
@@ -40,8 +41,13 @@ private slots:
void
_testSignals
(
void
);
void
_testFactSignals
(
void
);
void
_testLoadFromStream
(
void
);
void
_testSimpleLoadFromStream
(
void
);
void
_testLoadFromJson
(
void
);
void
_testSimpleLoadFromJson
(
void
);
void
_testSaveToJson
(
void
);
private:
void
_checkExpectedMissionItem
(
const
MissionItem
&
missionItem
);
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment