diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 92b6a52e04..e9f4fac2a1 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -1466,6 +1466,7 @@ void TestGui::testDatabaseSettings() auto* dbSettingsStackedWidget = dbSettingsDialog->findChild("stackedWidget"); auto* transformRoundsSpinBox = dbSettingsDialog->findChild("transformRoundsSpinBox"); auto advancedToggle = dbSettingsDialog->findChild("advancedSettingsToggle"); + auto* dbSettingsButtonBox = dbSettingsDialog->findChild("buttonBox"); advancedToggle->setChecked(true); QApplication::processEvents(); @@ -1477,6 +1478,27 @@ void TestGui::testDatabaseSettings() QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter); QTRY_COMPARE(m_db->kdf()->rounds(), 123456); + // test disable and default values for maximum history items and size + triggerAction("actionDatabaseSettings"); + auto* historyMaxItemsCheckBox = dbSettingsDialog->findChild("historyMaxItemsCheckBox"); + auto* historyMaxItemsSpinBox = dbSettingsDialog->findChild("historyMaxItemsSpinBox"); + auto* historyMaxSizeCheckBox = dbSettingsDialog->findChild("historyMaxSizeCheckBox"); + auto* historyMaxSizeSpinBox = dbSettingsDialog->findChild("historyMaxSizeSpinBox"); + // test defaults + QCOMPARE(historyMaxItemsSpinBox->value(), Metadata::DefaultHistoryMaxItems); + QCOMPARE(historyMaxSizeSpinBox->value(), qRound(Metadata::DefaultHistoryMaxSize / qreal(1024 * 1024))); + // disable and test setting as well + historyMaxItemsCheckBox->setChecked(false); + historyMaxSizeCheckBox->setChecked(false); + QTest::mouseClick(dbSettingsButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton); + QTRY_COMPARE(m_db->metadata()->historyMaxItems(), -1); + QTRY_COMPARE(m_db->metadata()->historyMaxSize(), -1); + // then open to check the saved disabled state in gui + triggerAction("actionDatabaseSettings"); + QCOMPARE(historyMaxItemsCheckBox->isChecked(), false); + QCOMPARE(historyMaxSizeCheckBox->isChecked(), false); + QTest::mouseClick(dbSettingsButtonBox->button(QDialogButtonBox::Cancel), Qt::LeftButton); + checkSaveDatabase(); }