Skip to content

Commit

Permalink
Add tests for autosaveDelay gui and metadata
Browse files Browse the repository at this point in the history
Try to toggle in gui, set a value, save it.
Chcek value saved is currect in metadata.
Check that on loading saved value presented in gui and toggeled.

Part of issue keepassxreboot#8553
  • Loading branch information
jNullj committed Jul 1, 2023
1 parent b1273cc commit 7f1486c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/gui/TestGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,10 @@ void TestGui::testDatabaseSettings()
auto* dbSettingsStackedWidget = dbSettingsDialog->findChild<QStackedWidget*>("stackedWidget");
auto* transformRoundsSpinBox = dbSettingsDialog->findChild<QSpinBox*>("transformRoundsSpinBox");
auto advancedToggle = dbSettingsDialog->findChild<QCheckBox*>("advancedSettingsToggle");
auto* autosaveDelayCheckBox = dbSettingsDialog->findChild<QCheckBox*>("autosaveDelayCheckBox");
auto* autosaveDelaySpinBox = dbSettingsDialog->findChild<QSpinBox*>("autosaveDelaySpinBox");
auto* dbSettingsButtonBox = dbSettingsDialog->findChild<QDialogButtonBox*>("buttonBox");
int autosaveDelayTestValue = 2;

advancedToggle->setChecked(true);
QApplication::processEvents();
Expand All @@ -1481,7 +1485,20 @@ void TestGui::testDatabaseSettings()
QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter);
QTRY_COMPARE(m_db->kdf()->rounds(), 123456);

// Test loading default values and setting autosaveDelay
triggerAction("actionDatabaseSettings");
QVERIFY(autosaveDelayCheckBox->isChecked() == false);
autosaveDelayCheckBox->toggle();
autosaveDelaySpinBox->setValue(autosaveDelayTestValue);
QTest::mouseClick(dbSettingsButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
QTRY_COMPARE(m_db->metadata()->autosaveDelayMin(), autosaveDelayTestValue);

checkSaveDatabase();

// Test loading autosaveDelay non-default values
triggerAction("actionDatabaseSettings");
QTRY_COMPARE(autosaveDelayCheckBox->isChecked(), true);
QTRY_COMPARE(autosaveDelaySpinBox->value(), autosaveDelayTestValue);
}

void TestGui::testKeePass1Import()
Expand Down

0 comments on commit 7f1486c

Please sign in to comment.