From 7ad330eccba89bff67325f98f0e66e2647c45cf6 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Tue, 31 Dec 2019 12:40:00 -0500 Subject: [PATCH] Improve GUI test reliability * Explicitly resize the window to improve testing on High DPI displays * Add additional bootstrap calls to mimic the actual application --- tests/gui/TestGui.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 2a0bef48..48b5c735 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -79,6 +79,10 @@ static QString dbFileName = QStringLiteral(KEEPASSX_TEST_DATA_DIR).append("/NewD void TestGui::initTestCase() { + Application::setApplicationName("KeePassXC"); + Application::setApplicationVersion(KEEPASSXC_VERSION); + QApplication::setQuitOnLastWindowClosed(false); + QVERIFY(Crypto::init()); Config::createTempFileInstance(); // Disable autosave so we can test the modified file indicator @@ -91,11 +95,12 @@ void TestGui::initTestCase() // Disable the update check first time alert config()->set("UpdateCheckMessageShown", true); - m_mainWindow.reset(new MainWindow()); - Bootstrap::restoreMainWindowState(*m_mainWindow); Bootstrap::bootstrapApplication(); + + m_mainWindow.reset(new MainWindow()); m_tabWidget = m_mainWindow->findChild("tabWidget"); m_mainWindow->show(); + m_mainWindow->resize(1024, 768); } // Every test starts with opening the temp database @@ -176,7 +181,7 @@ void TestGui::testSettingsDefaultTabOrder() void TestGui::testCreateDatabase() { - QTimer::singleShot(0, this, SLOT(createDatabaseCallback())); + QTimer::singleShot(50, this, SLOT(createDatabaseCallback())); triggerAction("actionDatabaseNew"); // there is a new empty db @@ -1435,8 +1440,9 @@ int TestGui::addCannedEntries() void TestGui::checkDatabase(QString dbFileName) { - if (dbFileName.isEmpty()) + if (dbFileName.isEmpty()) { dbFileName = m_dbFilePath; + } auto key = QSharedPointer::create(); key->addKey(QSharedPointer::create("a"));