Commit e0fed930 authored by Don Gagne's avatar Don Gagne

Fix SetupView to work with latest mavlink headers

- Updated MainWindowTest to catch this problem
- Also implemented initial pass at SetupView unit test
parent c674ee0b
......@@ -681,6 +681,7 @@ HEADERS += \
src/FactSystem/FactSystemTestPX4.h \
src/FactSystem/FactSystemTestGeneric.h \
src/QmlControls/QmlTestWidget.h \
src/VehicleSetup/SetupViewTest.h \
SOURCES += \
src/qgcunittest/UnitTest.cc \
......@@ -706,6 +707,7 @@ SOURCES += \
src/FactSystem/FactSystemTestPX4.cc \
src/FactSystem/FactSystemTestGeneric.cc \
src/QmlControls/QmlTestWidget.cc \
src/VehicleSetup/SetupViewTest.cc \
}
......
......@@ -30,6 +30,9 @@
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "SYS_AUTOSTART", NULL };
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix.
struct mavType {
int type;
const char* description;
......@@ -58,17 +61,23 @@ static const struct mavType mavTypeInfo[] = {
{ MAV_TYPE_ONBOARD_CONTROLLER, "Onbard companion controller" },
{ MAV_TYPE_VTOL_DUOROTOR, "Two-rotor VTOL" },
{ MAV_TYPE_VTOL_QUADROTOR, "Quad-rotor VTOL" },
{ MAV_TYPE_GIMBAL, "Gimbal" },
};
static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
#endif
AirframeComponent::AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Airframe"))
{
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix.
Q_UNUSED(mavTypeInfo); // Keeping this around for later use
// Validate that our mavTypeInfo array hasn't gotten out of sync
qDebug() << cMavTypes << MAV_TYPE_ENUM_END;
Q_ASSERT(cMavTypes == MAV_TYPE_ENUM_END);
static const int mavTypes[] = {
......@@ -92,13 +101,15 @@ AirframeComponent::AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopil
MAV_TYPE_KITE,
MAV_TYPE_ONBOARD_CONTROLLER,
MAV_TYPE_VTOL_DUOROTOR,
MAV_TYPE_VTOL_QUADROTOR
MAV_TYPE_VTOL_QUADROTOR,
MAV_TYPE_GIMBAL,
};
Q_UNUSED(mavTypes); // Keeping this around for later use
for (size_t i=0; i<cMavTypes; i++) {
Q_ASSERT(mavTypeInfo[i].type == mavTypes[i]);
}
#endif
}
QString AirframeComponent::name(void) const
......
/*=====================================================================
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 "SetupViewTest.h"
#include "MockLink.h"
#include "QGCMessageBox.h"
UT_REGISTER_TEST(SetupViewTest)
SetupViewTest::SetupViewTest(void)
{
}
void SetupViewTest::init(void)
{
UnitTest::init();
_mainWindow = MainWindow::_create(NULL);
Q_CHECK_PTR(_mainWindow);
}
void SetupViewTest::cleanup(void)
{
_mainWindow->close();
delete _mainWindow;
UnitTest::cleanup();
}
void SetupViewTest::_clickThrough_test(void)
{
LinkManager* linkMgr = LinkManager::instance();
Q_CHECK_PTR(linkMgr);
MockLink* link = new MockLink();
Q_CHECK_PTR(link);
link->setAutopilotType(MAV_AUTOPILOT_PX4);
LinkManager::instance()->addLink(link);
linkMgr->connectLink(link);
QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through
// Find the Setup button and click it
QGCToolBar* toolbar = _mainWindow->findChild<QGCToolBar*>();
Q_ASSERT(toolbar);
QList<QToolButton*> buttons = toolbar->findChildren<QToolButton*>();
QToolButton* setupButton = NULL;
foreach(QToolButton* button, buttons) {
if (button->text() == "Setup") {
setupButton = button;
break;
}
}
Q_ASSERT(setupButton);
QTest::mouseClick(setupButton, Qt::LeftButton);
QTest::qWait(1000);
// Click through all the setup buttons
// FIXME: NYI
// On MainWindow close we should get a message box telling the user to disconnect first. Disconnect will then pop
// the log file save dialog.
setExpectedMessageBox(QGCMessageBox::Yes);
setExpectedFileDialog(getSaveFileName, QStringList());
_mainWindow->close();
QTest::qWait(1000); // Need to allow signals to move between threads
checkExpectedMessageBox();
checkExpectedFileDialog();
}
/*=====================================================================
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 SetupViewTest_H
#define SetupViewTest_H
#include "UnitTest.h"
#include "MainWindow.h"
/// Click through test for Setup View buttons
class SetupViewTest : public UnitTest
{
Q_OBJECT
public:
SetupViewTest(void);
private slots:
void init(void);
void cleanup(void);
void _clickThrough_test(void);
private:
MainWindow* _mainWindow;
};
#endif
......@@ -54,21 +54,6 @@ void MainWindowTest::cleanup(void)
UnitTest::cleanup();
}
void MainWindowTest::_clickThrough_test(void)
{
QGCToolBar* toolbar = _mainWindow->findChild<QGCToolBar*>();
Q_ASSERT(toolbar);
QList<QToolButton*> buttons = toolbar->findChildren<QToolButton*>();
foreach(QToolButton* button, buttons) {
if (!button->menu()) {
QTest::mouseClick(button, Qt::LeftButton);
QTest::qWait(1000);
}
}
}
void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot)
{
LinkManager* linkMgr = LinkManager::instance();
......@@ -81,6 +66,18 @@ void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot)
linkMgr->connectLink(link);
QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through
// Click through all top level toolbar buttons
QGCToolBar* toolbar = _mainWindow->findChild<QGCToolBar*>();
Q_ASSERT(toolbar);
QList<QToolButton*> buttons = toolbar->findChildren<QToolButton*>();
foreach(QToolButton* button, buttons) {
if (!button->menu()) {
QTest::mouseClick(button, Qt::LeftButton);
QTest::qWait(1000);
}
}
// On MainWindow close we should get a message box telling the user to disconnect first. Cancel should do nothing.
setExpectedMessageBox(QGCMessageBox::Cancel);
_mainWindow->close();
......
......@@ -43,7 +43,6 @@ private slots:
void init(void);
void cleanup(void);
void _clickThrough_test(void);
void _connectWindowClosePX4_test(void);
void _connectWindowCloseGeneric_test(void);
......
......@@ -381,7 +381,7 @@
1 50 RTL_RETURN_ALT 100 9
1 50 SDLOG_EXT -1 6
1 50 SDLOG_RATE -1 6
1 50 SENS_ACC_XOFF 0 9
1 50 SENS_ACC_XOFF 1 9
1 50 SENS_ACC_XSCALE 1 9
1 50 SENS_ACC_YOFF 0 9
1 50 SENS_ACC_YSCALE 1 9
......@@ -396,13 +396,13 @@
1 50 SENS_DPRES_OFF 0 9
1 50 SENS_EXT_MAG 0 6
1 50 SENS_EXT_MAG_ROT 0 6
1 50 SENS_GYRO_XOFF 0 9
1 50 SENS_GYRO_XOFF 1 9
1 50 SENS_GYRO_XSCALE 1 9
1 50 SENS_GYRO_YOFF 0 9
1 50 SENS_GYRO_YSCALE 1 9
1 50 SENS_GYRO_ZOFF 0 9
1 50 SENS_GYRO_ZSCALE 1 9
1 50 SENS_MAG_XOFF 0 9
1 50 SENS_MAG_XOFF 1 9
1 50 SENS_MAG_XSCALE 1 9
1 50 SENS_MAG_YOFF 0 9
1 50 SENS_MAG_YSCALE 1 9
......
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