Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
8fc0149b
Commit
8fc0149b
authored
Oct 23, 2015
by
Don Gagne
Browse files
Add checkSignalsByMask and checkOnlySignalsByMask
Allows for signal count > 1
parent
00d395b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/qgcunittest/MultiSignalSpy.cc
View file @
8fc0149b
...
...
@@ -85,17 +85,14 @@ bool MultiSignalSpy::init(
return
true
;
}
/// @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
MultiSignalSpy
::
checkSignalByMask
(
quint16
mask
)
bool
MultiSignalSpy
::
_checkSignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
if
((
1
<<
i
)
&
mask
)
{
QSignalSpy
*
spy
=
_rgSpys
[
i
];
Q_ASSERT
(
spy
!=
NULL
);
if
(
spy
->
count
()
!=
1
)
{
if
(
(
multipleSignalsAllowed
&&
spy
->
count
()
==
0
)
||
spy
->
count
()
!=
1
)
{
_printSignalState
();
return
false
;
}
...
...
@@ -105,16 +102,14 @@ bool MultiSignalSpy::checkSignalByMask(quint16 mask)
return
true
;
}
/// @return true if signal count = 1 for specified signals and signal count of 0
/// for all other signals
bool
MultiSignalSpy
::
checkOnlySignalByMask
(
quint16
mask
)
bool
MultiSignalSpy
::
_checkOnlySignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
)
{
for
(
size_t
i
=
0
;
i
<
_cSignals
;
i
++
)
{
QSignalSpy
*
spy
=
_rgSpys
[
i
];
Q_ASSERT
(
spy
!=
NULL
);
if
((
1
<<
i
)
&
mask
)
{
if
(
spy
->
count
()
!=
1
)
{
if
(
(
multipleSignalsAllowed
&&
spy
->
count
()
==
0
)
||
(
!
multipleSignalsAllowed
&&
spy
->
count
()
!=
1
)
)
{
_printSignalState
();
return
false
;
}
...
...
@@ -129,6 +124,26 @@ bool MultiSignalSpy::checkOnlySignalByMask(quint16 mask)
return
true
;
}
bool
MultiSignalSpy
::
checkSignalByMask
(
quint16
mask
)
{
return
_checkSignalByMaskWorker
(
mask
,
false
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkOnlySignalByMask
(
quint16
mask
)
{
return
_checkOnlySignalByMaskWorker
(
mask
,
false
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkSignalsByMask
(
quint16
mask
)
{
return
_checkSignalByMaskWorker
(
mask
,
true
/* multipleSignalsAllowed */
);
}
bool
MultiSignalSpy
::
checkOnlySignalsByMask
(
quint16
mask
)
{
return
_checkOnlySignalByMaskWorker
(
mask
,
true
/* multipleSignalsAllowed */
);
}
/// @return true if signal count = 0 for specified signals
bool
MultiSignalSpy
::
checkNoSignalByMask
(
quint16
mask
)
{
...
...
src/qgcunittest/MultiSignalSpy.h
View file @
8fc0149b
...
...
@@ -43,8 +43,24 @@ public:
bool
init
(
QObject
*
signalEmitter
,
const
char
**
rgSignals
,
size_t
cSignals
);
/// @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
(
quint16
mask
);
/// @return true if signal count = 1 for specified signals and signal count of 0
/// for all other signals
bool
checkOnlySignalByMask
(
quint16
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
(
quint16
mask
);
/// @return true if signal count >= 1 for specified signals and signal count of 0
/// for all other signals
bool
checkOnlySignalsByMask
(
quint16
mask
);
bool
checkNoSignalByMask
(
quint16
mask
);
bool
checkNoSignals
(
void
);
...
...
@@ -61,6 +77,8 @@ private:
void
timerEvent
(
QTimerEvent
*
event
);
void
_printSignalState
(
void
);
bool
_checkSignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
);
bool
_checkOnlySignalByMaskWorker
(
quint16
mask
,
bool
multipleSignalsAllowed
);
QObject
*
_signalEmitter
;
const
char
**
_rgSignals
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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