Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/testlockfile.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/testlockfile.cpp b/test/testlockfile.cpp
index 16f246fcf..d0dcc2ae5 100644
--- a/test/testlockfile.cpp
+++ b/test/testlockfile.cpp
@@ -570,6 +570,67 @@ private slots:
QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("A/a1"), &fileRecordUnlocked));
QVERIFY(fileRecordUnlocked._lockstate._locked);
}
+
+ void testSyncLockedFiles()
+ {
+ FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
+ QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
+
+ int nGET = 0, nPUT = 0;
+ QObject parent;
+ fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData) -> QNetworkReply * {
+ Q_UNUSED(outgoingData)
+ Q_UNUSED(request)
+
+ if (op == QNetworkAccessManager::PutOperation) {
+ ++nPUT;
+ } else if (op == QNetworkAccessManager::GetOperation) {
+ ++nGET;
+ }
+
+ return nullptr;
+ });
+
+ ItemCompletedSpy completeSpy(fakeFolder);
+
+ completeSpy.clear();
+ QVERIFY(fakeFolder.syncOnce());
+ QCOMPARE(nGET, 0);
+ QCOMPARE(nPUT, 0);
+
+ QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1"))->_locked, OCC::SyncFileItem::LockStatus::UnlockedItem);
+ OCC::SyncJournalFileRecord fileRecordBefore;
+ QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("A/a1"), &fileRecordBefore));
+ QVERIFY(!fileRecordBefore._lockstate._locked);
+
+ fakeFolder.remoteModifier().modifyLockState(QStringLiteral("A/a1"), FileModifier::LockState::FileLocked, 1, QStringLiteral("Nextcloud Office"), {}, QStringLiteral("richdocuments"), QDateTime::currentDateTime().toSecsSinceEpoch(), 1226);
+ fakeFolder.remoteModifier().setModTimeKeepEtag(QStringLiteral("A/a1"), QDateTime::currentDateTime());
+ fakeFolder.remoteModifier().appendByte(QStringLiteral("A/a1"));
+
+ completeSpy.clear();
+ QVERIFY(fakeFolder.syncOnce());
+
+ QCOMPARE(nGET, 1);
+ QCOMPARE(nPUT, 0);
+
+ QCOMPARE(completeSpy.findItem(QStringLiteral("A/a1"))->_locked, OCC::SyncFileItem::LockStatus::LockedItem);
+ OCC::SyncJournalFileRecord fileRecordLocked;
+ QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("A/a1"), &fileRecordLocked));
+ QVERIFY(fileRecordLocked._lockstate._locked);
+
+ completeSpy.clear();
+ QVERIFY(fakeFolder.syncOnce());
+
+ QCOMPARE(nGET, 1);
+ QCOMPARE(nPUT, 0);
+
+ OCC::SyncJournalFileRecord fileRecordAfter;
+ QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("A/a1"), &fileRecordAfter));
+ QVERIFY(fileRecordAfter._lockstate._locked);
+
+ auto expectedState = fakeFolder.currentLocalState();
+ QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
+ }
};
QTEST_GUILESS_MAIN(TestLockFile)