mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 19:58:56 +03:00
Add test testCreateLocalPathsWithLeadingAndTrailingSpaces_syncOnSupportingOs.
- Fix discovery tests for files with invalid names. - Now leading/trailing spaces trigger an error only on Windows. Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
parent
c6bc7e630d
commit
cfb39b7034
1 changed files with 57 additions and 4 deletions
|
@ -358,6 +358,7 @@ private slots:
|
|||
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces1)->_status, SyncFileItem::Status::FileNameInvalid);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces2)->_status, SyncFileItem::Status::FileNameInvalid);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces3)->_status, SyncFileItem::Status::FileNameInvalid);
|
||||
|
@ -365,6 +366,15 @@ private slots:
|
|||
QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::FileNameInvalid);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::FileNameInvalid);
|
||||
QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::FileNameInvalid);
|
||||
#else
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces1)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces2)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces3)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::Success);
|
||||
#endif
|
||||
|
||||
fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces1);
|
||||
fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces2);
|
||||
|
@ -379,16 +389,14 @@ private slots:
|
|||
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, {QStringLiteral("foo"), QStringLiteral("bar"), QStringLiteral("bla"), QStringLiteral("A/foo"), QStringLiteral("A/bar"), QStringLiteral("A/bla")});
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces1)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces2)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces3)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::Success);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::NormalError);
|
||||
#else
|
||||
QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::Success);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -422,6 +430,43 @@ private slots:
|
|||
}
|
||||
}
|
||||
|
||||
void testCreateLocalPathsWithLeadingAndTrailingSpaces_syncOnSupportingOs()
|
||||
{
|
||||
FakeFolder fakeFolder{FileInfo()};
|
||||
fakeFolder.localModifier().mkdir("A");
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
|
||||
|
||||
const QString fileWithSpaces1("A/ space");
|
||||
const QString fileWithSpaces2("A/ space ");
|
||||
const QString fileWithSpaces3("A/space ");
|
||||
const QString folderWithSpaces1("A ");
|
||||
const QString folderWithSpaces2(" B ");
|
||||
|
||||
fakeFolder.localModifier().insert(fileWithSpaces1);
|
||||
fakeFolder.localModifier().insert(fileWithSpaces2);
|
||||
fakeFolder.localModifier().insert(fileWithSpaces3);
|
||||
fakeFolder.localModifier().mkdir(folderWithSpaces1);
|
||||
fakeFolder.localModifier().mkdir(folderWithSpaces2);
|
||||
|
||||
ItemCompletedSpy completeSpy(fakeFolder);
|
||||
completeSpy.clear();
|
||||
|
||||
QVERIFY(fakeFolder.syncOnce());
|
||||
if (!Utility::isWindows()) {
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces1)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces2)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(fileWithSpaces3)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(folderWithSpaces1)->_status, SyncFileItem::Status::Success);
|
||||
QCOMPARE(completeSpy.findItem(folderWithSpaces2)->_status, SyncFileItem::Status::Success);
|
||||
QVERIFY(fakeFolder.remoteModifier().find(fileWithSpaces1));
|
||||
QVERIFY(fakeFolder.remoteModifier().find(fileWithSpaces2));
|
||||
QVERIFY(fakeFolder.remoteModifier().find(fileWithSpaces3));
|
||||
QVERIFY(fakeFolder.remoteModifier().find(folderWithSpaces1));
|
||||
QVERIFY(fakeFolder.remoteModifier().find(folderWithSpaces2));
|
||||
}
|
||||
}
|
||||
|
||||
void testCreateFileWithTrailingSpaces_remoteGetRenamedManually()
|
||||
{
|
||||
// On Windows we can't create files/folders with leading/trailing spaces locally. So, we have to fail those items. On other OSs - we just sync them down normally.
|
||||
|
@ -481,7 +526,15 @@ private slots:
|
|||
QVERIFY(fakeFolder.syncOnce());
|
||||
|
||||
QVERIFY(fakeFolder.currentRemoteState().find(fileTrimmed));
|
||||
QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces));
|
||||
|
||||
if (Utility::isWindows()) {
|
||||
// no file with spaces on Windows
|
||||
QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces));
|
||||
} else {
|
||||
//Linux/Mac OS allows spaces
|
||||
QVERIFY(fakeFolder.currentRemoteState().find(fileWithSpaces));
|
||||
}
|
||||
|
||||
QVERIFY(fakeFolder.currentLocalState().find(fileWithSpaces));
|
||||
QVERIFY(fakeFolder.currentLocalState().find(fileTrimmed));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue