testexcludedfiles.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 STR_(X) #X
  11. #define STR(X) STR_(X)
  12. #define BIN_PATH STR(OWNCLOUD_BIN_PATH)
  13. class TestExcludedFiles: public QObject
  14. {
  15. Q_OBJECT
  16. private slots:
  17. void testFun()
  18. {
  19. auto & excluded = ExcludedFiles::instance();
  20. bool excludeHidden = true;
  21. bool keepHidden = false;
  22. bool x = excluded.isExcluded("/a/b", "/a", keepHidden);
  23. QVERIFY(!excluded.isExcluded("/a/b", "/a", keepHidden));
  24. QVERIFY(!excluded.isExcluded("/a/b~", "/a", keepHidden));
  25. QVERIFY(!excluded.isExcluded("/a/.b", "/a", keepHidden));
  26. QVERIFY(excluded.isExcluded("/a/.b", "/a", excludeHidden));
  27. QString path(BIN_PATH);
  28. path.append("/sync-exclude.lst");
  29. excluded.addExcludeFilePath(path);
  30. excluded.reloadExcludes();
  31. QVERIFY(!excluded.isExcluded("/a/b", "/a", keepHidden));
  32. QVERIFY(excluded.isExcluded("/a/b~", "/a", keepHidden));
  33. QVERIFY(!excluded.isExcluded("/a/.b", "/a", keepHidden));
  34. QVERIFY(excluded.isExcluded("/a/.Trashes", "/a", keepHidden));
  35. QVERIFY(excluded.isExcluded("/a/foo_conflict-bar", "/a", keepHidden));
  36. QVERIFY(excluded.isExcluded("/a/.b", "/a", excludeHidden));
  37. }
  38. };
  39. QTEST_APPLESS_MAIN(TestExcludedFiles)
  40. #include "testexcludedfiles.moc"