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
3942c3bb
Commit
3942c3bb
authored
Dec 04, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More implementation of Mock
parent
551ffcc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
MockQGCUASParamManager.cc
src/qgcunittest/MockQGCUASParamManager.cc
+9
-3
MockQGCUASParamManager.h
src/qgcunittest/MockQGCUASParamManager.h
+11
-5
No files found.
src/qgcunittest/MockQGCUASParamManager.cc
View file @
3942c3bb
...
...
@@ -25,6 +25,8 @@
#include <QTest>
#include <QDebug>
Q_LOGGING_CATEGORY
(
MockQGCUASParamManagerLog
,
"MockQGCUASParamManagerLog"
)
MockQGCUASParamManager
::
MockQGCUASParamManager
(
void
)
{
...
...
@@ -36,13 +38,17 @@ bool MockQGCUASParamManager::getParameterValue(int component, const QString& par
if
(
_mapParams
.
contains
(
parameter
))
{
value
=
_mapParams
[
parameter
];
return
true
;
}
qCDebug
(
MockQGCUASParamManagerLog
)
<<
QString
(
"getParameterValue: parameter not found %1"
).
arg
(
parameter
);
return
false
;
}
void
MockQGCUASParamManager
::
setParameter
(
int
component
,
QString
parameterName
,
QVariant
value
)
{
Q_UNUSED
(
component
);
_mapParamsSet
[
parameterName
]
=
value
;
qCDebug
(
MockQGCUASParamManagerLog
)
<<
QString
(
"setParameter: component(%1) parameter(%2) value(%3)"
).
arg
(
component
).
arg
(
parameterName
).
arg
(
value
.
toString
());
_mapParams
[
parameterName
]
=
value
;
emit
parameterUpdated
(
_defaultComponentId
,
parameterName
,
value
);
}
src/qgcunittest/MockQGCUASParamManager.h
View file @
3942c3bb
...
...
@@ -24,8 +24,12 @@
#ifndef MOCKQGCUASPARAMMANAGER_H
#define MOCKQGCUASPARAMMANAGER_H
#include <QLoggingCategory>
#include "QGCUASParamManagerInterface.h"
Q_DECLARE_LOGGING_CATEGORY
(
MockQGCUASParamManagerLog
)
/// @file
/// @brief This is a mock implementation of QGCUASParamManager for writing Unit Tests.
///
...
...
@@ -39,11 +43,12 @@ class MockQGCUASParamManager : public QGCUASParamManagerInterface
signals:
// The following QGCSUASParamManagerInterface signals are supported
void
parameterListUpToDate
();
// You can connect to this signal, but it will never be emitted
void
parameterUpdated
(
int
compId
,
QString
paramName
,
QVariant
value
);
public:
// Implemented QGCSUASParamManager overrides
virtual
bool
getParameterValue
(
int
component
,
const
QString
&
parameter
,
QVariant
&
value
)
const
;
virtual
int
getDefaultComponentId
(
void
)
{
return
0
;
}
virtual
int
getDefaultComponentId
(
void
)
{
return
_defaultComponentId
;
}
virtual
int
countOnboardParams
(
void
)
{
return
_mapParams
.
count
();
}
public
slots
:
...
...
@@ -53,7 +58,7 @@ public slots:
{
Q_UNUSED
(
forceSend
);
setParameter
(
componentId
,
key
,
value
);
}
virtual
void
sendPendingParameters
(
bool
persistAfterSend
=
false
,
bool
forceSend
=
false
)
{
Q_UNUSED
(
persistAfterSend
);
Q_UNUSED
(
forceSend
);
}
virtual
bool
parametersReady
(
void
)
{
return
fals
e
;
}
virtual
bool
parametersReady
(
void
)
{
return
tru
e
;
}
public:
// MockQGCUASParamManager methods
...
...
@@ -66,9 +71,9 @@ public:
void
setMockParameters
(
ParamMap_t
&
map
)
{
_mapParams
=
map
;
}
/// Returns the parameters which were set by calls to setParameter calls
ParamMap_t
getMockSetParameters
(
void
)
{
return
_mapParams
Set
;
}
ParamMap_t
getMockSetParameters
(
void
)
{
return
_mapParams
;
}
/// Clears the set of parameters set by setParameter calls
void
clearMockSetParameters
(
void
)
{
_mapParams
Set
.
clear
();
}
void
clearMockSetParameters
(
void
)
{
_mapParams
.
clear
();
}
public:
// Unimplemented QGCUASParamManagerInterface overrides
...
...
@@ -93,7 +98,8 @@ public slots:
private:
ParamMap_t
_mapParams
;
ParamMap_t
_mapParamsSet
;
static
const
int
_defaultComponentId
=
50
;
// Bogus variables used for return types of NYI methods
QList
<
int
>
_bogusQListInt
;
...
...
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