From e1a50e10551ec20aaf293be4a3a5df382f5d05fe Mon Sep 17 00:00:00 2001 From: jNullj Date: Sat, 11 Feb 2023 12:53:40 +0200 Subject: [PATCH] Improve autosaveDelay test stability After looking at CI tests in pull request #9100 the margin for the file save delay was too short. This commit extends the margin to 10 seconds and simplifies the test. --- tests/gui/TestGui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 26167001c9..8abbe10bab 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -1560,6 +1560,7 @@ void TestGui::testDatabaseSettings() // 2.e) Save changes editEntryWidget->setCurrentPage(0); editEntryWidgetButtonBox = editEntryWidget->findChild("buttonBox"); + QDateTime lastEntryModifiedTime = QDateTime::currentDateTime(); QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton); // 3 Double check both true negative and true positive @@ -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);