tst_qnetworkreply - remove qRegisterMetaType duplicates

The metatypes are registered in the constructor, don't need to
register them in test cases as well.
Registering in a test case is bad practice, as it could result
in tests failing when run individually due to unknown metatype.

Change-Id: Ic4d65d0f5fe3cdd3ab57cf2512a4906d71205a05
Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
This commit is contained in:
Shane Kearns 2012-03-05 17:36:28 +00:00 committed by Qt by Nokia
parent 69c428a810
commit fbd45a9311

View File

@ -2971,9 +2971,6 @@ void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous()
void tst_QNetworkReply::ioGetFromHttpWithProxyAuth() void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
{ {
qRegisterMetaType<QNetworkProxy>(); // for QSignalSpy
qRegisterMetaType<QAuthenticator *>();
// This test sends three requests // This test sends three requests
// The first two in parallel // The first two in parallel
// The third after the first two finished // The third after the first two finished
@ -3081,9 +3078,6 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
// HTTP caching proxies are tested by the above function // HTTP caching proxies are tested by the above function
// test SOCKSv5 proxies too // test SOCKSv5 proxies too
qRegisterMetaType<QNetworkProxy>(); // for QSignalSpy
qRegisterMetaType<QAuthenticator *>();
QFile reference(testDataDir + "/rfc3252.txt"); QFile reference(testDataDir + "/rfc3252.txt");
QVERIFY(reference.open(QIODevice::ReadOnly)); QVERIFY(reference.open(QIODevice::ReadOnly));
@ -3141,9 +3135,6 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
#ifndef QT_NO_SSL #ifndef QT_NO_SSL
void tst_QNetworkReply::ioGetFromHttpsWithSslErrors() void tst_QNetworkReply::ioGetFromHttpsWithSslErrors()
{ {
qRegisterMetaType<QNetworkReply*>(); // for QSignalSpy
qRegisterMetaType<QList<QSslError> >();
QFile reference(testDataDir + "/rfc3252.txt"); QFile reference(testDataDir + "/rfc3252.txt");
QVERIFY(reference.open(QIODevice::ReadOnly)); QVERIFY(reference.open(QIODevice::ReadOnly));
@ -3175,9 +3166,6 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors()
// same as above, except that we call ignoreSslErrors and don't connect // same as above, except that we call ignoreSslErrors and don't connect
// to the sslErrors() signal (which is *still* emitted) // to the sslErrors() signal (which is *still* emitted)
qRegisterMetaType<QNetworkReply*>(); // for QSignalSpy
qRegisterMetaType<QList<QSslError> >();
QFile reference(testDataDir + "/rfc3252.txt"); QFile reference(testDataDir + "/rfc3252.txt");
QVERIFY(reference.open(QIODevice::ReadOnly)); QVERIFY(reference.open(QIODevice::ReadOnly));
@ -3203,9 +3191,6 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors()
void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError() void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError()
{ {
qRegisterMetaType<QNetworkReply*>(); // for QSignalSpy
qRegisterMetaType<QList<QSslError> >();
QFile reference(testDataDir + "/rfc3252.txt"); QFile reference(testDataDir + "/rfc3252.txt");
QVERIFY(reference.open(QIODevice::ReadOnly)); QVERIFY(reference.open(QIODevice::ReadOnly));
@ -3709,9 +3694,6 @@ void tst_QNetworkReply::ioGetWithManyProxies()
{ {
// Test proxy factories // Test proxy factories
qRegisterMetaType<QNetworkProxy>(); // for QSignalSpy
qRegisterMetaType<QAuthenticator *>();
QFile reference(testDataDir + "/rfc3252.txt"); QFile reference(testDataDir + "/rfc3252.txt");
QVERIFY(reference.open(QIODevice::ReadOnly)); QVERIFY(reference.open(QIODevice::ReadOnly));
@ -4108,10 +4090,6 @@ void tst_QNetworkReply::ioPostToHttpFromSocket_data()
void tst_QNetworkReply::ioPostToHttpFromSocket() void tst_QNetworkReply::ioPostToHttpFromSocket()
{ {
qRegisterMetaType<QNetworkProxy>(); // for QSignalSpy
qRegisterMetaType<QAuthenticator *>();
qRegisterMetaType<QNetworkReply *>();
QFETCH(QByteArray, data); QFETCH(QByteArray, data);
QFETCH(QUrl, url); QFETCH(QUrl, url);
QFETCH(QNetworkProxy, proxy); QFETCH(QNetworkProxy, proxy);
@ -4711,7 +4689,6 @@ void tst_QNetworkReply::rateControl()
QNetworkRequest request("debugpipe://localhost:" + QString::number(sender.serverPort())); QNetworkRequest request("debugpipe://localhost:" + QString::number(sender.serverPort()));
QNetworkReplyPtr reply = manager.get(request); QNetworkReplyPtr reply = manager.get(request);
reply->setReadBufferSize(32768); reply->setReadBufferSize(32768);
qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
RateControlledReader reader(sender, reply, rate, 20); RateControlledReader reader(sender, reply, rate, 20);
@ -5104,7 +5081,6 @@ void tst_QNetworkReply::nestedEventLoops()
// seconds. (see above) // seconds. (see above)
qDebug("Takes 16 seconds to run, please wait"); qDebug("Takes 16 seconds to run, please wait");
qRegisterMetaType<QNetworkReply::NetworkError>();
QUrl url("http://" + QtNetworkSettings::serverName()); QUrl url("http://" + QtNetworkSettings::serverName());
QNetworkRequest request(url); QNetworkRequest request(url);
@ -5325,7 +5301,6 @@ void tst_QNetworkReply::authorizationError()
QCOMPARE(reply->error(), QNetworkReply::NoError); QCOMPARE(reply->error(), QNetworkReply::NoError);
qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
QSignalSpy finishedSpy(reply, SIGNAL(finished())); QSignalSpy finishedSpy(reply, SIGNAL(finished()));
// now run the request: // now run the request:
@ -6054,11 +6029,8 @@ void tst_QNetworkReply::qtbug4121unknownAuthentication()
QNetworkAccessManager manager; QNetworkAccessManager manager;
QNetworkReplyPtr reply = manager.get(request); QNetworkReplyPtr reply = manager.get(request);
qRegisterMetaType<QNetworkReply*>("QNetworkReply*");
qRegisterMetaType<QAuthenticator*>("QAuthenticator*");
QSignalSpy authSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); QSignalSpy authSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*))); QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*)));
qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);