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
acc50f49
Commit
acc50f49
authored
Feb 18, 2011
by
Alejandro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update files test unit
parent
759715d5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
152 additions
and
67 deletions
+152
-67
SlugsMavUnitTest.cc
qgcunittest/SlugsMavUnitTest.cc
+11
-0
SlugsMavUnitTest.h
qgcunittest/SlugsMavUnitTest.h
+3
-0
UASUnitTest.cc
qgcunittest/UASUnitTest.cc
+129
-64
UASUnitTest.h
qgcunittest/UASUnitTest.h
+9
-3
No files found.
qgcunittest/SlugsMavUnitTest.cc
View file @
acc50f49
...
...
@@ -21,3 +21,14 @@ void SlugsMavUnitTest::first_test()
QCOMPARE
(
1
,
1
);
}
void
SlugsMavUnitTest
::
getPwmCommands_test
()
{
mavlink_pwm_commands_t
*
k
=
slugsMav
->
getPwmCommands
();
k
->
aux1
=
80
;
mavlink_pwm_commands_t
*
k2
=
slugsMav
->
getPwmCommands
();
k2
->
aux1
=
81
;
QCOMPARE
(
k
->
aux1
,
k2
->
aux1
);
}
qgcunittest/SlugsMavUnitTest.h
View file @
acc50f49
...
...
@@ -4,6 +4,7 @@
#include <QObject>
#include <QtCore/QString>
#include <QtTest/QtTest>
#include "UAS.h"
#include "MAVLinkProtocol.h"
#include "UASInterface.h"
...
...
@@ -25,6 +26,8 @@ private slots:
void
cleanupTestCase
();
void
first_test
();
void
getPwmCommands_test
();
};
DECLARE_TEST
(
SlugsMavUnitTest
)
...
...
qgcunittest/UASUnitTest.cc
View file @
acc50f49
...
...
@@ -14,7 +14,6 @@ void UASUnitTest::cleanupTestCase()
{
delete
uas
;
delete
mav
;
}
void
UASUnitTest
::
getUASID_test
()
...
...
@@ -32,15 +31,13 @@ void UASUnitTest::getUASID_test()
QCOMPARE
(
uas
->
getUASID
(),
0
);
// Make sure that ID >= 0
QCOMPARE
(
uas
->
getUASID
(),
-
1
);
QCOMPARE
(
uas
->
getUASID
(),
100
);
}
void
UASUnitTest
::
getUASName_test
()
{
// Test that the name is build as MAV + ID
QCOMPARE
(
uas
->
getUASName
(),
"MAV
0
"
+
QString
::
number
(
UASID
));
QCOMPARE
(
uas
->
getUASName
(),
"MAV "
+
QString
::
number
(
UASID
));
}
...
...
@@ -123,7 +120,6 @@ void UASUnitTest::getStatusForCode_test()
QVERIFY
(
state
==
"UNKNOWN"
);
}
void
UASUnitTest
::
getLocalX_test
()
{
QCOMPARE
(
uas
->
getLocalX
(),
0.0
);
...
...
@@ -163,69 +159,21 @@ void UASUnitTest::getYaw_test()
void
UASUnitTest
::
getSelected_test
()
{
QCOMPARE
(
uas
->
getSelected
(),
false
);
//QCOMPARE(uas->getSelected(), true);
}
void
UASUnitTest
::
getSystemType_test
()
{
//QCOMPARE(uas->getSystemType(), -1);
QEXPECT_FAIL
(
""
,
"uas->getSystemType(), 0"
,
Continue
);
QCOMPARE
(
uas
->
getSystemType
(),
0
);
QEXPECT_FAIL
(
""
,
"uas->getSystemType(), 1"
,
Continue
);
QCOMPARE
(
uas
->
getSystemType
(),
1
);
int
systemType
=
uas
->
getSystemType
();
QCOMPARE
(
uas
->
getSystemType
(),
systemType
);
QCOMPARE
(
uas
->
getSystemType
(),
13
);
}
void
UASUnitTest
::
getAirframe_test
()
{
//QCOMPARE(uas->getAirframe(), -1);
QCOMPARE
(
uas
->
getAirframe
(),
0
);
uas
->
setAirframe
(
25
);
QCOMPARE
(
uas
->
getAirframe
(),
1
);
QVERIFY
(
uas
->
getAirframe
()
==
25
);
}
void
UASUnitTest
::
getLinks_test
()
{
// Compare that the links count equal to 0
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
0
);
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
();
// Compare that the links in LinkManager count equal to 0
QCOMPARE
(
links
.
count
(),
0
);
LinkInterface
*
l
;
uas
->
getLinks
()
->
append
(
l
);
// Compare that the links in LinkManager count equal to 1
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
1
);
QList
<
LinkInterface
*>
links2
=
LinkManager
::
instance
()
->
getLinks
();
// Compare that the links count equals after update add link in uas
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
links2
.
count
()
+
1
);
// Compare that the link l is equal to link[0] from links in uas
QCOMPARE
(
l
,
static_cast
<
LinkInterface
*>
(
uas
->
getLinks
()
->
at
(
0
)));
// Compare that the link l is equal to link[0] from links in uas through count links
QCOMPARE
(
l
,
static_cast
<
LinkInterface
*>
(
uas
->
getLinks
()
->
at
(
uas
->
getLinks
()
->
count
()
-
1
)));
uas
->
addLink
(
l
);
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
1
);
uas
->
removeLink
(
0
);
// dynamic_cast<QObject*>(l));
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
0
);
}
void
UASUnitTest
::
getWaypointList_test
()
{
QVector
<
Waypoint
*>
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
...
...
@@ -251,19 +199,136 @@ void UASUnitTest::getWaypointList_test()
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
QCOMPARE
(
kk
.
count
(),
0
);
wp
=
new
Waypoint
();
qDebug
()
<<
"disconnect SIGNAL waypointListChanged"
;
}
void
UASUnitTest
::
getWaypoint_test
()
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
5.6
,
0
,
0
,
0
,
false
,
false
,
0
,
0
,
MAV_FRAME_GLOBAL
,
MAV_ACTION_NAVIGATE
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
wp
=
new
Waypoint
();
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
false
);
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypointList
();
QCOMPARE
(
wpList
.
count
(),
1
);
QCOMPARE
(
static_cast
<
quint16
>
(
0
),
static_cast
<
Waypoint
*>
(
wpList
.
at
(
0
))
->
getId
());
wp
=
new
Waypoint
(
0
,
5.6
,
2
,
3
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
Waypoint
*
wp2
=
static_cast
<
Waypoint
*>
(
wpList
.
at
(
0
));
QCOMPARE
(
wp
->
getX
(),
wp2
->
getX
());
QCOMPARE
(
wp
->
getFrame
(),
MAV_FRAME_GLOBAL
);
QCOMPARE
(
wp
->
getFrame
(),
wp2
->
getFrame
());
}
// Fail clearWaypointList
//uas->getWaypointManager()->clearWaypointList();
//kk = uas->getWaypointManager()->getWaypointList();
//QCOMPARE(kk.count(), 1);
void
UASUnitTest
::
signalWayPoint_test
()
{
QSignalSpy
spy
(
uas
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
()));
Waypoint
*
wp
=
new
Waypoint
(
0
,
5.6
,
0
,
0
,
0
,
false
,
false
,
0
,
0
,
MAV_FRAME_GLOBAL
,
MAV_ACTION_NAVIGATE
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
QCOMPARE
(
spy
.
count
(),
1
);
// 1 listChanged for add wayPoint
uas
->
getWaypointManager
()
->
removeWaypoint
(
0
);
QCOMPARE
(
spy
.
count
(),
2
);
// 2 listChanged for remove wayPoint
QSignalSpy
spyDestroyed
(
uas
->
getWaypointManager
(),
SIGNAL
(
destroyed
()));
QVERIFY
(
spyDestroyed
.
isValid
());
QCOMPARE
(
spyDestroyed
.
count
(),
0
);
delete
uas
;
// delete(destroyed) uas for validating
QCOMPARE
(
spyDestroyed
.
count
(),
1
);
// count destroyed uas should are 1
uas
=
new
UAS
(
mav
,
UASID
);
QSignalSpy
spy2
(
uas
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
()));
QCOMPARE
(
spy2
.
count
(),
0
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
QCOMPARE
(
spy2
.
count
(),
1
);
uas
->
getWaypointManager
()
->
clearWaypointList
();
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypointList
();
QCOMPARE
(
wpList
.
count
(),
1
);
}
void
UASUnitTest
::
battery
_test
()
void
UASUnitTest
::
signalUASLink
_test
()
{
QCOMPARE
(
uas
->
getCommunicationStatus
(),
0
);
QSignalSpy
spy
(
uas
,
SIGNAL
(
modeChanged
(
int
,
QString
,
QString
)));
uas
->
setMode
(
2
);
QCOMPARE
(
spy
.
count
(),
0
);
// not solve for UAS not receiving message from UAS
QSignalSpy
spyS
(
LinkManager
::
instance
(),
SIGNAL
(
newLink
(
LinkInterface
*
)));
SerialLink
*
link
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
link
);
LinkManager
::
instance
()
->
addProtocol
(
link
,
mav
);
QCOMPARE
(
spyS
.
count
(),
1
);
LinkManager
::
instance
()
->
add
(
link
);
LinkManager
::
instance
()
->
addProtocol
(
link
,
mav
);
QCOMPARE
(
spyS
.
count
(),
1
);
// not add SerialLink, exist in list
SerialLink
*
link2
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
link2
);
LinkManager
::
instance
()
->
addProtocol
(
link2
,
mav
);
QCOMPARE
(
spyS
.
count
(),
2
);
// add SerialLink, not exist in list
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
();
foreach
(
LinkInterface
*
link
,
links
)
{
qDebug
()
<<
link
->
getName
();
qDebug
()
<<
QString
::
number
(
link
->
getId
());
qDebug
()
<<
QString
::
number
(
link
->
getNominalDataRate
());
QVERIFY
(
link
!=
NULL
);
uas
->
addLink
(
link
);
}
SerialLink
*
ff
=
static_cast
<
SerialLink
*>
(
uas
->
getLinks
()
->
at
(
0
));
QCOMPARE
(
ff
->
isConnected
(),
false
);
QCOMPARE
(
ff
->
isRunning
(),
false
);
QCOMPARE
(
ff
->
isFinished
(),
false
);
QCOMPARE
(
links
.
count
(),
uas
->
getLinks
()
->
count
());
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
2
);
LinkInterface
*
ff99
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
1
));
LinkManager
::
instance
()
->
removeLink
(
ff99
);
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
1
);
QCOMPARE
(
uas
->
getLinks
()
->
count
(),
2
);
QCOMPARE
(
static_cast
<
LinkInterface
*>
(
LinkManager
::
instance
()
->
getLinks
().
at
(
0
))
->
getId
(),
static_cast
<
LinkInterface
*>
(
uas
->
getLinks
()
->
at
(
0
))
->
getId
());
link
=
new
SerialLink
();
LinkManager
::
instance
()
->
add
(
link
);
LinkManager
::
instance
()
->
addProtocol
(
link
,
mav
);
QCOMPARE
(
spyS
.
count
(),
3
);
}
void
UASUnitTest
::
signalIdUASLink_test
()
{
SerialLink
*
myLink
=
new
SerialLink
();
myLink
->
setPortName
(
"COM 17"
);
LinkManager
::
instance
()
->
add
(
myLink
);
LinkManager
::
instance
()
->
addProtocol
(
myLink
,
mav
);
myLink
=
new
SerialLink
();
myLink
->
setPortName
(
"COM 18"
);
LinkManager
::
instance
()
->
add
(
myLink
);
LinkManager
::
instance
()
->
addProtocol
(
myLink
,
mav
);
QCOMPARE
(
LinkManager
::
instance
()
->
getLinks
().
count
(),
4
);
QList
<
LinkInterface
*>
links
=
LinkManager
::
instance
()
->
getLinks
();
LinkInterface
*
a
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
2
));
LinkInterface
*
b
=
static_cast
<
LinkInterface
*>
(
links
.
at
(
3
));
QCOMPARE
(
a
->
getName
(),
QString
(
"serial port COM 17"
));
QCOMPARE
(
b
->
getName
(),
QString
(
"serial port COM 18"
));
}
qgcunittest/UASUnitTest.h
View file @
acc50f49
...
...
@@ -11,12 +11,15 @@
#include "UASInterface.h"
#include "AutoTest.h"
#include "LinkManager.h"
#include "UASWaypointManager.h"
#include "SerialLink.h"
#include "LinkInterface.h"
class
UASUnitTest
:
public
QObject
{
Q_OBJECT
public:
#define UASID
5
0
#define UASID
10
0
MAVLinkProtocol
*
mav
;
UAS
*
uas
;
UASUnitTest
();
...
...
@@ -50,10 +53,13 @@ private slots:
void
getSystemType_test
();
void
getAirframe_test
();
void
getLinks_test
();
void
getWaypointList_test
();
void
getWaypoint_test
();
void
battery_test
();
void
signalWayPoint_test
();
void
signalUASLink_test
();
void
signalIdUASLink_test
();
protected:
UAS
*
prueba
;
...
...
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