From 0db095e02a3cc311a1121ab1b427c92c59687db7 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 4 Jul 2017 09:57:22 +0200 Subject: [PATCH] SyncEngineTest: Fix test reliability There was a rounding issue in the mtimes which sometimes resulted in an off-by-one error. Caused by storing a full QDateTime in the FileInfo but the mtime saved to the disk being truncated to seconds. --- test/testsyncengine.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index 1a9ac42d1..8835bd575 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -392,9 +392,7 @@ private slots: */ void testSyncFileItemProperties() { - FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() }; - - auto initialMtime = fakeFolder.currentLocalState().find("A/a1")->lastModified; + auto initialMtime = QDateTime::currentDateTime().addDays(-7); auto changedMtime = QDateTime::currentDateTime().addDays(-4); auto changedMtime2 = QDateTime::currentDateTime().addDays(-3); @@ -403,6 +401,15 @@ private slots: changedMtime.setMSecsSinceEpoch(changedMtime.toMSecsSinceEpoch() / 1000 * 1000); changedMtime2.setMSecsSinceEpoch(changedMtime2.toMSecsSinceEpoch() / 1000 * 1000); + // Ensure the initial mtimes are as expected + auto initialFileInfo = FileInfo::A12_B12_C12_S12(); + initialFileInfo.setModTime("A/a1", initialMtime); + initialFileInfo.setModTime("B/b1", initialMtime); + initialFileInfo.setModTime("C/c1", initialMtime); + + FakeFolder fakeFolder{ initialFileInfo }; + + // upload a fakeFolder.localModifier().appendByte("A/a1"); fakeFolder.localModifier().setModTime("A/a1", changedMtime);