testexcludedfiles.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "excludedfiles.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. auto & excluded = ExcludedFiles::instance();
  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.reloadExcludes();
  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/.b", "/a", excludeHidden));
  32. }
  33. };
  34. QTEST_APPLESS_MAIN(TestExcludedFiles)
  35. #include "testexcludedfiles.moc"