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
3b328f36
Commit
3b328f36
authored
Dec 11, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New FactSystem unit test
parent
817fbeaf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
274 additions
and
5 deletions
+274
-5
FactTextInput.qml
files/qml/FactTextInput.qml
+1
-1
qgroundcontrol.pro
qgroundcontrol.pro
+4
-4
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
FactSystemTest.cc
src/FactSystem/FactSystemTest.cc
+194
-0
FactSystemTest.h
src/FactSystem/FactSystemTest.h
+58
-0
FactSystemTest.qml
src/FactSystem/FactSystemTest.qml
+16
-0
No files found.
files/qml/FactTextInput.qml
View file @
3b328f36
import
QtQuick
2.
0
import
QtQuick
2.
2
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Controls
1.2
import
QGroundControl
.
FactSystem
1.0
import
QGroundControl
.
FactSystem
1.0
...
...
qgroundcontrol.pro
View file @
3b328f36
...
@@ -484,7 +484,6 @@ HEADERS += \
...
@@ -484,7 +484,6 @@ HEADERS += \
src
/
uas
/
QGCUASParamManagerInterface
.
h
\
src
/
uas
/
QGCUASParamManagerInterface
.
h
\
src
/
uas
/
QGCUASFileManager
.
h
\
src
/
uas
/
QGCUASFileManager
.
h
\
src
/
ui
/
QGCUASFileView
.
h
\
src
/
ui
/
QGCUASFileView
.
h
\
src
/
uas
/
QGCUASWorker
.
h
\
src
/
CmdLineOptParser
.
h
\
src
/
CmdLineOptParser
.
h
\
src
/
uas
/
QGXPX4UAS
.
h
\
src
/
uas
/
QGXPX4UAS
.
h
\
src
/
QGCFileDialog
.
h
\
src
/
QGCFileDialog
.
h
\
...
@@ -625,7 +624,6 @@ SOURCES += \
...
@@ -625,7 +624,6 @@ SOURCES += \
src
/
ui
/
menuactionhelper
.
cpp
\
src
/
ui
/
menuactionhelper
.
cpp
\
src
/
uas
/
QGCUASFileManager
.
cc
\
src
/
uas
/
QGCUASFileManager
.
cc
\
src
/
ui
/
QGCUASFileView
.
cc
\
src
/
ui
/
QGCUASFileView
.
cc
\
src
/
uas
/
QGCUASWorker
.
cc
\
src
/
CmdLineOptParser
.
cc
\
src
/
CmdLineOptParser
.
cc
\
src
/
uas
/
QGXPX4UAS
.
cc
\
src
/
uas
/
QGXPX4UAS
.
cc
\
src
/
QGCFileDialog
.
cc
\
src
/
QGCFileDialog
.
cc
\
...
@@ -670,7 +668,8 @@ HEADERS += \
...
@@ -670,7 +668,8 @@ HEADERS += \
src
/
qgcunittest
/
LinkManagerTest
.
h
\
src
/
qgcunittest
/
LinkManagerTest
.
h
\
src
/
qgcunittest
/
MainWindowTest
.
h
\
src
/
qgcunittest
/
MainWindowTest
.
h
\
src
/
AutoPilotPlugins
/
PX4
/
Tests
/
FlightModeConfigTest
.
h
\
src
/
AutoPilotPlugins
/
PX4
/
Tests
/
FlightModeConfigTest
.
h
\
src
/
qgcunittest
/
MavlinkLogTest
.
h
src
/
qgcunittest
/
MavlinkLogTest
.
h
\
src
/
FactSystem
/
FactSystemTest
.
h
SOURCES
+=
\
SOURCES
+=
\
src
/
qgcunittest
/
UnitTest
.
cc
\
src
/
qgcunittest
/
UnitTest
.
cc
\
...
@@ -691,7 +690,8 @@ SOURCES += \
...
@@ -691,7 +690,8 @@ SOURCES += \
src
/
qgcunittest
/
LinkManagerTest
.
cc
\
src
/
qgcunittest
/
LinkManagerTest
.
cc
\
src
/
qgcunittest
/
MainWindowTest
.
cc
\
src
/
qgcunittest
/
MainWindowTest
.
cc
\
src
/
AutoPilotPlugins
/
PX4
/
Tests
/
FlightModeConfigTest
.
cc
\
src
/
AutoPilotPlugins
/
PX4
/
Tests
/
FlightModeConfigTest
.
cc
\
src
/
qgcunittest
/
MavlinkLogTest
.
cc
src
/
qgcunittest
/
MavlinkLogTest
.
cc
\
src
/
FactSystem
/
FactSystemTest
.
cc
}
}
#
#
...
...
qgroundcontrol.qrc
View file @
3b328f36
...
@@ -230,6 +230,7 @@
...
@@ -230,6 +230,7 @@
</qresource>
</qresource>
<qresource prefix="/unittest">
<qresource prefix="/unittest">
<file alias="MockLink.param">src/qgcunittest/MockLink.param</file>
<file alias="MockLink.param">src/qgcunittest/MockLink.param</file>
<file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file>
</qresource>
</qresource>
<qresource prefix="/QLoggingCategory">
<qresource prefix="/QLoggingCategory">
<file alias="qtlogging.ini">files/QLoggingCategory/qtlogging.ini</file>
<file alias="qtlogging.ini">files/QLoggingCategory/qtlogging.ini</file>
...
...
src/FactSystem/FactSystemTest.cc
0 → 100644
View file @
3b328f36
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "FactSystemTest.h"
#include "LinkManager.h"
#include "MockLink.h"
#include "AutoPilotPluginManager.h"
#include "UASManager.h"
#include "QGCApplication.h"
#include "QGCQuickWidget.h"
#include <QQuickItem>
UT_REGISTER_TEST
(
FactSystemTest
)
/// FactSystem Unit Test
FactSystemTest
::
FactSystemTest
(
void
)
{
}
void
FactSystemTest
::
init
(
void
)
{
UnitTest
::
init
();
LinkManager
*
_linkMgr
=
LinkManager
::
instance
();
MockLink
*
link
=
new
MockLink
();
_linkMgr
->
addLink
(
link
);
_linkMgr
->
connectLink
(
link
);
// Wait for the uas to work it's way through the various threads
QSignalSpy
spyUas
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)));
QCOMPARE
(
spyUas
.
wait
(
5000
),
true
);
_uas
=
UASManager
::
instance
()
->
getActiveUAS
();
Q_ASSERT
(
_uas
);
_paramMgr
=
_uas
->
getParamManager
();
Q_ASSERT
(
_paramMgr
);
// Get the plugin for the uas
AutoPilotPluginManager
*
pluginMgr
=
AutoPilotPluginManager
::
instance
();
Q_ASSERT
(
pluginMgr
);
_plugin
=
pluginMgr
->
getInstanceForAutoPilotPlugin
(
_uas
);
Q_ASSERT
(
_plugin
);
// Wait for the plugin to be ready
QSignalSpy
spyPlugin
(
_plugin
,
SIGNAL
(
pluginReady
()));
if
(
!
_plugin
->
pluginIsReady
())
{
QCOMPARE
(
spyPlugin
.
wait
(
5000
),
true
);
}
Q_ASSERT
(
_plugin
->
pluginIsReady
());
}
void
FactSystemTest
::
cleanup
(
void
)
{
UnitTest
::
cleanup
();
}
/// Basic test of parameter values in Fact System
void
FactSystemTest
::
_parameter_test
(
void
)
{
// Get the parameter facts from the AutoPilot
AutoPilotPluginManager
*
pluginMgr
=
AutoPilotPluginManager
::
instance
();
Q_ASSERT
(
pluginMgr
);
AutoPilotPlugin
*
plugin
=
pluginMgr
->
getInstanceForAutoPilotPlugin
(
_uas
);
Q_ASSERT
(
plugin
);
QObject
*
parameterFacts
=
plugin
->
parameterFacts
();
QVERIFY
(
parameterFacts
!=
NULL
);
// Compare the value in the Parameter Manager with the value from the FactSystem
QVariant
factVariant
=
parameterFacts
->
property
(
"RC_MAP_THROTTLE"
);
Fact
*
fact
=
factVariant
.
value
<
Fact
*>
();
QVERIFY
(
fact
!=
NULL
);
QVariant
factValue
=
fact
->
value
();
QCOMPARE
(
factValue
.
isValid
(),
true
);
QVariant
paramValue
;
Q_ASSERT
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
"RC_MAP_THROTTLE"
,
paramValue
));
QCOMPARE
(
factValue
.
toInt
(),
paramValue
.
toInt
());
}
/// Test that QML can reference a Fact
void
FactSystemTest
::
_qml_test
(
void
)
{
QGCQuickWidget
*
widget
=
new
QGCQuickWidget
;
widget
->
setSource
(
QUrl
::
fromUserInput
(
"qrc:unittest/FactSystemTest.qml"
));
QQuickItem
*
rootObject
=
widget
->
rootObject
();
QObject
*
control
=
rootObject
->
findChild
<
QObject
*>
(
"testControl"
);
QVERIFY
(
control
!=
NULL
);
QVariant
qmlValue
=
control
->
property
(
"text"
).
toInt
();
QVariant
paramMgrValue
;
Q_ASSERT
(
_paramMgr
->
getParameterValue
(
_paramMgr
->
getDefaultComponentId
(),
"RC_MAP_THROTTLE"
,
paramMgrValue
));
QCOMPARE
(
qmlValue
.
toInt
(),
paramMgrValue
.
toInt
());
}
// Test correct behavior when the Param Manager gets a parameter update
void
FactSystemTest
::
_paramMgrSignal_test
(
void
)
{
// Get the parameter Fact from the AutoPilot
AutoPilotPluginManager
*
pluginMgr
=
AutoPilotPluginManager
::
instance
();
Q_ASSERT
(
pluginMgr
);
AutoPilotPlugin
*
plugin
=
pluginMgr
->
getInstanceForAutoPilotPlugin
(
_uas
);
Q_ASSERT
(
plugin
);
QObject
*
parameterFacts
=
plugin
->
parameterFacts
();
QVERIFY
(
parameterFacts
!=
NULL
);
QVariant
factVariant
=
parameterFacts
->
property
(
"RC_MAP_THROTTLE"
);
Fact
*
fact
=
factVariant
.
value
<
Fact
*>
();
QVERIFY
(
fact
!=
NULL
);
// Setting a new value into the parameter should trigger a valueChanged signal on the Fact
QSignalSpy
spyFact
(
fact
,
SIGNAL
(
valueChanged
(
QVariant
)));
QVariant
paramValue
=
12
;
_paramMgr
->
setParameter
(
_paramMgr
->
getDefaultComponentId
(),
"RC_MAP_THROTTLE"
,
paramValue
);
_paramMgr
->
sendPendingParameters
(
true
,
false
);
// Wait for the Fact::valueChanged signal to come through
QCOMPARE
(
spyFact
.
wait
(
5000
),
true
);
// Make sure the signal has the right value
QList
<
QVariant
>
arguments
=
spyFact
.
takeFirst
();
qDebug
()
<<
arguments
.
at
(
0
).
type
();
QCOMPARE
(
arguments
.
at
(
0
).
toInt
(),
12
);
// Make sure the Fact has the new value
QCOMPARE
(
fact
->
value
().
toInt
(),
12
);
}
/// Test QML getting an updated Fact value
void
FactSystemTest
::
_qmlUpdate_test
(
void
)
{
QGCQuickWidget
*
widget
=
new
QGCQuickWidget
;
widget
->
setSource
(
QUrl
::
fromUserInput
(
"qrc:unittest/FactSystemTest.qml"
));
// Change the value using param manager
QVariant
paramValue
=
12
;
_paramMgr
->
setParameter
(
_paramMgr
->
getDefaultComponentId
(),
"RC_MAP_THROTTLE"
,
paramValue
);
_paramMgr
->
sendPendingParameters
(
true
,
false
);
QTest
::
qWait
(
500
);
// Let the signals flow through
// Make sure the qml has the right value
QQuickItem
*
rootObject
=
widget
->
rootObject
();
QObject
*
control
=
rootObject
->
findChild
<
QObject
*>
(
"testControl"
);
QVERIFY
(
control
!=
NULL
);
QCOMPARE
(
control
->
property
(
"text"
).
toInt
(),
12
);
}
src/FactSystem/FactSystemTest.h
0 → 100644
View file @
3b328f36
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef FactSystemTest_H
#define FactSystemTest_H
#include "UnitTest.h"
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
// Unit Test for Fact System
class
FactSystemTest
:
public
UnitTest
{
Q_OBJECT
public:
FactSystemTest
(
void
);
private
slots
:
void
init
(
void
);
void
cleanup
(
void
);
void
_parameter_test
(
void
);
void
_qml_test
(
void
);
void
_paramMgrSignal_test
(
void
);
void
_qmlUpdate_test
(
void
);
private:
UASInterface
*
_uas
;
QGCUASParamManagerInterface
*
_paramMgr
;
AutoPilotPlugin
*
_plugin
;
LinkManager
*
_linkMgr
;
};
#endif
src/FactSystem/FactSystemTest.qml
0 → 100644
View file @
3b328f36
import
QtQuick
2.2
import
QtQuick
.
Controls
1.2
import
QGroundControl
.
FactSystem
1.0
import
QGroundControlFactControls
1.0
Item
{
TextInput
{
objectName
:
"
testControl
"
text
:
parameterFacts
.
RC_MAP_THROTTLE
.
value
font.family
:
"
Helvetica
"
font.pointSize
:
24
color
:
"
red
"
focus
:
true
onAccepted
:
{
parameterFacts
.
RC_MAP_THROTTLE
.
value
=
text
;
}
}
}
\ No newline at end of file
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