Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/syncenginetestutils.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h
index fe4676821..ee15d8e33 100644
--- a/test/syncenginetestutils.h
+++ b/test/syncenginetestutils.h
@@ -706,10 +706,17 @@ public:
class FakeQNAM : public QNetworkAccessManager
{
+public:
+ using Override = std::function<QNetworkReply *(Operation, const QNetworkRequest &)>;
+
+private:
FileInfo _remoteRootFileInfo;
FileInfo _uploadFileInfo;
// maps a path to an HTTP error
QHash<QString, int> _errorPaths;
+ // monitor requests and optionally provide custom replies
+ Override _override;
+
public:
FakeQNAM(FileInfo initialRoot) : _remoteRootFileInfo{std::move(initialRoot)} { }
FileInfo &currentRemoteState() { return _remoteRootFileInfo; }
@@ -717,6 +724,8 @@ public:
QHash<QString, int> &errorPaths() { return _errorPaths; }
+ void setOverride(const Override &override) { _override = override; }
+
protected:
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
QIODevice *outgoingData = 0) {
@@ -728,8 +737,13 @@ protected:
bool isUpload = request.url().path().startsWith(sUploadUrl.path());
FileInfo &info = isUpload ? _uploadFileInfo : _remoteRootFileInfo;
+ if (_override) {
+ if (auto reply = _override(op, request))
+ return reply;
+ }
+
auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute);
- if (verb == QLatin1String("PROPFIND"))
+ if (verb == "PROPFIND")
// Ignore outgoingData always returning somethign good enough, works for now.
return new FakePropfindReply{info, op, request, this};
else if (verb == QLatin1String("GET") || op == QNetworkAccessManager::GetOperation)
@@ -825,6 +839,7 @@ public:
void clear() { _qnam->errorPaths().clear(); }
};
ErrorList serverErrorPaths() { return {_fakeQnam}; }
+ void setServerOverride(const FakeQNAM::Override &override) { _fakeQnam->setOverride(override); }
QString localPath() const {
// SyncEngine wants a trailing slash