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
834c862c
Commit
834c862c
authored
Feb 29, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2914 from DonLakeFlyer/ComplexUnitTest
ComplexMissionItem unit test
parents
1e58767a
7d8b78ed
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
453 additions
and
58 deletions
+453
-58
qgroundcontrol.pro
qgroundcontrol.pro
+2
-0
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+20
-17
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+1
-1
ComplexMissionItemTest.cc
src/MissionManager/ComplexMissionItemTest.cc
+258
-0
ComplexMissionItemTest.h
src/MissionManager/ComplexMissionItemTest.h
+114
-0
VisualMissionItem.h
src/MissionManager/VisualMissionItem.h
+2
-2
MultiSignalSpy.cc
src/qgcunittest/MultiSignalSpy.cc
+36
-23
MultiSignalSpy.h
src/qgcunittest/MultiSignalSpy.h
+18
-15
UnitTestList.cc
src/qgcunittest/UnitTestList.cc
+2
-0
No files found.
qgroundcontrol.pro
View file @
834c862c
...
...
@@ -506,6 +506,7 @@ HEADERS += \
src
/
FactSystem
/
FactSystemTestBase
.
h
\
src
/
FactSystem
/
FactSystemTestGeneric
.
h
\
src
/
FactSystem
/
FactSystemTestPX4
.
h
\
src
/
MissionManager
/
ComplexMissionItemTest
.
h
\
src
/
MissionManager
/
MissionControllerTest
.
h
\
src
/
MissionManager
/
MissionControllerManagerTest
.
h
\
src
/
MissionManager
/
MissionItemTest
.
h
\
...
...
@@ -530,6 +531,7 @@ SOURCES += \
src
/
FactSystem
/
FactSystemTestBase
.
cc
\
src
/
FactSystem
/
FactSystemTestGeneric
.
cc
\
src
/
FactSystem
/
FactSystemTestPX4
.
cc
\
src
/
MissionManager
/
ComplexMissionItemTest
.
cc
\
src
/
MissionManager
/
MissionControllerTest
.
cc
\
src
/
MissionManager
/
MissionControllerManagerTest
.
cc
\
src
/
MissionManager
/
MissionItemTest
.
cc
\
...
...
src/MissionManager/ComplexMissionItem.cc
View file @
834c862c
...
...
@@ -59,7 +59,8 @@ ComplexMissionItem::ComplexMissionItem(Vehicle* vehicle, QObject* parent)
connect
(
&
_gridSpacingFact
,
&
Fact
::
valueChanged
,
this
,
&
ComplexMissionItem
::
_generateGrid
);
connect
(
&
_gridAngleFact
,
&
Fact
::
valueChanged
,
this
,
&
ComplexMissionItem
::
_generateGrid
);
connect
(
this
,
&
ComplexMissionItem
::
cameraTriggerChanged
,
this
,
&
ComplexMissionItem
::
_signalLastSequenceNumberChanged
);
connect
(
this
,
&
ComplexMissionItem
::
cameraTriggerChanged
,
this
,
&
ComplexMissionItem
::
_cameraTriggerChanged
);
}
void
ComplexMissionItem
::
clearPolygon
(
void
)
...
...
@@ -77,8 +78,10 @@ void ComplexMissionItem::clearPolygon(void)
_polygonPath
.
clear
();
_clearGrid
();
setDirty
(
true
);
emit
specifiesCoordinateChanged
();
emit
lastSequenceNumberChanged
(
lastSequenceNumber
());
}
void
ComplexMissionItem
::
addPolygonCoordinate
(
const
QGeoCoordinate
coordinate
)
...
...
@@ -87,14 +90,13 @@ void ComplexMissionItem::addPolygonCoordinate(const QGeoCoordinate coordinate)
emit
polygonPathChanged
();
int
pointCount
=
_polygonPath
.
count
();
if
(
pointCount
==
1
)
{
setCoordinate
(
coordinate
);
}
else
if
(
pointCount
==
3
)
{
emit
specifiesCoordinateChanged
();
if
(
pointCount
>=
3
)
{
if
(
pointCount
==
3
)
{
emit
specifiesCoordinateChanged
();
}
_generateGrid
();
}
_setExitCoordinate
(
coordinate
);
_generateGrid
();
setDirty
(
true
);
}
int
ComplexMissionItem
::
lastSequenceNumber
(
void
)
const
...
...
@@ -103,10 +105,10 @@ int ComplexMissionItem::lastSequenceNumber(void) const
if
(
_gridPoints
.
count
())
{
lastSeq
+=
_gridPoints
.
count
()
-
1
;
}
if
(
_cameraTrigger
)
{
// Account for two trigger messages
lastSeq
+=
2
;
if
(
_cameraTrigger
)
{
// Account for two trigger messages
lastSeq
+=
2
;
}
}
return
lastSeq
;
...
...
@@ -117,7 +119,6 @@ void ComplexMissionItem::setCoordinate(const QGeoCoordinate& coordinate)
if
(
_coordinate
!=
coordinate
)
{
_coordinate
=
coordinate
;
emit
coordinateChanged
(
_coordinate
);
_setExitCoordinate
(
coordinate
);
}
}
...
...
@@ -259,8 +260,6 @@ void ComplexMissionItem::_clearGrid(void)
}
emit
gridPointsChanged
();
_gridPoints
.
clear
();
emit
gridPointsChanged
();
}
void
ComplexMissionItem
::
_generateGrid
(
void
)
...
...
@@ -511,7 +510,11 @@ QmlObjectListModel* ComplexMissionItem::getMissionItems(void) const
return
pMissionItems
;
}
void
ComplexMissionItem
::
_
signalLastSequenceNumb
erChanged
(
void
)
void
ComplexMissionItem
::
_
cameraTrigg
erChanged
(
void
)
{
emit
lastSequenceNumberChanged
(
lastSequenceNumber
());
setDirty
(
true
);
if
(
_gridPoints
.
count
())
{
// If we have grid turn on/off camera trigger will add/remove two camera trigger mission items
emit
lastSequenceNumberChanged
(
lastSequenceNumber
());
}
}
src/MissionManager/ComplexMissionItem.h
View file @
834c862c
...
...
@@ -103,7 +103,7 @@ signals:
void
gridAltitudeRelativeChanged
(
bool
gridAltitudeRelative
);
private
slots
:
void
_
signalLastSequenceNumb
erChanged
(
void
);
void
_
cameraTrigg
erChanged
(
void
);
private:
void
_clear
(
void
);
...
...
src/MissionManager/ComplexMissionItemTest.cc
0 → 100644
View file @
834c862c
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "ComplexMissionItemTest.h"
ComplexMissionItemTest
::
ComplexMissionItemTest
(
void
)
{
_polyPoints
<<
QGeoCoordinate
(
47.633550640000003
,
-
122.08982199
)
<<
QGeoCoordinate
(
47.634129020000003
,
-
122.08887249
)
<<
QGeoCoordinate
(
47.633619320000001
,
-
122.08811074
)
<<
QGeoCoordinate
(
47.633189139999999
,
-
122.08900124
);
}
void
ComplexMissionItemTest
::
init
(
void
)
{
_rgComplexMissionItemSignals
[
polygonPathChangedIndex
]
=
SIGNAL
(
polygonPathChanged
());
_rgComplexMissionItemSignals
[
lastSequenceNumberChangedIndex
]
=
SIGNAL
(
lastSequenceNumberChanged
(
int
));
_rgComplexMissionItemSignals
[
altitudeChangedIndex
]
=
SIGNAL
(
altitudeChanged
(
double
));
_rgComplexMissionItemSignals
[
gridAngleChangedIndex
]
=
SIGNAL
(
gridAngleChanged
(
double
));
_rgComplexMissionItemSignals
[
gridPointsChangedIndex
]
=
SIGNAL
(
gridPointsChanged
());
_rgComplexMissionItemSignals
[
cameraTriggerChangedIndex
]
=
SIGNAL
(
cameraTriggerChanged
(
bool
));
_rgComplexMissionItemSignals
[
altDifferenceChangedIndex
]
=
SIGNAL
(
altDifferenceChanged
(
double
));
_rgComplexMissionItemSignals
[
altPercentChangedIndex
]
=
SIGNAL
(
altPercentChanged
(
double
));
_rgComplexMissionItemSignals
[
azimuthChangedIndex
]
=
SIGNAL
(
azimuthChanged
(
double
));
_rgComplexMissionItemSignals
[
commandDescriptionChangedIndex
]
=
SIGNAL
(
commandDescriptionChanged
());
_rgComplexMissionItemSignals
[
commandNameChangedIndex
]
=
SIGNAL
(
commandNameChanged
());
_rgComplexMissionItemSignals
[
coordinateChangedIndex
]
=
SIGNAL
(
coordinateChanged
(
const
QGeoCoordinate
&
));
_rgComplexMissionItemSignals
[
exitCoordinateChangedIndex
]
=
SIGNAL
(
exitCoordinateChanged
(
const
QGeoCoordinate
&
));
_rgComplexMissionItemSignals
[
dirtyChangedIndex
]
=
SIGNAL
(
dirtyChanged
(
bool
));
_rgComplexMissionItemSignals
[
distanceChangedIndex
]
=
SIGNAL
(
distanceChanged
(
double
));
_rgComplexMissionItemSignals
[
isCurrentItemChangedIndex
]
=
SIGNAL
(
isCurrentItemChanged
(
bool
));
_rgComplexMissionItemSignals
[
sequenceNumberChangedIndex
]
=
SIGNAL
(
sequenceNumberChanged
(
int
));
_rgComplexMissionItemSignals
[
isSimpleItemChangedIndex
]
=
SIGNAL
(
isSimpleItemChanged
(
bool
));
_rgComplexMissionItemSignals
[
specifiesCoordinateChangedIndex
]
=
SIGNAL
(
specifiesCoordinateChanged
());
_rgComplexMissionItemSignals
[
isStandaloneCoordinateChangedIndex
]
=
SIGNAL
(
isStandaloneCoordinateChanged
());
_rgComplexMissionItemSignals
[
coordinateHasRelativeAltitudeChangedIndex
]
=
SIGNAL
(
coordinateHasRelativeAltitudeChanged
(
bool
));
_rgComplexMissionItemSignals
[
exitCoordinateHasRelativeAltitudeChangedIndex
]
=
SIGNAL
(
exitCoordinateHasRelativeAltitudeChanged
(
bool
));
_rgComplexMissionItemSignals
[
exitCoordinateSameAsEntryChangedIndex
]
=
SIGNAL
(
exitCoordinateSameAsEntryChanged
(
bool
));
_complexItem
=
new
ComplexMissionItem
(
NULL
/* Vehicle */
,
this
);
// It's important to check that the right signals are emitted at the right time since that drives ui change.
// It's also important to check that things are not being over-signalled when they should not be, since that can lead
// to incorrect ui or perf impact of uneeded signals propogating ui change.
_multiSpy
=
new
MultiSignalSpy
();
Q_CHECK_PTR
(
_multiSpy
);
QCOMPARE
(
_multiSpy
->
init
(
_complexItem
,
_rgComplexMissionItemSignals
,
_cComplexMissionItemSignals
),
true
);
}
void
ComplexMissionItemTest
::
cleanup
(
void
)
{
delete
_complexItem
;
delete
_multiSpy
;
}
void
ComplexMissionItemTest
::
_testDirty
(
void
)
{
QVERIFY
(
!
_complexItem
->
dirty
());
_complexItem
->
setDirty
(
false
);
QVERIFY
(
!
_complexItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkNoSignals
());
_complexItem
->
setDirty
(
true
);
QVERIFY
(
_complexItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
QVERIFY
(
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
_multiSpy
->
clearAllSignals
();
_complexItem
->
setDirty
(
false
);
QVERIFY
(
!
_complexItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
));
QVERIFY
(
!
_multiSpy
->
pullBoolFromSignalIndex
(
dirtyChangedIndex
));
}
void
ComplexMissionItemTest
::
_testAddPolygonCoordinate
(
void
)
{
QCOMPARE
(
_complexItem
->
polygonPath
().
count
(),
0
);
// First call to addPolygonCoordinate should trigger:
// polygonPathChanged
// dirtyChanged
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
0
]);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
polygonPathChangedMask
|
dirtyChangedMask
));
// Validate object data
QVariantList
polyList
=
_complexItem
->
polygonPath
();
QCOMPARE
(
polyList
.
count
(),
1
);
QCOMPARE
(
polyList
[
0
].
value
<
QGeoCoordinate
>
(),
_polyPoints
[
0
]);
// Reset
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
// Second call to addPolygonCoordinate should only trigger:
// polygonPathChanged
// dirtyChanged
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
1
]);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
polygonPathChangedMask
|
dirtyChangedMask
));
polyList
=
_complexItem
->
polygonPath
();
QCOMPARE
(
polyList
.
count
(),
2
);
for
(
int
i
=
0
;
i
<
polyList
.
count
();
i
++
)
{
QCOMPARE
(
polyList
[
i
].
value
<
QGeoCoordinate
>
(),
_polyPoints
[
i
]);
}
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
// Third call to addPolygonCoordinate should trigger:
// polygonPathChanged
// dirtyChanged
// Grid is generated for the first time on closing of polygon which triggers:
// coordinateChanged - grid generates new entry coordinate
// exitCoordinateChanged - grid generates new exit coordinate
// specifiesCoordinateChanged - once grid entry/exit shows up specifiesCoordinate gets set to true
// Grid generation triggers the following signals
// lastSequenceNumberChanged - number of internal mission items changes
// gridPointsChanged - grid points show up for the first time
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
2
]);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
polygonPathChangedMask
|
lastSequenceNumberChangedMask
|
gridPointsChangedMask
|
coordinateChangedMask
|
exitCoordinateChangedMask
|
specifiesCoordinateChangedMask
|
dirtyChangedMask
));
int
seqNum
=
_multiSpy
->
pullIntFromSignalIndex
(
lastSequenceNumberChangedIndex
);
QVERIFY
(
seqNum
>
0
);
polyList
=
_complexItem
->
polygonPath
();
QCOMPARE
(
polyList
.
count
(),
3
);
for
(
int
i
=
0
;
i
<
polyList
.
count
();
i
++
)
{
QCOMPARE
(
polyList
[
i
].
value
<
QGeoCoordinate
>
(),
_polyPoints
[
i
]);
}
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
// Forth call to addPolygonCoordinate should trigger:
// polygonPathChanged
// dirtyChanged
// Grid is generated again on polygon change which triggers:
// lastSequenceNumberChanged - number of internal mission items changes
// gridPointsChanged - grid points show up for the first time
// exitCoordinateChanged - grid generates new exit coordinate
// Note: Given the data set the entry coordinate stays the same
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
3
]);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
polygonPathChangedMask
|
lastSequenceNumberChangedMask
|
gridPointsChangedMask
|
exitCoordinateChangedMask
|
dirtyChangedMask
));
seqNum
=
_multiSpy
->
pullIntFromSignalIndex
(
lastSequenceNumberChangedIndex
);
QVERIFY
(
seqNum
>
0
);
polyList
=
_complexItem
->
polygonPath
();
QCOMPARE
(
polyList
.
count
(),
4
);
for
(
int
i
=
0
;
i
<
polyList
.
count
();
i
++
)
{
QCOMPARE
(
polyList
[
i
].
value
<
QGeoCoordinate
>
(),
_polyPoints
[
i
]);
}
}
void
ComplexMissionItemTest
::
_testClearPolygon
(
void
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
i
]);
}
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
// Call to clearPolygon should trigger:
// polygonPathChangedMask
// dirtyChanged
// lastSequenceNumberChangedMask
// gridPointsChangedMask
// dirtyChangedMask
// specifiesCoordinateChangedMask
_complexItem
->
clearPolygon
();
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
polygonPathChangedMask
|
lastSequenceNumberChangedMask
|
gridPointsChangedMask
|
dirtyChangedMask
|
specifiesCoordinateChangedMask
));
QVERIFY
(
!
_multiSpy
->
pullBoolFromSignalIndex
(
specifiesCoordinateChangedIndex
));
QCOMPARE
(
_multiSpy
->
pullIntFromSignalIndex
(
lastSequenceNumberChangedIndex
),
0
);
QCOMPARE
(
_complexItem
->
polygonPath
().
count
(),
0
);
QCOMPARE
(
_complexItem
->
gridPoints
().
count
(),
0
);
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
}
void
ComplexMissionItemTest
::
_testCameraTrigger
(
void
)
{
QVERIFY
(
!
_complexItem
->
property
(
"cameraTrigger"
).
toBool
());
// Turning on/off camera triggering while there is no grid should trigger:
// cameraTriggerChanged
// dirtyChanged
// lastSequenceNumber should not change
int
lastSeq
=
_complexItem
->
lastSequenceNumber
();
_complexItem
->
setProperty
(
"cameraTrigger"
,
true
);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
|
cameraTriggerChangedMask
));
QVERIFY
(
_multiSpy
->
pullBoolFromSignalIndex
(
cameraTriggerChangedIndex
));
QCOMPARE
(
_complexItem
->
lastSequenceNumber
(),
lastSeq
);
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
_complexItem
->
setProperty
(
"cameraTrigger"
,
false
);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
dirtyChangedMask
|
cameraTriggerChangedMask
));
QVERIFY
(
!
_multiSpy
->
pullBoolFromSignalIndex
(
cameraTriggerChangedIndex
));
QCOMPARE
(
_complexItem
->
lastSequenceNumber
(),
lastSeq
);
// Set up a grid
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
i
]);
}
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
lastSeq
=
_complexItem
->
lastSequenceNumber
();
QVERIFY
(
lastSeq
>
0
);
// Turning on camera triggering should add two more mission items, this should trigger:
// lastSequenceNumberChanged
// dirtyChanged
_complexItem
->
setProperty
(
"cameraTrigger"
,
true
);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
lastSequenceNumberChangedMask
|
dirtyChangedMask
|
cameraTriggerChangedMask
));
QCOMPARE
(
_multiSpy
->
pullIntFromSignalIndex
(
lastSequenceNumberChangedIndex
),
lastSeq
+
2
);
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
// Turn off camera triggering and make sure things go back to previous count
_complexItem
->
setProperty
(
"cameraTrigger"
,
false
);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
lastSequenceNumberChangedMask
|
dirtyChangedMask
|
cameraTriggerChangedMask
));
QCOMPARE
(
_multiSpy
->
pullIntFromSignalIndex
(
lastSequenceNumberChangedIndex
),
lastSeq
);
}
src/MissionManager/ComplexMissionItemTest.h
0 → 100644
View file @
834c862c
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef ComplexMissionItemTest_H
#define ComplexMissionItemTest_H
#include "UnitTest.h"
#include "TCPLink.h"
#include "MultiSignalSpy.h"
#include "ComplexMissionItem.h"
#include <QGeoCoordinate>
/// Unit test for SimpleMissionItem
class
ComplexMissionItemTest
:
public
UnitTest
{
Q_OBJECT
public:
ComplexMissionItemTest
(
void
);
protected:
void
init
(
void
)
final
;
void
cleanup
(
void
)
final
;
private
slots
:
void
_testDirty
(
void
);
void
_testAddPolygonCoordinate
(
void
);
void
_testClearPolygon
(
void
);
void
_testCameraTrigger
(
void
);
private:
enum
{
polygonPathChangedIndex
=
0
,
lastSequenceNumberChangedIndex
,
altitudeChangedIndex
,
gridAngleChangedIndex
,
gridPointsChangedIndex
,
cameraTriggerChangedIndex
,
altDifferenceChangedIndex
,
altPercentChangedIndex
,
azimuthChangedIndex
,
commandDescriptionChangedIndex
,
commandNameChangedIndex
,
coordinateChangedIndex
,
exitCoordinateChangedIndex
,
dirtyChangedIndex
,
distanceChangedIndex
,
isCurrentItemChangedIndex
,
sequenceNumberChangedIndex
,
isSimpleItemChangedIndex
,
specifiesCoordinateChangedIndex
,
isStandaloneCoordinateChangedIndex
,
coordinateHasRelativeAltitudeChangedIndex
,
exitCoordinateHasRelativeAltitudeChangedIndex
,
exitCoordinateSameAsEntryChangedIndex
,
maxSignalIndex
};
enum
{
polygonPathChangedMask
=
1
<<
polygonPathChangedIndex
,
lastSequenceNumberChangedMask
=
1
<<
lastSequenceNumberChangedIndex
,
altitudeChangedMask
=
1
<<
altitudeChangedIndex
,
gridAngleChangedMask
=
1
<<
gridAngleChangedIndex
,
gridPointsChangedMask
=
1
<<
gridPointsChangedIndex
,
cameraTriggerChangedMask
=
1
<<
cameraTriggerChangedIndex
,
altDifferenceChangedMask
=
1
<<
altDifferenceChangedIndex
,
altPercentChangedMask
=
1
<<
altPercentChangedIndex
,
azimuthChangedMask
=
1
<<
azimuthChangedIndex
,
commandDescriptionChangedMask
=
1
<<
commandDescriptionChangedIndex
,
commandNameChangedMask
=
1
<<
commandNameChangedIndex
,
coordinateChangedMask
=
1
<<
coordinateChangedIndex
,
exitCoordinateChangedMask
=
1
<<
exitCoordinateChangedIndex
,
dirtyChangedMask
=
1
<<
dirtyChangedIndex
,
distanceChangedMask
=
1
<<
distanceChangedIndex
,
isCurrentItemChangedMask
=
1
<<
isCurrentItemChangedIndex
,
sequenceNumberChangedMask
=
1
<<
sequenceNumberChangedIndex
,
isSimpleItemChangedMask
=
1
<<
isSimpleItemChangedIndex
,
specifiesCoordinateChangedMask
=
1
<<
specifiesCoordinateChangedIndex
,
isStandaloneCoordinateChangedMask
=
1
<<
isStandaloneCoordinateChangedIndex
,
coordinateHasRelativeAltitudeChangedMask
=
1
<<
coordinateHasRelativeAltitudeChangedIndex
,
exitCoordinateHasRelativeAltitudeChangedMask
=
1
<<
exitCoordinateHasRelativeAltitudeChangedIndex
,
exitCoordinateSameAsEntryChangedMask
=
1
<<
exitCoordinateSameAsEntryChangedIndex
,
};
static
const
size_t
_cComplexMissionItemSignals
=
maxSignalIndex
;
const
char
*
_rgComplexMissionItemSignals
[
_cComplexMissionItemSignals
];
MultiSignalSpy
*
_multiSpy
;
ComplexMissionItem
*
_complexItem
;
QList
<
QGeoCoordinate
>
_polyPoints
;
};
#endif
src/MissionManager/VisualMissionItem.h
View file @
834c862c
...
...
@@ -75,7 +75,7 @@ public:
Q_PROPERTY
(
bool
exitCoordinateHasRelativeAltitude
READ
exitCoordinateHasRelativeAltitude
NOTIFY
exitCoordinateHasRelativeAltitudeChanged
)
/// @return true: exitCoordinate and coordinate are the same value
Q_PROPERTY
(
bool
exitCoordinateSameAsEntry
READ
exitCoordinateSameAsEntry
NOTIFY
exitCoordinateSameAsEntry
)
Q_PROPERTY
(
bool
exitCoordinateSameAsEntry
READ
exitCoordinateSameAsEntry
NOTIFY
exitCoordinateSameAsEntry
Changed
)
// General properties associated with all types of visual mission items
...
...
@@ -152,7 +152,7 @@ signals:
void
coordinateHasRelativeAltitudeChanged
(
bool
coordinateHasRelativeAltitude
);
void
exitCoordinateHasRelativeAltitudeChanged
(
bool
exitCoordinateHasRelativeAltitude
);
void
exitCoordinateSameAsEntry
(
bool
exitCoordinateSameAsEntry
);
void
exitCoordinateSameAsEntry
Changed
(
bool
exitCoordinateSameAsEntry
);
protected:
Vehicle
*
_vehicle
;
...
...
src/qgcunittest/MultiSignalSpy.cc
View file @
834c862c
...
...
@@ -53,10 +53,9 @@ MultiSignalSpy::~MultiSignalSpy()
/// Initializes the class. Must be called once before use.
/// @return true if success, false for failure
bool
MultiSignalSpy
::
init
(
QObject
*
signalEmitter
,
///< [in] object which the signals are emitted from
const
char
**
rgSignals
,
///< [in] array of signals to spy on
size_t
cSignals
)
///< [in] numbers of signals in rgSignals
bool
MultiSignalSpy
::
init
(
QObject
*
signalEmitter
,
///< [in] object which the signals are emitted from
const
char
**
rgSignals
,
///< [in] array of signals to spy on
size_t
cSignals
)
///< [in] numbers of signals in rgSignals
{
if
(
!
signalEmitter
||
!
rgSignals
||
cSignals
==
0
)
{
qDebug
()
<<
"Invalid arguments"
;
...
...
@@ -85,7 +84,7 @@ bool MultiSignalSpy::init(
return
true
;
}
bool
MultiSignalSpy
::
_checkSignalByMaskWorker
(
quint
16
mask
,
bool
multipleSignalsAllowed
)
bool
MultiSignalSpy
::
_checkSignalByMaskWorker
(
quint
32
mask
,
bool
multipleSignalsAllowed
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
if
((
1
<<
i
)
&
mask
)
{
...
...
@@ -94,7 +93,7 @@ bool MultiSignalSpy::_checkSignalByMaskWorker(quint16 mask, bool multipleSignals
if
((
multipleSignalsAllowed
&&
spy
->
count
()
==
0
)
||
(
!
multipleSignalsAllowed
&&
spy
->
count
()
!=
1
))
{
qDebug
()
<<
"Failed index:"
<<
i
;
_printSignalState
();
_printSignalState
(
mask
);
return
false
;
}
}
...
...
@@ -103,7 +102,7 @@ bool MultiSignalSpy::_checkSignalByMaskWorker(quint16 mask, bool multipleSignals
return
true
;
}
bool
MultiSignalSpy
::
_checkOnlySignalByMaskWorker
(
quint
16
mask
,
bool
multipleSignalsAllowed
)
bool
MultiSignalSpy
::
_checkOnlySignalByMaskWorker
(
quint
32
mask
,
bool
multipleSignalsAllowed
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
QSignalSpy
*
spy
=
_rgSpys
[
i
];
...
...
@@ -111,12 +110,12 @@ bool MultiSignalSpy::_checkOnlySignalByMaskWorker(quint16 mask, bool multipleSig
if
((
1
<<
i
)
&
mask
)
{
if
((
multipleSignalsAllowed
&&
spy
->
count
()
==
0
)
||
(
!
multipleSignalsAllowed
&&
spy
->
count
()
!=
1
))
{
_printSignalState
();
_printSignalState
(
mask
);
return
false
;
}
}
else
{
if
(
spy
->
count
()
!=
0
)
{
_printSignalState
();
_printSignalState
(
mask
);
return
false
;
}
}
...
...
@@ -125,28 +124,28 @@ bool MultiSignalSpy::_checkOnlySignalByMaskWorker(quint16 mask, bool multipleSig
return
true
;
}
bool
MultiSignalSpy
::
checkSignalByMask
(
quint
16
mask
)
bool
MultiSignalSpy
::
checkSignalByMask
(
quint
32
mask
)
{
return
_checkSignalByMaskWorker
(
mask
,
false
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkOnlySignalByMask
(
quint
16
mask
)
bool
MultiSignalSpy
::
checkOnlySignalByMask
(
quint
32
mask
)
{
return
_checkOnlySignalByMaskWorker
(
mask
,
false
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkSignalsByMask
(
quint
16
mask
)
bool
MultiSignalSpy
::
checkSignalsByMask
(
quint
32
mask
)
{
return
_checkSignalByMaskWorker
(
mask
,
true
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkOnlySignalsByMask
(
quint
16
mask
)
bool
MultiSignalSpy
::
checkOnlySignalsByMask
(
quint
32
mask
)
{
return
_checkOnlySignalByMaskWorker
(
mask
,
true
/* multipleSignalsAllowed */
);
}
/// @return true if signal count = 0 for specified signals
bool
MultiSignalSpy
::
checkNoSignalByMask
(
quint
16
mask
)
bool
MultiSignalSpy
::
checkNoSignalByMask
(
quint
32
mask
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
if
((
1
<<
i
)
&
mask
)
{
...
...
@@ -154,7 +153,7 @@ bool MultiSignalSpy::checkNoSignalByMask(quint16 mask)
Q_ASSERT
(
spy
!=
NULL
);
if
(
spy
->
count
()
!=
0
)
{
_printSignalState
();
_printSignalState
(
mask
);
return
false
;
}
}
...
...
@@ -170,7 +169,7 @@ bool MultiSignalSpy::checkNoSignals(void)
}
/// @return QSignalSpy for the specified signal
QSignalSpy
*
MultiSignalSpy
::
getSpyByIndex
(
quint
16
index
)
QSignalSpy
*
MultiSignalSpy
::
getSpyByIndex
(
quint
32
index
)
{
Q_ASSERT
(
index
<
_cSignals
);
Q_ASSERT
(
_rgSpys
[
index
]
!=
NULL
);
...
...
@@ -179,7 +178,7 @@ QSignalSpy* MultiSignalSpy::getSpyByIndex(quint16 index)
}
/// Sets the signal count to 0 for the specified signal
void
MultiSignalSpy
::
clearSignalByIndex
(
quint
16
index
)
void
MultiSignalSpy
::
clearSignalByIndex
(
quint
32
index
)
{
Q_ASSERT
(
index
<
_cSignals
);
Q_ASSERT
(
_rgSpys
[
index
]
!=
NULL
);
...
...
@@ -188,7 +187,7 @@ void MultiSignalSpy::clearSignalByIndex(quint16 index)
}
/// Sets the signal count to 0 for all specified signals
void
MultiSignalSpy
::
clearSignalsByMask
(
quint
16
mask
)
void
MultiSignalSpy
::
clearSignalsByMask
(
quint
32
mask
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
if
((
1
<<
i
)
&
mask
)
{
...
...
@@ -203,7 +202,7 @@ void MultiSignalSpy::clearSignalsByMask(quint16 mask)
/// Sets the signal count to 0 for all signals
void
MultiSignalSpy
::
clearAllSignals
(
void
)
{
for
(
quint
16
i
=
0
;
i
<
_cSignals
;
i
++
)
{
for
(
quint
32
i
=
0
;
i
<
_cSignals
;
i
++
)
{
clearSignalByIndex
(
i
);
}
}
...
...
@@ -217,7 +216,7 @@ void MultiSignalSpy::timerEvent(QTimerEvent * event)
/// Waits the specified signal
/// @return false for timeout
bool
MultiSignalSpy
::
waitForSignalByIndex
(
quint
16
index
,
///< [in] index of signal to wait on
quint
32
index
,
///< [in] index of signal to wait on
int
msec
)
///< [in] numbers of milleconds to wait before timeout, -1 wait forever
{
// Check input parameters
...
...
@@ -250,17 +249,31 @@ bool MultiSignalSpy::waitForSignalByIndex(
return
spy
->
count
()
!=
0
;
}
void
MultiSignalSpy
::
_printSignalState
(
void
)
void
MultiSignalSpy
::
_printSignalState
(
quint32
mask
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
bool
expected
=
(
1
<<
i
)
&
mask
;
QSignalSpy
*
spy
=
_rgSpys
[
i
];
Q_ASSERT
(
spy
!=
NULL
);
qDebug
()
<<
"Signal index:"
<<
i
<<
"count:"
<<
spy
->
count
();
qDebug
()
<<
"Signal index:"
<<
i
<<
"count:"
<<
spy
->
count
()
<<
"expected:"
<<
expected
<<
_rgSignals
[
i
]
;
}
}
bool
MultiSignalSpy
::
pullBoolFromSignalIndex
(
quint
16
index
)
bool
MultiSignalSpy
::
pullBoolFromSignalIndex
(
quint
32
index
)
{
QSignalSpy
*
spy
=
getSpyByIndex
(
index
);
return
spy
->
value
(
0
).
value
(
0
).
toBool
();
}
int
MultiSignalSpy
::
pullIntFromSignalIndex
(
quint32
index
)
{
QSignalSpy
*
spy
=
getSpyByIndex
(
index
);
return
spy
->
value
(
0
).
value
(
0
).
toInt
();
}
QGeoCoordinate
MultiSignalSpy
::
pullQGeoCoordinateFromSignalIndex
(
quint32
index
)
{
QSignalSpy
*
spy
=
getSpyByIndex
(
index
);
return
spy
->
value
(
0
).
value
(
0
).
value
<
QGeoCoordinate
>
();
}
src/qgcunittest/MultiSignalSpy.h
View file @
834c862c
...
...
@@ -26,6 +26,7 @@
#include <QObject>
#include <QSignalSpy>
#include <QGeoCoordinate>
/// @file
/// @brief This class allows you to keep track of signal counts on a set of signals associated with an object.
...
...
@@ -46,42 +47,44 @@ public:
/// @param mask bit mask specifying which signals to check. The lowest order bit represents
/// index 0 into the rgSignals array and so on up the bit mask.
/// @return true if signal count = 1 for the specified signals
bool
checkSignalByMask
(
quint
16
mask
);
bool
checkSignalByMask
(
quint
32
mask
);
/// @return true if signal count = 1 for specified signals and signal count of 0
/// for all other signals
bool
checkOnlySignalByMask
(
quint
16
mask
);
bool
checkOnlySignalByMask
(
quint
32
mask
);
/// @param mask bit mask specifying which signals to check. The lowest order bit represents
/// index 0 into the rgSignals array and so on up the bit mask.
/// @return true if signal count >= 1 for the specified signals
bool
checkSignalsByMask
(
quint
16
mask
);
bool
checkSignalsByMask
(
quint
32
mask
);
/// @return true if signal count >= 1 for specified signals and signal count of 0
/// for all other signals
bool
checkOnlySignalsByMask
(
quint
16
mask
);
bool
checkOnlySignalsByMask
(
quint
32
mask
);
bool
checkNoSignalByMask
(
quint
16
mask
);
bool
checkNoSignalByMask
(
quint
32
mask
);
bool
checkNoSignals
(
void
);
void
clearSignalByIndex
(
quint
16
index
);
void
clearSignalsByMask
(
quint
16
mask
);
void
clearSignalByIndex
(
quint
32
index
);
void
clearSignalsByMask
(
quint
32
mask
);
void
clearAllSignals
(
void
);
bool
waitForSignalByIndex
(
quint
16
index
,
int
msec
);
bool
waitForSignalByIndex
(
quint
32
index
,
int
msec
);
QSignalSpy
*
getSpyByIndex
(
quint16
index
);
QSignalSpy
*
getSpyByIndex
(
quint32
index
);
// Returns the value type for the first parameter of the signal
bool
pullBoolFromSignalIndex
(
quint32
index
);
int
pullIntFromSignalIndex
(
quint32
index
);
QGeoCoordinate
pullQGeoCoordinateFromSignalIndex
(
quint32
index
);
/// Returns the boolean value for a signal which has a single bool param
bool
pullBoolFromSignalIndex
(
quint16
index
);
private:
// QObject overrides
void
timerEvent
(
QTimerEvent
*
event
);
void
_printSignalState
(
void
);
bool
_checkSignalByMaskWorker
(
quint
16
mask
,
bool
multipleSignalsAllowed
);
bool
_checkOnlySignalByMaskWorker
(
quint
16
mask
,
bool
multipleSignalsAllowed
);
void
_printSignalState
(
quint32
mask
);
bool
_checkSignalByMaskWorker
(
quint
32
mask
,
bool
multipleSignalsAllowed
);
bool
_checkOnlySignalByMaskWorker
(
quint
32
mask
,
bool
multipleSignalsAllowed
);
QObject
*
_signalEmitter
;
const
char
**
_rgSignals
;
...
...
src/qgcunittest/UnitTestList.cc
View file @
834c862c
...
...
@@ -33,6 +33,7 @@
#include "MessageBoxTest.h"
#include "MissionItemTest.h"
#include "SimpleMissionItemTest.h"
#include "ComplexMissionItemTest.h"
#include "MissionControllerTest.h"
#include "MissionManagerTest.h"
#include "RadioConfigTest.h"
...
...
@@ -49,6 +50,7 @@ UT_REGISTER_TEST(MavlinkLogTest)
UT_REGISTER_TEST
(
MessageBoxTest
)
UT_REGISTER_TEST
(
MissionItemTest
)
UT_REGISTER_TEST
(
SimpleMissionItemTest
)
UT_REGISTER_TEST
(
ComplexMissionItemTest
)
UT_REGISTER_TEST
(
MissionControllerTest
)
UT_REGISTER_TEST
(
MissionManagerTest
)
UT_REGISTER_TEST
(
RadioConfigTest
)
...
...
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