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
8e6e0668
Commit
8e6e0668
authored
Jun 22, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new ParameterLoader unit test
parent
9507d24c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
174 additions
and
0 deletions
+174
-0
qgroundcontrol.pro
qgroundcontrol.pro
+2
-0
ParameterLoaderTest.cc
src/qgcunittest/ParameterLoaderTest.cc
+137
-0
ParameterLoaderTest.h
src/qgcunittest/ParameterLoaderTest.h
+33
-0
UnitTestList.cc
src/qgcunittest/UnitTestList.cc
+2
-0
No files found.
qgroundcontrol.pro
View file @
8e6e0668
...
...
@@ -571,6 +571,7 @@ HEADERS += \
src/qgcunittest/MavlinkLogTest.h \
src/qgcunittest/MessageBoxTest.h \
src/qgcunittest/MultiSignalSpy.h \
src/qgcunittest/ParameterLoaderTest.h \
src/qgcunittest/RadioConfigTest.h \
src/qgcunittest/TCPLinkTest.h \
src/qgcunittest/TCPLoopBackServer.h \
...
...
@@ -596,6 +597,7 @@ SOURCES += \
src/qgcunittest/MavlinkLogTest.cc \
src/qgcunittest/MessageBoxTest.cc \
src/qgcunittest/MultiSignalSpy.cc \
src/qgcunittest/ParameterLoaderTest.cc \
src/qgcunittest/RadioConfigTest.cc \
src/qgcunittest/TCPLinkTest.cc \
src/qgcunittest/TCPLoopBackServer.cc \
...
...
src/qgcunittest/ParameterLoaderTest.cc
0 → 100644
View file @
8e6e0668
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include "ParameterLoaderTest.h"
#include "MultiVehicleManager.h"
#include "QGCApplication.h"
#include "ParameterLoader.h"
/// Test failure modes which should still lead to param load success
void
ParameterLoaderTest
::
_noFailureWorker
(
MockConfiguration
::
FailureMode_t
failureMode
)
{
Q_ASSERT
(
!
_mockLink
);
_mockLink
=
MockLink
::
startPX4MockLink
(
false
,
failureMode
);
MultiVehicleManager
*
vehicleMgr
=
qgcApp
()
->
toolbox
()
->
multiVehicleManager
();
QVERIFY
(
vehicleMgr
);
// Wait for the Vehicle to get created
QSignalSpy
spyVehicle
(
vehicleMgr
,
SIGNAL
(
activeVehicleAvailableChanged
(
bool
)));
QCOMPARE
(
spyVehicle
.
wait
(
5000
),
true
);
QCOMPARE
(
spyVehicle
.
count
(),
1
);
QList
<
QVariant
>
arguments
=
spyVehicle
.
takeFirst
();
QCOMPARE
(
arguments
.
count
(),
1
);
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
true
);
Vehicle
*
vehicle
=
vehicleMgr
->
activeVehicle
();
QVERIFY
(
vehicle
);
// We should get progress bar updates during load
QSignalSpy
spyProgress
(
vehicle
->
getParameterLoader
(),
SIGNAL
(
parameterListProgress
(
float
)));
QCOMPARE
(
spyProgress
.
wait
(
2000
),
true
);
arguments
=
spyProgress
.
takeFirst
();
QCOMPARE
(
arguments
.
count
(),
1
);
QVERIFY
(
arguments
.
at
(
0
).
toFloat
()
>
0.0
f
);
// When param load is complete we get the param ready signal
QSignalSpy
spyParamsReady
(
vehicleMgr
,
SIGNAL
(
parameterReadyVehicleAvailableChanged
(
bool
)));
QCOMPARE
(
spyParamsReady
.
wait
(
60000
),
true
);
arguments
=
spyParamsReady
.
takeFirst
();
QCOMPARE
(
arguments
.
count
(),
1
);
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
true
);
// Progress should have been set back to 0
arguments
=
spyProgress
.
takeLast
();
QCOMPARE
(
arguments
.
count
(),
1
);
QCOMPARE
(
arguments
.
at
(
0
).
toFloat
(),
0.0
f
);
}
void
ParameterLoaderTest
::
_noFailure
(
void
)
{
_noFailureWorker
(
MockConfiguration
::
FailNone
);
}
void
ParameterLoaderTest
::
_requestListMissingParamSuccess
(
void
)
{
_noFailureWorker
(
MockConfiguration
::
FailMissingParamOnInitialReqest
);
}
// Test no response to param_request_list
void
ParameterLoaderTest
::
_requestListNoResponse
(
void
)
{
Q_ASSERT
(
!
_mockLink
);
_mockLink
=
MockLink
::
startPX4MockLink
(
false
,
MockConfiguration
::
FailParamNoReponseToRequestList
);
MultiVehicleManager
*
vehicleMgr
=
qgcApp
()
->
toolbox
()
->
multiVehicleManager
();
QVERIFY
(
vehicleMgr
);
// Wait for the Vehicle to get created
QSignalSpy
spyVehicle
(
vehicleMgr
,
SIGNAL
(
activeVehicleAvailableChanged
(
bool
)));
QCOMPARE
(
spyVehicle
.
wait
(
5000
),
true
);
QCOMPARE
(
spyVehicle
.
count
(),
1
);
QList
<
QVariant
>
arguments
=
spyVehicle
.
takeFirst
();
QCOMPARE
(
arguments
.
count
(),
1
);
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
true
);
Vehicle
*
vehicle
=
vehicleMgr
->
activeVehicle
();
QVERIFY
(
vehicle
);
QSignalSpy
spyParamsReady
(
vehicleMgr
,
SIGNAL
(
parameterReadyVehicleAvailableChanged
(
bool
)));
QSignalSpy
spyProgress
(
vehicle
->
getParameterLoader
(),
SIGNAL
(
parameterListProgress
(
float
)));
// We should not get any progress bar updates, nor a parameter ready signal
QCOMPARE
(
spyProgress
.
wait
(
500
),
false
);
QCOMPARE
(
spyParamsReady
.
wait
(
40000
),
false
);
// User should have been notified
checkMultipleExpectedMessageBox
(
5
);
}
// MockLink will fail to send a param on initial request, it will also fail to send it on subsequent
// param_read requests.
void
ParameterLoaderTest
::
_requestListMissingParamFail
(
void
)
{
// Will pop error about missing params
setExpectedMessageBox
(
QMessageBox
::
Ok
);
Q_ASSERT
(
!
_mockLink
);
_mockLink
=
MockLink
::
startPX4MockLink
(
false
,
MockConfiguration
::
FailMissingParamOnAllRequests
);
MultiVehicleManager
*
vehicleMgr
=
qgcApp
()
->
toolbox
()
->
multiVehicleManager
();
QVERIFY
(
vehicleMgr
);
// Wait for the Vehicle to get created
QSignalSpy
spyVehicle
(
vehicleMgr
,
SIGNAL
(
activeVehicleAvailableChanged
(
bool
)));
QCOMPARE
(
spyVehicle
.
wait
(
5000
),
true
);
QCOMPARE
(
spyVehicle
.
count
(),
1
);
QList
<
QVariant
>
arguments
=
spyVehicle
.
takeFirst
();
QCOMPARE
(
arguments
.
count
(),
1
);
QCOMPARE
(
arguments
.
at
(
0
).
toBool
(),
true
);
Vehicle
*
vehicle
=
vehicleMgr
->
activeVehicle
();
QVERIFY
(
vehicle
);
QSignalSpy
spyParamsReady
(
vehicleMgr
,
SIGNAL
(
parameterReadyVehicleAvailableChanged
(
bool
)));
QSignalSpy
spyProgress
(
vehicle
->
getParameterLoader
(),
SIGNAL
(
parameterListProgress
(
float
)));
// We will get progress bar updates, since it will fail after getting partially through the request
QCOMPARE
(
spyProgress
.
wait
(
2000
),
true
);
arguments
=
spyProgress
.
takeFirst
();
QCOMPARE
(
arguments
.
count
(),
1
);
QVERIFY
(
arguments
.
at
(
0
).
toFloat
()
>
0.0
f
);
// We should get a parameters ready signal, but Vehicle should indicate missing params
QCOMPARE
(
spyParamsReady
.
wait
(
40000
),
true
);
QCOMPARE
(
vehicle
->
missingParameters
(),
true
);
// User should have been notified
checkExpectedMessageBox
();
}
src/qgcunittest/ParameterLoaderTest.h
0 → 100644
View file @
8e6e0668
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#ifndef ParameterLoaderTest_H
#define ParameterLoaderTest_H
#include "UnitTest.h"
#include "MockLink.h"
#include "MultiSignalSpy.h"
#include "MockLink.h"
class
ParameterLoaderTest
:
public
UnitTest
{
Q_OBJECT
private
slots
:
void
_noFailure
(
void
);
void
_requestListNoResponse
(
void
);
void
_requestListMissingParamSuccess
(
void
);
void
_requestListMissingParamFail
(
void
);
private:
void
_noFailureWorker
(
MockConfiguration
::
FailureMode_t
failureMode
);
};
#endif
src/qgcunittest/UnitTestList.cc
View file @
8e6e0668
...
...
@@ -29,6 +29,7 @@
#include "MainWindowTest.h"
#include "FileManagerTest.h"
#include "TCPLinkTest.h"
#include "ParameterLoaderTest.h"
UT_REGISTER_TEST
(
FactSystemTestGeneric
)
UT_REGISTER_TEST
(
FactSystemTestPX4
)
...
...
@@ -46,6 +47,7 @@ UT_REGISTER_TEST(MissionManagerTest)
UT_REGISTER_TEST
(
RadioConfigTest
)
UT_REGISTER_TEST
(
TCPLinkTest
)
UT_REGISTER_TEST
(
FileManagerTest
)
UT_REGISTER_TEST
(
ParameterLoaderTest
)
// List of unit test which are currently disabled.
// If disabling a new test, include reason in comment.
...
...
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