testexcludedfiles.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 "csync_exclude.h"
  9. using namespace OCC;
  10. #define EXCLUDE_LIST_FILE SOURCEDIR "/../../sync-exclude.lst"
  11. class TestExcludedFiles: public QObject
  12. {
  13. Q_OBJECT
  14. private slots:
  15. void testFun()
  16. {
  17. ExcludedFiles excluded;
  18. bool excludeHidden = true;
  19. bool keepHidden = false;
  20. QVERIFY(!excluded.isExcluded("/a/b", "/a", keepHidden));
  21. QVERIFY(!excluded.isExcluded("/a/b~", "/a", keepHidden));
  22. QVERIFY(!excluded.isExcluded("/a/.b", "/a", keepHidden));
  23. QVERIFY(excluded.isExcluded("/a/.b", "/a", excludeHidden));
  24. excluded.addExcludeFilePath(EXCLUDE_LIST_FILE);
  25. excluded.reloadExcludeFiles();
  26. QVERIFY(!excluded.isExcluded("/a/b", "/a", keepHidden));
  27. QVERIFY(excluded.isExcluded("/a/b~", "/a", keepHidden));
  28. QVERIFY(!excluded.isExcluded("/a/.b", "/a", keepHidden));
  29. QVERIFY(excluded.isExcluded("/a/.Trashes", "/a", keepHidden));
  30. QVERIFY(excluded.isExcluded("/a/foo_conflict-bar", "/a", keepHidden));
  31. QVERIFY(excluded.isExcluded("/a/foo (conflicted copy bar)", "/a", keepHidden));
  32. QVERIFY(excluded.isExcluded("/a/.b", "/a", excludeHidden));
  33. }
  34. };
  35. QTEST_APPLESS_MAIN(TestExcludedFiles)
  36. #include "testexcludedfiles.moc"