summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2016-08-24 14:44:41 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2016-08-25 07:59:16 +0000
commit0b3509d85da168780ec8b2daf928c801d80ebe0a (patch)
tree57a56816152ff862bc45ab73af837f885ef5f8ff /tests/auto/network/access
parentd037cb78213f61bbb9f7ef05793c6c1dc4c76a57 (diff)
tst_qnetworkreply: deduplicate some code
Moved a line of code that appeared after each call to setupSslServer() into that function and replaced a copy of its code with a call to it. Moved a line from the end of both branches of an if/else to after it. Change-Id: I74ef3e643e41ce0279a6de7f4828baea4423f267 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index 856af50d33..8e370e193d 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -547,6 +547,7 @@ static void setupSslServer(QSslSocket* serverSocket)
serverSocket->setProtocol(QSsl::AnyProtocol);
serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem");
serverSocket->setPrivateKey(testDataDir + "/certs/server.key");
+ serverSocket->startServerEncryption();
}
#endif
@@ -596,7 +597,6 @@ protected:
if (!doSsl) {
client = new QTcpSocket;
client->setSocketDescriptor(socketDescriptor);
- connectSocketSignals();
} else {
#ifndef QT_NO_SSL
QSslSocket *serverSocket = new QSslSocket;
@@ -604,15 +604,14 @@ protected:
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
setupSslServer(serverSocket);
- serverSocket->startServerEncryption();
client = serverSocket;
- connectSocketSignals();
} else {
delete serverSocket;
return;
}
#endif
}
+ connectSocketSignals();
client->setParent(this);
++totalConnections;
}
@@ -943,7 +942,6 @@ public:
serverSocket->setSocketDescriptor(socketDescriptor);
connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
setupSslServer(serverSocket);
- serverSocket->startServerEncryption();
sslSocket = serverSocket;
} else
#endif
@@ -4784,16 +4782,9 @@ public:
emit newPlainConnection(serverSocket);
return;
}
- QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath();
- if (testDataDir.isEmpty())
- testDataDir = QCoreApplication::applicationDirPath();
-
connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot()));
- serverSocket->setProtocol(QSsl::AnyProtocol);
connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), serverSocket, SLOT(ignoreSslErrors()));
- serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem");
- serverSocket->setPrivateKey(testDataDir + "/certs/server.key");
- serverSocket->startServerEncryption();
+ setupSslServer(serverSocket);
} else {
delete serverSocket;
}