From cac402bba6db3171e2f1528ca1e43262c1ebb9cd Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 8 Dec 2014 15:58:25 -0800 Subject: [PATCH] Test disallow of close if active connections --- src/qgcunittest/MainWindowTest.cc | 27 +++++++++++++++++++++++++++ src/qgcunittest/MainWindowTest.h | 1 + 2 files changed, 28 insertions(+) diff --git a/src/qgcunittest/MainWindowTest.cc b/src/qgcunittest/MainWindowTest.cc index 0ddb90868..408e95d87 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 47c9c20d6..87eb8270e 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; -- 2.22.0