Browse Source

Merge pull request #1515 from DonLakeFlyer/MockLink

MockLink now part of all debug builds
QGC4.4
Don Gagne 10 years ago
parent
commit
0306941d74
  1. 16
      QGCApplication.pro
  2. 2
      qgroundcontrol.qrc
  3. 11
      src/QGCApplication.cc
  4. 12
      src/comm/LinkConfiguration.cc
  5. 2
      src/comm/LinkConfiguration.h
  6. 8
      src/comm/LinkManager.cc
  7. 4
      src/comm/LinkManager.h
  8. 0
      src/comm/MockLink.cc
  9. 0
      src/comm/MockLink.h
  10. 0
      src/comm/MockLink.params
  11. 0
      src/comm/MockLinkMissionItemHandler.cc
  12. 0
      src/comm/MockLinkMissionItemHandler.h
  13. 4
      src/ui/QGCCommConfiguration.cc
  14. 2
      src/ui/QGCCommConfiguration.h
  15. 2
      src/ui/QGCLinkConfiguration.cc

16
QGCApplication.pro

@ -357,6 +357,12 @@ HEADERS += \ @@ -357,6 +357,12 @@ HEADERS += \
src/ViewWidgets/ViewWidgetController.h \
src/Waypoint.h \
DebugBuild {
HEADERS += \
src/comm/MockLink.h \
src/comm/MockLinkMissionItemHandler.h
}
!AndroidBuild {
HEADERS += \
src/input/JoystickInput.h \
@ -486,6 +492,12 @@ SOURCES += \ @@ -486,6 +492,12 @@ SOURCES += \
src/ViewWidgets/ViewWidgetController.cc \
src/Waypoint.cc \
DebugBuild {
SOURCES += \
src/comm/MockLink.cc \
src/comm/MockLinkMissionItemHandler.cc
}
!AndroidBuild {
SOURCES += \
src/input/JoystickInput.cc \
@ -529,8 +541,6 @@ HEADERS += \ @@ -529,8 +541,6 @@ HEADERS += \
src/qgcunittest/MainWindowTest.h \
src/qgcunittest/MavlinkLogTest.h \
src/qgcunittest/MessageBoxTest.h \
src/qgcunittest/MockLink.h \
src/qgcunittest/MockLinkMissionItemHandler.h \
src/qgcunittest/PX4RCCalibrationTest.h \
src/qgcunittest/UnitTest.h \
src/VehicleSetup/SetupViewTest.h \
@ -549,8 +559,6 @@ SOURCES += \ @@ -549,8 +559,6 @@ SOURCES += \
src/qgcunittest/MainWindowTest.cc \
src/qgcunittest/MavlinkLogTest.cc \
src/qgcunittest/MessageBoxTest.cc \
src/qgcunittest/MockLink.cc \
src/qgcunittest/MockLinkMissionItemHandler.cc \
src/qgcunittest/PX4RCCalibrationTest.cc \
src/qgcunittest/UnitTest.cc \
src/VehicleSetup/SetupViewTest.cc \

2
qgroundcontrol.qrc

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/unittest">
<file alias="MockLink.params">src/qgcunittest/MockLink.params</file>
<file alias="MockLink.params">src/comm/MockLink.params</file>
<file alias="FactSystemTest.qml">src/FactSystem/FactSystemTest.qml</file>
</qresource>

11
src/QGCApplication.cc

@ -108,6 +108,11 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : @@ -108,6 +108,11 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
#ifdef __android__
QLoggingCategory::setFilterRules(QStringLiteral("*Log.debug=false"));
#endif
#ifndef __android__
#ifdef QT_DEBUG
// First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy
// it to the correct location. This way default debug builds will have logging turned off.
@ -137,9 +142,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : @@ -137,9 +142,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
if (loggingFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&loggingFile);
out << "[Rules]\n";
out << "*Log=false\n";
out << "*Log.debug=false\n";
foreach(QString category, QGCLoggingCategoryRegister::instance()->registeredCategories()) {
out << category << "=false\n";
out << category << ".debug=false\n";
}
} else {
qDebug() << "Unable to create logging file" << QString(qtLoggingFile) << "in" << iniFileLocation;
@ -147,7 +152,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : @@ -147,7 +152,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
}
}
#endif
#endif
// Set application information
if (_runningUnitTests) {
// We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app

12
src/comm/LinkConfiguration.cc

@ -32,11 +32,9 @@ This file is part of the QGROUNDCONTROL project @@ -32,11 +32,9 @@ This file is part of the QGROUNDCONTROL project
#include "UDPLink.h"
#include "TCPLink.h"
#ifdef UNITTEST_BUILD
#ifndef __android__
#ifdef QT_DEBUG
#include "MockLink.h"
#endif
#endif
#define LINK_SETTING_ROOT "LinkConfigurations"
@ -93,13 +91,11 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na @@ -93,13 +91,11 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na
case LinkConfiguration::TypeTcp:
config = new TCPConfiguration(name);
break;
#ifdef UNITTEST_BUILD
#ifndef __android__
#ifdef QT_DEBUG
case LinkConfiguration::TypeMock:
config = new MockConfiguration(name);
break;
#endif
#endif
}
return config;
}
@ -121,13 +117,11 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc @@ -121,13 +117,11 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc
case TypeTcp:
dupe = new TCPConfiguration(dynamic_cast<TCPConfiguration*>(source));
break;
#ifdef UNITTEST_BUILD
#ifndef __android__
#ifdef QT_DEBUG
case TypeMock:
dupe = new MockConfiguration(dynamic_cast<MockConfiguration*>(source));
break;
#endif
#endif
}
return dupe;
}

2
src/comm/LinkConfiguration.h

@ -49,7 +49,7 @@ public: @@ -49,7 +49,7 @@ public:
TypeXbee, ///< XBee Proprietary Link
TypeOpal, ///< Opal-RT Link
#endif
#ifdef UNITTEST_BUILD
#ifdef QT_DEBUG
TypeMock, ///< Mock Link for Unitesting
#endif
TypeLast // Last type value (type >= TypeLast == invalid)

8
src/comm/LinkManager.cc

@ -88,13 +88,11 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config) @@ -88,13 +88,11 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config)
case LinkConfiguration::TypeTcp:
pLink = new TCPLink(dynamic_cast<TCPConfiguration*>(config));
break;
#ifdef UNITTEST_BUILD
#ifndef __android__
#ifdef QT_DEBUG
case LinkConfiguration::TypeMock:
pLink = new MockLink(dynamic_cast<MockConfiguration*>(config));
break;
#endif
#endif
}
if(pLink) {
_addLink(pLink);
@ -384,14 +382,12 @@ void LinkManager::loadLinkConfigurationList() @@ -384,14 +382,12 @@ void LinkManager::loadLinkConfigurationList()
pLink = (LinkConfiguration*)new TCPConfiguration(name);
pLink->setPreferred(preferred);
break;
#ifdef UNITTEST_BUILD
#ifndef __android__
#ifdef QT_DEBUG
case LinkConfiguration::TypeMock:
pLink = (LinkConfiguration*)new MockConfiguration(name);
pLink->setPreferred(false);
break;
#endif
#endif
}
if(pLink) {
// Have the instance load its own values

4
src/comm/LinkManager.h

@ -39,11 +39,9 @@ This file is part of the PIXHAWK project @@ -39,11 +39,9 @@ This file is part of the PIXHAWK project
#include "UDPLink.h"
#include "TCPLink.h"
#ifdef UNITTEST_BUILD
#ifndef __android__
#ifdef QT_DEBUG
#include "MockLink.h"
#endif
#endif
#include "ProtocolInterface.h"
#include "QGCSingleton.h"

0
src/qgcunittest/MockLink.cc → src/comm/MockLink.cc

0
src/qgcunittest/MockLink.h → src/comm/MockLink.h

0
src/qgcunittest/MockLink.params → src/comm/MockLink.params

0
src/qgcunittest/MockLinkMissionItemHandler.cc → src/comm/MockLinkMissionItemHandler.cc

0
src/qgcunittest/MockLinkMissionItemHandler.h → src/comm/MockLinkMissionItemHandler.h

4
src/ui/QGCCommConfiguration.cc

@ -48,7 +48,7 @@ QGCCommConfiguration::QGCCommConfiguration(QWidget *parent, LinkConfiguration *c @@ -48,7 +48,7 @@ QGCCommConfiguration::QGCCommConfiguration(QWidget *parent, LinkConfiguration *c
_ui->typeCombo->addItem(tr("Serial"), LinkConfiguration::TypeSerial);
_ui->typeCombo->addItem(tr("UDP"), LinkConfiguration::TypeUdp);
_ui->typeCombo->addItem(tr("TCP"), LinkConfiguration::TypeTcp);
#ifdef UNITTEST_BUILD
#ifdef QT_DEBUG
_ui->typeCombo->addItem(tr("Mock"), LinkConfiguration::TypeMock);
#endif
@ -134,7 +134,7 @@ void QGCCommConfiguration::_loadTypeConfigWidget(int type) @@ -134,7 +134,7 @@ void QGCCommConfiguration::_loadTypeConfigWidget(int type)
_ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeTcp));
}
break;
#ifdef UNITTEST_BUILD
#ifdef QT_DEBUG
case LinkConfiguration::TypeMock: {
_ui->linkScrollArea->setWidget(NULL);
_ui->linkGroupBox->setTitle(tr("Mock Link"));

2
src/ui/QGCCommConfiguration.h

@ -54,7 +54,7 @@ public: @@ -54,7 +54,7 @@ public:
QGC_LINK_TCP,
QGC_LINK_SIMULATION,
QGC_LINK_FORWARDING,
#ifdef UNITTEST_BUILD
#ifdef QT_DEBUG
QGC_LINK_MOCK,
#endif
#ifdef QGC_XBEE_ENABLED

2
src/ui/QGCLinkConfiguration.cc

@ -158,7 +158,7 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config) @@ -158,7 +158,7 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config)
}
}
break;
#ifdef UNITTEST_BUILD
#ifdef QT_DEBUG
case LinkConfiguration::TypeMock:
config->setName(
QString("Mock Link"));

Loading…
Cancel
Save