testsyncdelete.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * This software is in the public domain, furnished "as is", without technical
  3. * support, and with no warranty, express or implied, as to its usefulness for
  4. * any purpose.
  5. *
  6. */
  7. #include <QtTest>
  8. #include "syncenginetestutils.h"
  9. #include <syncengine.h>
  10. using namespace OCC;
  11. class TestSyncDelete : public QObject
  12. {
  13. Q_OBJECT
  14. private slots:
  15. void testDeleteDirectoryWithNewFile()
  16. {
  17. FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
  18. // Remove a directory on the server with new files on the client
  19. fakeFolder.remoteModifier().remove("A");
  20. fakeFolder.localModifier().insert("A/hello.txt");
  21. // Symetry
  22. fakeFolder.localModifier().remove("B");
  23. fakeFolder.remoteModifier().insert("B/hello.txt");
  24. QVERIFY(fakeFolder.syncOnce());
  25. // A/a1 must be gone because the directory was removed on the server, but hello.txt must be there
  26. QVERIFY(!fakeFolder.currentRemoteState().find("A/a1"));
  27. QVERIFY(fakeFolder.currentRemoteState().find("A/hello.txt"));
  28. // Symetry
  29. QVERIFY(!fakeFolder.currentRemoteState().find("B/b1"));
  30. QVERIFY(fakeFolder.currentRemoteState().find("B/hello.txt"));
  31. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  32. }
  33. void issue1329()
  34. {
  35. FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
  36. fakeFolder.localModifier().remove("B");
  37. QVERIFY(fakeFolder.syncOnce());
  38. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  39. // Add a directory that was just removed in the previous sync:
  40. fakeFolder.localModifier().mkdir("B");
  41. fakeFolder.localModifier().insert("B/b1");
  42. QVERIFY(fakeFolder.syncOnce());
  43. QVERIFY(fakeFolder.currentRemoteState().find("B/b1"));
  44. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  45. }
  46. };
  47. QTEST_GUILESS_MAIN(TestSyncDelete)
  48. #include "testsyncdelete.moc"