Index: unittests/tst_views.cpp =================================================================== diff -u -ra51b1ec80d65c7cf9f7f3b86f45a637a6d42efc1 -rf8321d4b6a5489f797122321a4821b4eeaaa50cb --- unittests/tst_views.cpp (.../tst_views.cpp) (revision a51b1ec80d65c7cf9f7f3b86f45a637a6d42efc1) +++ unittests/tst_views.cpp (.../tst_views.cpp) (revision f8321d4b6a5489f797122321a4821b4eeaaa50cb) @@ -15,12 +15,10 @@ #include "tst_views.h" // Qt -#include // Project #include "vtreatmentadjustmentresponsebase.h" #include "vtreatmentadjustmentultrafiltrationstate.h" -#include "MTreatmentParameters.h" #include "filehandler.h" tst_views::tst_views(QObject *parent) : QObject(parent) { } @@ -567,18 +565,32 @@ QString dir = QString("/tmp/newTreatment_%0.json").arg(QDateTime::currentDateTime().toString(datetimeFormat)); QString oldFilename = view.saveNewTreatment(objectWritten, dir); + QDateTime startTime = QDateTime::currentDateTime(); + int elapsedSeconds = 0; + while (!QFile(oldFilename).exists()) + { + elapsedSeconds = startTime.secsTo(QDateTime::currentDateTime()); + } - QThread::msleep(500); + startTime = QDateTime::currentDateTime(); QString filename = view.saveNewTreatment(objectWritten, dir); QVERIFY(oldFilename != filename); + QVERIFY(elapsedSeconds < 0.5); + elapsedSeconds = 0; + QJsonObject objectReadTemp; + while (!FileHandler::readJSON(filename, objectReadTemp) || (objectWritten != objectReadTemp)) + { + elapsedSeconds = startTime.secsTo(QDateTime::currentDateTime()); + } - QThread::msleep(500); + QVERIFY(elapsedSeconds < 0.5); QJsonObject objectRead; QVERIFY(FileHandler::readJSON(filename, objectRead)); QCOMPARE(objectWritten, objectRead); + } /*! @@ -724,7 +736,7 @@ QString path = QString("/tmp/ranges_%0.json").arg(QDateTime::currentDateTime().toString(datetimeFormat));; - _FileSaver.concurrentSave(path, document.toJson(), false); + _FileSaver.onConcurrentSave(path, document.toJson(), false); QThread::msleep(500);