WinRT: Fixed compilation of network autotests and benchmarks
Change-Id: Id689f199cfb22dce231cec36faba57ab958b1bac Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
This commit is contained in:
parent
fadcb0a72b
commit
1efe5d4b41
@ -552,6 +552,7 @@ class QDataStream;
|
||||
|
||||
#if defined(Q_OS_WINRT)
|
||||
# define QT_NO_FILESYSTEMWATCHER
|
||||
# define QT_NO_GETADDRINFO
|
||||
# define QT_NO_NETWORKPROXY
|
||||
# define QT_NO_PROCESS
|
||||
# define QT_NO_SOCKETNOTIFIER
|
||||
|
@ -197,14 +197,18 @@ void tst_QFtp::initTestCase_data()
|
||||
QTest::addColumn<bool>("setSession");
|
||||
|
||||
QTest::newRow("WithoutProxy") << false << 0 << false;
|
||||
#ifndef QT_NO_SOCKS5
|
||||
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy) << false;
|
||||
#endif
|
||||
//### doesn't work well yet.
|
||||
//QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy);
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QTest::newRow("WithoutProxyWithSession") << false << 0 << true;
|
||||
#ifndef QT_NO_SOCKS5
|
||||
QTest::newRow("WithSocks5ProxyAndSession") << true << int(QNetworkProxy::Socks5Proxy) << true;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QFtp::initTestCase()
|
||||
@ -232,11 +236,16 @@ void tst_QFtp::init()
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
QFETCH_GLOBAL(bool, setSession);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy) {
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
|
||||
} else if (proxyType == QNetworkProxy::HttpProxy) {
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
|
||||
}
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
Q_UNUSED(proxyType);
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
if (setSession) {
|
||||
@ -293,7 +302,11 @@ void tst_QFtp::cleanup()
|
||||
}
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#else
|
||||
QSKIP("No proxy support");
|
||||
#endif
|
||||
}
|
||||
|
||||
delete ftp;
|
||||
@ -749,14 +762,14 @@ void tst_QFtp::put()
|
||||
QFETCH( QByteArray, fileData );
|
||||
QFETCH( bool, useIODevice );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN) && !defined(QT_NO_NETWORKPROXY)
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 the put() test takes too long time on Windows.");
|
||||
}
|
||||
#endif
|
||||
#endif // OS_WIN && !QT_NO_NETWORKPROXY
|
||||
|
||||
const int timestep = 50;
|
||||
|
||||
|
@ -97,7 +97,9 @@ Q_DECLARE_METATYPE(QSharedPointer<char>)
|
||||
#include "../../../network-settings.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QAuthenticator*)
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
Q_DECLARE_METATYPE(QNetworkProxyQuery)
|
||||
#endif
|
||||
|
||||
typedef QSharedPointer<QNetworkReply> QNetworkReplyPtr;
|
||||
|
||||
@ -106,6 +108,7 @@ class tst_QNetworkReply: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
struct ProxyData {
|
||||
ProxyData(const QNetworkProxy &p, const QByteArray &t, bool auth)
|
||||
: tag(t), proxy(p), requiresAuthentication(auth)
|
||||
@ -114,6 +117,7 @@ class tst_QNetworkReply: public QObject
|
||||
QNetworkProxy proxy;
|
||||
bool requiresAuthentication;
|
||||
};
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
static bool seedCreated;
|
||||
static QString createUniqueExtension() {
|
||||
@ -134,7 +138,9 @@ class tst_QNetworkReply: public QObject
|
||||
QString wronlyFileName;
|
||||
#endif
|
||||
QString uniqueExtension;
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QList<ProxyData> proxies;
|
||||
#endif
|
||||
QNetworkAccessManager manager;
|
||||
MyCookieJar *cookieJar;
|
||||
#ifndef QT_NO_SSL
|
||||
@ -203,8 +209,10 @@ private Q_SLOTS:
|
||||
void getFromHttp();
|
||||
void getErrors_data();
|
||||
void getErrors();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void headFromHttp_data();
|
||||
void headFromHttp();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
void putToFile_data();
|
||||
void putToFile();
|
||||
void putToFtp_data();
|
||||
@ -261,9 +269,11 @@ private Q_SLOTS:
|
||||
void ioGetFromHttpWithAuth_data();
|
||||
void ioGetFromHttpWithAuth();
|
||||
void ioGetFromHttpWithAuthSynchronous();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void ioGetFromHttpWithProxyAuth();
|
||||
void ioGetFromHttpWithProxyAuthSynchronous();
|
||||
void ioGetFromHttpWithSocksProxy();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
#ifndef QT_NO_SSL
|
||||
void ioGetFromHttpsWithSslErrors();
|
||||
void ioGetFromHttpsWithIgnoreSslErrors();
|
||||
@ -278,8 +288,10 @@ private Q_SLOTS:
|
||||
void ioGetFromHttpWithCache_data();
|
||||
void ioGetFromHttpWithCache();
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void ioGetWithManyProxies_data();
|
||||
void ioGetWithManyProxies();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
void ioPutToFileFromFile_data();
|
||||
void ioPutToFileFromFile();
|
||||
@ -297,10 +309,12 @@ private Q_SLOTS:
|
||||
void ioPutToHttpFromFile();
|
||||
void ioPostToHttpFromFile_data();
|
||||
void ioPostToHttpFromFile();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void ioPostToHttpFromSocket_data();
|
||||
void ioPostToHttpFromSocket();
|
||||
void ioPostToHttpFromSocketSynchronous();
|
||||
void ioPostToHttpFromSocketSynchronous_data();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
void ioPostToHttpFromMiddleOfFileToEnd();
|
||||
void ioPostToHttpFromMiddleOfFileFiveBytes();
|
||||
void ioPostToHttpFromMiddleOfQBufferFiveBytes();
|
||||
@ -339,11 +353,13 @@ private Q_SLOTS:
|
||||
|
||||
void nestedEventLoops();
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void httpProxyCommands_data();
|
||||
void httpProxyCommands();
|
||||
void httpProxyCommandsSynchronous_data();
|
||||
void httpProxyCommandsSynchronous();
|
||||
void proxyChange();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
void authorizationError_data();
|
||||
void authorizationError();
|
||||
|
||||
@ -419,9 +435,11 @@ private Q_SLOTS:
|
||||
void dontInsertPartialContentIntoTheCache();
|
||||
|
||||
void httpUserAgent();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void authenticationCacheAfterCancel_data();
|
||||
void authenticationCacheAfterCancel();
|
||||
void authenticationWithDifferentRealm();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
void synchronousAuthenticationCache();
|
||||
void pipelining();
|
||||
|
||||
@ -638,6 +656,7 @@ public:
|
||||
{ QNetworkCookieJar::setAllCookies(cookieList); }
|
||||
};
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
class MyProxyFactory: public QNetworkProxyFactory
|
||||
{
|
||||
public:
|
||||
@ -660,6 +679,7 @@ public:
|
||||
return toReturn;
|
||||
}
|
||||
};
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
class MyMemoryCache: public QAbstractNetworkCache
|
||||
{
|
||||
@ -1154,7 +1174,9 @@ tst_QNetworkReply::tst_QNetworkReply()
|
||||
{
|
||||
qRegisterMetaType<QNetworkReply *>(); // for QSignalSpy
|
||||
qRegisterMetaType<QAuthenticator *>();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
qRegisterMetaType<QNetworkProxy>();
|
||||
#endif
|
||||
#ifndef QT_NO_SSL
|
||||
qRegisterMetaType<QList<QSslError> >();
|
||||
#endif
|
||||
@ -1165,6 +1187,7 @@ tst_QNetworkReply::tst_QNetworkReply()
|
||||
cookieJar = new MyCookieJar;
|
||||
manager.setCookieJar(cookieJar);
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QHostInfo hostInfo = QHostInfo::fromName(QtNetworkSettings::serverName());
|
||||
|
||||
proxies << ProxyData(QNetworkProxy::NoProxy, "", false);
|
||||
@ -1178,10 +1201,13 @@ tst_QNetworkReply::tst_QNetworkReply()
|
||||
<< ProxyData(QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyserver, 1080), "+socks", false)
|
||||
<< ProxyData(QNetworkProxy(QNetworkProxy::Socks5Proxy, proxyserver, 1081), "+socksauth", true);
|
||||
} else {
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
printf("==================================================================\n");
|
||||
printf("Proxy could not be looked up. No proxy will be used while testing!\n");
|
||||
printf("==================================================================\n");
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
}
|
||||
|
||||
tst_QNetworkReply::~tst_QNetworkReply()
|
||||
@ -1438,7 +1464,9 @@ void tst_QNetworkReply::cleanup()
|
||||
|
||||
// clear the internal cache
|
||||
manager.clearAccessCache();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
manager.setProxy(QNetworkProxy());
|
||||
#endif
|
||||
manager.setCache(0);
|
||||
|
||||
// clear cookies
|
||||
@ -1732,6 +1760,7 @@ void tst_QNetworkReply::getFromHttp()
|
||||
QCOMPARE(reply->readAll(), reference.readAll());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::headFromHttp_data()
|
||||
{
|
||||
QTest::addColumn<qint64>("referenceSize");
|
||||
@ -1790,6 +1819,7 @@ void tst_QNetworkReply::headFromHttp()
|
||||
if (reply->header(QNetworkRequest::ContentTypeHeader).isValid())
|
||||
QCOMPARE(reply->header(QNetworkRequest::ContentTypeHeader).toString(), contentType);
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
void tst_QNetworkReply::getErrors_data()
|
||||
{
|
||||
@ -3270,6 +3300,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous()
|
||||
QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 401);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
|
||||
{
|
||||
// This test sends three requests
|
||||
@ -3432,6 +3463,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
|
||||
QCOMPARE(authspy.count(), 0);
|
||||
}
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
void tst_QNetworkReply::ioGetFromHttpsWithSslErrors()
|
||||
@ -3793,6 +3825,7 @@ void tst_QNetworkReply::ioGetFromHttpWithCache()
|
||||
QCOMPARE(reply->readAll().constData(), qPrintable(body));
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::ioGetWithManyProxies_data()
|
||||
{
|
||||
QTest::addColumn<QList<QNetworkProxy> >("proxyList");
|
||||
@ -4054,6 +4087,7 @@ void tst_QNetworkReply::ioGetWithManyProxies()
|
||||
QCOMPARE(authspy.count(), 0);
|
||||
}
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
void tst_QNetworkReply::ioPutToFileFromFile_data()
|
||||
{
|
||||
@ -4346,6 +4380,7 @@ void tst_QNetworkReply::ioPostToHttpFromFile()
|
||||
QCOMPARE(reply->readAll().trimmed(), md5sum(sourceFile.readAll()).toHex());
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::ioPostToHttpFromSocket_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("data");
|
||||
@ -4496,6 +4531,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous()
|
||||
|
||||
QCOMPARE(reply->readAll().trimmed(), md5sum(data).toHex());
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
// this tests checks if rewinding the POST-data to some place in the middle
|
||||
// worked.
|
||||
@ -5410,6 +5446,7 @@ void tst_QNetworkReply::nestedEventLoops()
|
||||
QCOMPARE(errorspy.count(), 0);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::httpProxyCommands_data()
|
||||
{
|
||||
QTest::addColumn<QUrl>("url");
|
||||
@ -5485,6 +5522,7 @@ void tst_QNetworkReply::httpProxyCommandsSynchronous_data()
|
||||
{
|
||||
httpProxyCommands_data();
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
struct QThreadCleanup
|
||||
{
|
||||
@ -5506,6 +5544,7 @@ struct QDeleteLaterCleanup
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::httpProxyCommandsSynchronous()
|
||||
{
|
||||
QFETCH(QUrl, url);
|
||||
@ -5586,6 +5625,7 @@ void tst_QNetworkReply::proxyChange()
|
||||
|
||||
QVERIFY(int(reply3->error()) > 0);
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
void tst_QNetworkReply::authorizationError_data()
|
||||
{
|
||||
@ -6502,6 +6542,7 @@ void tst_QNetworkReply::qtbug4121unknownAuthentication()
|
||||
QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QNetworkReply::authenticationCacheAfterCancel_data()
|
||||
{
|
||||
QTest::addColumn<QNetworkProxy>("proxy");
|
||||
@ -6716,6 +6757,7 @@ void tst_QNetworkReply::authenticationWithDifferentRealm()
|
||||
QVERIFY(!QTestEventLoop::instance().timeout());
|
||||
QCOMPARE(reply->error(), QNetworkReply::NoError);
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
class QtBug13431Helper : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -10,6 +10,10 @@ SUBDIRS=\
|
||||
qnetworkaddressentry \
|
||||
qhostaddress \
|
||||
|
||||
winrt: SUBDIRS -= \
|
||||
qnetworkproxy \
|
||||
qnetworkproxyfactory \
|
||||
|
||||
!contains(QT_CONFIG, private_tests): SUBDIRS -= \
|
||||
qauthenticator \
|
||||
qhostinfo \
|
||||
|
@ -339,12 +339,15 @@ void tst_QHostAddress::assignment()
|
||||
address = "::1";
|
||||
QCOMPARE(address, QHostAddress("::1"));
|
||||
|
||||
// WinRT does not support sockaddr_in
|
||||
#ifndef Q_OS_WINRT
|
||||
QHostAddress addr("4.2.2.1");
|
||||
sockaddr_in sockAddr;
|
||||
sockAddr.sin_family = AF_INET;
|
||||
sockAddr.sin_addr.s_addr = htonl(addr.toIPv4Address());
|
||||
address.setAddress((sockaddr *)&sockAddr);
|
||||
QCOMPARE(address, addr);
|
||||
#endif // !Q_OS_WINRT
|
||||
}
|
||||
|
||||
void tst_QHostAddress::scopeId()
|
||||
|
@ -64,7 +64,11 @@
|
||||
|
||||
#define PLATFORMSOCKETENGINE QNativeSocketEngine
|
||||
#define PLATFORMSOCKETENGINESTRING "QNativeSocketEngine"
|
||||
#include <private/qnativesocketengine_p.h>
|
||||
#ifndef Q_OS_WINRT
|
||||
# include <private/qnativesocketengine_p.h>
|
||||
#else
|
||||
# include <private/qnativesocketengine_winrt_p.h>
|
||||
#endif
|
||||
|
||||
#include <qstringlist.h>
|
||||
|
||||
@ -97,7 +101,9 @@ private slots:
|
||||
void networkError();
|
||||
void setSocketDescriptor();
|
||||
void invalidSend();
|
||||
#ifndef Q_OS_WINRT
|
||||
void receiveUrgentData();
|
||||
#endif
|
||||
void tooManySockets();
|
||||
};
|
||||
|
||||
@ -608,7 +614,9 @@ void tst_PlatformSocketEngine::networkError()
|
||||
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
|
||||
|
||||
// An unexpected network error!
|
||||
#ifdef Q_OS_WIN
|
||||
#ifdef Q_OS_WINRT
|
||||
client.close();
|
||||
#elif defined(Q_OS_WIN)
|
||||
// could use shutdown to produce different errors
|
||||
::closesocket(client.socketDescriptor());
|
||||
#else
|
||||
@ -641,6 +649,7 @@ void tst_PlatformSocketEngine::invalidSend()
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#ifndef Q_OS_WINRT
|
||||
void tst_PlatformSocketEngine::receiveUrgentData()
|
||||
{
|
||||
PLATFORMSOCKETENGINE server;
|
||||
@ -703,6 +712,7 @@ void tst_PlatformSocketEngine::receiveUrgentData()
|
||||
QCOMPARE(response.at(0), msg);
|
||||
#endif
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
|
||||
QTEST_MAIN(tst_PlatformSocketEngine)
|
||||
#include "tst_platformsocketengine.moc"
|
||||
|
@ -100,16 +100,20 @@ private slots:
|
||||
void maxPendingConnections();
|
||||
void listenError();
|
||||
void waitForConnectionTest();
|
||||
#ifndef Q_OS_WINRT
|
||||
void setSocketDescriptor();
|
||||
#endif
|
||||
void listenWhileListening();
|
||||
#ifndef QT_NO_PROCESS
|
||||
void addressReusable();
|
||||
#endif
|
||||
void setNewSocketDescriptorBlocking();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void invalidProxy_data();
|
||||
void invalidProxy();
|
||||
void proxyFactory_data();
|
||||
void proxyFactory();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
void qtbug14268_peek();
|
||||
|
||||
@ -158,7 +162,9 @@ void tst_QTcpServer::initTestCase_data()
|
||||
QTest::addColumn<int>("proxyType");
|
||||
|
||||
QTest::newRow("WithoutProxy") << false << 0;
|
||||
#ifndef QT_NO_SOCKS5
|
||||
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
|
||||
#endif
|
||||
|
||||
crashingServerDir = QFINDTESTDATA("crashingServer");
|
||||
QVERIFY2(!crashingServerDir.isEmpty(), qPrintable(
|
||||
@ -181,16 +187,22 @@ void tst_QTcpServer::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy) {
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
|
||||
}
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTcpServer::cleanup()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -369,9 +381,13 @@ void tst_QTcpServer::maxPendingConnections()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 only 1 connection is allowed ever");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
//### sees to fail sometimes ... a timing issue with the test on windows
|
||||
QTcpServer server;
|
||||
@ -407,9 +423,13 @@ void tst_QTcpServer::listenError()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 we can not make hard requirements on the address or port");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif //QT_NO_NETWORKPROXY
|
||||
}
|
||||
QTcpServer server;
|
||||
QVERIFY(!server.listen(QHostAddress("1.2.3.4"), 0));
|
||||
@ -453,9 +473,13 @@ void tst_QTcpServer::waitForConnectionTest()
|
||||
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("Localhost servers don't work well with SOCKS5");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
|
||||
QTcpSocket findLocalIpSocket;
|
||||
@ -481,6 +505,7 @@ void tst_QTcpServer::waitForConnectionTest()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
#ifndef Q_OS_WINRT
|
||||
void tst_QTcpServer::setSocketDescriptor()
|
||||
{
|
||||
QTcpServer server;
|
||||
@ -510,6 +535,7 @@ void tst_QTcpServer::setSocketDescriptor()
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
void tst_QTcpServer::listenWhileListening()
|
||||
@ -531,6 +557,7 @@ public:
|
||||
bool ok;
|
||||
|
||||
protected:
|
||||
#ifndef Q_OS_WINRT
|
||||
void incomingConnection(qintptr socketDescriptor)
|
||||
{
|
||||
// how a user woulddo it (qabstractsocketengine is not public)
|
||||
@ -543,6 +570,7 @@ protected:
|
||||
::close(socketDescriptor);
|
||||
#endif
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
};
|
||||
|
||||
#ifndef QT_NO_PROCESS
|
||||
@ -550,9 +578,13 @@ void tst_QTcpServer::addressReusable()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 this test does not make senans at the momment");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
#if defined(Q_OS_WINCE)
|
||||
QString signalName = QString::fromLatin1("/test_signal.txt");
|
||||
@ -596,9 +628,13 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 we can not make the socket descripter blocking");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
SeverWithBlockingSockets server;
|
||||
QVERIFY(server.listen());
|
||||
@ -609,6 +645,7 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking()
|
||||
QVERIFY(server.ok);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QTcpServer::invalidProxy_data()
|
||||
{
|
||||
QTest::addColumn<int>("type");
|
||||
@ -763,6 +800,7 @@ void tst_QTcpServer::proxyFactory()
|
||||
// Sometimes, error codes change for the better
|
||||
QTEST(int(server.serverError()), "expectedError");
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
class Qtbug14268Helper : public QObject
|
||||
{
|
||||
|
@ -132,7 +132,9 @@ private slots:
|
||||
void bind_data();
|
||||
void bind();
|
||||
void setInvalidSocketDescriptor();
|
||||
#ifndef Q_OS_WINRT
|
||||
void setSocketDescriptor();
|
||||
#endif
|
||||
void socketDescriptor();
|
||||
void blockingIMAP();
|
||||
void nonBlockingIMAP();
|
||||
@ -191,10 +193,12 @@ private slots:
|
||||
void taskQtBug5799ConnectionErrorEventLoop();
|
||||
void taskQtBug7054TimeoutErrorResetting();
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void invalidProxy_data();
|
||||
void invalidProxy();
|
||||
void proxyFactory_data();
|
||||
void proxyFactory();
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
void qtbug14268_peek();
|
||||
|
||||
@ -216,7 +220,9 @@ protected slots:
|
||||
void hostLookupSlot();
|
||||
void abortiveClose_abortSlot();
|
||||
void remoteCloseErrorSlot();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth);
|
||||
#endif
|
||||
void earlySocketBytesSent(qint64 bytes);
|
||||
void earlySocketReadyRead();
|
||||
|
||||
@ -354,6 +360,7 @@ void tst_QTcpSocket::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
QList<QHostAddress> addresses = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses();
|
||||
QVERIFY2(addresses.count() > 0, "failed to get ip address for test server");
|
||||
@ -382,6 +389,9 @@ void tst_QTcpSocket::init()
|
||||
break;
|
||||
}
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
|
||||
qt_qhostinfo_clear_cache();
|
||||
@ -406,15 +416,19 @@ QTcpSocket *tst_QTcpSocket::newSocket() const
|
||||
|
||||
void tst_QTcpSocket::cleanup()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QTcpSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth)
|
||||
{
|
||||
++proxyAuthCalled;
|
||||
auth->setUser("qsockstest");
|
||||
auth->setPassword("password");
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@ -552,6 +566,7 @@ void tst_QTcpSocket::setInvalidSocketDescriptor()
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#ifndef Q_OS_WINRT
|
||||
void tst_QTcpSocket::setSocketDescriptor()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
@ -596,6 +611,7 @@ void tst_QTcpSocket::setSocketDescriptor()
|
||||
delete dummy;
|
||||
#endif
|
||||
}
|
||||
#endif // !Q_OS_WINRT
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@ -1546,7 +1562,9 @@ void tst_QTcpSocket::synchronousApi()
|
||||
void tst_QTcpSocket::dontCloseOnTimeout()
|
||||
{
|
||||
QTcpServer server;
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
server.setProxy(QNetworkProxy(QNetworkProxy::NoProxy));
|
||||
#endif
|
||||
QVERIFY(server.listen());
|
||||
|
||||
QHostAddress serverAddress = QHostAddress::LocalHost;
|
||||
@ -1673,11 +1691,13 @@ private slots:
|
||||
{
|
||||
quit();
|
||||
}
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
inline void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth)
|
||||
{
|
||||
auth->setUser("qsockstest");
|
||||
auth->setPassword("password");
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
private:
|
||||
int exitCode;
|
||||
QTcpSocket *socket;
|
||||
@ -1970,11 +1990,13 @@ public slots:
|
||||
tst_QTcpSocket::exitLoop();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
inline void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth)
|
||||
{
|
||||
auth->setUser("qsockstest");
|
||||
auth->setPassword("password");
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -2500,6 +2522,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
|
||||
QVERIFY(socket->error() == QAbstractSocket::RemoteHostClosedError);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QTcpSocket::invalidProxy_data()
|
||||
{
|
||||
QTest::addColumn<int>("type");
|
||||
@ -2676,6 +2699,7 @@ void tst_QTcpSocket::proxyFactory()
|
||||
|
||||
delete socket;
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
// there is a similar test inside tst_qtcpserver that uses the event loop instead
|
||||
void tst_QTcpSocket::qtbug14268_peek()
|
||||
|
@ -148,7 +148,9 @@ void tst_QUdpSocket::initTestCase_data()
|
||||
QTest::addColumn<int>("proxyType");
|
||||
|
||||
QTest::newRow("WithoutProxy") << false << 0;
|
||||
#ifndef QT_NO_SOCKS5
|
||||
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
netConfMan = new QNetworkConfigurationManager(this);
|
||||
@ -171,16 +173,22 @@ void tst_QUdpSocket::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_SOCKS5
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy) {
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
|
||||
}
|
||||
#else
|
||||
QSKIP("No proxy support");
|
||||
#endif // !QT_NO_SOCKS5
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QUdpSocket::cleanup()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
}
|
||||
|
||||
|
||||
@ -250,9 +258,13 @@ void tst_QUdpSocket::broadcasting()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 Broadcast is not supported.");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
#ifdef Q_OS_AIX
|
||||
QSKIP("Broadcast does not work on darko");
|
||||
@ -746,9 +758,13 @@ void tst_QUdpSocket::bindMode()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy)
|
||||
QSKIP("With socks5 explicit port binding is not supported.");
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
|
||||
QUdpSocket socket;
|
||||
|
@ -14,3 +14,7 @@ SUBDIRS=\
|
||||
qtcpsocket \
|
||||
qhttpsocketengine \
|
||||
qsocks5socketengine \
|
||||
|
||||
winrt: SUBDIRS -= \
|
||||
qhttpsocketengine \
|
||||
qsocks5socketengine \
|
||||
|
@ -111,7 +111,9 @@ public slots:
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
private slots:
|
||||
@ -276,6 +278,7 @@ void tst_QSslSocket::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString();
|
||||
QNetworkProxy proxy;
|
||||
@ -302,6 +305,9 @@ void tst_QSslSocket::init()
|
||||
break;
|
||||
}
|
||||
QNetworkProxy::setApplicationProxy(proxy);
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
|
||||
qt_qhostinfo_clear_cache();
|
||||
@ -309,7 +315,9 @@ void tst_QSslSocket::init()
|
||||
|
||||
void tst_QSslSocket::cleanup()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
@ -326,12 +334,14 @@ QSslSocketPtr tst_QSslSocket::newSocket()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void tst_QSslSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth)
|
||||
{
|
||||
++proxyAuthCalled;
|
||||
auth->setUser("qsockstest");
|
||||
auth->setPassword("password");
|
||||
}
|
||||
#endif // !QT_NO_NETWORKPROXY
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
|
||||
|
@ -12,3 +12,7 @@ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked):
|
||||
qsslsocket_onDemandCertificates_member \
|
||||
qsslsocket_onDemandCertificates_static \
|
||||
}
|
||||
|
||||
winrt: SUBDIRS -= \
|
||||
qsslsocket_onDemandCertificates_member \
|
||||
qsslsocket_onDemandCertificates_static \
|
||||
|
@ -88,7 +88,9 @@ void tst_QTcpServer::initTestCase_data()
|
||||
QTest::addColumn<int>("proxyType");
|
||||
|
||||
QTest::newRow("WithoutProxy") << false << 0;
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QTcpServer::initTestCase()
|
||||
@ -100,16 +102,22 @@ void tst_QTcpServer::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, setProxy);
|
||||
if (setProxy) {
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QFETCH_GLOBAL(int, proxyType);
|
||||
if (proxyType == QNetworkProxy::Socks5Proxy) {
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
|
||||
}
|
||||
#else // !QT_NO_NETWORKPROXY
|
||||
QSKIP("No proxy support");
|
||||
#endif // QT_NO_NETWORKPROXY
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTcpServer::cleanup()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy);
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user