Skip to content

Commit

Permalink
Improve GUI test reliability
Browse files Browse the repository at this point in the history
* Explicitly resize the window to improve testing on High DPI displays
* Add additional bootstrap calls to mimic the actual application
  • Loading branch information
droidmonkey committed Jan 3, 2020
1 parent 7250fd9 commit 7ad330e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/gui/TestGui.cpp
Expand Up @@ -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
Expand All @@ -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<DatabaseTabWidget*>("tabWidget");
m_mainWindow->show();
m_mainWindow->resize(1024, 768);
}

// Every test starts with opening the temp database
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1435,8 +1440,9 @@ int TestGui::addCannedEntries()

void TestGui::checkDatabase(QString dbFileName)
{
if (dbFileName.isEmpty())
if (dbFileName.isEmpty()) {
dbFileName = m_dbFilePath;
}

auto key = QSharedPointer<CompositeKey>::create();
key->addKey(QSharedPointer<PasswordKey>::create("a"));
Expand Down

0 comments on commit 7ad330e

Please sign in to comment.