diff --git a/src/qgcunittest/MockQGCUASParamManager.cc b/src/qgcunittest/MockQGCUASParamManager.cc deleted file mode 100644 index b10fdfe96602c588563a6115ddabb32da96edfda..0000000000000000000000000000000000000000 --- a/src/qgcunittest/MockQGCUASParamManager.cc +++ /dev/null @@ -1,116 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - 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 . - - ======================================================================*/ - -#include "MockQGCUASParamManager.h" -#include "mavlink.h" -#include "QGCLoggingCategory.h" - -#include -#include - -QGC_LOGGING_CATEGORY(MockQGCUASParamManagerLog, "MockQGCUASParamManagerLog") - -MockQGCUASParamManager::MockQGCUASParamManager(void) -{ - _loadParams(); -} - -bool MockQGCUASParamManager::getParameterValue(int component, const QString& parameter, QVariant& value) const -{ - Q_UNUSED(component); - - 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) -{ - 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); -} - -void MockQGCUASParamManager::_loadParams(void) -{ - QFile paramFile(":/unittest/MockLink.params"); - - bool success = paramFile.open(QFile::ReadOnly); - Q_UNUSED(success); - Q_ASSERT(success); - - QTextStream paramStream(¶mFile); - - while (!paramStream.atEnd()) { - QString line = paramStream.readLine(); - - if (line.startsWith("#")) { - continue; - } - - QStringList paramData = line.split("\t"); - Q_ASSERT(paramData.count() == 5); - - QString paramName = paramData.at(2); - QString valStr = paramData.at(3); - uint paramType = paramData.at(4).toUInt(); - - QVariant paramValue; - switch (paramType) { - case MAV_PARAM_TYPE_REAL32: - paramValue = QVariant(valStr.toFloat()); - break; - case MAV_PARAM_TYPE_UINT32: - paramValue = QVariant(valStr.toUInt()); - break; - case MAV_PARAM_TYPE_INT32: - paramValue = QVariant(valStr.toInt()); - break; - case MAV_PARAM_TYPE_INT8: - paramValue = QVariant((unsigned char)valStr.toUInt()); - break; - default: - Q_ASSERT(false); - break; - } - - Q_ASSERT(!_mapParams.contains(paramName)); - _mapParams[paramName] = paramValue; - } -} - -QList MockQGCUASParamManager::getComponentForParam(const QString& parameter) const -{ - if (_mapParams.contains(parameter)) { - QList list; - list << 50; - return list; - } else { - return QList(); - } -} diff --git a/src/qgcunittest/MockQGCUASParamManager.h b/src/qgcunittest/MockQGCUASParamManager.h deleted file mode 100644 index 257e5fbdb392f8de70afad2efb7bffe4e646a121..0000000000000000000000000000000000000000 --- a/src/qgcunittest/MockQGCUASParamManager.h +++ /dev/null @@ -1,110 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - 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 . - - ======================================================================*/ - -#ifndef MOCKQGCUASPARAMMANAGER_H -#define MOCKQGCUASPARAMMANAGER_H - -#include - -#include "QGCUASParamManagerInterface.h" - -Q_DECLARE_LOGGING_CATEGORY(MockQGCUASParamManagerLog) - -/// @file -/// @brief This is a mock implementation of QGCUASParamManager for writing Unit Tests. -/// -/// @author Don Gagne - - -class MockQGCUASParamManager : public QGCUASParamManagerInterface -{ - Q_OBJECT - -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 _defaultComponentId; } - virtual int countOnboardParams(void) { return _mapParams.count(); } - -public slots: - // Implemented QGCSUASParamManager overrides - void setParameter(int component, QString parameterName, QVariant value); - virtual void setPendingParam(int componentId, const QString& key, const QVariant& value, bool forceSend = false) - { 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 true; } - -public: - // MockQGCUASParamManager methods - MockQGCUASParamManager(void); - - /// QMap of parameters, QString key is paremeter name, QVariant value is parameter value - typedef QMap ParamMap_t; - - /// Sets current set of parameters to support calls like getParameterValue - void setMockParameters(ParamMap_t& map) { _mapParams = map; } - - /// Returns the parameters which were set by calls to setParameter calls - ParamMap_t getMockSetParameters(void) { return _mapParams; } - /// Clears the set of parameters set by setParameter calls - void clearMockSetParameters(void) { _mapParams.clear(); } - -public: - // Unimplemented QGCUASParamManagerInterface overrides - virtual QList getComponentForParam(const QString& parameter) const; - virtual void setParamDescriptions(const QMap& paramDescs) { Q_ASSERT(false); Q_UNUSED(paramDescs); } - virtual int countPendingParams() { Q_ASSERT(false); return 0; } - virtual UASParameterDataModel* dataModel() { Q_ASSERT(false); return NULL; } - -public slots: - // Unimplemented QGCUASParamManagerInterface overrides - virtual void requestParameterList() { Q_ASSERT(false); } - virtual void requestParameterListIfEmpty() { Q_ASSERT(false); } - virtual void clearAllPendingParams() { Q_ASSERT(false); } - virtual void requestParameterUpdate(int component, const QString& parameter) - { Q_ASSERT(false); Q_UNUSED(component); Q_UNUSED(parameter); } - virtual void writeOnboardParamsToStream(QTextStream &stream, const QString& uasName) - { Q_ASSERT(false); Q_UNUSED(stream); Q_UNUSED(uasName); } - virtual void readPendingParamsFromStream(QTextStream &stream) { Q_ASSERT(false); Q_UNUSED(stream); } - virtual void requestRcCalibrationParamsUpdate() { Q_ASSERT(false); } - virtual void copyVolatileParamsToPersistent() { Q_ASSERT(false); } - virtual void copyPersistentParamsToVolatile() { Q_ASSERT(false); } - -private: - void _loadParams(void); - - ParamMap_t _mapParams; - - static const int _defaultComponentId = 50; - - // Bogus variables used for return types of NYI methods - QList _bogusQListInt; -}; - -#endif \ No newline at end of file diff --git a/src/qgcunittest/MockUAS.cc b/src/qgcunittest/MockUAS.cc deleted file mode 100644 index 82dedffc2f10f1a7ff87b4647184e4d50faa43f9..0000000000000000000000000000000000000000 --- a/src/qgcunittest/MockUAS.cc +++ /dev/null @@ -1,54 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - 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 . - - ======================================================================*/ - -#include "MockUAS.h" - -QString MockUAS::_bogusStaticString; - -MockUAS::MockUAS(void) : - _systemType(MAV_TYPE_QUADROTOR), - _systemId(1), - _mavlinkPlugin(NULL) -{ - -} - -void MockUAS::setMockParametersAndSignal(MockQGCUASParamManager::ParamMap_t& map) -{ - _paramManager.setMockParameters(map); - - QMapIterator i(map); - while (i.hasNext()) { - i.next(); - emit parameterChanged(_systemId, 0, i.key(), i.value()); - } -} - -void MockUAS::sendMessage(mavlink_message_t message) -{ - if (!_mavlinkPlugin) { - Q_ASSERT(false); - } - - _mavlinkPlugin->sendMessage(message); -} \ No newline at end of file diff --git a/src/qgcunittest/MockUAS.h b/src/qgcunittest/MockUAS.h deleted file mode 100644 index d0b7b3087b4bc1bcff1b8acce59344e46cb0364d..0000000000000000000000000000000000000000 --- a/src/qgcunittest/MockUAS.h +++ /dev/null @@ -1,191 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - 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 . - - ======================================================================*/ - -#ifndef MOCKUAS_H -#define MOCKUAS_H - -#include "UASInterface.h" -#include "MockQGCUASParamManager.h" -#include "MockMavlinkInterface.h" - -#include - -/// @file -/// @brief This is a mock implementation of a UAS used for writing Unit Tests. Normal usage is to -/// call MockUASManager::setMockActiveUAS to set it to the active mock UAS> -/// -/// @author Don Gagne - -class MockUAS : public UASInterface -{ - Q_OBJECT - -signals: - // The following UASInterface signals are supported - // void parameterChanged(int uas, int component, QString parameterName, QVariant value); - // void remoteControlChannelRawChanged(int channelId, float raw); - -public: - // Implemented UASInterface overrides - virtual int getSystemType(void) { return _systemType; } - virtual int getUASID(void) const { return _systemId; } - virtual bool isAirplane() { return false; } - virtual QGCUASParamManagerInterface* getParamManager() { return &_paramManager; }; - - // sendMessage is only supported if a mavlink plugin is installed. - virtual void sendMessage(mavlink_message_t message); - -public: - // MockUAS methods - MockUAS(void); - - // Use these methods to setup/control the mock UAS - - void setMockSystemType(int systemType) { _systemType = systemType; } - void setMockSystemId(int systemId) { _systemId = systemId; } - - /// @return returns mock QGCUASParamManager associated with the UAS. This mock implementation - /// allows you to simulate parameter input and validate parameter setting - MockQGCUASParamManager* getMockQGCUASParamManager(void) { return &_paramManager; } - - /// @brief Sets the parameter map into the mock QGCUASParamManager and signals parameterChanged for - /// each param - void setMockParametersAndSignal(MockQGCUASParamManager::ParamMap_t& map); - - void emitRemoteControlChannelRawChanged(int channel, float raw) { emit remoteControlChannelRawChanged(channel, raw); } - - /// @brief Installs a mavlink plugin. Only a single mavlink plugin is supported at a time. - void setMockMavlinkPlugin(MockMavlinkInterface* mavlinkPlugin) { _mavlinkPlugin = mavlinkPlugin; }; - -public: - // Unimplemented UASInterface overrides - virtual QString getUASName() const { Q_ASSERT(false); return _bogusString; }; - virtual const QString& getShortState() const { Q_ASSERT(false); return _bogusString; }; - virtual const QString& getShortMode() const { Q_ASSERT(false); return _bogusString; }; - virtual QString getShortModeTextFor(uint8_t base_mode, uint32_t custom_mode) const { Q_UNUSED(base_mode); Q_UNUSED(custom_mode); Q_ASSERT(false); return _bogusStaticString; }; - virtual quint64 getUptime() const { Q_ASSERT(false); return 0; }; - virtual double getLocalX() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getLocalY() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getLocalZ() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual bool localPositionKnown() const { Q_ASSERT(false); return false; }; - virtual double getLatitude() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getLongitude() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getAltitudeAMSL() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getAltitudeRelative() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual bool globalPositionKnown() const { Q_ASSERT(false); return false; }; - virtual double getRoll() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getPitch() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual double getYaw() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); }; - virtual bool getSelected() const { Q_ASSERT(false); return false; }; - virtual bool isArmed() const { Q_ASSERT(false); return false; }; - virtual int getAirframe() const { Q_ASSERT(false); return 0; }; - virtual UASWaypointManager* getWaypointManager(void) { Q_ASSERT(false); return NULL; }; - virtual QList getLinks() { Q_ASSERT(false); return QList(); }; - virtual bool systemCanReverse() const { Q_ASSERT(false); return false; }; - virtual QString getSystemTypeName() { Q_ASSERT(false); return _bogusString; }; - virtual int getAutopilotType() { return MAV_AUTOPILOT_PX4; }; - virtual QGCUASFileManager* getFileManager() {Q_ASSERT(false); return NULL; } - virtual void startCalibration(StartCalibrationType calType) { Q_UNUSED(calType); return; }; - virtual void stopCalibration() { return; }; - - /** @brief Send a message over this link (to this or to all UAS on this link) */ - virtual void sendMessage(LinkInterface* link, mavlink_message_t message){ Q_UNUSED(link); Q_UNUSED(message); Q_ASSERT(false); } - virtual QString getAutopilotTypeName() { Q_ASSERT(false); return _bogusString; }; - virtual void setAutopilotType(int apType) { Q_UNUSED(apType); Q_ASSERT(false); }; - virtual QMap getComponents() { Q_ASSERT(false); return _bogusMapIntQString; }; - virtual QList getActions() const { Q_ASSERT(false); return _bogusQListQActionPointer; }; - -public slots: - // Unimplemented UASInterface overrides - virtual void setUASName(const QString& name) { Q_UNUSED(name); Q_ASSERT(false); }; - virtual void executeCommand(MAV_CMD command) { Q_UNUSED(command); Q_ASSERT(false); }; - virtual void executeCommand(MAV_CMD command, int confirmation, float param1, float param2, float param3, float param4, float param5, float param6, float param7, int component) { Q_UNUSED(command); Q_UNUSED(confirmation); Q_UNUSED(param1); Q_UNUSED(param2); Q_UNUSED(param3); Q_UNUSED(param4); Q_UNUSED(param5); Q_UNUSED(param6); Q_UNUSED(param7); Q_UNUSED(component); Q_ASSERT(false); }; - virtual void executeCommandAck(int num, bool success) { Q_UNUSED(num); Q_UNUSED(success); Q_ASSERT(false); }; - virtual void setAirframe(int airframe) { Q_UNUSED(airframe); Q_ASSERT(false); }; - virtual void launch() { Q_ASSERT(false); }; - virtual void home() { Q_ASSERT(false); }; - virtual void land() { Q_ASSERT(false); }; - virtual void pairRX(int rxType, int rxSubType) { Q_UNUSED(rxType); Q_UNUSED(rxSubType); Q_ASSERT(false); }; - virtual void halt() { Q_ASSERT(false); }; - virtual void go() { Q_ASSERT(false); }; - virtual void setMode(uint8_t newBaseMode, uint32_t newCustomMode) { Q_UNUSED(newBaseMode); Q_UNUSED(newCustomMode); Q_ASSERT(false); }; - virtual void emergencySTOP() { Q_ASSERT(false); }; - virtual bool emergencyKILL() { Q_ASSERT(false); return false; }; - virtual void shutdown() { Q_ASSERT(false); }; - virtual void setTargetPosition(float x, float y, float z, float yaw) { Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(yaw); Q_ASSERT(false); }; - virtual void setLocalOriginAtCurrentGPSPosition() { Q_ASSERT(false); }; - virtual void setHomePosition(double lat, double lon, double alt) { Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); Q_ASSERT(false); }; - virtual void requestParameter(int component, const QString& parameter) { Q_UNUSED(component); Q_UNUSED(parameter); Q_ASSERT(false); }; - virtual void writeParametersToStorage() { Q_ASSERT(false); }; - virtual void readParametersFromStorage() { Q_ASSERT(false); }; - virtual void setParameter(const int component, const QString& id, const QVariant& value) - { Q_UNUSED(component); Q_UNUSED(id); Q_UNUSED(value); Q_ASSERT(false); }; - virtual void addLink(LinkInterface* link) { Q_UNUSED(link); Q_ASSERT(false); }; - virtual void setSelected() { Q_ASSERT(false); } - virtual void enableAllDataTransmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableRawSensorDataTransmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableExtendedSystemStatusTransmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableRCChannelDataTransmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableRawControllerDataTransmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enablePositionTransmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableExtra1Transmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableExtra2Transmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void enableExtra3Transmission(int rate) { Q_UNUSED(rate); Q_ASSERT(false); }; - virtual void setLocalPositionSetpoint(float x, float y, float z, float yaw) - { Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(yaw); Q_ASSERT(false); }; - virtual void setLocalPositionOffset(float x, float y, float z, float yaw) { Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(yaw); Q_ASSERT(false); }; - virtual void setBatterySpecs(const QString& specs) { Q_UNUSED(specs); Q_ASSERT(false); }; - virtual QString getBatterySpecs() { Q_ASSERT(false); return _bogusString; }; - virtual void sendHilState(quint64 time_us, float roll, float pitch, float yaw, float rollspeed, float pitchspeed, float yawspeed, double lat, double lon, double alt, float vx, float vy, float vz, float ind_airspeed, float true_airspeed, float xacc, float yacc, float zacc) - { Q_UNUSED(time_us); Q_UNUSED(roll); Q_UNUSED(pitch); Q_UNUSED(yaw); Q_UNUSED(rollspeed); Q_UNUSED(pitchspeed); Q_UNUSED(yawspeed); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); Q_UNUSED(vx); Q_UNUSED(vy); Q_UNUSED(vz); Q_UNUSED(ind_airspeed); Q_UNUSED(true_airspeed); Q_UNUSED(xacc); Q_UNUSED(yacc); Q_UNUSED(zacc); Q_ASSERT(false); }; - virtual void sendHilSensors(quint64 time_us, float xacc, float yacc, float zacc, float rollspeed, float pitchspeed, float yawspeed, float xmag, float ymag, float zmag, float abs_pressure, float diff_pressure, float pressure_alt, float temperature, quint32 fields_changed) - { Q_UNUSED(time_us); Q_UNUSED(xacc); Q_UNUSED(yacc); Q_UNUSED(zacc); Q_UNUSED(rollspeed); Q_UNUSED(pitchspeed); Q_UNUSED(yawspeed); Q_UNUSED(xmag); Q_UNUSED(ymag); Q_UNUSED(zmag); Q_UNUSED(abs_pressure); Q_UNUSED(diff_pressure); Q_UNUSED(pressure_alt); Q_UNUSED(temperature); Q_UNUSED(fields_changed); Q_ASSERT(false); }; - virtual void sendHilGps(quint64 time_us, double lat, double lon, double alt, int fix_type, float eph, float epv, float vel, float vn, float ve, float vd, float cog, int satellites) - { Q_UNUSED(time_us); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); Q_UNUSED(fix_type); Q_UNUSED(eph); Q_UNUSED(epv); Q_UNUSED(vel); Q_UNUSED(vn); Q_UNUSED(ve); Q_UNUSED(vd); Q_UNUSED(cog); Q_UNUSED(satellites); Q_ASSERT(false); }; - virtual void sendHilOpticalFlow(quint64 time_us, qint16 flow_x, qint16 flow_y, float flow_comp_m_x, - float flow_comp_m_y, quint8 quality, float ground_distance) - { Q_UNUSED(time_us); Q_UNUSED(flow_x); Q_UNUSED(flow_y); Q_UNUSED(flow_comp_m_x); Q_UNUSED(flow_comp_m_y); Q_UNUSED(quality); Q_UNUSED(ground_distance); Q_ASSERT(false);}; - virtual void sendMapRCToParam(QString param_id, float scale, float value0, quint8 param_rc_channel_index, float valueMin, float valueMax) - { Q_UNUSED(param_id); Q_UNUSED(scale); Q_UNUSED(value0); Q_UNUSED(param_rc_channel_index); Q_UNUSED(valueMin); Q_UNUSED(valueMax); } - virtual void unsetRCToParameterMap() {} - - virtual bool isRotaryWing() { Q_ASSERT(false); return false; } - virtual bool isFixedWing() { Q_ASSERT(false); return false; } - -private: - int _systemType; - int _systemId; - - MockQGCUASParamManager _paramManager; - - MockMavlinkInterface* _mavlinkPlugin; ///< Mock Mavlink plugin, NULL for none - - // Bogus variables used for return types of NYI methods - QString _bogusString; - static QString _bogusStaticString; - QMap _bogusMapIntQString; - QList _bogusQListQActionPointer; - QList _bogusQListInt; -}; - -#endif diff --git a/src/qgcunittest/MockUASManager.cc b/src/qgcunittest/MockUASManager.cc deleted file mode 100644 index 953dd9fc32328e950ad4ccb3c5244947bef4ff78..0000000000000000000000000000000000000000 --- a/src/qgcunittest/MockUASManager.cc +++ /dev/null @@ -1,57 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - 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 . - - ======================================================================*/ - -#include "MockUASManager.h" - -MockUASManager::MockUASManager(void) : - UASManagerInterface(NULL), - _mockUAS(NULL) -{ - -} - -UASInterface* MockUASManager::getActiveUAS(void) -{ - return _mockUAS; -} - -void MockUASManager::setMockActiveUAS(MockUAS* mockUAS) -{ - // Signal components that the last UAS is no longer active. - if (_mockUAS != NULL) { - emit activeUASStatusChanged(_mockUAS, false); - emit activeUASStatusChanged(_mockUAS->getUASID(), false); - } - _mockUAS = mockUAS; - - // And signal that a new UAS is. - emit activeUASSet(_mockUAS); - if (_mockUAS) - { - // We don't support swiching between different UAS - //_mockUAS->setSelected(); - emit activeUASStatusChanged(_mockUAS, true); - emit activeUASStatusChanged(_mockUAS->getUASID(), true); - } -} - diff --git a/src/qgcunittest/MockUASManager.h b/src/qgcunittest/MockUASManager.h deleted file mode 100644 index a1e83eca2322ffdf3393b951b7baa53a98cd165e..0000000000000000000000000000000000000000 --- a/src/qgcunittest/MockUASManager.h +++ /dev/null @@ -1,126 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2014 QGROUNDCONTROL PROJECT - - 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 . - - ======================================================================*/ - -#ifndef MOCKUASMANAGER_H -#define MOCKUASMANAGER_H - -#include "UASManagerInterface.h" -#include "MockUAS.h" - -/// @file -/// @brief This is a mock implementation of a UASManager used for writing Unit Tests. In order -/// to use it you must call UASManager::setMockUASManager which will then cause all further -/// calls to UASManager::instance to return the mock UASManager instead of the normal one. -/// -/// @author Don Gagne - -class MockUASManager : public UASManagerInterface -{ - Q_OBJECT - -signals: - // The following signals from UASManager interface are supported: - // void activeUASSet(UASInterface* UAS); - // void activeUASStatusChanged(UASInterface* UAS, bool active); - // void activeUASStatusChanged(int systemId, bool active); - -public: - // Implemented UASManagerInterface overrides - virtual UASInterface* getActiveUAS(void); - -public: - // MockUASManager methods - MockUASManager(void); - - // Does not support singleton deletion - virtual void deleteInstance(void) { Q_ASSERT(false); } - - /// Sets the currently active mock UAS - /// @param mockUAS new mock uas, NULL for no active UAS - void setMockActiveUAS(MockUAS* mockUAS); - -public: - // Unimplemented UASManagerInterface overrides - virtual UASWaypointManager *getActiveUASWaypointManager() { Q_ASSERT(false); return NULL; } - virtual UASInterface* silentGetActiveUAS() { Q_ASSERT(false); return NULL; } - virtual UASInterface* getUASForId(int id) { Q_ASSERT(false); Q_UNUSED(id); return NULL; } - virtual QList getUASList() { Q_ASSERT(false); return _bogusQListUASInterface; } - virtual double getHomeLatitude() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); } - virtual double getHomeLongitude() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); } - virtual double getHomeAltitude() const { Q_ASSERT(false); return std::numeric_limits::quiet_NaN(); } - virtual int getHomeFrame() const { Q_ASSERT(false); return 0; } - virtual Eigen::Vector3d wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude) - { Q_ASSERT(false); Q_UNUSED(latitude); Q_UNUSED(longitude); Q_UNUSED(altitude); return _bogusEigenVector3d; } - virtual Eigen::Vector3d ecefToEnu(const Eigen::Vector3d & ecef) - { Q_ASSERT(false); Q_UNUSED(ecef); return _bogusEigenVector3d; } - virtual void wgs84ToEnu(const double& lat, const double& lon, const double& alt, double* east, double* north, double* up) - { Q_ASSERT(false); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); Q_UNUSED(east); Q_UNUSED(north); Q_UNUSED(up); } - virtual void enuToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) - { Q_ASSERT(false); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); } - virtual void nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) - { Q_ASSERT(false); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); } - virtual void getLocalNEDSafetyLimits(double* x1, double* y1, double* z1, double* x2, double* y2, double* z2) - { Q_ASSERT(false); Q_UNUSED(x1); Q_UNUSED(y1); Q_UNUSED(z1); Q_UNUSED(x2); Q_UNUSED(y2); Q_UNUSED(z2); } - virtual bool isInLocalNEDSafetyLimits(double x, double y, double z) - { Q_ASSERT(false); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(z); return false; } - -public slots: - // Unimplemented UASManagerInterface overrides - virtual void setActiveUAS(UASInterface* UAS) { Q_ASSERT(false); Q_UNUSED(UAS); } - virtual void addUAS(UASInterface* UAS) { Q_ASSERT(false); Q_UNUSED(UAS); } - virtual void removeUAS(UASInterface* uas) { Q_ASSERT(false); Q_UNUSED(uas);} - virtual bool launchActiveUAS() { Q_ASSERT(false); return false; } - virtual bool haltActiveUAS() { Q_ASSERT(false); return false; } - virtual bool continueActiveUAS() { Q_ASSERT(false); return false; } - virtual bool returnActiveUAS() { Q_ASSERT(false); return false; } - virtual bool stopActiveUAS() { Q_ASSERT(false); return false; } - virtual bool killActiveUAS() { Q_ASSERT(false); return false; } - virtual bool shutdownActiveUAS() { Q_ASSERT(false); return false; } - virtual bool setHomePosition(double lat, double lon, double alt) - { Q_ASSERT(false); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); return false; } - virtual bool setHomePositionAndNotify(double lat, double lon, double alt) - { Q_ASSERT(false); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); return false; } - virtual void setLocalNEDSafetyBorders(double x1, double y1, double z1, double x2, double y2, double z2) - { Q_ASSERT(false); Q_UNUSED(x1); Q_UNUSED(y1); Q_UNUSED(z1); Q_UNUSED(x2); Q_UNUSED(y2); Q_UNUSED(z2); } - virtual void uavChangedHomePosition(int uav, double lat, double lon, double alt) - { Q_ASSERT(false); Q_UNUSED(uav); Q_UNUSED(lat); Q_UNUSED(lon); Q_UNUSED(alt); } - virtual void loadSettings() { Q_ASSERT(false); } - virtual void storeSettings() { Q_ASSERT(false); } - virtual void _shutdown(void) { Q_ASSERT(false); } - -private: - MockUAS* _mockUAS; - - // Bogus variables used for return types of NYI methods - QList _bogusQListUASInterface; - Eigen::Vector3d _bogusEigenVector3d; - -public: - /* Need to align struct pointer to prevent a memory assertion: - * See http://eigen.tuxfamily.org/dox-devel/TopicUnalignedArrayAssert.html - * for details - */ - EIGEN_MAKE_ALIGNED_OPERATOR_NEW -}; - -#endif \ No newline at end of file