mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 06:55:59 +03:00
ExcludedFiles: Add test
This commit is contained in:
parent
51a2e6c580
commit
225da68832
3 changed files with 52 additions and 0 deletions
|
@ -39,6 +39,7 @@ owncloud_add_test(XmlParse "")
|
|||
owncloud_add_test(FileSystem "")
|
||||
owncloud_add_test(TransChecksumValidator "")
|
||||
|
||||
owncloud_add_test(ExcludedFiles "")
|
||||
|
||||
SET(FolderMan_SRC ../src/gui/folderman.cpp)
|
||||
list(APPEND FolderMan_SRC ../src/gui/folder.cpp )
|
||||
|
|
|
@ -24,5 +24,6 @@ macro(owncloud_add_test test_class additional_cpp)
|
|||
)
|
||||
|
||||
add_definitions(-DOWNCLOUD_TEST)
|
||||
add_definitions(-DOWNCLOUD_BIN_PATH=${CMAKE_BINARY_DIR}/bin)
|
||||
add_test(NAME ${OWNCLOUD_TEST_CLASS}Test COMMAND ${OWNCLOUD_TEST_CLASS}Test)
|
||||
endmacro()
|
||||
|
|
50
test/testexcludedfiles.h
Normal file
50
test/testexcludedfiles.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include "excludedfiles.h"
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
#define STR_(X) #X
|
||||
#define STR(X) STR_(X)
|
||||
#define BIN_PATH STR(OWNCLOUD_BIN_PATH)
|
||||
|
||||
class TestExcludedFiles: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testFun()
|
||||
{
|
||||
auto & excluded = ExcludedFiles::instance();
|
||||
bool excludeHidden = true;
|
||||
bool keepHidden = false;
|
||||
|
||||
QVERIFY(!excluded.isExcluded("/a/b", "b", keepHidden));
|
||||
QVERIFY(!excluded.isExcluded("/a/b~", "b~", keepHidden));
|
||||
QVERIFY(!excluded.isExcluded("/a/.b", ".b", keepHidden));
|
||||
QVERIFY(excluded.isExcluded("/a/.b", ".b", excludeHidden));
|
||||
|
||||
QString path(BIN_PATH);
|
||||
path.append("/sync-exclude.lst");
|
||||
excluded.addExcludeFilePath(path);
|
||||
excluded.reloadExcludes();
|
||||
|
||||
QVERIFY(!excluded.isExcluded("/a/b", "b", keepHidden));
|
||||
QVERIFY(excluded.isExcluded("/a/b~", "b~", keepHidden));
|
||||
QVERIFY(!excluded.isExcluded("/a/.b", ".b", keepHidden));
|
||||
QVERIFY(excluded.isExcluded("/a/.Trashes", ".Trashes", keepHidden));
|
||||
QVERIFY(excluded.isExcluded("/a/foo_conflict-bar", "foo_conflict-bar", keepHidden));
|
||||
QVERIFY(excluded.isExcluded("/a/.b", ".b", excludeHidden));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in a new issue