From 8646586c1a8f1523dbb3c1edf3aaf7682edf9bb6 Mon Sep 17 00:00:00 2001 From: Joan Bruguera Date: Sun, 11 Mar 2018 15:29:48 +0100 Subject: [PATCH] Add GUI test for issue #1595 (minus the minimize at startup case). --- tests/gui/TestGui.cpp | 25 +++++++++++++++++++++++++ tests/gui/TestGui.h | 1 + 2 files changed, 26 insertions(+) diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index b2ccd332d..25c6f0c7d 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -71,6 +71,8 @@ void TestGui::initTestCase() Config::createTempFileInstance(); // Disable autosave so we can test the modified file indicator 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_tabWidget = m_mainWindow->findChild("tabWidget"); @@ -1091,6 +1093,29 @@ void TestGui::testDragAndDropKdbxFiles() QCOMPARE(m_tabWidget->count(), openedDatabasesCount); } +void TestGui::testTrayRestoreHide() +{ + QSystemTrayIcon *trayIcon = m_mainWindow->findChild(); + + 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() { delete m_mainWindow; diff --git a/tests/gui/TestGui.h b/tests/gui/TestGui.h index 0b403731d..e7232ccab 100644 --- a/tests/gui/TestGui.h +++ b/tests/gui/TestGui.h @@ -63,6 +63,7 @@ private slots: void testKeePass1Import(); void testDatabaseLocking(); void testDragAndDropKdbxFiles(); + void testTrayRestoreHide(); private: int addCannedEntries();