Commit 8ba44b79 authored by dogmaphobic's avatar dogmaphobic

Merge remote-tracking branch 'origin/master' into buildWork

* origin/master:
  Fix compiler warnings
  MockLink Start/Stop to Preferences
  Use vehicle count instead of link count
  Fix compiler warning
  Centralize unit test declaration location
  Add --unittest-stress support

Conflicts:
	QGCApplication.pro
parents 07089db2 6c9cb4ab
......@@ -24,6 +24,7 @@
<file alias="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file>
<file alias="MissionEditor.qml">src/MissionEditor/MissionEditor.qml</file>
<file alias="MissionEditorHelp.qml">src/MissionEditor/MissionEditorHelp.qml</file>
<file alias="MockLink.qml">src/ui/preferences/MockLink.qml</file>
<file alias="PowerComponent.qml">src/AutoPilotPlugins/PX4/PowerComponent.qml</file>
<file alias="PowerComponentSummary.qml">src/AutoPilotPlugins/PX4/PowerComponentSummary.qml</file>
<file alias="PX4FlowSensor.qml">src/VehicleSetup/PX4FlowSensor.qml</file>
......
......@@ -98,7 +98,7 @@ AirframeComponentController::~AirframeComponentController()
void AirframeComponentController::changeAutostart(void)
{
if (qgcApp()->toolbox()->multiVehicleManager()->vehicles().count() > 1) {
if (qgcApp()->toolbox()->multiVehicleManager()->vehicles()->count() > 1) {
QGCMessageBox::warning("Airframe Config", "You cannot change airframe configuration while connected to multiple vehicles.");
return;
}
......
......@@ -27,8 +27,6 @@
#include "FactSystemTestGeneric.h"
#include "QGCMAVLink.h"
UT_REGISTER_TEST(FactSystemTestGeneric)
/// FactSystem Unit Test for PX4 autpilot
FactSystemTestGeneric::FactSystemTestGeneric(void)
{
......
......@@ -27,8 +27,6 @@
#include "FactSystemTestPX4.h"
#include "QGCMAVLink.h"
UT_REGISTER_TEST(FactSystemTestPX4)
/// FactSystem Unit Test for PX4 autpilot
FactSystemTestPX4::FactSystemTestPX4(void)
{
......
......@@ -24,8 +24,6 @@
#include "MissionItemTest.h"
#include "MissionItem.h"
UT_REGISTER_TEST(MissionItemTest)
const MissionItemTest::ItemInfo_t MissionItemTest::_rgItemInfo[] = {
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_WAYPOINT, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
{ 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_UNLIM, 10.0, 20.0, 30.0, 1.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT },
......
......@@ -25,8 +25,6 @@
#include "LinkManager.h"
#include "MultiVehicleManager.h"
UT_REGISTER_TEST(MissionControllerTest)
MissionControllerTest::MissionControllerTest(void)
: _multiSpyMissionController(NULL)
, _multiSpyMissionItem(NULL)
......
......@@ -25,9 +25,6 @@
#include "LinkManager.h"
#include "MultiVehicleManager.h"
// FIXME: Temporarily disabled until this can be stabilized
//UT_REGISTER_TEST(MissionManagerTest)
const MissionManagerTest::TestCase_t MissionManagerTest::_rgTestCases[] = {
{ "0\t0\t3\t16\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 0, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_WAYPOINT, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } },
{ "1\t0\t3\t17\t10\t20\t30\t40\t-10\t-20\t-30\t1\r\n", { 1, QGeoCoordinate(-10.0, -20.0, -30.0), MAV_CMD_NAV_LOITER_UNLIM, 10.0, 20.0, 30.0, 40.0, true, false, MAV_FRAME_GLOBAL_RELATIVE_ALT } },
......
......@@ -66,3 +66,91 @@ bool QGroundControlQmlGlobal::loadBoolGlobalSetting (const QString& key, bool de
settings.beginGroup(kQmlGlobalKeyName);
return settings.value(key, defaultValue).toBool();
}
#ifdef QT_DEBUG
void QGroundControlQmlGlobal::_startMockLink(MockConfiguration* mockConfig)
{
MockLink* mockLink = new MockLink(mockConfig);
LinkManager* linkManager = qgcApp()->toolbox()->linkManager();
linkManager->_addLink(mockLink);
linkManager->connectLink(mockLink);
}
#endif
void QGroundControlQmlGlobal::startPX4MockLink(bool sendStatusText)
{
#ifdef QT_DEBUG
MockConfiguration mockConfig("PX4 MockLink");
mockConfig.setFirmwareType(MAV_AUTOPILOT_PX4);
mockConfig.setVehicleType(MAV_TYPE_QUADROTOR);
mockConfig.setSendStatusText(sendStatusText);
_startMockLink(&mockConfig);
#else
Q_UNUSED(sendStatusText);
#endif
}
void QGroundControlQmlGlobal::startGenericMockLink(bool sendStatusText)
{
#ifdef QT_DEBUG
MockConfiguration mockConfig("Generic MockLink");
mockConfig.setFirmwareType(MAV_AUTOPILOT_GENERIC);
mockConfig.setVehicleType(MAV_TYPE_QUADROTOR);
mockConfig.setSendStatusText(sendStatusText);
_startMockLink(&mockConfig);
#else
Q_UNUSED(sendStatusText);
#endif
}
void QGroundControlQmlGlobal::startAPMArduCopterMockLink(bool sendStatusText)
{
#ifdef QT_DEBUG
MockConfiguration mockConfig("APM ArduCopter MockLink");
mockConfig.setFirmwareType(MAV_AUTOPILOT_ARDUPILOTMEGA);
mockConfig.setVehicleType(MAV_TYPE_QUADROTOR);
mockConfig.setSendStatusText(sendStatusText);
_startMockLink(&mockConfig);
#else
Q_UNUSED(sendStatusText);
#endif
}
void QGroundControlQmlGlobal::startAPMArduPlaneMockLink(bool sendStatusText)
{
#ifdef QT_DEBUG
MockConfiguration mockConfig("APM ArduPlane MockLink");
mockConfig.setFirmwareType(MAV_AUTOPILOT_ARDUPILOTMEGA);
mockConfig.setVehicleType(MAV_TYPE_FIXED_WING);
mockConfig.setSendStatusText(sendStatusText);
_startMockLink(&mockConfig);
#else
Q_UNUSED(sendStatusText);
#endif
}
void QGroundControlQmlGlobal::stopAllMockLinks(void)
{
#ifdef QT_DEBUG
LinkManager* linkManager = qgcApp()->toolbox()->linkManager();
QList<LinkInterface*> links = linkManager->getLinks();
for (int i=0; i<links.count(); i++) {
LinkInterface* link = links[i];
MockLink* mockLink = qobject_cast<MockLink*>(link);
if (mockLink) {
linkManager->disconnectLink(mockLink);
}
}
#endif
}
......@@ -34,6 +34,10 @@
#include "HomePositionManager.h"
#include "FlightMapSettings.h"
#ifdef QT_DEBUG
#include "MockLink.h"
#endif
class QGCToolbox;
class QGroundControlQmlGlobal : public QObject
......@@ -58,6 +62,12 @@ public:
Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value);
Q_INVOKABLE bool loadBoolGlobalSetting (const QString& key, bool defaultValue);
Q_INVOKABLE void startPX4MockLink (bool sendStatusText);
Q_INVOKABLE void startGenericMockLink (bool sendStatusText);
Q_INVOKABLE void startAPMArduCopterMockLink (bool sendStatusText);
Q_INVOKABLE void startAPMArduPlaneMockLink (bool sendStatusText);
Q_INVOKABLE void stopAllMockLinks (void);
// Property accesors
HomePositionManager* homePositionManager () { return _homePositionManager; }
......@@ -123,6 +133,10 @@ signals:
void isVersionCheckEnabledChanged (bool enabled);
private:
#ifdef QT_DEBUG
void _startMockLink(MockConfiguration* mockConfig);
#endif
HomePositionManager* _homePositionManager;
FlightMapSettings* _flightMapSettings;
};
......
......@@ -246,16 +246,3 @@ Vehicle* MultiVehicleManager::getVehicleById(int vehicleId)
return NULL;
}
QList<Vehicle*> MultiVehicleManager::vehicles(void)
{
QList<Vehicle*> list;
for (int i=0; i< _vehicles.count(); i++) {
list += qobject_cast<Vehicle*>(_vehicles[i]);
}
return list;
}
......@@ -54,7 +54,7 @@ public:
Q_PROPERTY(bool activeVehicleAvailable READ activeVehicleAvailable NOTIFY activeVehicleAvailableChanged)
Q_PROPERTY(bool parameterReadyVehicleAvailable READ parameterReadyVehicleAvailable NOTIFY parameterReadyVehicleAvailableChanged)
Q_PROPERTY(Vehicle* activeVehicle READ activeVehicle WRITE setActiveVehicle NOTIFY activeVehicleChanged)
Q_PROPERTY(QmlObjectListModel* vehicles READ vehiclesModel CONSTANT)
Q_PROPERTY(QmlObjectListModel* vehicles READ vehicles CONSTANT)
// Methods
......@@ -70,8 +70,6 @@ public:
UAS* activeUas(void) { return _activeVehicle ? _activeVehicle->uas() : NULL; }
QList<Vehicle*> vehicles(void);
// Property accessors
bool activeVehicleAvailable(void) { return _activeVehicleAvailable; }
......@@ -81,7 +79,7 @@ public:
Vehicle* activeVehicle(void) { return _activeVehicle; }
void setActiveVehicle(Vehicle* vehicle);
QmlObjectListModel* vehiclesModel(void) { return &_vehicles; }
QmlObjectListModel* vehicles(void) { return &_vehicles; }
// Override from QGCTool
virtual void setToolbox(QGCToolbox *toolbox);
......
......@@ -29,8 +29,6 @@
#include "QGCMessageBox.h"
#include "MultiVehicleManager.h"
UT_REGISTER_TEST(SetupViewTest)
void SetupViewTest::_clickThrough_test(void)
{
_connectMockLink();
......
......@@ -156,16 +156,21 @@ int main(int argc, char *argv[])
// We parse a small set of command line options here prior to QGCApplication in order to handle the ones
// which need to be handled before a QApplication object is started.
bool stressUnitTests = false; // Stress test unit tests
bool quietWindowsAsserts = false; // Don't let asserts pop dialog boxes
QString unitTestOptions;
CmdLineOpt_t rgCmdLineOptions[] = {
{ "--unittest", &runUnitTests, &unitTestOptions },
{ "--unittest-stress", &stressUnitTests, &unitTestOptions },
{ "--no-windows-assert-ui", &quietWindowsAsserts, NULL },
// Add additional command line option flags here
};
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
if (stressUnitTests) {
runUnitTests = true;
}
if (quietWindowsAsserts) {
#ifdef Q_OS_WIN
......@@ -195,23 +200,27 @@ int main(int argc, char *argv[])
app->_initCommon();
int exitCode;
int exitCode = 0;
#ifndef __mobile__
#ifdef QT_DEBUG
if (runUnitTests) {
if (!app->_initForUnitTests()) {
return -1;
}
// Run the test
int failures = UnitTest::run(unitTestOptions);
if (failures == 0) {
qDebug() << "ALL TESTS PASSED";
} else {
qDebug() << failures << " TESTS FAILED!";
for (int i=0; i < (stressUnitTests ? 20 : 1); i++) {
if (!app->_initForUnitTests()) {
return -1;
}
// Run the test
int failures = UnitTest::run(unitTestOptions);
if (failures == 0) {
qDebug() << "ALL TESTS PASSED";
exitCode = 0;
} else {
qDebug() << failures << " TESTS FAILED!";
exitCode = -failures;
break;
}
}
exitCode = -failures;
} else
#endif
#endif
......
......@@ -29,8 +29,6 @@
#include "FileDialogTest.h"
#include "QGCFileDialog.h"
UT_REGISTER_TEST(FileDialogTest)
FileDialogTest::FileDialogTest(void)
{
......
......@@ -29,8 +29,6 @@
#include "UAS.h"
#include "QGCApplication.h"
//UT_REGISTER_TEST(FileManagerTest)
FileManagerTest::FileManagerTest(void)
: _fileServer(NULL)
, _fileManager(NULL)
......
......@@ -29,8 +29,6 @@
///
/// @author Don Gagne <don@thegagnes.com>
UT_REGISTER_TEST(FlightGearUnitTest)
FlightGearUnitTest::FlightGearUnitTest(void)
{
......
......@@ -29,8 +29,6 @@
#include "GeoTest.h"
#include "QGCGeo.h"
UT_REGISTER_TEST(GeoTest)
/*
GeoTest::GeoTest(void)
{
......
......@@ -30,8 +30,6 @@
#include "MockLink.h"
#include "QGCApplication.h"
UT_REGISTER_TEST(LinkManagerTest)
LinkManagerTest::LinkManagerTest(void) :
_linkMgr(NULL),
_multiSpy(NULL)
......
......@@ -31,9 +31,6 @@
#include "QGCMessageBox.h"
#include "MultiVehicleManager.h"
// FIXME: Temporarily turned off
//UT_REGISTER_TEST(MainWindowTest)
void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot)
{
_createMainWindow();
......
......@@ -34,9 +34,6 @@
#include "UAS.h"
#include "MultiVehicleManager.h"
// FIXME: Temporarily disabled until this can be stabilized
//UT_REGISTER_TEST(MavlinkLogTest)
const char* MavlinkLogTest::_tempLogFileTemplate = "FlightDataXXXXXX"; ///< Template for temporary log file
const char* MavlinkLogTest::_logFileExtension = "mavlink"; ///< Extension for log files
const char* MavlinkLogTest::_saveLogFilename = "qgroundcontrol.mavlink.ut"; ///< Filename to save log files to
......
......@@ -29,8 +29,6 @@
#include "MessageBoxTest.h"
#include "QGCMessageBox.h"
UT_REGISTER_TEST(MessageBoxTest)
MessageBoxTest::MessageBoxTest(void)
{
......
......@@ -31,7 +31,6 @@
///
/// @author Don Gagne <don@thegagnes.com>
UT_REGISTER_TEST(RadioConfigTest)
QGC_LOGGING_CATEGORY(RadioConfigTestLog, "RadioConfigTestLog")
// This will check for the wizard buttons being enabled of disabled according to the mask you pass in.
......
......@@ -29,10 +29,6 @@
///
/// @author Don Gagne <don@thegagnes.com>
// This unit test has gotten too flaky to run reliably under TeamCity. Removing for now till there is
// time to debug.
//UT_REGISTER_TEST(TCPLinkUnitTest)
TCPLinkUnitTest::TCPLinkUnitTest(void)
: _config(NULL)
, _link(NULL)
......
......@@ -38,7 +38,7 @@
#include "QGCMAVLink.h"
#include "LinkInterface.h"
#define UT_REGISTER_TEST(className) static UnitTestWrapper<className> t(#className);
#define UT_REGISTER_TEST(className) static UnitTestWrapper<className> className(#className);
class QGCMessageBox;
class QGCFileDialog;
......
/*=====================================================================
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/>.
======================================================================*/
// We keep the list of all unit tests in a global location so it's easier to see which
// ones are enabled/disabled
#include "FactSystemTestGeneric.h"
#include "FactSystemTestPX4.h"
#include "FileDialogTest.h"
#include "FlightGearTest.h"
#include "GeoTest.h"
#include "LinkManagerTest.h"
#include "MessageBoxTest.h"
#include "MissionItemTest.h"
#include "MissionControllerTest.h"
#include "PX4RCCalibrationTest.h"
#include "SetupViewTest.h"
#include "MavlinkLogTest.h"
UT_REGISTER_TEST(FactSystemTestGeneric)
UT_REGISTER_TEST(FactSystemTestPX4)
UT_REGISTER_TEST(FileDialogTest)
UT_REGISTER_TEST(FlightGearUnitTest)
UT_REGISTER_TEST(GeoTest)
UT_REGISTER_TEST(LinkManagerTest)
UT_REGISTER_TEST(MavlinkLogTest)
UT_REGISTER_TEST(MessageBoxTest)
UT_REGISTER_TEST(MissionItemTest)
UT_REGISTER_TEST(MissionControllerTest)
UT_REGISTER_TEST(RadioConfigTest)
UT_REGISTER_TEST(SetupViewTest)
// List of unit test which are currently disabled.
// If disabling a new test, include reason in comment.
// Why is this one off?
//UT_REGISTER_TEST(FileManagerTest)
// FIXME: Temporarily disabled until this can be stabilized
//UT_REGISTER_TEST(MainWindowTest)
// FIXME: Temporarily disabled until this can be stabilized
// FIXME: Temporarily disabled until this can be stabilized
//UT_REGISTER_TEST(MissionManagerTest)
// This unit test has gotten too flaky to run reliably under TeamCity. Removing for now till there is
// time to debug.
//UT_REGISTER_TEST(TCPLinkUnitTest)
......@@ -437,7 +437,7 @@ void MainWindow::showStatusBarCallback(bool checked)
void MainWindow::closeEvent(QCloseEvent *event)
{
// Disallow window close if there are active connections
if (qgcApp()->toolbox()->linkManager()->anyConnectedLinks()) {
if (qgcApp()->toolbox()->multiVehicleManager()->vehicles()->count()) {
QGCMessageBox::StandardButton button =
QGCMessageBox::warning(
tr("QGroundControl close"),
......
......@@ -169,6 +169,20 @@ Item {
checked = true
}
}
QGCButton {
width: parent.width * 0.8
height: ScreenTools.defaultFontPixelHeight * 2.5
text: "Mock Link"
visible: ScreenTools.isDebug
exclusiveGroup: panelActionGroup
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
if(__rightPanel.source != "MockLink.qml") {
__rightPanel.source = "MockLink.qml"
}
checked = true
}
}
QGCButton {
width: parent.width * 0.8
height: ScreenTools.defaultFontPixelHeight * 2.5
......
......@@ -41,8 +41,10 @@ MultiVehicleDockWidget::MultiVehicleDockWidget(const QString& title, QAction* ac
void MultiVehicleDockWidget::init(void)
{
foreach (Vehicle* vehicle, qgcApp()->toolbox()->multiVehicleManager()->vehicles()) {
_vehicleAdded(vehicle);
QmlObjectListModel* vehicles = qgcApp()->toolbox()->multiVehicleManager()->vehicles();
for (int i=0; i<vehicles->count(); i++) {
_vehicleAdded(qobject_cast<Vehicle*>(vehicles->get(i)));
}
if (qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()) {
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 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/>.
======================================================================*/
import QtQuick 2.3
import QGroundControl 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
Rectangle {
color: qgcPal.window
QGCPalette { id: qgcPal; colorGroupEnabled: true }
Column {
anchors.margins: ScreenTools.defaultFontPixelHeight
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight
QGCButton {
text: "PX4 Vehicle"
onClicked: QGroundControl.startPX4MockLink(sendStatusText.checked)
}
QGCButton {
text: "APM ArduCopter Vehicle"
onClicked: QGroundControl.startAPMArduCopterMockLink(sendStatusText.checked)
}
QGCButton {
text: "APM ArduPlane Vehicle"
onClicked: QGroundControl.startAPMArduPlaneMockLink(sendStatusText.checked)
}
QGCButton {
text: "Generic Vehicle"
onClicked: QGroundControl.startGenericMockLink(sendStatusText.checked)
}
QGCCheckBox {
id: sendStatusText
text: "Send status text + voice"
}
QGCButton {
text: "Stop All MockLinks"
onClicked: QGroundControl.stopAllMockLinks()
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment