Commit 1691530a authored by Don Gagne's avatar Don Gagne

Merge pull request #1320 from DonLakeFlyer/UTFixes

Unit Test fixes
parents 278871b8 e278b23b
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
/// ///
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
UT_REGISTER_TEST(FlightModeConfigTest) // Turned off due to signletonn shutdown sequencing problem. Also since FlightMode config is
// being re-written this test will need to be re-written as well.
//UT_REGISTER_TEST(FlightModeConfigTest)
FlightModeConfigTest::FlightModeConfigTest(void) : FlightModeConfigTest::FlightModeConfigTest(void) :
_mockUASManager(NULL), _mockUASManager(NULL),
......
...@@ -28,10 +28,11 @@ ...@@ -28,10 +28,11 @@
#include "MockLink.h" #include "MockLink.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
// TODO: This is not working in Windows. Needs to be updated for new tool bar any way. UT_REGISTER_TEST(SetupViewTest)
//UT_REGISTER_TEST(SetupViewTest)
SetupViewTest::SetupViewTest(void) SetupViewTest::SetupViewTest(void) :
_mainWindow(NULL),
_mainToolBar(NULL)
{ {
} }
...@@ -42,6 +43,9 @@ void SetupViewTest::init(void) ...@@ -42,6 +43,9 @@ void SetupViewTest::init(void)
_mainWindow = MainWindow::_create(NULL); _mainWindow = MainWindow::_create(NULL);
Q_CHECK_PTR(_mainWindow); Q_CHECK_PTR(_mainWindow);
_mainToolBar = _mainWindow->getMainToolBar();
Q_ASSERT(_mainToolBar);
} }
void SetupViewTest::cleanup(void) void SetupViewTest::cleanup(void)
...@@ -64,26 +68,10 @@ void SetupViewTest::_clickThrough_test(void) ...@@ -64,26 +68,10 @@ void SetupViewTest::_clickThrough_test(void)
linkMgr->connectLink(link); linkMgr->connectLink(link);
QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through
// Find the Setup button and click it // Switch to the Setup view
_mainToolBar->onSetupView();
// Tool Bar is now a QQuickWidget and cannot be manipulated like below
#if 0
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); QTest::qWait(1000);
#endif
// Click through all the setup buttons // Click through all the setup buttons
// FIXME: NYI // FIXME: NYI
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "UnitTest.h" #include "UnitTest.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MainToolBar.h"
/// Click through test for Setup View buttons /// Click through test for Setup View buttons
class SetupViewTest : public UnitTest class SetupViewTest : public UnitTest
...@@ -46,6 +47,7 @@ private slots: ...@@ -46,6 +47,7 @@ private slots:
private: private:
MainWindow* _mainWindow; MainWindow* _mainWindow;
MainToolBar* _mainToolBar;
}; };
#endif #endif
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
#include "MockLink.h" #include "MockLink.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
// TODO: This needs to be changed to accomodate the new QML based tool bar UT_REGISTER_TEST(MainWindowTest)
// UT_REGISTER_TEST(MainWindowTest)
MainWindowTest::MainWindowTest(void) MainWindowTest::MainWindowTest(void) :
_mainWindow(NULL),
_mainToolBar(NULL)
{ {
} }
...@@ -45,6 +46,9 @@ void MainWindowTest::init(void) ...@@ -45,6 +46,9 @@ void MainWindowTest::init(void)
_mainWindow = MainWindow::_create(NULL); _mainWindow = MainWindow::_create(NULL);
Q_CHECK_PTR(_mainWindow); Q_CHECK_PTR(_mainWindow);
_mainToolBar = _mainWindow->getMainToolBar();
Q_ASSERT(_mainToolBar);
} }
void MainWindowTest::cleanup(void) void MainWindowTest::cleanup(void)
...@@ -67,20 +71,16 @@ void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot) ...@@ -67,20 +71,16 @@ void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot)
linkMgr->connectLink(link); linkMgr->connectLink(link);
QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through
// Tool Bar is now a QQuickWidget and cannot be manipulated like below // Cycle through all the top level views
#if 0
// Click through all top level toolbar buttons
QGCToolBar* toolbar = _mainWindow->findChild<QGCToolBar*>();
Q_ASSERT(toolbar);
QList<QToolButton*> buttons = toolbar->findChildren<QToolButton*>(); _mainToolBar->onSetupView();
foreach(QToolButton* button, buttons) { QTest::qWait(1000);
if (!button->menu()) { _mainToolBar->onPlanView();
QTest::mouseClick(button, Qt::LeftButton); QTest::qWait(1000);
_mainToolBar->onFlyView();
QTest::qWait(1000);
_mainToolBar->onAnalyzeView();
QTest::qWait(1000); QTest::qWait(1000);
}
}
#endif
// On MainWindow close we should get a message box telling the user to disconnect first. Cancel should do nothing. // On MainWindow close we should get a message box telling the user to disconnect first. Cancel should do nothing.
setExpectedMessageBox(QGCMessageBox::Cancel); setExpectedMessageBox(QGCMessageBox::Cancel);
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "UnitTest.h" #include "UnitTest.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MainToolBar.h"
class MainWindowTest : public UnitTest class MainWindowTest : public UnitTest
{ {
...@@ -48,7 +49,9 @@ private slots: ...@@ -48,7 +49,9 @@ private slots:
private: private:
void _connectWindowClose_test(MAV_AUTOPILOT autopilot); void _connectWindowClose_test(MAV_AUTOPILOT autopilot);
MainWindow* _mainWindow; MainWindow* _mainWindow;
MainToolBar* _mainToolBar;
}; };
#endif #endif
...@@ -171,9 +171,7 @@ MainWindow::MainWindow(QSplashScreen* splashScreen) ...@@ -171,9 +171,7 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
QDockWidget* widget = new QDockWidget(this); QDockWidget* widget = new QDockWidget(this);
widget->setObjectName("ToolBarDockWidget"); widget->setObjectName("ToolBarDockWidget");
qmlRegisterType<MainToolBar>("QGroundControl.MainToolBar", 1, 0, "MainToolBar"); qmlRegisterType<MainToolBar>("QGroundControl.MainToolBar", 1, 0, "MainToolBar");
_mainToolBar = new MainToolBar(); _mainToolBar = new MainToolBar(widget);
_mainToolBar->setParent(widget);
_mainToolBar->setVisible(true);
widget->setWidget(_mainToolBar); widget->setWidget(_mainToolBar);
widget->setFeatures(QDockWidget::NoDockWidgetFeatures); widget->setFeatures(QDockWidget::NoDockWidgetFeatures);
widget->setTitleBarWidget(new QWidget(this)); // Disables the title bar widget->setTitleBarWidget(new QWidget(this)); // Disables the title bar
......
...@@ -126,6 +126,11 @@ public: ...@@ -126,6 +126,11 @@ public:
/// @brief Restore (and connects) the last used connection (if any) /// @brief Restore (and connects) the last used connection (if any)
void restoreLastUsedConnection(); void restoreLastUsedConnection();
#ifdef UNITTEST_BUILD
// Returns a pointer to the MainToolBar so that unit tests can change views.
MainToolBar* getMainToolBar(void) { return _mainToolBar; }
#endif
public slots: public slots:
/** @brief Show the application settings */ /** @brief Show the application settings */
......
...@@ -35,8 +35,9 @@ This file is part of the QGROUNDCONTROL project ...@@ -35,8 +35,9 @@ This file is part of the QGROUNDCONTROL project
#include "UASMessageHandler.h" #include "UASMessageHandler.h"
#include "UASMessageView.h" #include "UASMessageView.h"
MainToolBar::MainToolBar() MainToolBar::MainToolBar(QWidget* parent)
: _mav(NULL) : QGCQmlWidgetHolder(parent)
, _mav(NULL)
, _toolBar(NULL) , _toolBar(NULL)
, _currentView(ViewNone) , _currentView(ViewNone)
, _batteryVoltage(0.0) , _batteryVoltage(0.0)
......
...@@ -42,7 +42,7 @@ class MainToolBar : public QGCQmlWidgetHolder ...@@ -42,7 +42,7 @@ class MainToolBar : public QGCQmlWidgetHolder
Q_ENUMS(ViewType_t) Q_ENUMS(ViewType_t)
Q_ENUMS(MessageType_t) Q_ENUMS(MessageType_t)
public: public:
MainToolBar(); MainToolBar(QWidget* parent = NULL);
~MainToolBar(); ~MainToolBar();
typedef enum { typedef enum {
......
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