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
ed16694f
Commit
ed16694f
authored
Apr 26, 2012
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #88 from Susurrus/unitesting_fixfix
Unittesting fix
parents
27f2a93b
2010bccc
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
569 additions
and
372 deletions
+569
-372
qgcunittest.pro
qgcunittest.pro
+549
-75
SlugsMavUnitTest.cc
qgcunittest/SlugsMavUnitTest.cc
+0
-34
SlugsMavUnitTest.h
qgcunittest/SlugsMavUnitTest.h
+0
-35
UASUnitTest.cc
qgcunittest/UASUnitTest.cc
+20
-21
UASUnitTest.h
qgcunittest/UASUnitTest.h
+0
-6
tst_uasunittest.cc
qgcunittest/tst_uasunittest.cc
+0
-201
No files found.
qgcunittest.pro
View file @
ed16694f
This diff is collapsed.
Click to expand it.
qgcunittest/SlugsMavUnitTest.cc
deleted
100644 → 0
View file @
27f2a93b
#include "SlugsMavUnitTest.h"
SlugsMavUnitTest
::
SlugsMavUnitTest
()
{
}
void
SlugsMavUnitTest
::
initTestCase
()
{
mav
=
new
MAVLinkProtocol
();
slugsMav
=
new
SlugsMAV
(
mav
,
UASID
);
}
void
SlugsMavUnitTest
::
cleanupTestCase
()
{
delete
slugsMav
;
delete
mav
;
}
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
deleted
100644 → 0
View file @
27f2a93b
#ifndef SLUGSMAVUNITTEST_H
#define SLUGSMAVUNITTEST_H
#include <QObject>
#include <QtCore/QString>
#include <QtTest/QtTest>
#include "UAS.h"
#include "MAVLinkProtocol.h"
#include "UASInterface.h"
#include "AutoTest.h"
#include "SlugsMAV.h"
class
SlugsMavUnitTest
:
public
QObject
{
Q_OBJECT
public:
#define UASID 5
MAVLinkProtocol
*
mav
;
SlugsMAV
*
slugsMav
;
SlugsMavUnitTest
();
signals:
private
slots
:
void
initTestCase
();
void
cleanupTestCase
();
void
first_test
();
void
getPwmCommands_test
();
};
DECLARE_TEST
(
SlugsMavUnitTest
)
#endif // SLUGSMAVUNITTEST_H
qgcunittest/UASUnitTest.cc
View file @
ed16694f
...
...
@@ -6,9 +6,8 @@ UASUnitTest::UASUnitTest()
void
UASUnitTest
::
initTestCase
()
{
mav
=
new
MAVLinkProtocol
();
link
=
new
SerialLink
();
uas
=
new
UAS
(
mav
,
UASID
);
mav
=
new
MAVLinkProtocol
();
uas
=
new
UAS
(
mav
,
UASID
);
}
void
UASUnitTest
::
cleanupTestCase
()
...
...
@@ -27,7 +26,7 @@ void UASUnitTest::getUASID_test()
// Test that the chosen ID was assigned at construction
QCOMPARE
(
uas
->
getUASID
(),
UASID
);
// Make sure that no other ID was se
r
t
// Make sure that no other ID was set
QEXPECT_FAIL
(
""
,
"When you set an ID it does not use the default ID of 0"
,
Continue
);
QCOMPARE
(
uas
->
getUASID
(),
0
);
...
...
@@ -177,27 +176,27 @@ void UASUnitTest::getAirframe_test()
void
UASUnitTest
::
getWaypointList_test
()
{
QVector
<
Waypoint
*>
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
QVector
<
Waypoint
*>
kk
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
QCOMPARE
(
kk
.
count
(),
0
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
0
,
0
,
0
,
0
,
false
,
false
,
0
,
0
,
MAV_FRAME_GLOBAL
,
MAV_ACTION_NAVIGATE
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
0
.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
false
,
false
,
MAV_FRAME_GLOBAL
,
MAV_CMD_MISSION_START
,
"blah"
);
uas
->
getWaypointManager
()
->
addWaypoint
Editable
(
wp
,
true
);
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
kk
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
QCOMPARE
(
kk
.
count
(),
1
);
wp
=
new
Waypoint
();
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
false
);
uas
->
getWaypointManager
()
->
addWaypoint
Editable
(
wp
,
false
);
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
kk
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
QCOMPARE
(
kk
.
count
(),
2
);
uas
->
getWaypointManager
()
->
removeWaypoint
(
1
);
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
kk
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
QCOMPARE
(
kk
.
count
(),
1
);
uas
->
getWaypointManager
()
->
removeWaypoint
(
0
);
kk
=
uas
->
getWaypointManager
()
->
getWaypointList
();
kk
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
QCOMPARE
(
kk
.
count
(),
0
);
qDebug
()
<<
"disconnect SIGNAL waypointListChanged"
;
...
...
@@ -205,17 +204,17 @@ void UASUnitTest::getWaypointList_test()
void
UASUnitTest
::
getWaypoint_test
()
{
Waypoint
*
wp
=
new
Waypoint
(
0
,
5.6
,
0
,
0
,
0
,
false
,
false
,
0
,
0
,
MAV_FRAME_GLOBAL
,
MAV_ACTION_NAVIGATE
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
false
,
false
,
MAV_FRAME_GLOBAL
,
MAV_CMD_MISSION_START
,
"blah"
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
uas
->
getWaypointManager
()
->
addWaypoint
Editable
(
wp
,
true
);
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypointList
();
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
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
);
uas
->
getWaypointManager
()
->
addWaypoint
Editable
(
wp
,
true
);
Waypoint
*
wp2
=
static_cast
<
Waypoint
*>
(
wpList
.
at
(
0
));
QCOMPARE
(
wp
->
getX
(),
wp2
->
getX
());
...
...
@@ -226,9 +225,9 @@ void UASUnitTest::getWaypoint_test()
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
);
Waypoint
*
wp
=
new
Waypoint
(
0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
false
,
false
,
MAV_FRAME_GLOBAL
,
MAV_CMD_MISSION_START
,
"blah"
);
uas
->
getWaypointManager
()
->
addWaypoint
Editable
(
wp
,
true
);
QCOMPARE
(
spy
.
count
(),
1
);
// 1 listChanged for add wayPoint
uas
->
getWaypointManager
()
->
removeWaypoint
(
0
);
...
...
@@ -245,11 +244,11 @@ void UASUnitTest::signalWayPoint_test()
QSignalSpy
spy2
(
uas
->
getWaypointManager
(),
SIGNAL
(
waypointListChanged
()));
QCOMPARE
(
spy2
.
count
(),
0
);
uas
->
getWaypointManager
()
->
addWaypoint
(
wp
,
true
);
uas
->
getWaypointManager
()
->
addWaypoint
Editable
(
wp
,
true
);
QCOMPARE
(
spy2
.
count
(),
1
);
uas
->
getWaypointManager
()
->
clearWaypointList
();
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypointList
();
QVector
<
Waypoint
*>
wpList
=
uas
->
getWaypointManager
()
->
getWaypoint
Editable
List
();
QCOMPARE
(
wpList
.
count
(),
1
);
}
...
...
qgcunittest/UASUnitTest.h
View file @
ed16694f
...
...
@@ -25,8 +25,6 @@ public:
UAS
*
uas
;
UASUnitTest
();
signals:
private
slots
:
void
initTestCase
();
void
cleanupTestCase
();
...
...
@@ -61,10 +59,6 @@ private slots:
void
signalWayPoint_test
();
void
signalUASLink_test
();
void
signalIdUASLink_test
();
protected:
UAS
*
prueba
;
};
DECLARE_TEST
(
UASUnitTest
)
...
...
qgcunittest/tst_uasunittest.cc
deleted
100644 → 0
View file @
27f2a93b
#include <QtCore/QString>
#include <QtTest/QtTest>
#include "UAS.h"
#include "MAVLinkProtocol.h"
#include "UASInterface.h"
class
UASUnitTest
:
public
QObject
{
Q_OBJECT
public:
#define UASID 50
MAVLinkProtocol
*
mav
;
UAS
*
uas
;
UASUnitTest
();
private
Q_SLOTS
:
void
initTestCase
();
void
cleanupTestCase
();
void
getUASID_test
();
void
getUASName_test
();
void
getUpTime_test
();
void
getCommunicationStatus_test
();
void
filterVoltage_test
();
void
getAutopilotType_test
();
void
setAutopilotType_test
();
void
getStatusForCode_test
();
void
getLocalX_test
();
void
getLocalY_test
();
void
getLocalZ_test
();
void
getLatitude_test
();
void
getLongitude_test
();
void
getAltitude_test
();
void
getRoll_test
();
void
getPitch_test
();
void
getYaw_test
();
private:
protected:
UAS
*
prueba
;
};
UASUnitTest
::
UASUnitTest
()
{
}
void
UASUnitTest
::
initTestCase
()
{
mav
=
new
MAVLinkProtocol
();
uas
=
new
UAS
(
mav
,
UASID
);
}
void
UASUnitTest
::
cleanupTestCase
()
{
delete
uas
;
delete
mav
;
}
void
UASUnitTest
::
getUASID_test
()
{
// Test a default ID of zero is assigned
UAS
*
uas2
=
new
UAS
(
mav
);
QCOMPARE
(
uas2
->
getUASID
(),
0
);
delete
uas2
;
// Test that the chosen ID was assigned at construction
QCOMPARE
(
uas
->
getUASID
(),
UASID
);
// Make sure that no other ID was sert
QEXPECT_FAIL
(
""
,
"When you set an ID it does not use the default ID of 0"
,
Continue
);
QCOMPARE
(
uas
->
getUASID
(),
0
);
}
void
UASUnitTest
::
getUASName_test
()
{
// Test that the name is build as MAV + ID
QCOMPARE
(
uas
->
getUASName
(),
"MAV 0"
+
QString
::
number
(
UASID
));
}
void
UASUnitTest
::
getUpTime_test
()
{
UAS
*
uas2
=
new
UAS
(
mav
);
// Test that the uptime starts at zero to a
// precision of seconds
QCOMPARE
(
floor
(
uas2
->
getUptime
()
/
1000.0
),
0.0
);
// Sleep for three seconds
QTest
::
qSleep
(
3000
);
// Test that the up time is computed correctly to a
// precision of seconds
QCOMPARE
(
floor
(
uas2
->
getUptime
()
/
1000.0
),
3.0
);
delete
uas2
;
}
void
UASUnitTest
::
getCommunicationStatus_test
()
{
// Verify that upon construction the Comm status is disconnected
QCOMPARE
(
uas
->
getCommunicationStatus
(),
static_cast
<
int
>
(
UASInterface
::
COMM_DISCONNECTED
));
}
void
UASUnitTest
::
filterVoltage_test
()
{
float
verificar
=
uas
->
filterVoltage
(
0.4
f
);
// Verify that upon construction the Comm status is disconnected
QCOMPARE
(
verificar
,
8.52
f
);
}
void
UASUnitTest
::
getAutopilotType_test
()
{
int
verificar
=
uas
->
getAutopilotType
();
// Verify that upon construction the autopilot is set to -1
QCOMPARE
(
verificar
,
-
1
);
}
void
UASUnitTest
::
setAutopilotType_test
()
{
uas
->
setAutopilotType
(
2
);
// Verify that the autopilot is set
QCOMPARE
(
uas
->
getAutopilotType
(),
2
);
}
void
UASUnitTest
::
getStatusForCode_test
()
{
QString
state
,
desc
;
state
=
""
;
desc
=
""
;
uas
->
getStatusForCode
(
MAV_STATE_UNINIT
,
state
,
desc
);
QVERIFY
(
state
==
"UNINIT"
);
uas
->
getStatusForCode
(
MAV_STATE_UNINIT
,
state
,
desc
);
QVERIFY
(
state
==
"UNINIT"
);
uas
->
getStatusForCode
(
MAV_STATE_BOOT
,
state
,
desc
);
QVERIFY
(
state
==
"BOOT"
);
uas
->
getStatusForCode
(
MAV_STATE_CALIBRATING
,
state
,
desc
);
QVERIFY
(
state
==
"CALIBRATING"
);
uas
->
getStatusForCode
(
MAV_STATE_ACTIVE
,
state
,
desc
);
QVERIFY
(
state
==
"ACTIVE"
);
uas
->
getStatusForCode
(
MAV_STATE_STANDBY
,
state
,
desc
);
QVERIFY
(
state
==
"STANDBY"
);
uas
->
getStatusForCode
(
MAV_STATE_CRITICAL
,
state
,
desc
);
QVERIFY
(
state
==
"CRITICAL"
);
uas
->
getStatusForCode
(
MAV_STATE_EMERGENCY
,
state
,
desc
);
QVERIFY
(
state
==
"EMERGENCY"
);
uas
->
getStatusForCode
(
MAV_STATE_POWEROFF
,
state
,
desc
);
QVERIFY
(
state
==
"SHUTDOWN"
);
uas
->
getStatusForCode
(
5325
,
state
,
desc
);
QVERIFY
(
state
==
"UNKNOWN"
);
}
void
UASUnitTest
::
getLocalX_test
()
{
QCOMPARE
(
uas
->
getLocalX
(),
0.0
);
}
void
UASUnitTest
::
getLocalY_test
()
{
QCOMPARE
(
uas
->
getLocalY
(),
0.0
);
}
void
UASUnitTest
::
getLocalZ_test
()
{
QCOMPARE
(
uas
->
getLocalZ
(),
0.0
);
}
void
UASUnitTest
::
getLatitude_test
()
{
QCOMPARE
(
uas
->
getLatitude
(),
0.0
);
}
void
UASUnitTest
::
getLongitude_test
()
{
QCOMPARE
(
uas
->
getLongitude
(),
0.0
);
}
void
UASUnitTest
::
getAltitude_test
()
{
QCOMPARE
(
uas
->
getAltitude
(),
0.0
);
}
void
UASUnitTest
::
getRoll_test
()
{
QCOMPARE
(
uas
->
getRoll
(),
0.0
);
}
void
UASUnitTest
::
getPitch_test
()
{
QCOMPARE
(
uas
->
getPitch
(),
0.0
);
}
void
UASUnitTest
::
getYaw_test
()
{
QCOMPARE
(
uas
->
getYaw
(),
0.0
);
}
QTEST_APPLESS_MAIN
(
UASUnitTest
);
#include "tst_uasunittest.moc"
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