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