Commit 519ee5ab authored by Don Gagne's avatar Don Gagne

Update unit test for new log save behavior

parent 6813d2c1
...@@ -110,14 +110,11 @@ void SetupViewTest::_clickThrough_test(void) ...@@ -110,14 +110,11 @@ void SetupViewTest::_clickThrough_test(void)
QTest::qWait(1000); QTest::qWait(1000);
} }
// On MainWindow close we should get a message box telling the user to disconnect first. Disconnect will then pop // On MainWindow close we should get a message box telling the user to disconnect first.
// the log file save dialog.
setExpectedMessageBox(QGCMessageBox::Yes); setExpectedMessageBox(QGCMessageBox::Yes);
setExpectedFileDialog(getSaveFileName, QStringList());
_mainWindow->close(); _mainWindow->close();
QTest::qWait(1000); // Need to allow signals to move between threads QTest::qWait(1000); // Need to allow signals to move between threads
checkExpectedMessageBox(); checkExpectedMessageBox();
checkExpectedFileDialog();
} }
...@@ -145,7 +145,7 @@ private: ...@@ -145,7 +145,7 @@ private:
MissionList_t _missionItems; MissionList_t _missionItems;
uint8_t _mavBaseMode; uint8_t _mavBaseMode;
uint8_t _mavCustomMode; uint32_t _mavCustomMode;
uint8_t _mavState; uint8_t _mavState;
MockConfiguration* _config; MockConfiguration* _config;
......
...@@ -100,11 +100,8 @@ void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot) ...@@ -100,11 +100,8 @@ void MainWindowTest::_connectWindowClose_test(MAV_AUTOPILOT autopilot)
QTest::qWait(1000); // Need to allow signals to move between threads QTest::qWait(1000); // Need to allow signals to move between threads
checkExpectedMessageBox(); checkExpectedMessageBox();
// We are going to disconnect the link which is going to pop a save file dialog
setExpectedFileDialog(getSaveFileName, QStringList());
linkMgr->disconnectLink(link); linkMgr->disconnectLink(link);
QTest::qWait(1000); // Need to allow signals to move between threads QTest::qWait(1000); // Need to allow signals to move between threads
checkExpectedFileDialog();
} }
void MainWindowTest::_connectWindowClosePX4_test(void) { void MainWindowTest::_connectWindowClosePX4_test(void) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "MockLink.h" #include "MockLink.h"
#include "QGCTemporaryFile.h" #include "QGCTemporaryFile.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "UAS.h"
UT_REGISTER_TEST(MavlinkLogTest) UT_REGISTER_TEST(MavlinkLogTest)
...@@ -133,7 +134,7 @@ void MavlinkLogTest::_bootLogDetectionZeroLength_test(void) ...@@ -133,7 +134,7 @@ void MavlinkLogTest::_bootLogDetectionZeroLength_test(void)
// Zero length log files should not generate any additional UI pop-ups. It should just be deleted silently. // Zero length log files should not generate any additional UI pop-ups. It should just be deleted silently.
} }
void MavlinkLogTest::_connectLog_test(void) void MavlinkLogTest::_connectLogWorker(bool arm)
{ {
LinkManager* linkMgr = LinkManager::instance(); LinkManager* linkMgr = LinkManager::instance();
Q_CHECK_PTR(linkMgr); Q_CHECK_PTR(linkMgr);
...@@ -142,20 +143,48 @@ void MavlinkLogTest::_connectLog_test(void) ...@@ -142,20 +143,48 @@ void MavlinkLogTest::_connectLog_test(void)
Q_CHECK_PTR(link); Q_CHECK_PTR(link);
LinkManager::instance()->_addLink(link); LinkManager::instance()->_addLink(link);
linkMgr->connectLink(link); linkMgr->connectLink(link);
QTest::qWait(5000); // Give enough time for UI to settle and heartbeats to go through
// Wait for the uas to work it's way through the various threads
QSignalSpy spyUas(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)));
QCOMPARE(spyUas.wait(5000), true);
UASInterface* uasInterface = UASManager::instance()->getActiveUAS();
QVERIFY(uasInterface);
UAS* uas = dynamic_cast<UAS*>(uasInterface);
QVERIFY(uas);
QDir logSaveDir;
if (arm) {
uas->armSystem();
QTest::qWait(1500); // Wait long enough for heartbeat to come through
// On Disconnect: We should get a getSaveFileName dialog. // On Disconnect: We should get a getSaveFileName dialog.
QDir logSaveDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); logSaveDir.setPath(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
QString logSaveFile(logSaveDir.filePath(_saveLogFilename)); QString logSaveFile(logSaveDir.filePath(_saveLogFilename));
setExpectedFileDialog(getSaveFileName, QStringList(logSaveFile)); setExpectedFileDialog(getSaveFileName, QStringList(logSaveFile));
}
linkMgr->disconnectLink(link); linkMgr->disconnectLink(link);
QTest::qWait(1000); // Need to allow signals to move between threads QTest::qWait(1000); // Need to allow signals to move between threads
if (arm) {
checkExpectedFileDialog(); checkExpectedFileDialog();
// Make sure the file is there and delete it // Make sure the file is there and delete it
QCOMPARE(logSaveDir.remove(_saveLogFilename), true); QCOMPARE(logSaveDir.remove(_saveLogFilename), true);
}
}
void MavlinkLogTest::_connectLogNoArm_test(void)
{
_connectLogWorker(false);
}
void MavlinkLogTest::_connectLogArm_test(void)
{
_connectLogWorker(true);
} }
void MavlinkLogTest::_deleteTempLogFiles_test(void) void MavlinkLogTest::_deleteTempLogFiles_test(void)
......
...@@ -45,7 +45,8 @@ private slots: ...@@ -45,7 +45,8 @@ private slots:
void _bootLogDetectionCancel_test(void); void _bootLogDetectionCancel_test(void);
void _bootLogDetectionSave_test(void); void _bootLogDetectionSave_test(void);
void _bootLogDetectionZeroLength_test(void); void _bootLogDetectionZeroLength_test(void);
void _connectLog_test(void); void _connectLogNoArm_test(void);
void _connectLogArm_test(void);
void _deleteTempLogFiles_test(void); void _deleteTempLogFiles_test(void);
signals: signals:
...@@ -53,6 +54,7 @@ signals: ...@@ -53,6 +54,7 @@ signals:
private: private:
void _createTempLogFile(bool zeroLength); void _createTempLogFile(bool zeroLength);
void _connectLogWorker(bool arm);
static const char* _tempLogFileTemplate; ///< Template for temporary log file static const char* _tempLogFileTemplate; ///< Template for temporary log file
static const char* _logFileExtension; ///< Extension for log files static const char* _logFileExtension; ///< Extension for log files
......
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