Add GUI test for issue #1595 (minus the minimize at startup case).

This commit is contained in:
Joan Bruguera 2018-03-11 15:29:48 +01:00 committed by TheZ3ro
parent bf9c1b3205
commit 8646586c1a
2 changed files with 26 additions and 0 deletions

View File

@ -71,6 +71,8 @@ void TestGui::initTestCase()
Config::createTempFileInstance(); Config::createTempFileInstance();
// Disable autosave so we can test the modified file indicator // Disable autosave so we can test the modified file indicator
Config::instance()->set("AutoSaveAfterEveryChange", false); Config::instance()->set("AutoSaveAfterEveryChange", false);
// Enable the tray icon so we can test hiding/restoring the window
Config::instance()->set("GUI/ShowTrayIcon", true);
m_mainWindow = new MainWindow(); m_mainWindow = new MainWindow();
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget"); m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
@ -1091,6 +1093,29 @@ void TestGui::testDragAndDropKdbxFiles()
QCOMPARE(m_tabWidget->count(), openedDatabasesCount); QCOMPARE(m_tabWidget->count(), openedDatabasesCount);
} }
void TestGui::testTrayRestoreHide()
{
QSystemTrayIcon *trayIcon = m_mainWindow->findChild<QSystemTrayIcon*>();
QVERIFY(m_mainWindow->isVisible());
trayIcon->activated(QSystemTrayIcon::Trigger);
Tools::wait(100);
QVERIFY(!m_mainWindow->isVisible());
trayIcon->activated(QSystemTrayIcon::Trigger);
Tools::wait(100);
QVERIFY(m_mainWindow->isVisible());
trayIcon->activated(QSystemTrayIcon::Trigger);
Tools::wait(100);
QVERIFY(!m_mainWindow->isVisible());
trayIcon->activated(QSystemTrayIcon::Trigger);
Tools::wait(100);
QVERIFY(m_mainWindow->isVisible());
}
void TestGui::cleanupTestCase() void TestGui::cleanupTestCase()
{ {
delete m_mainWindow; delete m_mainWindow;

View File

@ -63,6 +63,7 @@ private slots:
void testKeePass1Import(); void testKeePass1Import();
void testDatabaseLocking(); void testDatabaseLocking();
void testDragAndDropKdbxFiles(); void testDragAndDropKdbxFiles();
void testTrayRestoreHide();
private: private:
int addCannedEntries(); int addCannedEntries();