diff --git a/src/qgcunittest/MainWindowTest.cc b/src/qgcunittest/MainWindowTest.cc index 0ddb90868df81e396f8204c8723dfc0fbe89606d..408e95d870e695ec0dd530dc2b53161b4536bdb5 100644 --- a/src/qgcunittest/MainWindowTest.cc +++ b/src/qgcunittest/MainWindowTest.cc @@ -28,6 +28,8 @@ #include "MainWindowTest.h" #include "QGCToolBar.h" +#include "MockLink.h" +#include "QGCMessageBox.h" UT_REGISTER_TEST(MainWindowTest) @@ -66,3 +68,28 @@ void MainWindowTest::_clickThrough_test(void) } } + +void MainWindowTest::_connectWindowClose_test(void) +{ + LinkManager* linkMgr = LinkManager::instance(); + Q_CHECK_PTR(linkMgr); + + MockLink* link = new MockLink(); + Q_CHECK_PTR(link); + // FIXME: LinkManager/MainWindow needs to be re-architected so that you don't have to addLink to MainWindow to get things to work + _mainWindow->addLink(link); + linkMgr->connectLink(link); + QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through + + // On MainWindow close we should get a message box telling the user to disconnect first + setExpectedMessageBox(QGCMessageBox::Ok); + _mainWindow->close(); + QTest::qWait(1000); // Need to allow signals to move between threads + checkExpectedMessageBox(); + + // We are going to disconnect the link which is going to pop a save file dialog + setExpectedFileDialog(getSaveFileName, QStringList()); + linkMgr->disconnectLink(link); + QTest::qWait(1000); // Need to allow signals to move between threads + checkExpectedFileDialog(); +} diff --git a/src/qgcunittest/MainWindowTest.h b/src/qgcunittest/MainWindowTest.h index 47c9c20d6abdc4f01c2bd070bb47d636be77c395..87eb8270eafde5d5b2e59799ca00af8b23b11dac 100644 --- a/src/qgcunittest/MainWindowTest.h +++ b/src/qgcunittest/MainWindowTest.h @@ -44,6 +44,7 @@ private slots: void cleanup(void); void _clickThrough_test(void); + void _connectWindowClose_test(void); private: MainWindow* _mainWindow;