Skip to content

Commit

Permalink
Improve autosaveDelay test stability
Browse files Browse the repository at this point in the history
After looking at CI tests in pull request keepassxreboot#9100 the margin for the file save delay was too short.
This commit extends the margin to 10 seconds and simplifies the test.
  • Loading branch information
jNullj committed Feb 11, 2023
1 parent 470ae27 commit e1a50e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/gui/TestGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,7 @@ void TestGui::testDatabaseSettings()
// 2.e) Save changes
editEntryWidget->setCurrentPage(0);
editEntryWidgetButtonBox = editEntryWidget->findChild<QDialogButtonBox*>("buttonBox");
QDateTime lastEntryModifiedTime = QDateTime::currentDateTime();
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);

// 3 Double check both true negative and true positive
Expand All @@ -1569,11 +1570,10 @@ void TestGui::testDatabaseSettings()
QCOMPARE(fileInfo.lastModified(), lastModified);

// 3.b) Test modification time after expected
int marginDelay = 500; // error margin to account for extra delays (ms)
Tools::wait(autosaveDelayTestValue * 60 * 1000 / 2 + marginDelay / 2);
int marginDelay = 10000; // error margin to account for extra save delays (ms)
Tools::wait(autosaveDelayTestValue * 60 * 1000 / 2 + marginDelay);
fileInfo.refresh();
QVERIFY2(fileInfo.lastModified().msecsTo(QDateTime::currentDateTime()) < marginDelay,
"AutosaveDelay: wrong timing");
QVERIFY2(fileInfo.lastModified() >= lastEntryModifiedTime, "AutosaveDelay: wrong timing");

// 4 cleanup
config()->set(Config::AutoSaveAfterEveryChange, false);
Expand Down

0 comments on commit e1a50e1

Please sign in to comment.