Commit 97039eb6 authored by Don Gagne's avatar Don Gagne

Rework RadioCal unit test to Qml RadioCal

parent 20df7ebf
...@@ -515,8 +515,7 @@ HEADERS += \ ...@@ -515,8 +515,7 @@ HEADERS += \
src/qgcunittest/UnitTest.h \ src/qgcunittest/UnitTest.h \
src/VehicleSetup/SetupViewTest.h \ src/VehicleSetup/SetupViewTest.h \
src/qgcunittest/FileManagerTest.h \ src/qgcunittest/FileManagerTest.h \
src/qgcunittest/PX4RCCalibrationTest.h \
#src/qgcunittest/PX4RCCalibrationTest.h \
SOURCES += \ SOURCES += \
src/qgcunittest/FlightGearTest.cc \ src/qgcunittest/FlightGearTest.cc \
...@@ -534,8 +533,7 @@ SOURCES += \ ...@@ -534,8 +533,7 @@ SOURCES += \
src/qgcunittest/UnitTest.cc \ src/qgcunittest/UnitTest.cc \
src/VehicleSetup/SetupViewTest.cc \ src/VehicleSetup/SetupViewTest.cc \
src/qgcunittest/FileManagerTest.cc \ src/qgcunittest/FileManagerTest.cc \
src/qgcunittest/PX4RCCalibrationTest.cc \
#src/qgcunittest/PX4RCCalibrationTest.cc \
} # DebugBuild|WindowsDebugAndRelease } # DebugBuild|WindowsDebugAndRelease
} # AndroidBuild } # AndroidBuild
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
QGC_LOGGING_CATEGORY(RadioComponentControllerLog, "RadioComponentControllerLog") QGC_LOGGING_CATEGORY(RadioComponentControllerLog, "RadioComponentControllerLog")
#ifdef UNITTEST_BUILD
// Nasty hack to expose controller to unit test code
RadioComponentController* RadioComponentController::_unitTestController = NULL;
#endif
const int RadioComponentController::_updateInterval = 150; ///< Interval for timer which updates radio channel widgets const int RadioComponentController::_updateInterval = 150; ///< Interval for timer which updates radio channel widgets
const int RadioComponentController::_rcCalPWMCenterPoint = ((RadioComponentController::_rcCalPWMValidMaxValue - RadioComponentController::_rcCalPWMValidMinValue) / 2.0f) + RadioComponentController::_rcCalPWMValidMinValue; const int RadioComponentController::_rcCalPWMCenterPoint = ((RadioComponentController::_rcCalPWMValidMaxValue - RadioComponentController::_rcCalPWMValidMinValue) / 2.0f) + RadioComponentController::_rcCalPWMValidMinValue;
// FIXME: Double check these mins againt 150% throws // FIXME: Double check these mins againt 150% throws
...@@ -93,6 +98,11 @@ RadioComponentController::RadioComponentController(void) : ...@@ -93,6 +98,11 @@ RadioComponentController::RadioComponentController(void) :
_nextButton(NULL), _nextButton(NULL),
_skipButton(NULL) _skipButton(NULL)
{ {
#ifdef UNITTEST_BUILD
// Nasty hack to expose controller to unit test code
_unitTestController = this;
#endif
connect(_uas, &UASInterface::remoteControlChannelRawChanged, this, &RadioComponentController::_remoteControlChannelRawChanged); connect(_uas, &UASInterface::remoteControlChannelRawChanged, this, &RadioComponentController::_remoteControlChannelRawChanged);
_loadSettings(); _loadSettings();
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
Q_DECLARE_LOGGING_CATEGORY(RadioComponentControllerLog) Q_DECLARE_LOGGING_CATEGORY(RadioComponentControllerLog)
//class RadioComponentControllerTest; class RadioConfigest;
namespace Ui { namespace Ui {
class RadioComponentController; class RadioComponentController;
...@@ -49,7 +49,7 @@ class RadioComponentController : public FactPanelController ...@@ -49,7 +49,7 @@ class RadioComponentController : public FactPanelController
{ {
Q_OBJECT Q_OBJECT
//friend class RadioComponentControllerTest; ///< This allows our unit test to access internal information needed. friend class RadioConfigTest; ///< This allows our unit test to access internal information needed.
public: public:
RadioComponentController(void); RadioComponentController(void);
...@@ -324,6 +324,11 @@ private: ...@@ -324,6 +324,11 @@ private:
QQuickItem* _skipButton; QQuickItem* _skipButton;
QString _imageHelp; QString _imageHelp;
#ifdef UNITTEST_BUILD
// Nasty hack to expose controller to unit test code
static RadioComponentController* _unitTestController;
#endif
}; };
#endif // RadioComponentController_H #endif // RadioComponentController_H
This diff is collapsed.
...@@ -21,30 +21,30 @@ ...@@ -21,30 +21,30 @@
======================================================================*/ ======================================================================*/
#ifndef PX4RCCALIBRATIONTEST_H #ifndef RadioConfigTest_H
#define PX4RCCALIBRATIONTEST_H #define RadioConfigTest_H
#include "UnitTest.h" #include "UnitTest.h"
#include "MockLink.h" #include "MockLink.h"
#include "MultiSignalSpy.h" #include "MultiSignalSpy.h"
#include "px4_configuration/PX4RCCalibration.h" #include "RadioComponentController.h"
#include "QGCLoggingCategory.h" #include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
#include "QGCQmlWidgetHolder.h"
/// @file /// @file
/// @brief PX4RCCalibration Widget unit test /// @brief Radio Config unit test
/// ///
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
Q_DECLARE_LOGGING_CATEGORY(PX4RCCalibrationTestLog) Q_DECLARE_LOGGING_CATEGORY(RadioConfigTestLog)
/// @brief PX4RCCalibration Widget unit test class RadioConfigTest : public UnitTest
class PX4RCCalibrationTest : public UnitTest
{ {
Q_OBJECT Q_OBJECT
public: public:
PX4RCCalibrationTest(void); RadioConfigTest(void);
private slots: private slots:
void init(void); void init(void);
...@@ -71,10 +71,10 @@ private: ...@@ -71,10 +71,10 @@ private:
void _minRCChannels(void); void _minRCChannels(void);
void _beginCalibration(void); void _beginCalibration(void);
void _stickMoveWaitForSettle(int channel, int value); void _stickMoveWaitForSettle(int channel, int value);
void _stickMoveAutoStep(const char* functionStr, enum PX4RCCalibration::rcCalFunctions function, enum MoveToDirection direction, bool identifyStep); void _stickMoveAutoStep(const char* functionStr, enum RadioComponentController::rcCalFunctions function, enum MoveToDirection direction, bool identifyStep);
void _switchMinMaxStep(void); void _switchMinMaxStep(void);
void _flapsDetectStep(void); void _flapsDetectStep(void);
void _switchSelectAutoStep(const char* functionStr, PX4RCCalibration::rcCalFunctions function); void _switchSelectAutoStep(const char* functionStr, RadioComponentController::rcCalFunctions function);
enum { enum {
validateMinMaxMask = 1 << 0, validateMinMaxMask = 1 << 0,
...@@ -97,7 +97,7 @@ private: ...@@ -97,7 +97,7 @@ private:
MockLink* _mockLink; MockLink* _mockLink;
AutoPilotPlugin* _autopilot; AutoPilotPlugin* _autopilot;
PX4RCCalibration* _calWidget; QGCQmlWidgetHolder* _calWidget;
enum { enum {
nextButtonMask = 1 << 0, nextButtonMask = 1 << 0,
...@@ -105,13 +105,6 @@ private: ...@@ -105,13 +105,6 @@ private:
skipButtonMask = 1 << 2 skipButtonMask = 1 << 2
}; };
QPushButton* _nextButton;
QPushButton* _cancelButton;
QPushButton* _skipButton;
QLabel* _statusLabel;
RCValueWidget* _rgValueWidget[PX4RCCalibration::_chanMax];
const char* _rgSignals[1]; const char* _rgSignals[1];
MultiSignalSpy* _multiSpyNextButtonMessageBox; MultiSignalSpy* _multiSpyNextButtonMessageBox;
...@@ -125,9 +118,11 @@ private: ...@@ -125,9 +118,11 @@ private:
static const int _stickSettleWait; static const int _stickSettleWait;
static const struct ChannelSettings _rgChannelSettings[_availableChannels]; static const struct ChannelSettings _rgChannelSettings[_availableChannels];
static const struct ChannelSettings _rgChannelSettingsValidate[PX4RCCalibration::_chanMax]; static const struct ChannelSettings _rgChannelSettingsValidate[RadioComponentController::_chanMax];
int _rgFunctionChannelMap[RadioComponentController::rcCalFunctionMax];
int _rgFunctionChannelMap[PX4RCCalibration::rcCalFunctionMax]; RadioComponentController* _controller;
}; };
#endif #endif
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