tests/auto/network: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).

- Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer).
- Replace Q[TRY]_VERIFY(smartPointer == 0)  by
          Q[TRY]_VERIFY(smartPointer.isNull()).
- Replace Q[TRY]_VERIFY(a == b) by  Q[TRY]_COMPARE(a, b) and
  add casts where necessary. The values will then be logged
  should a test fail.

Change-Id: Icaa1edafcc6e2779fbd6dbc2c058544d6e07f1e9
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Friedemann Kleint 2015-07-24 15:47:02 +02:00
parent cc7fcecd7a
commit 57dbdcd92f
17 changed files with 355 additions and 354 deletions

View File

@ -83,7 +83,7 @@ void tst_QNetworkCookie::getterSetter()
QNetworkCookie cookie;
QNetworkCookie otherCookie;
QVERIFY(cookie == otherCookie);
QCOMPARE(cookie, otherCookie);
QCOMPARE(cookie, otherCookie);
QVERIFY(!(cookie != otherCookie));
@ -133,7 +133,7 @@ void tst_QNetworkCookie::getterSetter()
cookie.setSecure(false);
QVERIFY(!cookie.isSecure());
QVERIFY(cookie == otherCookie);
QCOMPARE(cookie, otherCookie);
}
void tst_QNetworkCookie::parseSingleCookie_data()

View File

@ -1678,7 +1678,7 @@ void tst_QNetworkReply::getFromFile()
static const char fileData[] = "This is some data that is in the file.\r\n";
QByteArray data = QByteArray::fromRawData(fileData, sizeof fileData - 1);
QVERIFY(file.write(data) == data.size());
QCOMPARE(file.write(data), data.size());
file.flush();
QCOMPARE(file.size(), qint64(data.size()));
@ -2926,9 +2926,9 @@ void tst_QNetworkReply::connectToIPv6Address()
//qDebug() << server.receivedData;
QByteArray hostinfo = "\r\nHost: " + hostfield + ":" + QByteArray::number(server.serverPort()) + "\r\n";
QVERIFY(server.receivedData.contains(hostinfo));
QVERIFY(content == dataToSend);
QCOMPARE(content, dataToSend);
QCOMPARE(reply->url(), request.url());
QVERIFY(reply->error() == error);
QCOMPARE(reply->error(), error);
}
void tst_QNetworkReply::sendCustomRequestToHttp_data()
@ -3060,7 +3060,7 @@ void tst_QNetworkReply::ioGetFromFile()
QVERIFY(file.open());
QFETCH(QByteArray, data);
QVERIFY(file.write(data) == data.size());
QCOMPARE(file.write(data), data.size());
file.flush();
QCOMPARE(file.size(), qint64(data.size()));
@ -3130,8 +3130,8 @@ void tst_QNetworkReply::ioGetFromFtpWithReuse()
DataReader reader2(reply2);
QSignalSpy spy(reply1.data(), SIGNAL(finished()));
QVERIFY(waitForFinish(reply1) == Success);
QVERIFY(waitForFinish(reply2) == Success);
QCOMPARE(waitForFinish(reply1), int(Success));
QCOMPARE(waitForFinish(reply2), int(Success));
QCOMPARE(reply1->url(), request.url());
QCOMPARE(reply2->url(), request.url());
@ -3181,8 +3181,8 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseParallel()
DataReader reader2(reply2);
QSignalSpy spy(reply1.data(), SIGNAL(finished()));
QVERIFY(waitForFinish(reply2) == Success);
QVERIFY(waitForFinish(reply1) == Success);
QCOMPARE(waitForFinish(reply2), int(Success));
QCOMPARE(waitForFinish(reply1), int(Success));
QCOMPARE(reply1->url(), request.url());
QCOMPARE(reply2->url(), request.url());
@ -3284,8 +3284,8 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QVERIFY(waitForFinish(reply2) == Success);
QVERIFY(waitForFinish(reply1) == Success);
QCOMPARE(waitForFinish(reply2), int(Success));
QCOMPARE(waitForFinish(reply1), int(Success));
manager.disconnect(SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@ -3414,8 +3414,8 @@ void tst_QNetworkReply::ioGetFromHttpWithProxyAuth()
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
QVERIFY(waitForFinish(reply2) == Success);
QVERIFY(waitForFinish(reply1) == Success);
QCOMPARE(waitForFinish(reply2), int(Success));
QCOMPARE(waitForFinish(reply1), int(Success));
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@ -3537,7 +3537,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy()
connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@ -3625,7 +3625,7 @@ void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError()
QSignalSpy sslspy(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
connect(reply, SIGNAL(metaDataChanged()), SLOT(storeSslConfiguration()));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->error(), QNetworkReply::SslHandshakeFailedError);
QCOMPARE(sslspy.count(), 0);
@ -3683,7 +3683,7 @@ void tst_QNetworkReply::ioGetFromHttpBrokenServer()
QNetworkReplyPtr reply(manager.get(request));
QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->url(), request.url());
QCOMPARE(spy.count(), 1);
@ -4734,7 +4734,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag()
connect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*)));
@ -5104,7 +5104,7 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress()
QVERIFY(!QTestEventLoop::instance().timeout());
// final check: only 1 uploadProgress has been emitted
QVERIFY(spy.length() == 1);
QCOMPARE(spy.length(), 1);
QList<QVariant> args = spy.last();
QVERIFY(!args.isEmpty());
QCOMPARE(args.at(0).toLongLong(), buffer.size());
@ -5348,7 +5348,7 @@ void tst_QNetworkReply::chaining()
QVERIFY(sourceFile.open());
QFETCH(QByteArray, data);
QVERIFY(sourceFile.write(data) == data.size());
QCOMPARE(sourceFile.write(data), data.size());
sourceFile.flush();
QCOMPARE(sourceFile.size(), qint64(data.size()));
@ -5360,7 +5360,7 @@ void tst_QNetworkReply::chaining()
request.setUrl(url);
QNetworkReplyPtr putReply(manager.put(request, getReply.data()));
QVERIFY(waitForFinish(putReply) == Success);
QCOMPARE(waitForFinish(putReply), int(Success));
QCOMPARE(getReply->url(), QUrl::fromLocalFile(sourceFile.fileName()));
QCOMPARE(getReply->error(), QNetworkReply::NoError);
@ -5767,7 +5767,7 @@ void tst_QNetworkReply::proxyChange()
// verify that the replies succeeded
QCOMPARE(reply1->error(), QNetworkReply::NoError);
QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
QVERIFY(reply1->size() == 1);
QCOMPARE(reply1->size(), 1);
QCOMPARE(reply2->error(), QNetworkReply::NoError);
QCOMPARE(reply2->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
@ -5784,7 +5784,7 @@ void tst_QNetworkReply::proxyChange()
manager.setProxy(dummyProxy);
QNetworkReplyPtr reply3(manager.get(req));
QVERIFY(waitForFinish(reply3) == Failure);
QCOMPARE(waitForFinish(reply3), int(Failure));
QVERIFY(int(reply3->error()) > 0);
}
@ -5820,7 +5820,7 @@ void tst_QNetworkReply::authorizationError()
QSignalSpy errorSpy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
QSignalSpy finishedSpy(reply.data(), SIGNAL(finished()));
// now run the request:
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QFETCH(int, errorSignalCount);
QCOMPARE(errorSpy.count(), errorSignalCount);
@ -5995,7 +5995,7 @@ public slots:
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
QVERIFY(!reply->error());
QVERIFY(reply->bytesAvailable() == 27906);
QCOMPARE(reply->bytesAvailable(), 27906);
if (requestsFinishedCount == 60) {
QTestEventLoop::instance().exitLoop();
@ -6513,7 +6513,7 @@ public:
void finishedSlot() {
// We should have already received all readyRead
QVERIFY(!bytesAvailableList.isEmpty());
QVERIFY(bytesAvailableList.last() == uploadSize);
QCOMPARE(bytesAvailableList.last(), uploadSize);
}
};
@ -6596,7 +6596,7 @@ void tst_QNetworkReply::ioGetFromHttpWithoutContentLength()
QCOMPARE(reply->url(), request.url());
QVERIFY(reply->isFinished());
QVERIFY(reply->error() == QNetworkReply::NoError);
QCOMPARE(reply->error(), QNetworkReply::NoError);
}
// Is handled somewhere else too, introduced this special test to have it more accessible
@ -6663,7 +6663,7 @@ void tst_QNetworkReply::compressedHttpReplyBrokenGzip()
QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort())));
QNetworkReplyPtr reply(manager.get(request));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(reply->error(), QNetworkReply::ProtocolFailure);
}
@ -6676,7 +6676,7 @@ void tst_QNetworkReply::getFromUnreachableIp()
QNetworkRequest request(QUrl("http://255.255.255.255/42/23/narf/narf/narf"));
QNetworkReplyPtr reply(manager.get(request));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QVERIFY(reply->error() != QNetworkReply::NoError);
}
@ -7465,7 +7465,7 @@ void tst_QNetworkReply::httpAbort()
QNetworkRequest request3("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt");
QNetworkReplyPtr reply3(manager.get(request3));
QVERIFY(waitForFinish(reply3) == Success);
QCOMPARE(waitForFinish(reply3), int(Success));
QVERIFY(reply3->isFinished());
reply3->abort();
@ -8095,11 +8095,11 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects()
QSignalSpy redSpy(reply.data(), SIGNAL(redirected(QUrl)));
QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(redSpy.count(), request.maximumRedirectsAllowed());
QCOMPARE(spy.count(), 1);
QVERIFY(reply->error() == QNetworkReply::TooManyRedirectsError);
QCOMPARE(reply->error(), QNetworkReply::TooManyRedirectsError);
// Increase max redirects to allow successful completion
request.setMaximumRedirectsAllowed(3);
@ -8111,7 +8111,7 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects()
QCOMPARE(redSpy2.count(), 2);
QCOMPARE(reply2->url(), server3Url);
QVERIFY(reply2->error() == QNetworkReply::NoError);
QCOMPARE(reply2->error(), QNetworkReply::NoError);
}
void tst_QNetworkReply::ioHttpRedirectErrors_data()
@ -8151,10 +8151,10 @@ void tst_QNetworkReply::ioHttpRedirectErrors()
reply.data()->ignoreSslErrors();
QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError)));
QVERIFY(waitForFinish(reply) == Failure);
QCOMPARE(waitForFinish(reply), int(Failure));
QCOMPARE(spy.count(), 1);
QVERIFY(reply->error() == error);
QCOMPARE(reply->error(), error);
}
#ifndef QT_NO_SSL

View File

@ -68,7 +68,7 @@ void tst_QNetworkConfiguration::invalidPoint()
QVERIFY(pt.name().isEmpty());
QVERIFY(!pt.isValid());
QVERIFY(pt.type() == QNetworkConfiguration::Invalid);
QCOMPARE(pt.type(), QNetworkConfiguration::Invalid);
QVERIFY(!(pt.state() & QNetworkConfiguration::Defined));
QVERIFY(!(pt.state() & QNetworkConfiguration::Discovered));
QVERIFY(!(pt.state() & QNetworkConfiguration::Active));
@ -77,7 +77,7 @@ void tst_QNetworkConfiguration::invalidPoint()
QNetworkConfiguration pt2(pt);
QVERIFY(pt2.name().isEmpty());
QVERIFY(!pt2.isValid());
QVERIFY(pt2.type() == QNetworkConfiguration::Invalid);
QCOMPARE(pt2.type(), QNetworkConfiguration::Invalid);
QVERIFY(!(pt2.state() & QNetworkConfiguration::Defined));
QVERIFY(!(pt2.state() & QNetworkConfiguration::Discovered));
QVERIFY(!(pt2.state() & QNetworkConfiguration::Active));
@ -91,27 +91,27 @@ void tst_QNetworkConfiguration::comparison()
//compare invalid connection points
QNetworkConfiguration pt1;
QVERIFY(!pt1.isValid());
QVERIFY(pt1.type() == QNetworkConfiguration::Invalid);
QCOMPARE(pt1.type(), QNetworkConfiguration::Invalid);
QNetworkConfiguration pt2(pt1);
QVERIFY(pt1==pt2);
QVERIFY(!(pt1!=pt2));
QVERIFY(pt1.name() == pt2.name());
QVERIFY(pt1.isValid() == pt2.isValid());
QVERIFY(pt1.type() == pt2.type());
QVERIFY(pt1.state() == pt2.state());
QVERIFY(pt1.purpose() == pt2.purpose());
QCOMPARE(pt1.name(), pt2.name());
QCOMPARE(pt1.isValid(), pt2.isValid());
QCOMPARE(pt1.type(), pt2.type());
QCOMPARE(pt1.state(), pt2.state());
QCOMPARE(pt1.purpose(), pt2.purpose());
QNetworkConfiguration pt3;
pt3 = pt1;
QVERIFY(pt1==pt3);
QVERIFY(!(pt1!=pt3));
QVERIFY(pt1.name() == pt3.name());
QVERIFY(pt1.isValid() == pt3.isValid());
QVERIFY(pt1.type() == pt3.type());
QVERIFY(pt1.state() == pt3.state());
QVERIFY(pt1.purpose() == pt3.purpose());
QCOMPARE(pt1.name(), pt3.name());
QCOMPARE(pt1.isValid(), pt3.isValid());
QCOMPARE(pt1.type(), pt3.type());
QCOMPARE(pt1.state(), pt3.state());
QCOMPARE(pt1.purpose(), pt3.purpose());
//test case must run on machine that has valid connection points
QNetworkConfigurationManager manager;
@ -131,11 +131,11 @@ void tst_QNetworkConfiguration::comparison()
pt3 = defaultConfig;
QVERIFY(defaultConfig==pt3);
QVERIFY(!(defaultConfig!=pt3));
QVERIFY(defaultConfig.name() == pt3.name());
QVERIFY(defaultConfig.isValid() == pt3.isValid());
QVERIFY(defaultConfig.type() == pt3.type());
QVERIFY(defaultConfig.state() == pt3.state());
QVERIFY(defaultConfig.purpose() == pt3.purpose());
QCOMPARE(defaultConfig.name(), pt3.name());
QCOMPARE(defaultConfig.isValid(), pt3.isValid());
QCOMPARE(defaultConfig.type(), pt3.type());
QCOMPARE(defaultConfig.state(), pt3.state());
QCOMPARE(defaultConfig.purpose(), pt3.purpose());
}
void tst_QNetworkConfiguration::children()
@ -178,7 +178,7 @@ void tst_QNetworkConfiguration::isRoamingAvailable()
if ( c.children().count() <= 1 )
QVERIFY(!c.isRoamingAvailable());
foreach(QNetworkConfiguration child, c.children()) {
QVERIFY(QNetworkConfiguration::InternetAccessPoint == child.type());
QCOMPARE(QNetworkConfiguration::InternetAccessPoint, child.type());
QCOMPARE(child.children().count(), 0);
}
} else {

View File

@ -168,7 +168,7 @@ void tst_QNetworkConfigurationManager::defaultConfiguration()
QVERIFY(!defaultConfig.isRoamingAvailable());
QCOMPARE(defaultConfig.state(), QNetworkConfiguration::Discovered);
QNetworkConfiguration copy = manager.configurationFromIdentifier(defaultConfig.identifier());
QVERIFY(copy == defaultConfig);
QCOMPARE(copy, defaultConfig);
}
}
@ -190,7 +190,7 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier()
QNetworkConfiguration direct = manager.configurationFromIdentifier(c.identifier());
QVERIFY(direct.isValid());
QVERIFY(direct == c);
QCOMPARE(direct, c);
}
//assume that there is no item with identifier 'FooBar'

View File

@ -187,19 +187,19 @@ void tst_QNetworkSession::invalidSession()
// 1. Verify that session created with invalid configuration remains in invalid state
QNetworkSession session(QNetworkConfiguration(), 0);
QVERIFY(!session.isOpen());
QVERIFY(session.state() == QNetworkSession::Invalid);
QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
QCOMPARE(session.state(), QNetworkSession::Invalid);
QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError);
// 2. Verify that opening session with invalid configuration both 1) emits invalidconfigurationerror and 2) sets session's state as invalid.
QSignalSpy errorSpy(&session, SIGNAL(error(QNetworkSession::SessionError)));
session.open();
session.waitForOpened(1000); // Should bail out right away
QVERIFY(errorSpy.count() == 1);
QCOMPARE(errorSpy.count(), 1);
QNetworkSession::SessionError error =
qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
QVERIFY(error == QNetworkSession::InvalidConfigurationError);
QVERIFY(session.error() == QNetworkSession::InvalidConfigurationError);
QVERIFY(session.state() == QNetworkSession::Invalid);
QCOMPARE(error, QNetworkSession::InvalidConfigurationError);
QCOMPARE(session.error(), QNetworkSession::InvalidConfigurationError);
QCOMPARE(session.state(), QNetworkSession::Invalid);
#ifdef QNETWORKSESSION_MANUAL_TESTS
@ -210,7 +210,7 @@ void tst_QNetworkSession::invalidSession()
qDebug() << "Delete the WLAN IAP from phone now (waiting 60 seconds): " << invalidatedConfig.name();
QTest::qWait(60000);
QVERIFY(!invalidatedConfig.isValid());
QVERIFY(invalidatedSession.state() == QNetworkSession::Invalid);
QCOMPARE(invalidatedSession.state(), QNetworkSession::Invalid);
qDebug() << "Add the WLAN IAP back (waiting 60 seconds): " << invalidatedConfig.name();
QTest::qWait(60000);
}
@ -235,11 +235,11 @@ void tst_QNetworkSession::invalidSession()
QVERIFY(definedSession.state() == QNetworkSession::NotAvailable); // State is not available because WLAN is not in coverage
QVERIFY(!errorSpy.isEmpty()); // Session tells with error about invalidated configuration
sessionError = qvariant_cast<QNetworkSession::SessionError> (errorSpy.first().at(0));
QVERIFY(sessionError == QNetworkSession::InvalidConfigurationError);
QCOMPARE(sessionError, QNetworkSession::InvalidConfigurationError);
qDebug() << "Turn the WLAN IAP back on (waiting 60 seconds): " << definedConfig.name();
QTest::qWait(60000);
updateConfigurations();
QVERIFY(definedConfig.state() == QNetworkConfiguration::Discovered);
QCOMPARE(definedConfig.state(), QNetworkConfiguration::Discovered);
}
#endif
}
@ -260,7 +260,7 @@ void tst_QNetworkSession::sessionProperties()
{
QFETCH(QNetworkConfiguration, configuration);
QNetworkSession session(configuration);
QVERIFY(session.configuration() == configuration);
QCOMPARE(session.configuration(), configuration);
QStringList validBearerNames = QStringList() << QLatin1String("Unknown")
<< QLatin1String("Ethernet")
<< QLatin1String("WLAN")
@ -303,10 +303,10 @@ void tst_QNetworkSession::sessionProperties()
} else {
switch (configuration.state()) {
case QNetworkConfiguration::Undefined:
QVERIFY(session.state() == QNetworkSession::NotAvailable);
QCOMPARE(session.state(), QNetworkSession::NotAvailable);
break;
case QNetworkConfiguration::Defined:
QVERIFY(session.state() == QNetworkSession::NotAvailable);
QCOMPARE(session.state(), QNetworkSession::NotAvailable);
break;
case QNetworkConfiguration::Discovered:
QVERIFY(session.state() == QNetworkSession::Connecting ||
@ -372,12 +372,12 @@ void tst_QNetworkSession::userChoiceSession()
{
QFETCH(QNetworkConfiguration, configuration);
QVERIFY(configuration.type() == QNetworkConfiguration::UserChoice);
QCOMPARE(configuration.type(), QNetworkConfiguration::UserChoice);
QNetworkSession session(configuration);
// Check that configuration was really set
QVERIFY(session.configuration() == configuration);
QCOMPARE(session.configuration(), configuration);
QVERIFY(!session.isOpen());
@ -431,7 +431,7 @@ void tst_QNetworkSession::userChoiceSession()
if (expectStateChange)
QTRY_VERIFY_WITH_TIMEOUT(!stateChangedSpy.isEmpty(), TestTimeOut);
QVERIFY(session.state() == QNetworkSession::Connected);
QCOMPARE(session.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
#endif
@ -462,16 +462,16 @@ void tst_QNetworkSession::userChoiceSession()
manager.configurationFromIdentifier(activeIdentifier);
QVERIFY(activeConfiguration.isValid());
QVERIFY(activeConfiguration.type() == QNetworkConfiguration::InternetAccessPoint);
QCOMPARE(activeConfiguration.type(), QNetworkConfiguration::InternetAccessPoint);
//resetting ActiveConfiguration is ignored (read only property)
session.setSessionProperty("ActiveConfiguration", testIdentifier);
QVERIFY(session.sessionProperty("ActiveConfiguration").toString() != testIdentifier);
if (userChoiceConfiguration.type() == QNetworkConfiguration::InternetAccessPoint) {
QVERIFY(userChoiceConfiguration == activeConfiguration);
QCOMPARE(userChoiceConfiguration, activeConfiguration);
} else {
QVERIFY(userChoiceConfiguration.type() == QNetworkConfiguration::ServiceNetwork);
QCOMPARE(userChoiceConfiguration.type(), QNetworkConfiguration::ServiceNetwork);
QVERIFY(userChoiceConfiguration.children().contains(activeConfiguration));
}
} else {
@ -508,13 +508,13 @@ void tst_QNetworkSession::sessionOpenCloseStop()
// Test initial state of the session.
{
QVERIFY(session.configuration() == configuration);
QCOMPARE(session.configuration(), configuration);
QVERIFY(!session.isOpen());
// session may be invalid if configuration is removed between when
// sessionOpenCloseStop_data() is called and here.
QVERIFY((configuration.isValid() && (session.state() != QNetworkSession::Invalid)) ||
(!configuration.isValid() && (session.state() == QNetworkSession::Invalid)));
QVERIFY(session.error() == QNetworkSession::UnknownSessionError);
QCOMPARE(session.error(), QNetworkSession::UnknownSessionError);
}
// The remaining tests require the session to be not NotAvailable.
@ -544,7 +544,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::SessionError error =
qvariant_cast<QNetworkSession::SessionError>(errorSpy.first().at(0));
QVERIFY(session.state() == previousState);
QCOMPARE(session.state(), previousState);
if (error == QNetworkSession::OperationNotSupportedError) {
// The session needed to bring up the interface,
@ -574,13 +574,13 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::State state =
qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(0).at(0));
QVERIFY(state == QNetworkSession::Connecting);
QCOMPARE(state, QNetworkSession::Connecting);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(1).at(0));
QVERIFY(state == QNetworkSession::Connected);
QCOMPARE(state, QNetworkSession::Connected);
}
QVERIFY(session.state() == QNetworkSession::Connected);
QCOMPARE(session.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
#endif
@ -603,10 +603,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
// Test opening a second session.
{
QVERIFY(session2.configuration() == configuration);
QCOMPARE(session2.configuration(), configuration);
QVERIFY(!session2.isOpen());
QVERIFY(session2.state() == QNetworkSession::Connected);
QVERIFY(session.error() == QNetworkSession::UnknownSessionError);
QCOMPARE(session2.state(), QNetworkSession::Connected);
QCOMPARE(session.error(), QNetworkSession::UnknownSessionError);
session2.open();
@ -614,10 +614,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
if (errorSpy2.isEmpty()) {
QVERIFY(session2.isOpen());
QVERIFY(session2.state() == QNetworkSession::Connected);
QCOMPARE(session2.state(), QNetworkSession::Connected);
}
QVERIFY(session.isOpen());
QVERIFY(session.state() == QNetworkSession::Connected);
QCOMPARE(session.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
if (errorSpy2.isEmpty()) {
@ -651,8 +651,8 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::SessionError error2 =
qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0));
QVERIFY(error == QNetworkSession::SessionAbortedError);
QVERIFY(error2 == QNetworkSession::SessionAbortedError);
QCOMPARE(error, QNetworkSession::SessionAbortedError);
QCOMPARE(error2, QNetworkSession::SessionAbortedError);
QCOMPARE(errorSpy.count(), 1);
QCOMPARE(errorSpy2.count(), 1);
@ -671,8 +671,8 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QTRY_VERIFY_WITH_TIMEOUT(stateChangedSpy2.count() >= 1 || !errorSpy2.isEmpty(), TestTimeOut);
if (!errorSpy2.isEmpty()) {
QVERIFY(session2.state() == previousState);
QVERIFY(session.state() == previousState);
QCOMPARE(session2.state(), previousState);
QCOMPARE(session.state(), previousState);
QNetworkSession::SessionError error =
qvariant_cast<QNetworkSession::SessionError>(errorSpy2.first().at(0));
@ -700,22 +700,22 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::State state;
if (stateChangedSpy2.count() == 4) {
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0));
QVERIFY(state == QNetworkSession::Connecting);
QCOMPARE(state, QNetworkSession::Connecting);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0));
QVERIFY(state == QNetworkSession::Connected);
QCOMPARE(state, QNetworkSession::Connected);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(2).at(0));
QVERIFY(state == QNetworkSession::Closing);
QCOMPARE(state, QNetworkSession::Closing);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0));
QVERIFY(state == QNetworkSession::Disconnected);
QCOMPARE(state, QNetworkSession::Disconnected);
} else if (stateChangedSpy2.count() == 2) {
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0));
QVERIFY(state == QNetworkSession::Closing);
QCOMPARE(state, QNetworkSession::Closing);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0));
QVERIFY(state == QNetworkSession::Disconnected);
QCOMPARE(state, QNetworkSession::Disconnected);
} else {
QFAIL("Unexpected amount of state changes when roaming.");
}
@ -751,7 +751,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
if (stateChangedSpy.count() > 1) {
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0));
QVERIFY(state == QNetworkSession::Roaming);
QCOMPARE(state, QNetworkSession::Roaming);
}
roamedSuccessfully = true;
}
@ -779,9 +779,9 @@ void tst_QNetworkSession::sessionOpenCloseStop()
if (stateChangedSpy2.count() == 2) {
QNetworkSession::State state =
qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0));
QVERIFY(state == QNetworkSession::Closing);
QCOMPARE(state, QNetworkSession::Closing);
state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0));
QVERIFY(state == QNetworkSession::Disconnected);
QCOMPARE(state, QNetworkSession::Disconnected);
} else {
QVERIFY(stateChangedSpy2.count() >= 1);
@ -794,7 +794,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QNetworkSession::State state =
qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0));
QVERIFY(state == QNetworkSession::Disconnected);
QCOMPARE(state, QNetworkSession::Disconnected);
}
}
@ -821,14 +821,14 @@ void tst_QNetworkSession::sessionOpenCloseStop()
session2.close();
QTRY_VERIFY_WITH_TIMEOUT(!sessionClosedSpy2.isEmpty(), TestTimeOut);
QVERIFY(stateChangedSpy2.count() == stateChangedCountBeforeClose);
QCOMPARE(stateChangedSpy2.count(), stateChangedCountBeforeClose);
QVERIFY(sessionClosedSpy.isEmpty());
QVERIFY(session.isOpen());
QVERIFY(!session2.isOpen());
QVERIFY(session.state() == QNetworkSession::Connected);
QVERIFY(session2.state() == QNetworkSession::Connected);
QCOMPARE(session.state(), QNetworkSession::Connected);
QCOMPARE(session2.state(), QNetworkSession::Connected);
#ifndef QT_NO_NETWORKINTERFACE
QVERIFY(session.interface().isValid());
QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress());
@ -1236,7 +1236,7 @@ void tst_QNetworkSession::sessionAutoClose()
QNetworkSession session(configuration);
QVERIFY(session.configuration() == configuration);
QCOMPARE(session.configuration(), configuration);
QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout"));
@ -1262,7 +1262,7 @@ void tst_QNetworkSession::sessionAutoClose()
QVERIFY(!session.isOpen());
QVERIFY(session.configuration() == configuration);
QCOMPARE(session.configuration(), configuration);
autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout"));

View File

@ -82,7 +82,7 @@ void tst_QAuthenticator::basicAuth()
QAuthenticator auth;
auth.detach();
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
QList<QPair<QByteArray, QByteArray> > headers;
headers << qMakePair<QByteArray, QByteArray>(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8());
@ -94,7 +94,7 @@ void tst_QAuthenticator::basicAuth()
auth.setUser(user);
auth.setPassword(password);
QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData());
}
@ -125,7 +125,7 @@ void tst_QAuthenticator::ntlmAuth()
auth.detach();
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
QList<QPair<QByteArray, QByteArray> > headers;

View File

@ -234,7 +234,7 @@ void tst_QHostAddress::setAddress_QString()
QFETCH(int, protocol);
QHostAddress hostAddr;
QVERIFY(hostAddr.setAddress(address) == ok);
QCOMPARE(hostAddr.setAddress(address), ok);
if (ok)
QTEST(hostAddr.toString(), "resAddr");
@ -330,7 +330,7 @@ void tst_QHostAddress::compare()
QCOMPARE(first == second, result);
QCOMPARE(second == first, result);
if (result == true)
QVERIFY(qHash(first) == qHash(second));
QCOMPARE(qHash(first), qHash(second));
}
void tst_QHostAddress::assignment()
@ -399,11 +399,11 @@ void tst_QHostAddress::streaming()
QByteArray ba;
QDataStream ds1(&ba, QIODevice::WriteOnly);
ds1 << address;
QVERIFY(ds1.status() == QDataStream::Ok);
QCOMPARE(ds1.status(), QDataStream::Ok);
QDataStream ds2(&ba, QIODevice::ReadOnly);
QHostAddress address2;
ds2 >> address2;
QVERIFY(ds2.status() == QDataStream::Ok);
QCOMPARE(ds2.status(), QDataStream::Ok);
QCOMPARE(address, address2);
}

View File

@ -76,7 +76,7 @@ void tst_QNetworkAddressEntry::getSetCheck()
entry = entry2;
QCOMPARE(entry, entry2);
QVERIFY(entry == entry);
QCOMPARE(entry, entry);
QVERIFY(!(entry != entry2));
}

View File

@ -130,18 +130,18 @@ void tst_PlatformSocketEngine::construction()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.isValid());
QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol);
QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol);
QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
QVERIFY(socketDevice.socketDescriptor() != -1);
QVERIFY(socketDevice.localAddress() == QHostAddress());
QVERIFY(socketDevice.localPort() == 0);
QVERIFY(socketDevice.peerAddress() == QHostAddress());
QVERIFY(socketDevice.peerPort() == 0);
QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
QCOMPARE(socketDevice.localAddress(), QHostAddress());
QCOMPARE(socketDevice.localPort(), quint16(0));
QCOMPARE(socketDevice.peerAddress(), QHostAddress());
QCOMPARE(socketDevice.peerPort(), quint16(0));
QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QVERIFY(socketDevice.bytesAvailable() == -1);
QCOMPARE(socketDevice.bytesAvailable(), -1);
QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
@ -154,16 +154,16 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
const bool isConnected = socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143);
if (!isConnected) {
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
}
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@ -200,8 +200,8 @@ void tst_PlatformSocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//---------------------------------------------------------------------------
@ -213,13 +213,13 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
QVERIFY(udpSocket.isValid());
QVERIFY(udpSocket.socketDescriptor() != -1);
QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol);
QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket);
QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol);
QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket);
QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState);
// Bind #1 to localhost
QVERIFY(udpSocket.bind(QHostAddress("127.0.0.1"), 0));
QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
quint16 port = udpSocket.localPort();
QVERIFY(port != 0);
@ -229,7 +229,7 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(QHostAddress("127.0.0.1"), port));
QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
// Write a message to #1
QByteArray message1 = "hei der";
@ -248,7 +248,7 @@ void tst_PlatformSocketEngine::udpLoopbackTest()
QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(),
&senderAddress,
&senderPort) == message1.size());
QVERIFY(senderAddress == QHostAddress("127.0.0.1"));
QCOMPARE(senderAddress, QHostAddress("127.0.0.1"));
QVERIFY(senderPort != 0);
}
@ -261,13 +261,13 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
bool init = udpSocket.initialize(QAbstractSocket::UdpSocket, QAbstractSocket::IPv6Protocol);
if (!init) {
QVERIFY(udpSocket.error() == QAbstractSocket::UnsupportedSocketOperationError);
QCOMPARE(udpSocket.error(), QAbstractSocket::UnsupportedSocketOperationError);
} else {
QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv6Protocol);
QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv6Protocol);
// Bind #1 to localhost
QVERIFY(udpSocket.bind(QHostAddress("::1"), 0));
QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
quint16 port = udpSocket.localPort();
QVERIFY(port != 0);
@ -277,7 +277,7 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(QHostAddress("::1"), port));
QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
// Write a message to #1
QByteArray message1 = "hei der";
@ -296,7 +296,7 @@ void tst_PlatformSocketEngine::udpIPv6LoopbackTest()
QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(),
&senderAddress,
&senderPort) == message1.size());
QVERIFY(senderAddress == QHostAddress("::1"));
QCOMPARE(senderAddress, QHostAddress("::1"));
QVERIFY(senderPort != 0);
}
}
@ -314,7 +314,7 @@ void tst_PlatformSocketEngine::broadcastTest()
// Bind to any port on all interfaces
QVERIFY(broadcastSocket.bind(QHostAddress::Any, 0));
QVERIFY(broadcastSocket.state() == QAbstractSocket::BoundState);
QCOMPARE(broadcastSocket.state(), QAbstractSocket::BoundState);
quint16 port = broadcastSocket.localPort();
QVERIFY(port > 0);
@ -354,20 +354,20 @@ void tst_PlatformSocketEngine::serverTest()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
QVERIFY(server.state() == QAbstractSocket::BoundState);
QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
// The server accepts the connection
@ -378,7 +378,7 @@ void tst_PlatformSocketEngine::serverTest()
// socket descriptor from accept(). It's pre-connected.
PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
// The server socket sends a greeting to the clietn
QByteArray greeting = "Greetings!";
@ -407,13 +407,13 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance()
QVERIFY(udpSocket.initialize(QAbstractSocket::UdpSocket));
QVERIFY(udpSocket.isValid());
QVERIFY(udpSocket.socketDescriptor() != -1);
QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol);
QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket);
QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol);
QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket);
QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState);
// Bind #1 to localhost
QVERIFY(udpSocket.bind(QHostAddress("127.0.0.1"), 0));
QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
quint16 port = udpSocket.localPort();
QVERIFY(port != 0);
@ -423,7 +423,7 @@ void tst_PlatformSocketEngine::udpLoopbackPerformance()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(QHostAddress("127.0.0.1"), port));
QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
const int messageSize = 8192;
QByteArray message1(messageSize, '@');
@ -459,12 +459,12 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
QVERIFY(server.state() == QAbstractSocket::BoundState);
QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
PLATFORMSOCKETENGINE client;
@ -472,9 +472,9 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
// Connect to our server
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
// The server accepts the connection
@ -485,7 +485,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance()
// socket descriptor from accept(). It's pre-connected.
PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
const int messageSize = 1024 * 256;
QByteArray message1(messageSize, '@');
@ -562,7 +562,7 @@ void tst_PlatformSocketEngine::bind()
PLATFORMSOCKETENGINE binder;
QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder.bind(QHostAddress::AnyIPv4, 82));
QVERIFY(binder.error() == QAbstractSocket::SocketAccessError);
QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError);
#endif
PLATFORMSOCKETENGINE binder2;
@ -572,7 +572,7 @@ void tst_PlatformSocketEngine::bind()
PLATFORMSOCKETENGINE binder3;
QVERIFY(binder3.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(!binder3.bind(QHostAddress::AnyIPv4, 31180));
QVERIFY(binder3.error() == QAbstractSocket::AddressInUseError);
QCOMPARE(binder3.error(), QAbstractSocket::AddressInUseError);
if (QtNetworkSettings::hasIPv6()) {
PLATFORMSOCKETENGINE binder4;
@ -582,7 +582,7 @@ void tst_PlatformSocketEngine::bind()
PLATFORMSOCKETENGINE binder5;
QVERIFY(binder5.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv6Protocol));
QVERIFY(!binder5.bind(QHostAddress::AnyIPv6, 31180));
QVERIFY(binder5.error() == QAbstractSocket::AddressInUseError);
QCOMPARE(binder5.error(), QAbstractSocket::AddressInUseError);
}
PLATFORMSOCKETENGINE binder6;
@ -599,11 +599,11 @@ void tst_PlatformSocketEngine::networkError()
const bool isConnected = client.connectToHost(QtNetworkSettings::serverIP(), 143);
if (!isConnected) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
// An unexpected network error!
#ifdef Q_OS_WINRT
@ -650,19 +650,19 @@ void tst_PlatformSocketEngine::receiveUrgentData()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
QVERIFY(server.state() == QAbstractSocket::BoundState);
QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
QCOMPARE(server.state(), QAbstractSocket::ListeningState);
PLATFORMSOCKETENGINE client;
QVERIFY(client.initialize(QAbstractSocket::TcpSocket));
if (!client.connectToHost(QHostAddress("127.0.0.1"), port)) {
QVERIFY(client.state() == QAbstractSocket::ConnectingState);
QCOMPARE(client.state(), QAbstractSocket::ConnectingState);
QVERIFY(client.waitForWrite());
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
}
int socketDescriptor = server.accept();
@ -670,7 +670,7 @@ void tst_PlatformSocketEngine::receiveUrgentData()
PLATFORMSOCKETENGINE serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
char msg;
int available;

View File

@ -164,18 +164,18 @@ void tst_QHttpSocketEngine::construction()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.isValid());
QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol);
QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol);
QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
// QVERIFY(socketDevice.socketDescriptor() != -1);
QVERIFY(socketDevice.localAddress() == QHostAddress());
QVERIFY(socketDevice.localPort() == 0);
QVERIFY(socketDevice.peerAddress() == QHostAddress());
QVERIFY(socketDevice.peerPort() == 0);
QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
QCOMPARE(socketDevice.localAddress(), QHostAddress());
QCOMPARE(socketDevice.localPort(), quint16(0));
QCOMPARE(socketDevice.peerAddress(), QHostAddress());
QCOMPARE(socketDevice.peerPort(), quint16(0));
QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QVERIFY(socketDevice.bytesAvailable() == 0);
QCOMPARE(socketDevice.bytesAvailable(), 0);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
@ -299,15 +299,15 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
QVERIFY(!socketDevice.localAddress().isNull());
QVERIFY(socketDevice.localPort() > 0);
@ -345,8 +345,8 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.waitForRead());
char c;
QCOMPARE(socketDevice.read(&c, sizeof(c)), (qint64) -1);
QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//---------------------------------------------------------------------------
@ -360,14 +360,14 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
if (socketDevice.waitForWrite(30000)) {
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState ||
socketDevice.state() == QAbstractSocket::UnconnectedState);
} else {
QVERIFY(socketDevice.error() == QAbstractSocket::SocketTimeoutError);
QCOMPARE(socketDevice.error(), QAbstractSocket::SocketTimeoutError);
}
}
@ -381,12 +381,12 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
QVERIFY(server.state() == QAbstractSocket::BoundState);
QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
QHttpSocketEngine client;
@ -408,7 +408,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance()
// socket descriptor from accept(). It's pre-connected.
QSocketLayer serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
const int messageSize = 1024 * 256;
QByteArray message1(messageSize, '@');
@ -544,7 +544,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
QVERIFY(tcpSocketNonBlocking_totalWritten == 8);
QCOMPARE(tcpSocketNonBlocking_totalWritten, 8);
QTestEventLoop::instance().enterLoop(30);
@ -569,7 +569,7 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
QVERIFY(tcpSocketNonBlocking_totalWritten == 10);
QCOMPARE(tcpSocketNonBlocking_totalWritten, 10);
// Wait for greeting
QTestEventLoop::instance().enterLoop(30);
@ -637,7 +637,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
QFAIL("Network operation timed out");
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("Host: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
@ -659,7 +659,7 @@ void tst_QHttpSocketEngine::downloadBigFile()
QVERIFY(bytesAvailable >= 10000000);
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
bytesAvailable / (1024.0 * 1024.0),
@ -689,15 +689,15 @@ void tst_QHttpSocketEngine::passwordAuth()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3128, "qsockstest", "password"));
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@ -733,8 +733,8 @@ void tst_QHttpSocketEngine::passwordAuth()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//----------------------------------------------------------------------------------

View File

@ -246,8 +246,8 @@ void tst_QLocalSocket::socket_basic()
QCOMPARE(socket.serverName(), QString());
QCOMPARE(socket.fullServerName(), QString());
socket.abort();
QVERIFY(socket.bytesAvailable() == 0);
QVERIFY(socket.bytesToWrite() == 0);
QCOMPARE(socket.bytesAvailable(), 0);
QCOMPARE(socket.bytesToWrite(), 0);
QCOMPARE(socket.canReadLine(), false);
socket.close();
socket.disconnectFromServer();
@ -255,7 +255,7 @@ void tst_QLocalSocket::socket_basic()
QVERIFY(!socket.errorString().isEmpty());
QCOMPARE(socket.flush(), false);
QCOMPARE(socket.isValid(), false);
QVERIFY(socket.readBufferSize() == 0);
QCOMPARE(socket.readBufferSize(), 0);
socket.setReadBufferSize(0);
//QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
QCOMPARE(socket.state(), QLocalSocket::UnconnectedState);
@ -375,13 +375,13 @@ void tst_QLocalSocket::listenAndConnect()
QVERIFY(!socket->errorString().isEmpty());
QVERIFY(socket->error() != QLocalSocket::UnknownSocketError);
QCOMPARE(socket->state(), QLocalSocket::UnconnectedState);
//QVERIFY(socket->socketDescriptor() == -1);
//QCOMPARE(socket->socketDescriptor(), -1);
QCOMPARE(qvariant_cast<QLocalSocket::LocalSocketError>(spyError.first()[0]),
QLocalSocket::ServerNotFoundError);
}
QVERIFY(socket->bytesAvailable() == 0);
QVERIFY(socket->bytesToWrite() == 0);
QCOMPARE(socket->bytesAvailable(), 0);
QCOMPARE(socket->bytesToWrite(), 0);
QCOMPARE(socket->canReadLine(), false);
QCOMPARE(socket->flush(), false);
QCOMPARE(socket->isValid(), canListen);
@ -432,7 +432,7 @@ void tst_QLocalSocket::listenAndConnect()
} else {
QVERIFY(server.serverName().isEmpty());
QVERIFY(server.fullServerName().isEmpty());
QVERIFY(server.nextPendingConnection() == (QLocalSocket*)0);
QCOMPARE(server.nextPendingConnection(), (QLocalSocket*)0);
QCOMPARE(spyNewConnection.count(), 0);
QCOMPARE(server.hits.count(), 0);
QVERIFY(!server.errorString().isEmpty());
@ -616,7 +616,7 @@ void tst_QLocalSocket::readBufferOverflow()
QVERIFY(client.waitForReadyRead());
QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
// no more bytes available
QVERIFY(client.bytesAvailable() == 0);
QCOMPARE(client.bytesAvailable(), 0);
}
// QLocalSocket/Server can take a name or path, check that it works as expected
@ -912,7 +912,7 @@ void tst_QLocalSocket::waitForDisconnectByServer()
QLocalSocket *serverSocket = server.nextPendingConnection();
QVERIFY(serverSocket);
serverSocket->close();
QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState);
QCOMPARE(serverSocket->state(), QLocalSocket::UnconnectedState);
QVERIFY(socket.waitForDisconnected(3000));
QCOMPARE(spy.count(), 1);
}
@ -1197,11 +1197,12 @@ void tst_QLocalSocket::verifyListenWithDescriptor()
QVERIFY2(server.listen(listenSocket), "failed to start create QLocalServer with local socket");
#ifdef Q_OS_LINUX
const QChar at(QLatin1Char('@'));
if (!bound) {
QVERIFY(server.serverName().at(0) == QLatin1Char('@'));
QVERIFY(server.fullServerName().at(0) == QLatin1Char('@'));
QCOMPARE(server.serverName().at(0), at);
QCOMPARE(server.fullServerName().at(0), at);
} else if (abstract) {
QVERIFY2(server.fullServerName().at(0) == QLatin1Char('@'), "abstract sockets should start with a '@'");
QVERIFY2(server.fullServerName().at(0) == at, "abstract sockets should start with a '@'");
} else {
QCOMPARE(server.fullServerName(), path);
if (path.contains(QLatin1String("/"))) {

View File

@ -193,18 +193,18 @@ void tst_QSocks5SocketEngine::construction()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.isValid());
QVERIFY(socketDevice.protocol() == QAbstractSocket::IPv4Protocol);
QVERIFY(socketDevice.socketType() == QAbstractSocket::TcpSocket);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.protocol(), QAbstractSocket::IPv4Protocol);
QCOMPARE(socketDevice.socketType(), QAbstractSocket::TcpSocket);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
// QVERIFY(socketDevice.socketDescriptor() != -1);
QVERIFY(socketDevice.localAddress() == QHostAddress());
QVERIFY(socketDevice.localPort() == 0);
QVERIFY(socketDevice.peerAddress() == QHostAddress());
QVERIFY(socketDevice.peerPort() == 0);
QVERIFY(socketDevice.error() == QAbstractSocket::UnknownSocketError);
QCOMPARE(socketDevice.localAddress(), QHostAddress());
QCOMPARE(socketDevice.localPort(), quint16(0));
QCOMPARE(socketDevice.peerAddress(), QHostAddress());
QCOMPARE(socketDevice.peerPort(), quint16(0));
QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::bytesAvailable() was called in QAbstractSocket::UnconnectedState");
QVERIFY(socketDevice.bytesAvailable() == 0);
QCOMPARE(socketDevice.bytesAvailable(), 0);
//QTest::ignoreMessage(QtWarningMsg, "QSocketLayer::hasPendingDatagrams() was called in QAbstractSocket::UnconnectedState");
QVERIFY(!socketDevice.hasPendingDatagrams());
@ -334,15 +334,15 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@ -377,8 +377,8 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//---------------------------------------------------------------------------
@ -392,14 +392,14 @@ void tst_QSocks5SocketEngine::simpleErrorsAndStates()
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
QVERIFY(!socketDevice.connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(), 8088));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
if (socketDevice.waitForWrite(15000)) {
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState ||
socketDevice.state() == QAbstractSocket::ConnectedState);
} else {
QVERIFY(socketDevice.error() == QAbstractSocket::SocketTimeoutError);
QCOMPARE(socketDevice.error(), QAbstractSocket::SocketTimeoutError);
}
}
@ -413,12 +413,12 @@ void tst_QSocks5SocketEngine::tcpLoopbackPerformance()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
QVERIFY(server.state() == QAbstractSocket::BoundState);
QCOMPARE(server.state(), QAbstractSocket::BoundState);
quint16 port = server.localPort();
// Listen for incoming connections
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
QSocks5SocketEngine client;
@ -440,7 +440,7 @@ void tst_QSocks5SocketEngine::tcpLoopbackPerformance()
// socket descriptor from accept(). It's pre-connected.
QSocketLayer serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
const int messageSize = 1024 * 256;
QByteArray message1(messageSize, '@');
@ -482,11 +482,11 @@ void tst_QSocks5SocketEngine::serverTest()
// Bind to any port on all interfaces
QVERIFY(server.bind(QHostAddress("0.0.0.0"), 0));
QVERIFY(server.state() == QAbstractSocket::BoundState);
QCOMPARE(server.state(), QAbstractSocket::BoundState);
// Listen for incoming connections
QVERIFY(server.listen());
QVERIFY(server.state() == QAbstractSocket::ListeningState);
QCOMPARE(server.state(), QAbstractSocket::ListeningState);
// Initialize a Tcp socket
QSocks5SocketEngine client;
@ -501,7 +501,7 @@ void tst_QSocks5SocketEngine::serverTest()
if (!client.connectToHost(server.localAddress(), server.localPort())) {
QVERIFY(client.waitForWrite());
// QTest::wait(100); // ### timing problem on win32
QVERIFY(client.state() == QAbstractSocket::ConnectedState);
QCOMPARE(client.state(), QAbstractSocket::ConnectedState);
//QTest::wait(100);
}
@ -516,14 +516,14 @@ void tst_QSocks5SocketEngine::serverTest()
QSocks5SocketEngine serverSocket;
QVERIFY(serverSocket.initialize(socketDescriptor));
QVERIFY(serverSocket.state() == QAbstractSocket::ConnectedState);
QCOMPARE(serverSocket.state(), QAbstractSocket::ConnectedState);
QVERIFY(serverSocket.localAddress() == client.peerAddress());
QVERIFY(serverSocket.localPort() == client.peerPort());
QCOMPARE(serverSocket.localAddress(), client.peerAddress());
QCOMPARE(serverSocket.localPort(), client.peerPort());
// this seems depends on the socks server implementation, especially
// when connecting /to/ the socks server /through/ the same socks server
//QVERIFY(serverSocket.peerAddress() == client.localAddress());
//QVERIFY(serverSocket.peerPort() == client.localPort());
//QCOMPARE(serverSocket.peerAddress(), client.localAddress());
//QCOMPARE(serverSocket.peerPort(), client.localPort());
// The server socket sends a greeting to the client
QByteArray greeting = "Greetings!";
@ -557,16 +557,16 @@ void tst_QSocks5SocketEngine::udpTest()
udpSocket.setProxy(proxy);
QVERIFY(udpSocket.protocol() == QAbstractSocket::IPv4Protocol);
QVERIFY(udpSocket.socketType() == QAbstractSocket::UdpSocket);
QVERIFY(udpSocket.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(udpSocket.protocol(), QAbstractSocket::IPv4Protocol);
QCOMPARE(udpSocket.socketType(), QAbstractSocket::UdpSocket);
QCOMPARE(udpSocket.state(), QAbstractSocket::UnconnectedState);
// Bind #1
bool bindSuccessful = udpSocket.bind(QHostAddress("0.0.0.0"), 0);
if (!bindSuccessful)
QEXPECT_FAIL("", "QTBUG-23380 / QTBUG-35490: Fails on some Ubuntu 11.10 x64 configurations and on new network test server", Abort);
QVERIFY(bindSuccessful);
QVERIFY(udpSocket.state() == QAbstractSocket::BoundState);
QCOMPARE(udpSocket.state(), QAbstractSocket::BoundState);
QVERIFY(udpSocket.localPort() != 0);
// Initialize device #2
@ -577,7 +577,7 @@ void tst_QSocks5SocketEngine::udpTest()
// Connect device #2 to #1
QVERIFY(udpSocket2.connectToHost(udpSocket.localAddress(), udpSocket.localPort()));
QVERIFY(udpSocket2.state() == QAbstractSocket::ConnectedState);
QCOMPARE(udpSocket2.state(), QAbstractSocket::ConnectedState);
// Write a message to #1
QByteArray message1 = "hei der";
@ -596,8 +596,8 @@ void tst_QSocks5SocketEngine::udpTest()
QVERIFY(udpSocket.readDatagram(answer.data(), answer.size(),
&senderAddress,
&senderPort) == message1.size());
QVERIFY(senderAddress == udpSocket2.localAddress());
QVERIFY(senderPort == udpSocket2.localPort());
QCOMPARE(senderAddress, udpSocket2.localAddress());
QCOMPARE(senderPort, udpSocket2.localPort());
}
void tst_QSocks5SocketEngine::tcpSocketBlockingTest()
@ -705,7 +705,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
QVERIFY(tcpSocketNonBlocking_totalWritten == 8);
QCOMPARE(tcpSocketNonBlocking_totalWritten, 8);
QTestEventLoop::instance().enterLoop(30);
@ -729,7 +729,7 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
QFAIL("Timed out");
}
QVERIFY(tcpSocketNonBlocking_totalWritten == 10);
QCOMPARE(tcpSocketNonBlocking_totalWritten, 10);
// Wait for greeting
QTestEventLoop::instance().enterLoop(30);
@ -797,7 +797,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QFAIL("Network operation timed out");
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
@ -819,7 +819,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QCOMPARE(bytesAvailable, qint64(10000000));
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
/*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
bytesAvailable / (1024.0 * 1024.0),
@ -852,19 +852,19 @@ void tst_QSocks5SocketEngine::passwordAuth()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password"));
// Connect to imap.trolltech.com's IP
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
QVERIFY(socketDevice.waitForWrite());
if (!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)) {
qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData());
}
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@ -899,8 +899,8 @@ void tst_QSocks5SocketEngine::passwordAuth()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
//----------------------------------------------------------------------------------
@ -918,21 +918,21 @@ void tst_QSocks5SocketEngine::passwordAuth2()
// Initialize device
QVERIFY(socketDevice.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081));
socketDevice.setReceiver(this);
QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143));
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState);
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectingState);
while (socketDevice.state() == QAbstractSocket::ConnectingState) {
QVERIFY(socketDevice.waitForWrite());
socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143);
}
if (socketDevice.state() != QAbstractSocket::ConnectedState)
qDebug("%d, %s", socketDevice.error(), socketDevice.errorString().toLatin1().constData());
QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState);
QVERIFY(socketDevice.peerAddress() == QtNetworkSettings::serverIP());
QCOMPARE(socketDevice.state(), QAbstractSocket::ConnectedState);
QCOMPARE(socketDevice.peerAddress(), QtNetworkSettings::serverIP());
// Wait for the greeting
QVERIFY(socketDevice.waitForRead());
@ -967,8 +967,8 @@ void tst_QSocks5SocketEngine::passwordAuth2()
QVERIFY(socketDevice.waitForRead());
char c;
QVERIFY(socketDevice.read(&c, sizeof(c)) == -1);
QVERIFY(socketDevice.error() == QAbstractSocket::RemoteHostClosedError);
QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socketDevice.error(), QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socketDevice.state(), QAbstractSocket::UnconnectedState);
}
void tst_QSocks5SocketEngine::fragmentation_data()
@ -1017,7 +1017,7 @@ void tst_QSocks5SocketEngine::fragmentation()
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(socket.localAddress() == QHostAddress("1.2.3.4") || socket.localAddress() == QHostAddress("0123:4567:89ab:cdef:0123:4567:89ab:cdef"));
QVERIFY(socket.localPort() == 0x0506);
QCOMPARE(socket.localPort(), quint16(0x0506));
}
void tst_QSocks5SocketEngine::incomplete_data()

View File

@ -265,11 +265,11 @@ void tst_QTcpServer::ipv6Server()
//### need to enter the event loop for the server to get the connection ?? ( windows)
QTcpServer server;
if (!server.listen(QHostAddress::LocalHostIPv6, 8944)) {
QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError);
QCOMPARE(server.serverError(), QAbstractSocket::UnsupportedSocketOperationError);
return;
}
QVERIFY(server.serverPort() == 8944);
QCOMPARE(server.serverPort(), quint16(8944));
QVERIFY(server.serverAddress() == QHostAddress::LocalHostIPv6);
QTcpSocket client;
@ -835,17 +835,17 @@ void tst_QTcpServer::qtbug14268_peek()
client.write("abc\n");
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(helper.lastDataPeeked == QByteArray("6162630a"));
QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a"));
client.write("def\n");
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a"));
QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a6465660a"));
client.write("ghi\n");
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a6768690a"));
QCOMPARE(helper.lastDataPeeked, QByteArray("6162630a6465660a6768690a"));
}
void tst_QTcpServer::serverAddress_data()

View File

@ -483,9 +483,9 @@ void tst_QTcpSocket::constructing()
QCOMPARE(socket->readLine(), QByteArray());
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
QCOMPARE((int) socket->localPort(), 0);
QVERIFY(socket->localAddress() == QHostAddress());
QCOMPARE(socket->localAddress(), QHostAddress());
QCOMPARE((int) socket->peerPort(), 0);
QVERIFY(socket->peerAddress() == QHostAddress());
QCOMPARE(socket->peerAddress(), QHostAddress());
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError);
QCOMPARE(socket->errorString(), QString("Unknown error"));
@ -755,7 +755,7 @@ void tst_QTcpSocket::socketDescriptor()
QVERIFY(socket->state() == QAbstractSocket::HostLookupState ||
socket->state() == QAbstractSocket::ConnectingState);
QVERIFY(socket->waitForConnected(10000));
QVERIFY(socket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(socket->state(), QAbstractSocket::ConnectedState);
QVERIFY(socket->socketDescriptor() != -1);
delete socket;
@ -936,7 +936,7 @@ void tst_QTcpSocket::nonBlockingIMAP()
QFAIL("Timed out");
}
QVERIFY(nonBlockingIMAP_totalWritten == 8);
QCOMPARE(nonBlockingIMAP_totalWritten, 8);
enterLoop(30);
@ -961,7 +961,7 @@ void tst_QTcpSocket::nonBlockingIMAP()
QFAIL("Timed out");
}
QVERIFY(nonBlockingIMAP_totalWritten == 10);
QCOMPARE(nonBlockingIMAP_totalWritten, 10);
// Wait for greeting
enterLoop(30);
@ -1086,7 +1086,7 @@ void tst_QTcpSocket::partialRead()
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForConnected(10000));
QVERIFY(socket->state() == QTcpSocket::ConnectedState);
QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
char buf[512];
QByteArray greeting = expectedReplyIMAP();
@ -1110,7 +1110,7 @@ void tst_QTcpSocket::unget()
QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForConnected(10000));
QVERIFY(socket->state() == QTcpSocket::ConnectedState);
QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
char buf[512];
QByteArray greeting = expectedReplyIMAP();
@ -1168,7 +1168,7 @@ void tst_QTcpSocket::openCloseOpenClose()
QCOMPARE(int(socket->openMode()), int(QIODevice::NotOpen));
QVERIFY(socket->isSequential());
QVERIFY(!socket->isOpen());
QVERIFY(socket->socketType() == QTcpSocket::TcpSocket);
QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket);
char c;
QCOMPARE(socket->getChar(&c), false);
@ -1177,13 +1177,13 @@ void tst_QTcpSocket::openCloseOpenClose()
QCOMPARE(socket->readLine(), QByteArray());
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
QCOMPARE((int) socket->localPort(), 0);
QVERIFY(socket->localAddress() == QHostAddress());
QCOMPARE(socket->localAddress(), QHostAddress());
QCOMPARE((int) socket->peerPort(), 0);
QVERIFY(socket->peerAddress() == QHostAddress());
QCOMPARE(socket->peerAddress(), QHostAddress());
QCOMPARE(socket->error(), QTcpSocket::UnknownSocketError);
QCOMPARE(socket->errorString(), QString("Unknown error"));
QVERIFY(socket->state() == QTcpSocket::UnconnectedState);
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForConnected(10000));
@ -1200,7 +1200,7 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect()
for (int i = 0; i < 3; ++i) {
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QVERIFY(socket->socketType() == QTcpSocket::TcpSocket);
QCOMPARE(socket->socketType(), QTcpSocket::TcpSocket);
socket->connectToHost(QtNetworkSettings::serverName(), 143);
QVERIFY(socket->waitForReadyRead(10000));
@ -1260,7 +1260,7 @@ void tst_QTcpSocket::disconnectWhileConnecting()
connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot()));
enterLoop(10);
QVERIFY2(!timeout(), "Network timeout");
QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
if (!closeDirectly) {
QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite));
socket->close();
@ -1272,7 +1272,7 @@ void tst_QTcpSocket::disconnectWhileConnecting()
QTcpSocket *othersocket = server.nextPendingConnection();
if (othersocket->state() != QAbstractSocket::UnconnectedState)
QVERIFY2(othersocket->waitForDisconnected(10000), "Network timeout");
QVERIFY(othersocket->state() == QAbstractSocket::UnconnectedState);
QCOMPARE(othersocket->state(), QAbstractSocket::UnconnectedState);
QCOMPARE(othersocket->readAll(), data);
delete socket;
@ -1375,7 +1375,7 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop()
}
QVERIFY2(socket->waitForDisconnected(10000), "Network timeout");
QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
if (!closeDirectly) {
QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite));
socket->close();
@ -1414,10 +1414,10 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
QFETCH(bool, doClose);
if (doClose) {
socket->close();
QVERIFY(socket->openMode() == QIODevice::NotOpen);
QCOMPARE(socket->openMode(), QIODevice::NotOpen);
} else {
socket->disconnectFromHost();
QVERIFY(socket->openMode() == QIODevice::ReadWrite);
QCOMPARE(socket->openMode(), QIODevice::ReadWrite);
QVERIFY(socket->waitForDisconnected(5000));
}
@ -1428,12 +1428,12 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
// recheck
if (doClose) {
QVERIFY(socket->openMode() == QIODevice::NotOpen);
QCOMPARE(socket->openMode(), QIODevice::NotOpen);
} else {
QVERIFY(socket->openMode() == QIODevice::ReadWrite);
QCOMPARE(socket->openMode(), QIODevice::ReadWrite);
}
QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
}
//----------------------------------------------------------------------------------
@ -1457,7 +1457,7 @@ void tst_QTcpSocket::downloadBigFile()
}
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0);
QVERIFY(tmpSocket->write(hostName.data()) > 0);
@ -2685,12 +2685,12 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
socket->connectToHost(QtNetworkSettings::serverName(), 443);
QVERIFY(socket->waitForConnected(5*1000));
QVERIFY(socket->error() == QAbstractSocket::UnknownSocketError);
QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError);
// We connected to the HTTPS port. Wait two seconds to receive data. We will receive
// nothing because we would need to start the SSL handshake
QVERIFY(!socket->waitForReadyRead(2*1000));
QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError);
QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError);
// Now write some crap to make the server disconnect us. 4 lines are enough.
socket->write("a\r\nb\r\nc\r\nd\r\n");
@ -2700,7 +2700,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
// should get a better error since the server disconnected us
QVERIFY(!socket->waitForReadyRead(2*1000));
// It must NOT be the SocketTimeoutError that had been set before
QVERIFY(socket->error() == QAbstractSocket::RemoteHostClosedError);
QCOMPARE(socket->error(), QAbstractSocket::RemoteHostClosedError);
}
#ifndef QT_NO_NETWORKPROXY
@ -2894,25 +2894,25 @@ void tst_QTcpSocket::qtbug14268_peek()
QTcpSocket *outgoing = socketPair.endPoints[0];
QTcpSocket *incoming = socketPair.endPoints[1];
QVERIFY(incoming->state() == QTcpSocket::ConnectedState);
QVERIFY(outgoing->state() == QTcpSocket::ConnectedState);
QCOMPARE(incoming->state(), QTcpSocket::ConnectedState);
QCOMPARE(outgoing->state(), QTcpSocket::ConnectedState);
outgoing->write("abc\n");
QVERIFY(outgoing->waitForBytesWritten(2000));
QVERIFY(incoming->waitForReadyRead(2000));
QVERIFY(incoming->peek(128*1024) == QByteArray("abc\n"));
QCOMPARE(incoming->peek(128*1024), QByteArray("abc\n"));
outgoing->write("def\n");
QVERIFY(outgoing->waitForBytesWritten(2000));
QVERIFY(incoming->waitForReadyRead(2000));
QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\n"));
QCOMPARE(incoming->peek(128*1024), QByteArray("abc\ndef\n"));
outgoing->write("ghi\n");
QVERIFY(outgoing->waitForBytesWritten(2000));
QVERIFY(incoming->waitForReadyRead(2000));
QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\nghi\n"));
QCOMPARE(incoming->peek(128*1024), QByteArray("abc\ndef\nghi\n"));
QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n"));
QCOMPARE(incoming->read(128*1024), QByteArray("abc\ndef\nghi\n"));
}
void tst_QTcpSocket::setSocketOption()
@ -2926,8 +2926,8 @@ void tst_QTcpSocket::setSocketOption()
QTcpSocket *outgoing = socketPair.endPoints[0];
QTcpSocket *incoming = socketPair.endPoints[1];
QVERIFY(incoming->state() == QTcpSocket::ConnectedState);
QVERIFY(outgoing->state() == QTcpSocket::ConnectedState);
QCOMPARE(incoming->state(), QTcpSocket::ConnectedState);
QCOMPARE(outgoing->state(), QTcpSocket::ConnectedState);
outgoing->setSocketOption(QAbstractSocket::LowDelayOption, true);
QVariant v = outgoing->socketOption(QAbstractSocket::LowDelayOption);
@ -3007,7 +3007,7 @@ void tst_QTcpSocket::serverDisconnectWithBuffered()
delete newConnection;
QVERIFY(socket->waitForConnected(5000)); // ready for write
QVERIFY(socket->state() == QAbstractSocket::ConnectedState);
QCOMPARE(socket->state(), QAbstractSocket::ConnectedState);
QSignalSpy spyStateChanged(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
QSignalSpy spyDisconnected(socket, SIGNAL(disconnected()));
@ -3017,10 +3017,10 @@ void tst_QTcpSocket::serverDisconnectWithBuffered()
QCOMPARE(socket->read(buf, sizeof(buf)), Q_INT64_C(1));
if (socket->state() != QAbstractSocket::UnconnectedState) {
QVERIFY(socket->waitForDisconnected(5000));
QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
}
// Test signal emitting
QVERIFY(spyDisconnected.count() == 1);
QCOMPARE(spyDisconnected.count(), 1);
QVERIFY(spyStateChanged.count() > 0);
QVERIFY(qvariant_cast<QAbstractSocket::SocketState>(spyStateChanged.last().first())
== QAbstractSocket::UnconnectedState);

View File

@ -223,7 +223,7 @@ void tst_QUdpSocket::constructing()
QVERIFY(socket.isSequential());
QVERIFY(!socket.isOpen());
QVERIFY(socket.socketType() == QUdpSocket::UdpSocket);
QCOMPARE(socket.socketType(), QUdpSocket::UdpSocket);
QCOMPARE((int) socket.bytesAvailable(), 0);
QCOMPARE(socket.canReadLine(), false);
QCOMPARE(socket.readLine(), QByteArray());
@ -749,7 +749,7 @@ void tst_QUdpSocket::writeDatagram()
QCOMPARE(client.error(), QUdpSocket::DatagramTooLargeError);
break;
}
QVERIFY(bytesspy.count() == 1);
QCOMPARE(bytesspy.count(), 1);
QCOMPARE(*static_cast<const qint64 *>(bytesspy.at(0).at(0).constData()),
qint64(i * 1024));
QCOMPARE(errorspy.count(), 0);

View File

@ -767,7 +767,7 @@ void tst_QSslCertificate::certInfo()
QVERIFY(cert.expiryDate() < QDateTime::currentDateTime()); // cert has expired
QSslCertificate copy = cert;
QVERIFY(cert == copy);
QCOMPARE(cert, copy);
QVERIFY(!(cert != copy));
QCOMPARE(cert, QSslCertificate(pem, QSsl::Pem));
@ -1061,7 +1061,7 @@ void tst_QSslCertificate::extensions()
QSslCertificate cert = certList[0];
QList<QSslCertificateExtension> extensions = cert.extensions();
QVERIFY(extensions.count() == 9);
QCOMPARE(extensions.count(), 9);
int unknown_idx = -1;
int authority_info_idx = -1;
@ -1093,8 +1093,8 @@ void tst_QSslCertificate::extensions()
// Unknown
QSslCertificateExtension unknown = extensions[unknown_idx];
QVERIFY(unknown.oid() == QStringLiteral("1.3.6.1.5.5.7.1.12"));
QVERIFY(unknown.name() == QStringLiteral("1.3.6.1.5.5.7.1.12"));
QCOMPARE(unknown.oid(), QStringLiteral("1.3.6.1.5.5.7.1.12"));
QCOMPARE(unknown.name(), QStringLiteral("1.3.6.1.5.5.7.1.12"));
QVERIFY(!unknown.isCritical());
QVERIFY(!unknown.isSupported());
@ -1106,8 +1106,8 @@ void tst_QSslCertificate::extensions()
// Authority Info Access
QSslCertificateExtension aia = extensions[authority_info_idx];
QVERIFY(aia.oid() == QStringLiteral("1.3.6.1.5.5.7.1.1"));
QVERIFY(aia.name() == QStringLiteral("authorityInfoAccess"));
QCOMPARE(aia.oid(), QStringLiteral("1.3.6.1.5.5.7.1.1"));
QCOMPARE(aia.name(), QStringLiteral("authorityInfoAccess"));
QVERIFY(!aia.isCritical());
QVERIFY(aia.isSupported());
@ -1116,13 +1116,13 @@ void tst_QSslCertificate::extensions()
QString ocsp = aiaValue[QStringLiteral("OCSP")].toString();
QString caIssuers = aiaValue[QStringLiteral("caIssuers")].toString();
QVERIFY(ocsp == QStringLiteral("http://EVIntl-ocsp.verisign.com"));
QVERIFY(caIssuers == QStringLiteral("http://EVIntl-aia.verisign.com/EVIntl2006.cer"));
QCOMPARE(ocsp, QStringLiteral("http://EVIntl-ocsp.verisign.com"));
QCOMPARE(caIssuers, QStringLiteral("http://EVIntl-aia.verisign.com/EVIntl2006.cer"));
// Basic constraints
QSslCertificateExtension basic = extensions[basic_constraints_idx];
QVERIFY(basic.oid() == QStringLiteral("2.5.29.19"));
QVERIFY(basic.name() == QStringLiteral("basicConstraints"));
QCOMPARE(basic.oid(), QStringLiteral("2.5.29.19"));
QCOMPARE(basic.name(), QStringLiteral("basicConstraints"));
QVERIFY(!basic.isCritical());
QVERIFY(basic.isSupported());
@ -1132,16 +1132,16 @@ void tst_QSslCertificate::extensions()
// Subject key identifier
QSslCertificateExtension subjectKey = extensions[subject_key_idx];
QVERIFY(subjectKey.oid() == QStringLiteral("2.5.29.14"));
QVERIFY(subjectKey.name() == QStringLiteral("subjectKeyIdentifier"));
QCOMPARE(subjectKey.oid(), QStringLiteral("2.5.29.14"));
QCOMPARE(subjectKey.name(), QStringLiteral("subjectKeyIdentifier"));
QVERIFY(!subjectKey.isCritical());
QVERIFY(subjectKey.isSupported());
QVERIFY(subjectKey.value().toString() == QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0"));
QCOMPARE(subjectKey.value().toString(), QStringLiteral("5F:90:23:CD:24:CA:52:C9:36:29:F0:7E:9D:B1:FE:08:E0:EE:69:F0"));
// Authority key identifier
QSslCertificateExtension authKey = extensions[auth_key_idx];
QVERIFY(authKey.oid() == QStringLiteral("2.5.29.35"));
QVERIFY(authKey.name() == QStringLiteral("authorityKeyIdentifier"));
QCOMPARE(authKey.oid(), QStringLiteral("2.5.29.35"));
QCOMPARE(authKey.name(), QStringLiteral("authorityKeyIdentifier"));
QVERIFY(!authKey.isCritical());
QVERIFY(authKey.isSupported());
@ -1159,7 +1159,7 @@ void tst_QSslCertificate::extensionsCritical()
QSslCertificate cert = certList[0];
QList<QSslCertificateExtension> extensions = cert.extensions();
QVERIFY(extensions.count() == 9);
QCOMPARE(extensions.count(), 9);
int basic_constraints_idx = -1;
int key_usage_idx = -1;
@ -1178,8 +1178,8 @@ void tst_QSslCertificate::extensionsCritical()
// Basic constraints
QSslCertificateExtension basic = extensions[basic_constraints_idx];
QVERIFY(basic.oid() == QStringLiteral("2.5.29.19"));
QVERIFY(basic.name() == QStringLiteral("basicConstraints"));
QCOMPARE(basic.oid(), QStringLiteral("2.5.29.19"));
QCOMPARE(basic.name(), QStringLiteral("basicConstraints"));
QVERIFY(basic.isCritical());
QVERIFY(basic.isSupported());
@ -1189,8 +1189,8 @@ void tst_QSslCertificate::extensionsCritical()
// Key Usage
QSslCertificateExtension keyUsage = extensions[key_usage_idx];
QVERIFY(keyUsage.oid() == QStringLiteral("2.5.29.15"));
QVERIFY(keyUsage.name() == QStringLiteral("keyUsage"));
QCOMPARE(keyUsage.oid(), QStringLiteral("2.5.29.15"));
QCOMPARE(keyUsage.name(), QStringLiteral("keyUsage"));
QVERIFY(keyUsage.isCritical());
QVERIFY(!keyUsage.isSupported());
}
@ -1249,21 +1249,21 @@ void tst_QSslCertificate::threadSafeConstMethods()
t2.start();
QVERIFY(t1.wait(5000));
QVERIFY(t2.wait(5000));
QVERIFY(t1.cert == t2.cert);
QVERIFY(t1.effectiveDate == t2.effectiveDate);
QVERIFY(t1.expiryDate == t2.expiryDate);
QCOMPARE(t1.cert, t2.cert);
QCOMPARE(t1.effectiveDate, t2.effectiveDate);
QCOMPARE(t1.expiryDate, t2.expiryDate);
//QVERIFY(t1.extensions == t2.extensions); // no equality operator, so not tested
QVERIFY(t1.isBlacklisted == t2.isBlacklisted);
QVERIFY(t1.issuerInfo == t2.issuerInfo);
QVERIFY(t1.issuerInfoAttributes == t2.issuerInfoAttributes);
QVERIFY(t1.publicKey == t2.publicKey);
QVERIFY(t1.serialNumber == t2.serialNumber);
QVERIFY(t1.subjectInfo == t2.subjectInfo);
QVERIFY(t1.subjectInfoAttributes == t2.subjectInfoAttributes);
QVERIFY(t1.toDer == t2.toDer);
QVERIFY(t1.toPem == t2.toPem);
QVERIFY(t1.toText == t2.toText);
QVERIFY(t1.version == t2.version);
QCOMPARE(t1.isBlacklisted, t2.isBlacklisted);
QCOMPARE(t1.issuerInfo, t2.issuerInfo);
QCOMPARE(t1.issuerInfoAttributes, t2.issuerInfoAttributes);
QCOMPARE(t1.publicKey, t2.publicKey);
QCOMPARE(t1.serialNumber, t2.serialNumber);
QCOMPARE(t1.subjectInfo, t2.subjectInfo);
QCOMPARE(t1.subjectInfoAttributes, t2.subjectInfoAttributes);
QCOMPARE(t1.toDer, t2.toDer);
QCOMPARE(t1.toPem, t2.toPem);
QCOMPARE(t1.toText, t2.toText);
QCOMPARE(t1.version, t2.version);
}

View File

@ -820,7 +820,7 @@ void tst_QSslSocket::peerCertificateChain()
this->socket = socket.data();
QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"));
QVERIFY(caCertificates.count() == 1);
QCOMPARE(caCertificates.count(), 1);
socket->addCaCertificates(caCertificates);
#ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND
connect(socket.data(), SIGNAL(sslErrors(QList<QSslError>)),
@ -866,7 +866,7 @@ void tst_QSslSocket::peerCertificateChain()
QSKIP("Skipping flaky test - See QTBUG-29941");
QCOMPARE(socket->peerCertificateChain().first(), socket->peerCertificate());
QVERIFY(socket->peerCertificateChain() == certChain);
QCOMPARE(socket->peerCertificateChain(), certChain);
socket->disconnectFromHost();
QVERIFY(socket->waitForDisconnected());
@ -1733,7 +1733,7 @@ void tst_QSslSocket::spontaneousWrite()
QSslSocket *sender = server.socket;
QVERIFY(sender);
QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
QCOMPARE(sender->state(), QAbstractSocket::ConnectedState);
receiver->setObjectName("receiver");
sender->setObjectName("sender");
receiver->ignoreSslErrors();
@ -1778,7 +1778,7 @@ void tst_QSslSocket::setReadBufferSize()
QSslSocket *sender = server.socket;
QVERIFY(sender);
QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
QCOMPARE(sender->state(), QAbstractSocket::ConnectedState);
receiver->setObjectName("receiver");
sender->setObjectName("sender");
receiver->ignoreSslErrors();
@ -2332,7 +2332,7 @@ void tst_QSslSocket::readFromClosedSocket()
socket->close();
QVERIFY(!socket->bytesAvailable());
QVERIFY(!socket->bytesToWrite());
QVERIFY(socket->state() == QAbstractSocket::UnconnectedState);
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
}
void tst_QSslSocket::writeBigChunk()
@ -2359,7 +2359,7 @@ void tst_QSslSocket::writeBigChunk()
QString errorBefore = socket->errorString();
int ret = socket->write(data.constData(), data.size());
QVERIFY(data.size() == ret);
QCOMPARE(data.size(), ret);
// spin the event loop once so QSslSocket::transmit() gets called
QCoreApplication::processEvents();
@ -2376,7 +2376,7 @@ void tst_QSslSocket::writeBigChunk()
QByteArray("unexpected error: ").append(qPrintable(errorAfter)));
// check that everything has been written to OpenSSL
QVERIFY(socket->bytesToWrite() == 0);
QCOMPARE(socket->bytesToWrite(), 0);
socket->close();
}
@ -2400,7 +2400,7 @@ void tst_QSslSocket::blacklistedCertificates()
QSslSocket *sender = server.socket;
QVERIFY(sender);
QVERIFY(sender->state() == QAbstractSocket::ConnectedState);
QCOMPARE(sender->state(), QAbstractSocket::ConnectedState);
receiver->setObjectName("receiver");
sender->setObjectName("sender");
receiver->startClientEncryption();
@ -2726,9 +2726,9 @@ void tst_QSslSocket::qtbug18498_peek2()
while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
char c;
QVERIFY(client->peek(&c,1) == 1);
QCOMPARE(client->peek(&c,1), 1);
QCOMPARE(c, 'H');
QVERIFY(client->read(&c,1) == 1);
QCOMPARE(client->read(&c,1), 1);
QCOMPARE(c, 'H');
QByteArray b = client->peek(2);
QCOMPARE(b, QByteArray("EL"));
@ -2764,7 +2764,7 @@ void tst_QSslSocket::qtbug18498_peek2()
// ### Qt5 use QTRY_VERIFY
while (server->bytesAvailable() < 10 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
QVERIFY(server->peek(&c,1) == 1);
QCOMPARE(server->peek(&c,1), 1);
QCOMPARE(c, 'S');
b = server->peek(3);
QCOMPARE(b, QByteArray("STA"));
@ -2800,9 +2800,9 @@ void tst_QSslSocket::qtbug18498_peek2()
while (client->bytesAvailable() < 7 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
QVERIFY(server->mode() == QSslSocket::SslServerMode && client->mode() == QSslSocket::SslClientMode);
QVERIFY(client->peek(&c,1) == 1);
QCOMPARE(client->peek(&c,1), 1);
QCOMPARE(c, 'h');
QVERIFY(client->read(&c,1) == 1);
QCOMPARE(client->read(&c,1), 1);
QCOMPARE(c, 'h');
b = client->peek(2);
QCOMPARE(b, QByteArray("el"));
@ -2812,7 +2812,7 @@ void tst_QSslSocket::qtbug18498_peek2()
stopwatch.start();
while (server->bytesAvailable() < 9 && stopwatch.elapsed() < 5000)
QTest::qWait(100);
QVERIFY(server->peek(&c,1) == 1);
QCOMPARE(server->peek(&c,1), 1);
QCOMPARE(c, 'g');
QCOMPARE(server->readAll(), QByteArray("goodbye\r\n"));
client->disconnectFromHost();
@ -2846,7 +2846,7 @@ void tst_QSslSocket::dhServer()
client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
loop.exec();
QVERIFY(client->state() == QAbstractSocket::ConnectedState);
QCOMPARE(client->state(), QAbstractSocket::ConnectedState);
}
void tst_QSslSocket::ecdhServer()
@ -2876,7 +2876,7 @@ void tst_QSslSocket::ecdhServer()
client->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
loop.exec();
QVERIFY(client->state() == QAbstractSocket::ConnectedState);
QCOMPARE(client->state(), QAbstractSocket::ConnectedState);
}
void tst_QSslSocket::verifyClientCertificate_data()