1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
* This software is in the public domain, furnished "as is", without technical
* support, and with no warranty, express or implied, as to its usefulness for
* any purpose.
*
*/
#include <QtTest>
#include "testutils/syncenginetestutils.h"
#include <syncengine.h>
using namespace OCC;
class TestSyncDelete : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase_data()
{
QTest::addColumn<Vfs::Mode>("vfsMode");
QTest::addColumn<bool>("filesAreDehydrated");
QTest::newRow("Vfs::Off") << Vfs::Off << false;
if (VfsPluginManager::instance().isVfsPluginAvailable(Vfs::WindowsCfApi)) {
QTest::newRow("Vfs::WindowsCfApi dehydrated") << Vfs::WindowsCfApi << true;
// TODO: the hydrated version will fail due to an issue in the winvfs plugin, so leave it disabled for now.
// QTest::newRow("Vfs::WindowsCfApi hydrated") << Vfs::WindowsCfApi << false;
} else if (Utility::isWindows()) {
qWarning("Skipping Vfs::WindowsCfApi");
}
}
void testDeleteDirectoryWithNewFile()
{
QFETCH_GLOBAL(Vfs::Mode, vfsMode);
QFETCH_GLOBAL(bool, filesAreDehydrated);
FakeFolder fakeFolder(FileInfo::A12_B12_C12_S12(), vfsMode, filesAreDehydrated);
// Remove a directory on the server with new files on the client
fakeFolder.remoteModifier().remove(QStringLiteral("A"));
fakeFolder.localModifier().insert(QStringLiteral("A/hello.txt"));
// Symetry
fakeFolder.localModifier().remove(QStringLiteral("B"));
fakeFolder.remoteModifier().insert(QStringLiteral("B/hello.txt"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
// A/a1 must be gone because the directory was removed on the server, but hello.txt must be there
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("A/a1")));
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("A/hello.txt")));
// Symetry
QVERIFY(!fakeFolder.currentRemoteState().find(QStringLiteral("B/b1")));
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("B/hello.txt")));
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
void issue1329()
{
QFETCH_GLOBAL(Vfs::Mode, vfsMode);
QFETCH_GLOBAL(bool, filesAreDehydrated);
FakeFolder fakeFolder(FileInfo::A12_B12_C12_S12(), vfsMode, filesAreDehydrated);
fakeFolder.localModifier().remove(QStringLiteral("B"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
// Add a directory that was just removed in the previous sync:
fakeFolder.localModifier().mkdir(QStringLiteral("B"));
fakeFolder.localModifier().insert(QStringLiteral("B/b1"));
QVERIFY(fakeFolder.applyLocalModificationsAndSync());
QVERIFY(fakeFolder.currentRemoteState().find(QStringLiteral("B/b1")));
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
};
QTEST_GUILESS_MAIN(TestSyncDelete)
#include "testsyncdelete.moc"
|