mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
b7ff4a76e8
To be able to test the SyncEngine efficiently, a set of server mocking classes have been implemented on top of QNetworkAccessManager. The local disk side hasn't been mocked since this would require adding a large abstraction layer in csync. The SyncEngine is instead pointed to a different temporary dir in each test and we test by interacting with files in this directory instead. The FakeFolder object wraps the SyncEngine with those abstractions and allow controlling the local files, and the fake remote state through the FileModifier interface, using a FileInfo tree structure for the remote-side implementation as well as feeding and comparing the states on both side in tests. Tests run fast and require no setup to be run, but each server feature that we want to test on the client side needs to be implemented in this fake objects library. For example, the OC-FileId header isn't set as of this commit, and we can't test the file move logic properly without implementing it first. The TestSyncFileStatusTracker tests already contain a few QEXPECT_FAIL for what I esteem being issues that need to be fixed in order to catch up on our test coverage without making this patch too huge.
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
/*
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*/
|
|
|
|
#ifndef SYNCFILESTATUS_H
|
|
#define SYNCFILESTATUS_H
|
|
|
|
#include <QMetaType>
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
#include "owncloudlib.h"
|
|
|
|
namespace OCC {
|
|
|
|
/**
|
|
* @brief The SyncFileStatus class
|
|
* @ingroup libsync
|
|
*/
|
|
class OWNCLOUDSYNC_EXPORT SyncFileStatus
|
|
{
|
|
public:
|
|
enum SyncFileStatusTag {
|
|
StatusNone,
|
|
StatusSync,
|
|
StatusWarning,
|
|
StatusUpToDate,
|
|
StatusError,
|
|
};
|
|
|
|
SyncFileStatus();
|
|
SyncFileStatus(SyncFileStatusTag);
|
|
|
|
void set(SyncFileStatusTag tag);
|
|
SyncFileStatusTag tag() const;
|
|
|
|
void setSharedWithMe( bool isShared );
|
|
bool sharedWithMe() const;
|
|
|
|
QString toSocketAPIString() const;
|
|
private:
|
|
SyncFileStatusTag _tag;
|
|
bool _sharedWithMe;
|
|
|
|
};
|
|
|
|
inline bool operator==(const SyncFileStatus &a, const SyncFileStatus &b) {
|
|
return a.tag() == b.tag() && a.sharedWithMe() == b.sharedWithMe();
|
|
}
|
|
|
|
inline bool operator!=(const SyncFileStatus &a, const SyncFileStatus &b) {
|
|
return !(a == b);
|
|
}
|
|
}
|
|
|
|
Q_DECLARE_METATYPE(OCC::SyncFileStatus)
|
|
|
|
#endif // SYNCFILESTATUS_H
|