diff --git a/src/VehicleSetup/SetupViewTest.cc b/src/VehicleSetup/SetupViewTest.cc index c1f6647..113072e 100644 --- a/src/VehicleSetup/SetupViewTest.cc +++ b/src/VehicleSetup/SetupViewTest.cc @@ -28,10 +28,11 @@ #include "MockLink.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) _mainWindow = MainWindow::_create(NULL); Q_CHECK_PTR(_mainWindow); + + _mainToolBar = _mainWindow->getMainToolBar(); + Q_ASSERT(_mainToolBar); } void SetupViewTest::cleanup(void) @@ -64,26 +68,10 @@ void SetupViewTest::_clickThrough_test(void) 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 - - // Tool Bar is now a QQuickWidget and cannot be manipulated like below -#if 0 - QGCToolBar* toolbar = _mainWindow->findChild(); - Q_ASSERT(toolbar); - - QList buttons = toolbar->findChildren(); - QToolButton* setupButton = NULL; - foreach(QToolButton* button, buttons) { - if (button->text() == "Setup") { - setupButton = button; - break; - } - } - - Q_ASSERT(setupButton); - QTest::mouseClick(setupButton, Qt::LeftButton); + // Switch to the Setup view + _mainToolBar->onSetupView(); QTest::qWait(1000); -#endif + // Click through all the setup buttons // FIXME: NYI diff --git a/src/VehicleSetup/SetupViewTest.h b/src/VehicleSetup/SetupViewTest.h index 8a1b86a..0868149 100644 --- a/src/VehicleSetup/SetupViewTest.h +++ b/src/VehicleSetup/SetupViewTest.h @@ -29,6 +29,7 @@ #include "UnitTest.h" #include "MainWindow.h" +#include "MainToolBar.h" /// Click through test for Setup View buttons class SetupViewTest : public UnitTest @@ -45,7 +46,8 @@ private slots: void _clickThrough_test(void); private: - MainWindow* _mainWindow; + MainWindow* _mainWindow; + MainToolBar* _mainToolBar; }; #endif diff --git a/src/qgcunittest/MainWindowTest.cc b/src/qgcunittest/MainWindowTest.cc index bff4829..2b007bb 100644 --- a/src/qgcunittest/MainWindowTest.cc +++ b/src/qgcunittest/MainWindowTest.cc @@ -31,10 +31,11 @@ #include "MockLink.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) _mainWindow = MainWindow::_create(NULL); Q_CHECK_PTR(_mainWindow); + + _mainToolBar = _mainWindow->getMainToolBar(); + Q_ASSERT(_mainToolBar); } void MainWindowTest::cleanup(void) @@ -67,21 +71,17 @@ 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 - // Tool Bar is now a QQuickWidget and cannot be manipulated like below -#if 0 - // Click through all top level toolbar buttons - QGCToolBar* toolbar = _mainWindow->findChild(); - Q_ASSERT(toolbar); + // Cycle through all the top level views + + _mainToolBar->onSetupView(); + QTest::qWait(1000); + _mainToolBar->onPlanView(); + QTest::qWait(1000); + _mainToolBar->onFlyView(); + QTest::qWait(1000); + _mainToolBar->onAnalyzeView(); + QTest::qWait(1000); - QList buttons = toolbar->findChildren(); - foreach(QToolButton* button, buttons) { - if (!button->menu()) { - QTest::mouseClick(button, Qt::LeftButton); - QTest::qWait(1000); - } - } -#endif - // On MainWindow close we should get a message box telling the user to disconnect first. Cancel should do nothing. setExpectedMessageBox(QGCMessageBox::Cancel); _mainWindow->close(); diff --git a/src/qgcunittest/MainWindowTest.h b/src/qgcunittest/MainWindowTest.h index 517c3ad..488b435 100644 --- a/src/qgcunittest/MainWindowTest.h +++ b/src/qgcunittest/MainWindowTest.h @@ -31,6 +31,7 @@ #include "UnitTest.h" #include "MainWindow.h" +#include "MainToolBar.h" class MainWindowTest : public UnitTest { @@ -48,7 +49,9 @@ private slots: private: void _connectWindowClose_test(MAV_AUTOPILOT autopilot); - MainWindow* _mainWindow; + + MainWindow* _mainWindow; + MainToolBar* _mainToolBar; }; #endif