diff --git a/src/core/NetworkManager.cpp b/src/core/NetworkManager.cpp index 8fc4c9e06..276eee0aa 100644 --- a/src/core/NetworkManager.cpp +++ b/src/core/NetworkManager.cpp @@ -32,4 +32,9 @@ QNetworkAccessManager* getNetMgr() } return g_netMgr; } + +NetworkRequestBuilder buildRequest(const QUrl& url) +{ + return NetworkRequestBuilder(url); +} #endif diff --git a/src/core/NetworkManager.h b/src/core/NetworkManager.h index 1e571d95c..0cc9ad45a 100644 --- a/src/core/NetworkManager.h +++ b/src/core/NetworkManager.h @@ -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 diff --git a/tests/TestNetworkRequest.cpp b/tests/TestNetworkRequest.cpp index 4cdae043e..8d2adc8f0 100644 --- a/tests/TestNetworkRequest.cpp +++ b/tests/TestNetworkRequest.cpp @@ -1,4 +1,5 @@ #include "TestNetworkRequest.h" +#include "core/NetworkManager.h" #include "core/NetworkRequest.h" #include "mock/MockNetworkAccessManager.h" #include @@ -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();