From 9406131e52f5cad9bdd44d74bf5be6e6ed21fb3e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 30 Oct 2024 12:17:27 +0800 Subject: [PATCH] Add test for correct handling of live photo mov deletion Signed-off-by: Claudio Cambra --- test/testlocaldiscovery.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/testlocaldiscovery.cpp b/test/testlocaldiscovery.cpp index 687b46d79..bb6bcdc01 100644 --- a/test/testlocaldiscovery.cpp +++ b/test/testlocaldiscovery.cpp @@ -333,6 +333,41 @@ private slots: QVERIFY(!fakeFolder.currentRemoteState().find("C/filename.ext")); } + void testRedownloadDeletedLivePhotoMov() + { + FakeFolder fakeFolder{FileInfo{}}; + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + const auto livePhotoImg = QStringLiteral("IMG_0001.heic"); + const auto livePhotoMov = QStringLiteral("IMG_0001.mov"); + fakeFolder.localModifier().insert(livePhotoImg); + fakeFolder.localModifier().insert(livePhotoMov); + + ItemCompletedSpy completeSpy(fakeFolder); + QVERIFY(fakeFolder.syncOnce()); + + QCOMPARE(completeSpy.findItem(livePhotoImg)->_status, SyncFileItem::Status::Success); + QCOMPARE(completeSpy.findItem(livePhotoMov)->_status, SyncFileItem::Status::Success); + + fakeFolder.remoteModifier().setIsLivePhoto(livePhotoImg, true); + fakeFolder.remoteModifier().setIsLivePhoto(livePhotoMov, true); + QVERIFY(fakeFolder.syncOnce()); + + SyncJournalFileRecord imgRecord; + QVERIFY(fakeFolder.syncJournal().getFileRecord(livePhotoImg, &imgRecord)); + QVERIFY(imgRecord._isLivePhoto); + + SyncJournalFileRecord movRecord; + QVERIFY(fakeFolder.syncJournal().getFileRecord(livePhotoMov, &movRecord)); + QVERIFY(movRecord._isLivePhoto); + + completeSpy.clear(); + fakeFolder.localModifier().remove(livePhotoMov); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(completeSpy.findItem(livePhotoMov)->_status, SyncFileItem::Status::Success); + QCOMPARE(completeSpy.findItem(livePhotoMov)->_instruction, CSYNC_INSTRUCTION_SYNC); + QCOMPARE(completeSpy.findItem(livePhotoMov)->_direction, SyncFileItem::Direction::Down); + } + void testCreateFileWithTrailingSpaces_localAndRemoteTrimmedDoNotExist_renameAndUploadFile() { FakeFolder fakeFolder{FileInfo{}};