Comparar commits

..

20 Commits

Autor SHA1 Mensagem Data
Olivier Goffart 172689d35c Merge remote-tracking branch 'origin/2.3' 2017-02-14 15:08:10 +01:00
Jocelyn Turcotte 60a4a742a3 Disable tests uncompatible with Qt4 for that build 2017-02-14 14:32:41 +01:00
Jocelyn Turcotte b26db062d2 Fix the UNIT_TESTING build on Windows
- Put all tests in the bin directory so that DLLs can be loaded
- Add missing exports
- Skip tests that use code depending on zlib
- The "GMT" timezone is named differently, use the int constructor instead

5 tests are still failing, it's not really worth fixing at the moment
since no developper is currently using Windows as its main platform.
2017-02-14 14:32:41 +01:00
Jocelyn Turcotte 611f633ba8 Fix FolderManTest on macOS
On macOS /var is a symlink to /private/var and we have to make sure that we
use the canonical path before and after it enters the code to make sure we
compare paths correctly.
2017-02-14 14:32:41 +01:00
Jocelyn Turcotte 3265948458 Fix ExcludedFilesTest on macOS
Use the same logic to find sync-exclude as check_csync_exclude.c
2017-02-14 14:32:41 +01:00
Jocelyn Turcotte 0e3e9d5991 Fix FileSystemTest on macOS 2017-02-14 14:32:41 +01:00
Jocelyn Turcotte 0be6cd3bf7 Fix FolderWatcherTest on macOS and Windows
- We need to use a QGuiApplication on macOS or else we don't get notifications
- Switch to use QSignalSpy rather than lists and sleeps
- Use system() for all modifications since we pass kFSEventStreamCreateFlagIgnoreSelf
- Keep using the local process on Windows since it catches its own events
2017-02-14 14:32:41 +01:00
Jocelyn Turcotte 867b78052d Fix UtilityTest on macOS 2017-02-14 14:32:41 +01:00
Olivier Goffart 058f7df635 Folder: remove unused variable 2017-02-14 10:10:07 +01:00
Jenkins for ownCloud c1552d7984 [tx-robot] updated from transifex 2017-02-14 02:18:27 +01:00
Markus Goetz 575b981542 Modify Jenkinsfile for 2.3 2017-02-13 14:47:51 +01:00
Jenkins for ownCloud 0d0af95956 [tx-robot] updated from transifex 2017-02-13 02:18:28 +01:00
Jenkins for ownCloud 6c5d873647 [tx-robot] updated from transifex 2017-02-12 02:18:28 +01:00
Jenkins for ownCloud 71187e1744 [tx-robot] updated from transifex 2017-02-11 02:18:34 +01:00
Christian Kamm 006ce854a6 Doc: For conflicts, the local file is renamed #5521 2017-02-10 12:50:35 +01:00
Jenkins for ownCloud 697178bab6 [tx-robot] updated from transifex 2017-02-10 02:18:29 +01:00
Jenkins for ownCloud d8a86da377 [tx-robot] updated from transifex 2017-02-09 02:18:33 +01:00
Jocelyn Turcotte d1dace9e7f Remove unneeded Q_DECLARE_METATYPE 2017-02-08 17:57:20 +01:00
Jocelyn Turcotte 1cec2ca13d Fix TestSyncEngine::abortAfterFailedMkdir
It could be possible that _firstJob is marked as finished if
aborted before its parent PropagateDirectory was marked as finished,
allowing a posted scheduleNextJob call to schedule the child job
in-between.
2017-02-08 17:32:04 +01:00
Jocelyn Turcotte 1d9e08d109 Skip TestSyncEngine::abortAfterFailedMkdir 2017-02-08 17:25:32 +01:00
56 arquivos alterados com 6369 adições e 5574 exclusões
+2
Ver Arquivo
@@ -7,6 +7,8 @@ endif()
project(client)
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(OEM_THEME_DIR "" CACHE STRING "Define directory containing a custom theme")
if ( EXISTS ${OEM_THEME_DIR}/OEM.cmake )
include ( ${OEM_THEME_DIR}/OEM.cmake )
+1 -1
Ver Arquivo
@@ -39,7 +39,7 @@ node('CLIENT') {
stage 'Win32'
def win32 = docker.image('deepdiver/docker-owncloud-client-win32:latest')
def win32 = docker.image('guruz/docker-owncloud-client-win32:latest')
win32.pull() // make sure we have the latest available from Docker Hub
win32.inside {
sh '''
+1 -1
Ver Arquivo
@@ -5,7 +5,7 @@ set( MIRALL_VERSION_YEAR 2016 )
set( MIRALL_SOVERSION 0 )
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
set( MIRALL_VERSION_SUFFIX "beta1") #e.g. beta1, beta2, rc1
set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
if( NOT DEFINED MIRALL_VERSION_BUILD )
-1
Ver Arquivo
@@ -28,7 +28,6 @@ include(ConfigureChecks.cmake)
set(SOURCE_DIR ${CMAKE_SOURCE_DIR})
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
+1 -1
Ver Arquivo
@@ -207,7 +207,7 @@ __attribute__ ((packed))
#endif
;
void csync_file_stat_free(csync_file_stat_t *st);
OCSYNC_EXPORT void csync_file_stat_free(csync_file_stat_t *st);
/*
* context for the treewalk function
+5 -7
Ver Arquivo
@@ -56,17 +56,15 @@ int csync_get_statedb_exists(CSYNC *ctx);
*
* @return 0 on success, less than 0 if an error occurred with errno set.
*/
int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb);
OCSYNC_EXPORT int csync_statedb_load(CSYNC *ctx, const char *statedb, sqlite3 **pdb);
int csync_statedb_close(CSYNC *ctx);
OCSYNC_EXPORT int csync_statedb_close(CSYNC *ctx);
csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash);
OCSYNC_EXPORT csync_file_stat_t *csync_statedb_get_stat_by_hash(CSYNC *ctx, uint64_t phash);
csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, uint64_t inode);
OCSYNC_EXPORT csync_file_stat_t *csync_statedb_get_stat_by_inode(CSYNC *ctx, uint64_t inode);
csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx, const char *file_id);
char *csync_statedb_get_etag(CSYNC *ctx, uint64_t jHash);
OCSYNC_EXPORT csync_file_stat_t *csync_statedb_get_stat_by_file_id(CSYNC *ctx, const char *file_id);
/**
* @brief Query all files metadata inside and below a path.
+10 -5
Ver Arquivo
@@ -132,11 +132,16 @@ changed and no synchronization occurs.
In the event a file has changed on both the local and the remote repository
since the last sync run, it can not easily be decided which version of the file
is the one that should be used. However, changes to any side will not be lost. Instead,
a *conflict case* is created. The client resolves this conflict by creating a
conflict file of the older of the two files and saving the newer file under the
original file name. Conflict files are always created on the client and never
on the server. The conflict file uses the same name as the original file, but
is appended with the timestamp of the conflict detection.
a *conflict case* is created. The client resolves this conflict by renaming the
local file, appending a conflict label and timestamp, and saving the remote file
under the original file name.
Example: Assume there is a conflict in message.txt because its contents have
changed both locally and remotely since the last sync run. The local file with
the local changes will be renamed to message_conflict-20160101-153110.txt and
the remote file will be downloaded and saved as message.txt.
Conflict files are always created on the client and never on the server.
.. _ignored-files-label:
+22
Ver Arquivo
@@ -697,6 +697,24 @@ X-GNOME-Autostart-Delay=3
# Translations
# Translations
# Translations
# Translations
# Translations
# Translations
# Translations
# Translations
Comment[oc]=@APPLICATION_NAME@ sincronizacion del client
GenericName[oc]=Dorsièr de Sincronizacion
@@ -753,6 +771,10 @@ Comment[he]=@APPLICATION_NAME@ לקוח סנכון שולחן עבודה
GenericName[he]=סנכון תיקייה
Name[he]=@APPLICATION_NAME@ לקוח סנכרון שולחן עבודה
Icon[he]=@APPLICATION_EXECUTABLE@
Comment[ia]=@APPLICATION_NAME@ cliente de synchronisation pro scriptorio
GenericName[ia]=Synchronisar Dossier
Name[ia]=@APPLICATION_NAME@ cliente de synchronisation pro scriptorio
Icon[ia]=@APPLICATION_EXECUTABLE@
Comment[id]=Klien sinkronisasi desktop @APPLICATION_NAME@
GenericName[id]=Folder Sync
Name[id]=Klien sync desktop @APPLICATION_NAME@
-1
Ver Arquivo
@@ -1,7 +1,6 @@
# TODO: OSX and LIB_ONLY seem to require this to go to binary dir only
if(NOT TOKEN_AUTH_ONLY)
endif()
set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(synclib_NAME ${APPLICATION_EXECUTABLE}sync)
-1
Ver Arquivo
@@ -53,7 +53,6 @@ Folder::Folder(const FolderDefinition& definition,
, _accountState(accountState)
, _definition(definition)
, _csyncUnavail(false)
, _wipeDb(false)
, _proxyDirty(true)
, _lastSyncDuration(0)
, _consecutiveFailingSyncs(0)
-1
Ver Arquivo
@@ -324,7 +324,6 @@ private:
SyncResult _syncResult;
QScopedPointer<SyncEngine> _engine;
bool _csyncUnavail;
bool _wipeDb;
bool _proxyDirty;
QPointer<RequestEtagJob> _requestEtagJob;
QString _lastEtag;
-2
Ver Arquivo
@@ -515,5 +515,3 @@ QString SocketApi::buildRegisterPathMessage(const QString& path)
}
} // namespace OCC
Q_DECLARE_METATYPE(OCC::SocketListener)
+1 -1
Ver Arquivo
@@ -84,7 +84,7 @@ QString OWNCLOUDSYNC_EXPORT longWinPath( const QString& inpath );
*/
time_t OWNCLOUDSYNC_EXPORT getModTime(const QString& filename);
bool setModTime(const QString &filename, time_t modTime);
bool OWNCLOUDSYNC_EXPORT setModTime(const QString &filename, time_t modTime);
/**
* @brief Get the size for a file
+1 -1
Ver Arquivo
@@ -662,7 +662,7 @@ void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status)
bool wasFirstJob = false;
if (subJob == _firstJob.data()) {
wasFirstJob = true;
_firstJob.reset();
_firstJob.take();
} else {
int i = _subJobs.indexOf(subJob);
ASSERT(i >= 0);
+1 -1
Ver Arquivo
@@ -227,7 +227,7 @@ public:
private slots:
bool possiblyRunNextJob(PropagatorJob *next) {
if (next->_state == NotYetStarted) {
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)), Qt::QueuedConnection);
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)));
connect(next, SIGNAL(itemCompleted(const SyncFileItemPtr &)), this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
connect(next, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
connect(next, SIGNAL(ready()), this, SIGNAL(ready()));
+7 -8
Ver Arquivo
@@ -273,14 +273,13 @@ void Utility::usleep(int usec)
bool Utility::fsCasePreserving()
{
bool re = false;
if( isWindows() || isMac() ) {
re = true;
} else {
bool isTest = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING").toInt();
re = isTest;
}
return re;
#ifndef WITH_TESTING
QByteArray env = qgetenv("OWNCLOUD_TEST_CASE_PRESERVING");
if (!env.isEmpty())
return env.toInt();
#endif
return isWindows() || isMac();
}
bool Utility::fileNamesEqual( const QString& fn1, const QString& fn2)
+8 -14
Ver Arquivo
@@ -9,7 +9,6 @@ setup_qt()
include(owncloud_add_test.cmake)
owncloud_add_test(OwncloudPropagator "")
owncloud_add_test(Utility "")
owncloud_add_test(Updater "")
SET(FolderWatcher_SRC ../src/gui/folderwatcher.cpp)
@@ -24,31 +23,29 @@ IF( APPLE )
list(APPEND FolderWatcher_SRC ../src/gui/folderwatcher_mac.cpp)
list(APPEND FolderWatcher_SRC ../src/gui/socketapisocket_mac.mm)
ENDIF()
owncloud_add_test(FolderWatcher "${FolderWatcher_SRC}")
if( UNIX AND NOT APPLE )
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
endif(HAVE_QT5 AND NOT BUILD_WITH_QT4)
endif(UNIX AND NOT APPLE)
owncloud_add_test(CSyncSqlite "")
owncloud_add_test(NetrcParser ../src/cmd/netrcparser.cpp)
owncloud_add_test(OwnSql "")
owncloud_add_test(SyncJournalDB "")
owncloud_add_test(SyncFileItem "")
owncloud_add_test(ConcatUrl "")
owncloud_add_test(XmlParse "")
owncloud_add_test(FileSystem "")
owncloud_add_test(ChecksumValidator "")
owncloud_add_test(ExcludedFiles "")
if(HAVE_QT5 AND NOT BUILD_WITH_QT4)
owncloud_add_test(FileSystem "")
owncloud_add_test(Utility "")
owncloud_add_test(SyncEngine "syncenginetestutils.h")
owncloud_add_test(SyncFileStatusTracker "syncenginetestutils.h")
owncloud_add_test(ChunkingNg "syncenginetestutils.h")
owncloud_add_test(UploadReset "syncenginetestutils.h")
owncloud_add_test(FolderWatcher "${FolderWatcher_SRC}")
if( UNIX AND NOT APPLE )
owncloud_add_test(InotifyWatcher "${FolderWatcher_SRC}")
endif(UNIX AND NOT APPLE)
owncloud_add_benchmark(LargeSync "syncenginetestutils.h")
endif(HAVE_QT5 AND NOT BUILD_WITH_QT4)
@@ -60,8 +57,5 @@ list(APPEND FolderMan_SRC ../src/gui/syncrunfilelog.cpp )
list(APPEND FolderMan_SRC ../src/gui/lockwatcher.cpp )
list(APPEND FolderMan_SRC ${FolderWatcher_SRC})
list(APPEND FolderMan_SRC stub.cpp )
#include_directories(${QTKEYCHAIN_INCLUDE_DIR})
#include_directories(${CMAKE_BINARY_DIR}/src/gui)
#include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/qjson)
owncloud_add_test(FolderMan "${FolderMan_SRC}")
+2
Ver Arquivo
@@ -12,6 +12,7 @@ macro(owncloud_add_test test_class additional_cpp)
add_executable(${OWNCLOUD_TEST_CLASS}Test test${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp ${additional_cpp})
qt5_use_modules(${OWNCLOUD_TEST_CLASS}Test Test Sql Xml Network)
set_target_properties(${OWNCLOUD_TEST_CLASS}Test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
target_link_libraries(${OWNCLOUD_TEST_CLASS}Test
updater
@@ -40,6 +41,7 @@ macro(owncloud_add_benchmark test_class additional_cpp)
add_executable(${OWNCLOUD_TEST_CLASS}Bench benchmarks/bench${OWNCLOUD_TEST_CLASS_LOWERCASE}.cpp ${additional_cpp})
qt5_use_modules(${OWNCLOUD_TEST_CLASS}Bench Test Sql Xml Network)
set_target_properties(${OWNCLOUD_TEST_CLASS}Bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY})
target_link_libraries(${OWNCLOUD_TEST_CLASS}Bench
updater
+1 -1
Ver Arquivo
@@ -345,7 +345,7 @@ public:
} else
xml.writeEmptyElement(davUri, QStringLiteral("resourcetype"));
auto gmtDate = fileInfo.lastModified.toTimeZone(QTimeZone("GMT"));
auto gmtDate = fileInfo.lastModified.toTimeZone(QTimeZone(0));
auto stringDate = gmtDate.toString("ddd, dd MMM yyyy HH:mm:ss 'GMT'");
xml.writeTextElement(davUri, QStringLiteral("getlastmodified"), stringDate);
xml.writeTextElement(davUri, QStringLiteral("getcontentlength"), QString::number(fileInfo.size));
+8 -3
Ver Arquivo
@@ -55,7 +55,6 @@ using namespace OCC;
private slots:
void initTestCase() {
qDebug() << Q_FUNC_INFO;
_root = QDir::tempPath() + "/" + "test_" + QString::number(qrand());
QDir rootDir(_root);
@@ -65,7 +64,9 @@ using namespace OCC;
}
void testUploadChecksummingAdler() {
#ifndef ZLIB_FOUND
QSKIP("ZLIB not found.", SkipSingle);
#else
ComputeChecksum *vali = new ComputeChecksum(this);
_expectedType = "Adler32";
vali->setChecksumType(_expectedType);
@@ -81,6 +82,7 @@ using namespace OCC;
loop.exec();
delete vali;
#endif
}
void testUploadChecksummingMd5() {
@@ -119,7 +121,9 @@ using namespace OCC;
}
void testDownloadChecksummingAdler() {
#ifndef ZLIB_FOUND
QSKIP("ZLIB not found.", SkipSingle);
#else
QByteArray adler = checkSumAdlerC;
adler.append(":");
adler.append(FileSystem::calcAdler32( _testfile ));
@@ -143,6 +147,7 @@ using namespace OCC;
QTRY_VERIFY(_errorSeen);
delete vali;
#endif
}
+2 -6
Ver Arquivo
@@ -11,9 +11,7 @@
using namespace OCC;
#define STR_(X) #X
#define STR(X) STR_(X)
#define BIN_PATH STR(OWNCLOUD_BIN_PATH)
#define EXCLUDE_LIST_FILE SOURCEDIR"/../sync-exclude.lst"
class TestExcludedFiles: public QObject
{
@@ -31,9 +29,7 @@ private slots:
QVERIFY(!excluded.isExcluded("/a/.b", "/a", keepHidden));
QVERIFY(excluded.isExcluded("/a/.b", "/a", excludeHidden));
QString path(BIN_PATH);
path.append("/sync-exclude.lst");
excluded.addExcludeFilePath(path);
excluded.addExcludeFilePath(EXCLUDE_LIST_FILE);
excluded.reloadExcludes();
QVERIFY(!excluded.isExcluded("/a/b", "/a", keepHidden));
+23 -38
Ver Arquivo
@@ -17,7 +17,7 @@ class TestFileSystem : public QObject
{
Q_OBJECT
QString _root;
QTemporaryDir _root;
QByteArray shellSum( const QByteArray& cmd, const QString& file )
@@ -38,51 +38,36 @@ class TestFileSystem : public QObject
}
private slots:
void initTestCase() {
qsrand(QTime::currentTime().msec());
QString subdir("test_"+QString::number(qrand()));
_root = QDir::tempPath() + "/" + subdir;
QDir dir("/tmp");
dir.mkdir(subdir);
qDebug() << "creating test directory " << _root;
}
void cleanupTestCase()
{
if( !_root.isEmpty() )
system(QString("rm -rf "+_root).toUtf8());
}
void testMd5Calc()
{
QString file( _root+"/file_a.bin");
writeRandomFile(file);
QFileInfo fi(file);
QVERIFY(fi.exists());
QByteArray sum = calcMd5(file);
QString file( _root.path() + "/file_a.bin");
QVERIFY(writeRandomFile(file));
QFileInfo fi(file);
QVERIFY(fi.exists());
QByteArray sum = calcMd5(file);
QByteArray sSum = shellSum("/usr/bin/md5sum", file);
qDebug() << "calculated" << sum << "versus md5sum:"<< sSum;
QVERIFY(!sSum.isEmpty());
QVERIFY(!sum.isEmpty());
QVERIFY(sSum == sum );
QByteArray sSum = shellSum("md5sum", file);
if (sSum.isEmpty())
QSKIP("Couldn't execute md5sum to calculate checksum, executable missing?", SkipSingle);
QVERIFY(!sum.isEmpty());
QCOMPARE(sSum, sum);
}
void testSha1Calc()
{
QString file( _root+"/file_b.bin");
writeRandomFile(file);
QFileInfo fi(file);
QVERIFY(fi.exists());
QByteArray sum = calcSha1(file);
QString file( _root.path() + "/file_b.bin");
writeRandomFile(file);
QFileInfo fi(file);
QVERIFY(fi.exists());
QByteArray sum = calcSha1(file);
QByteArray sSum = shellSum("/usr/bin/sha1sum", file);
qDebug() << "calculated" << sum << "versus sha1sum:"<< sSum;
QVERIFY(!sSum.isEmpty());
QVERIFY(!sum.isEmpty());
QVERIFY(sSum == sum );
QByteArray sSum = shellSum("sha1sum", file);
if (sSum.isEmpty())
QSKIP("Couldn't execute sha1sum to calculate checksum, executable missing?", SkipSingle);
QVERIFY(!sum.isEmpty());
QCOMPARE(sSum, sum);
}
};
+33 -32
Ver Arquivo
@@ -63,6 +63,7 @@ private slots:
f.open(QFile::WriteOnly);
f.write("hello");
}
QString dirPath = dir2.canonicalPath();
AccountPtr account = Account::create();
QUrl url("http://example.de");
@@ -73,22 +74,22 @@ private slots:
AccountStatePtr newAccountState(new AccountState(account));
FolderMan *folderman = FolderMan::instance();
QCOMPARE(folderman, &_fm);
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dir.path() + "/sub/ownCloud1")));
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dir.path() + "/ownCloud2")));
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dirPath + "/sub/ownCloud1")));
QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dirPath + "/ownCloud2")));
// those should be allowed
// QString FolderMan::checkPathValidityForNewFolder(const QString& path, const QUrl &serverUrl, bool forNewDirectory)
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/free"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/free2/"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/free"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/free2/"), QString());
// Not an existing directory -> Ok
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/bliblablu"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/free/bliblablu"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/bliblablu/some/more"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/bliblablu"), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/free/bliblablu"), QString());
// QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/bliblablu/some/more"), QString());
// A file -> Error
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/file.txt").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/file.txt").isNull());
// There are folders configured in those folders, url needs to be taken into account: -> ERROR
QUrl url2(url);
@@ -96,51 +97,51 @@ private slots:
url2.setUserName(user);
// The following both fail because they refer to the same account (user and url)
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1", url2).isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/", url2).isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1", url2).isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/", url2).isNull());
// Now it will work because the account is different
QUrl url3("http://anotherexample.org");
url3.setUserName("dummy");
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1", url3), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/", url3), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1", url3), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/", url3), QString());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path()).isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder/f").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath).isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder/f").isNull());
// make a bunch of links
QVERIFY(QFile::link(dir.path() + "/sub/free", dir.path() + "/link1"));
QVERIFY(QFile::link(dir.path() + "/sub", dir.path() + "/link2"));
QVERIFY(QFile::link(dir.path() + "/sub/ownCloud1", dir.path() + "/link3"));
QVERIFY(QFile::link(dir.path() + "/sub/ownCloud1/folder", dir.path() + "/link4"));
QVERIFY(QFile::link(dirPath + "/sub/free", dirPath + "/link1"));
QVERIFY(QFile::link(dirPath + "/sub", dirPath + "/link2"));
QVERIFY(QFile::link(dirPath + "/sub/ownCloud1", dirPath + "/link3"));
QVERIFY(QFile::link(dirPath + "/sub/ownCloud1/folder", dirPath + "/link4"));
// Ok
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link1").isNull());
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link2/free").isNull());
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1").isNull());
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free").isNull());
// Not Ok
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link2").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link2").isNull());
// link 3 points to an existing sync folder. To make it fail, the account must be the same
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3", url2).isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3", url2).isNull());
// while with a different account, this is fine
QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/link3", url3), QString());
QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/link3", url3), QString());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link4").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3/folder").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link4").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3/folder").isNull());
// test some non existing sub path (error)
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/some/sub/path").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/blublu").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder/g/h").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3/folder/neu_folder").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/some/sub/path").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/blublu").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder/g/h").isNull());
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3/folder/neu_folder").isNull());
// Subfolder of links
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link1/subfolder").isNull());
QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link2/free/subfolder").isNull());
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1/subfolder").isNull());
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free/subfolder").isNull());
// Invalid paths
QVERIFY(!folderman->checkPathValidityForNewFolder("").isNull());
+124 -117
Ver Arquivo
@@ -10,174 +10,181 @@
#include "folderwatcher.h"
#include "utility.h"
void touch(const QString &file)
{
#ifdef Q_OS_WIN
OCC::Utility::writeRandomFile(file);
#else
QString cmd;
cmd = QString("touch %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
}
void mkdir(const QString &file)
{
#ifdef Q_OS_WIN
QDir dir;
dir.mkdir(file);
#else
QString cmd = QString("mkdir %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
}
void rmdir(const QString &file)
{
#ifdef Q_OS_WIN
QDir dir;
dir.rmdir(file);
#else
QString cmd = QString("rmdir %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
}
void rm(const QString &file)
{
#ifdef Q_OS_WIN
QFile::remove(file);
#else
QString cmd = QString("rm %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
}
void mv(const QString &file1, const QString &file2)
{
#ifdef Q_OS_WIN
QFile::rename(file1, file2);
#else
QString cmd = QString("mv %1 %2").arg(file1, file2);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
}
using namespace OCC;
class TestFolderWatcher : public QObject
{
Q_OBJECT
public slots:
void slotFolderChanged( const QString& path ) {
if (_skipNotifications.contains(path)) {
return;
}
if (_requiredNotifications.contains(path)) {
_receivedNotifications.insert(path);
}
}
QTemporaryDir _root;
QString _rootPath;
QScopedPointer<FolderWatcher> _watcher;
QScopedPointer<QSignalSpy> _pathChangedSpy;
void slotEnd() { // in case something goes wrong...
_loop.quit();
QVERIFY2(1 == 0, "Loop hang!");
}
private:
QString _root;
FolderWatcher *_watcher;
QEventLoop _loop;
QTimer _timer;
QSet<QString> _requiredNotifications;
QSet<QString> _receivedNotifications;
QSet<QString> _skipNotifications;
void processAndWait()
bool waitForPathChanged(const QString &path)
{
_loop.processEvents();
Utility::usleep(200000);
_loop.processEvents();
QElapsedTimer t;
t.start();
while (t.elapsed() < 5000) {
// Check if it was already reported as changed by the watcher
for (int i = 0; i < _pathChangedSpy->size(); ++i) {
const auto &args = _pathChangedSpy->at(i);
if (args.first().toString() == path)
return true;
}
// Wait a bit and test again (don't bother checking if we timed out or not)
_pathChangedSpy->wait(200);
}
return false;
}
public:
TestFolderWatcher() {
qsrand(QTime::currentTime().msec());
QDir rootDir(_root.path());
_rootPath = rootDir.canonicalPath();
qDebug() << "creating test directory tree in " << _rootPath;
rootDir.mkpath("a1/b1/c1");
rootDir.mkpath("a1/b1/c2");
rootDir.mkpath("a1/b2/c1");
rootDir.mkpath("a1/b3/c3");
rootDir.mkpath("a2/b3/c3");
Utility::writeRandomFile( _rootPath+"/a1/random.bin");
Utility::writeRandomFile( _rootPath+"/a1/b2/todelete.bin");
Utility::writeRandomFile( _rootPath+"/a2/renamefile");
Utility::writeRandomFile( _rootPath+"/a1/movefile");
_watcher.reset(new FolderWatcher(_rootPath));
_pathChangedSpy.reset(new QSignalSpy(_watcher.data(), SIGNAL(pathChanged(QString))));
}
private slots:
void initTestCase() {
qsrand(QTime::currentTime().msec());
_root = QDir::tempPath() + "/" + "test_" + QString::number(qrand());
qDebug() << "creating test directory tree in " << _root;
QDir rootDir(_root);
rootDir.mkpath(_root + "/a1/b1/c1");
rootDir.mkpath(_root + "/a1/b1/c2");
rootDir.mkpath(_root + "/a1/b2/c1");
rootDir.mkpath(_root + "/a1/b3/c3");
rootDir.mkpath(_root + "/a2/b3/c3");
Utility::writeRandomFile( _root+"/a1/random.bin");
Utility::writeRandomFile( _root+"/a1/b2/todelete.bin");
Utility::writeRandomFile( _root+"/a2/renamefile");
Utility::writeRandomFile( _root+"/a1/movefile");
_watcher = new FolderWatcher(_root);
QObject::connect(_watcher, SIGNAL(pathChanged(QString)), this, SLOT(slotFolderChanged(QString)));
_timer.singleShot(5000, this, SLOT(slotEnd()));
}
void init()
{
_receivedNotifications.clear();
_requiredNotifications.clear();
_skipNotifications.clear();
}
void checkNotifications()
{
processAndWait();
QCOMPARE(_receivedNotifications, _requiredNotifications);
_pathChangedSpy->clear();
}
void testACreate() { // create a new file
QString file(_root + "/foo.txt");
QString file(_rootPath + "/foo.txt");
QString cmd;
_requiredNotifications.insert(file);
cmd = QString("echo \"xyz\" > %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
checkNotifications();
QVERIFY(waitForPathChanged(file));
}
void testATouch() { // touch an existing file.
QString file(_root + "/a1/random.bin");
_requiredNotifications.insert(file);
#ifdef Q_OS_WIN
Utility::writeRandomFile(QString("%1/a1/random.bin").arg(_root));
#else
QString cmd;
cmd = QString("touch %1").arg(file);
qDebug() << "Command: " << cmd;
system(cmd.toLocal8Bit());
#endif
checkNotifications();
QString file(_rootPath + "/a1/random.bin");
touch(file);
QVERIFY(waitForPathChanged(file));
}
void testCreateADir() {
QString file(_root+"/a1/b1/new_dir");
_requiredNotifications.insert(file);
//_skipNotifications.insert(_root + "/a1/b1/new_dir");
QDir dir;
dir.mkdir(file);
QVERIFY(QFile::exists(file));
checkNotifications();
QString file(_rootPath+"/a1/b1/new_dir");
mkdir(file);
QVERIFY(waitForPathChanged(file));
}
void testRemoveADir() {
QString file(_root+"/a1/b3/c3");
_requiredNotifications.insert(file);
QDir dir;
QVERIFY(dir.rmdir(file));
checkNotifications();
QString file(_rootPath+"/a1/b3/c3");
rmdir(file);
QVERIFY(waitForPathChanged(file));
}
void testRemoveAFile() {
QString file(_root+"/a1/b2/todelete.bin");
_requiredNotifications.insert(file);
QString file(_rootPath+"/a1/b2/todelete.bin");
QVERIFY(QFile::exists(file));
QFile::remove(file);
rm(file);
QVERIFY(!QFile::exists(file));
checkNotifications();
QVERIFY(waitForPathChanged(file));
}
void testRenameAFile() {
QString file1(_root+"/a2/renamefile");
QString file2(_root+"/a2/renamefile.renamed");
_requiredNotifications.insert(file1);
_requiredNotifications.insert(file2);
QString file1(_rootPath+"/a2/renamefile");
QString file2(_rootPath+"/a2/renamefile.renamed");
QVERIFY(QFile::exists(file1));
QFile::rename(file1, file2);
mv(file1, file2);
QVERIFY(QFile::exists(file2));
checkNotifications();
QVERIFY(waitForPathChanged(file1));
QVERIFY(waitForPathChanged(file2));
}
void testMoveAFile() {
QString old_file(_root+"/a1/movefile");
QString new_file(_root+"/a2/movefile.renamed");
_requiredNotifications.insert(old_file);
_requiredNotifications.insert(new_file);
QString old_file(_rootPath+"/a1/movefile");
QString new_file(_rootPath+"/a2/movefile.renamed");
QVERIFY(QFile::exists(old_file));
QFile::rename(old_file, new_file);
mv(old_file, new_file);
QVERIFY(QFile::exists(new_file));
checkNotifications();
}
void cleanupTestCase() {
if( _root.startsWith(QDir::tempPath() )) {
system( QString("rm -rf %1").arg(_root).toLocal8Bit() );
}
delete _watcher;
QVERIFY(waitForPathChanged(old_file));
QVERIFY(waitForPathChanged(new_file));
}
};
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// Qt4 does not have QTEST_GUILESS_MAIN, so we simulate it.
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
TestFolderWatcher tc;
return QTest::qExec(&tc, argc, argv);
}
#ifdef Q_OS_MAC
QTEST_MAIN(TestFolderWatcher)
#else
QTEST_GUILESS_MAIN(TestFolderWatcher)
#endif
+1 -2
Ver Arquivo
@@ -169,7 +169,6 @@ private slots:
void testFileNamesEqual()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
qDebug() << "*** checking fileNamesEqual function";
QTemporaryDir dir;
QVERIFY(dir.isValid());
QDir dir2(dir.path());
@@ -201,5 +200,5 @@ private slots:
};
QTEST_APPLESS_MAIN(TestUtility)
QTEST_GUILESS_MAIN(TestUtility)
#include "testutility.moc"
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff