mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 08:49:42 -05:00
Add shorthand method for creating a new NetworkRequestBuilder.
This commit is contained in:
parent
0924639092
commit
6a314f848f
@ -32,4 +32,9 @@ QNetworkAccessManager* getNetMgr()
|
|||||||
}
|
}
|
||||||
return g_netMgr;
|
return g_netMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkRequestBuilder buildRequest(const QUrl& url)
|
||||||
|
{
|
||||||
|
return NetworkRequestBuilder(url);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,9 +22,14 @@
|
|||||||
|
|
||||||
#ifdef WITH_XC_NETWORKING
|
#ifdef WITH_XC_NETWORKING
|
||||||
|
|
||||||
|
#include "core/NetworkRequest.h"
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
|
|
||||||
QNetworkAccessManager* getNetMgr();
|
QNetworkAccessManager* getNetMgr();
|
||||||
|
|
||||||
|
NetworkRequestBuilder buildRequest(const QUrl& targetUrl);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
Q_STATIC_ASSERT_X(false, "Qt Networking used when WITH_XC_NETWORKING is disabled!");
|
Q_STATIC_ASSERT_X(false, "Qt Networking used when WITH_XC_NETWORKING is disabled!");
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "TestNetworkRequest.h"
|
#include "TestNetworkRequest.h"
|
||||||
|
#include "core/NetworkManager.h"
|
||||||
#include "core/NetworkRequest.h"
|
#include "core/NetworkRequest.h"
|
||||||
#include "mock/MockNetworkAccessManager.h"
|
#include "mock/MockNetworkAccessManager.h"
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
@ -41,7 +42,7 @@ void TestNetworkRequest::testNetworkRequest()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
NetworkRequest request = NetworkRequestBuilder(requestedURL).setManager(&manager).build();
|
NetworkRequest request = buildRequest(requestedURL).setManager(&manager).build();
|
||||||
|
|
||||||
QString actualContent;
|
QString actualContent;
|
||||||
bool didError = false, didSucceed = false;
|
bool didError = false, didSucceed = false;
|
||||||
@ -136,7 +137,7 @@ void TestNetworkRequest::testNetworkRequestTimeout()
|
|||||||
reply.withFinishDelayUntil(&timer, &QTimer::timeout);
|
reply.withFinishDelayUntil(&timer, &QTimer::timeout);
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
NetworkRequest request = NetworkRequestBuilder(requestedURL).setManager(&manager).setTimeout(timeout).build();
|
NetworkRequest request = buildRequest(requestedURL).setManager(&manager).setTimeout(timeout).build();
|
||||||
|
|
||||||
// Start timer
|
// Start timer
|
||||||
timer.start();
|
timer.start();
|
||||||
@ -212,7 +213,7 @@ void TestNetworkRequest::testNetworkRequestRedirects()
|
|||||||
reply->withBody(QString{"test-content"}.toUtf8());
|
reply->withBody(QString{"test-content"}.toUtf8());
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
NetworkRequest request = NetworkRequestBuilder(requestedURL).setManager(&manager)
|
NetworkRequest request = buildRequest(requestedURL).setManager(&manager)
|
||||||
.setMaxRedirects(maxRedirects).build();
|
.setMaxRedirects(maxRedirects).build();
|
||||||
|
|
||||||
bool didSucceed = false, didError = false;
|
bool didSucceed = false, didError = false;
|
||||||
@ -289,7 +290,7 @@ void TestNetworkRequest::testNetworkRequestTimeoutWithRedirects()
|
|||||||
reply->withBody(QString{"test-content"}.toUtf8());
|
reply->withBody(QString{"test-content"}.toUtf8());
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
NetworkRequest request = NetworkRequestBuilder(requestedURL).setManager(&manager)
|
NetworkRequest request = buildRequest(requestedURL).setManager(&manager)
|
||||||
.setTimeout(timeout)
|
.setTimeout(timeout)
|
||||||
.setMaxRedirects(NetworkRequest::UNLIMITED_REDIRECTS).build();
|
.setMaxRedirects(NetworkRequest::UNLIMITED_REDIRECTS).build();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user