mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-18 11:51:51 +03:00
Unit tests. Test .lnk file with a real shortcut file. Test will hang if QFileInfo is used on .lnk files.
Signed-off-by: alex-z <blackslayer4@gmail.com>
This commit is contained in:
parent
f70d1c1079
commit
7501a03db6
3 changed files with 31 additions and 0 deletions
|
@ -101,6 +101,7 @@ configure_file(fakefiledrope2eefoldermetadata.json "${PROJECT_BINARY_DIR}/bin/fa
|
||||||
configure_file(e2etestsfakecert.pem "${PROJECT_BINARY_DIR}/bin/e2etestsfakecert.pem" COPYONLY)
|
configure_file(e2etestsfakecert.pem "${PROJECT_BINARY_DIR}/bin/e2etestsfakecert.pem" COPYONLY)
|
||||||
configure_file(e2etestsfakecertprivatekey.pem "${PROJECT_BINARY_DIR}/bin/e2etestsfakecertprivatekey.pem" COPYONLY)
|
configure_file(e2etestsfakecertprivatekey.pem "${PROJECT_BINARY_DIR}/bin/e2etestsfakecertprivatekey.pem" COPYONLY)
|
||||||
configure_file(e2etestsfakecertpublickey.pem "${PROJECT_BINARY_DIR}/bin/e2etestsfakecertpublickey.pem" COPYONLY)
|
configure_file(e2etestsfakecertpublickey.pem "${PROJECT_BINARY_DIR}/bin/e2etestsfakecertpublickey.pem" COPYONLY)
|
||||||
|
configure_file(fake2eelocksucceeded.json "${PROJECT_BINARY_DIR}/bin/fakeshortcut.base64" COPYONLY)
|
||||||
|
|
||||||
|
|
||||||
if(ADD_E2E_TESTS)
|
if(ADD_E2E_TESTS)
|
||||||
|
|
1
test/fakeshortcut.base64
Normal file
1
test/fakeshortcut.base64
Normal file
|
@ -0,0 +1 @@
|
||||||
|
TAAAAAEUAgAAAAAAwAAAAAAAAEbbQAAAIAAAAAAJorPzgNoB9zzzZuSO2gEACaKz84DaAdAmUQAAAAAAAQAAAAAAAAAAAAAAAAAAAH8BFAAfUOBP0CDqOmkQotgIACswMJ0ZAC9DOlwAAAAAAAAAAAAAAAAAAAAAAAAAjAAxAAAAAACPWAkbEQBQUk9HUkF+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vTQqHAqAy8RGkUDvSbsmL67hGR24Rc899HgoYAAAAJAACgQQAAADFTUFPiilhGvEw4Q7v8E5MmmG3OJQAAAAQAAAAAHwAAAAkAAABTAC0AMQAtADUALQAxADgAAAAAAAAAAAA5AAAAMVNQU7EWbUStjXBIp0hALqQ9eIwdAAAAaAAAAABIAAAAF1Nw2ThL+k6aiadcTJDozAAAAAAAAAAAAAAAAA==
|
|
@ -1368,6 +1368,8 @@ private slots:
|
||||||
FakeFolder fakeFolder{FileInfo{}};
|
FakeFolder fakeFolder{FileInfo{}};
|
||||||
auto vfs = setupVfs(fakeFolder);
|
auto vfs = setupVfs(fakeFolder);
|
||||||
|
|
||||||
|
qInfo("Starting .lnk test. It might hand and will get killed after timeout...");
|
||||||
|
|
||||||
// Create a Windows shortcut (.lnk) file
|
// Create a Windows shortcut (.lnk) file
|
||||||
fakeFolder.remoteModifier().insert("linkfile.lnk");
|
fakeFolder.remoteModifier().insert("linkfile.lnk");
|
||||||
|
|
||||||
|
@ -1379,6 +1381,33 @@ private slots:
|
||||||
triggerDownload(fakeFolder, "linkfile.lnk");
|
triggerDownload(fakeFolder, "linkfile.lnk");
|
||||||
QVERIFY(fakeFolder.syncOnce());
|
QVERIFY(fakeFolder.syncOnce());
|
||||||
QVERIFY(itemInstruction(completeSpy, "linkfile.lnk", CSYNC_INSTRUCTION_SYNC));
|
QVERIFY(itemInstruction(completeSpy, "linkfile.lnk", CSYNC_INSTRUCTION_SYNC));
|
||||||
|
|
||||||
|
// a real .lnk file contents stored as base64 for tests
|
||||||
|
QFile fakeShortcutBase64(QStringLiteral("fakeshortcut.base64"));
|
||||||
|
QVERIFY(fakeShortcutBase64.open(QFile::ReadOnly));
|
||||||
|
const auto fakeShortcutBase64Binary = QByteArray::fromBase64(fakeShortcutBase64.readAll());
|
||||||
|
fakeShortcutBase64.close();
|
||||||
|
|
||||||
|
// fill the .lnk file with binary data from real shortcut and turn it into OnlineOnly file
|
||||||
|
const QString shortcutFilePathOnDisk = fakeFolder.localPath() + "linkfile.lnk";
|
||||||
|
QFile shorcutFileOnDisk(shortcutFilePathOnDisk);
|
||||||
|
QVERIFY(shorcutFileOnDisk.open(QFile::WriteOnly));
|
||||||
|
QVERIFY(shorcutFileOnDisk.write(fakeShortcutBase64Binary));
|
||||||
|
shorcutFileOnDisk.close();
|
||||||
|
|
||||||
|
// run tests on it
|
||||||
|
::setPinState(shortcutFilePathOnDisk, PinState::OnlineOnly, cfapi::NoRecurse);
|
||||||
|
QVERIFY(fakeFolder.syncOnce());
|
||||||
|
QVERIFY(vfs->pinState("linkfile.lnk").isValid());
|
||||||
|
QVERIFY(itemInstruction(completeSpy, "linkfile.lnk", CSYNC_INSTRUCTION_SYNC));
|
||||||
|
|
||||||
|
// trigget download of online only .lnk file
|
||||||
|
triggerDownload(fakeFolder, "linkfile.lnk");
|
||||||
|
QVERIFY(fakeFolder.syncOnce());
|
||||||
|
QVERIFY(vfs->pinState("linkfile.lnk").isValid());
|
||||||
|
QVERIFY(itemInstruction(completeSpy, "linkfile.lnk", CSYNC_INSTRUCTION_SYNC));
|
||||||
|
|
||||||
|
qInfo("Finishing .lnk test");
|
||||||
}
|
}
|
||||||
|
|
||||||
void testFolderDoesNotUpdatePlaceholderMetadata()
|
void testFolderDoesNotUpdatePlaceholderMetadata()
|
||||||
|
|
Loading…
Reference in a new issue