diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-05-27 02:26:49 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-05-27 02:26:49 (GMT) |
commit | 271a96f201ebcd346bb532e207c1d0e465f89584 (patch) | |
tree | 3cfca45c9d5e1e1ab3162a444c4110d20c1056cf /tests | |
parent | e4026fee42b584c59db3f9f6d5acd2b4a08324d0 (diff) | |
parent | dd33e048451ffc5420adbca9f30dba65f5dcf5e2 (diff) | |
download | Qt-271a96f201ebcd346bb532e207c1d0e465f89584.zip Qt-271a96f201ebcd346bb532e207c1d0e465f89584.tar.gz Qt-271a96f201ebcd346bb532e207c1d0e465f89584.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging: (25 commits)
Added some of my Qt 4.8 changes to the changelog
Update bearer startup code in network autotests
symbian socket engine: share ip address conversion code
license header check: fix exception for URL TLD table
QUrl TLD: fix documentation file for "Add QUrl::topLevelDomain() ..."
Add QUrl::topLevelDomain() and move TLD table from QtNetwork to QtCore
fix Symbian ordinals for merge request re. utf8 characters in SSL certs
add auto test for SSL certificates containing utf8 characters
fix coding style for merge request re. utf8 characters in SSL certs
Use OpenSSL X509_NAME_ENTRY API to parse UTF8 subjectName/issuerName
Fix the build for QUuid
Improved performance of the QLocale::name() function.
Optimize QUuid::QUuid(const char *)
QDataStream: speedup steaming of QUuid.
Add QUuid::toRfc4122() and fromRfc4122()
Add QUuid::toByteArray() and relevant
Optimize QUuid::toString() and relevant
Add some autotests and benchmarks for QUuid
tst_qhostinfo: Fix IPv6 lookup detection on Windows.
Fix typo in comment
...
Diffstat (limited to 'tests')
19 files changed, 504 insertions, 50 deletions
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 2686a00..335e832 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -177,7 +177,7 @@ void tst_Headers::allSourceFilesData() || sourceFile.endsWith("/src/corelib/global/qconfig.h") || sourceFile.endsWith("/src/corelib/global/qconfig.cpp") || sourceFile.endsWith("/src/tools/uic/qclass_lib_map.h") - || sourceFile.endsWith("src/network/access/qnetworkcookiejartlds_p.h") + || sourceFile.endsWith("src/corelib/io/qurltlds_p.h") ) continue; diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index c21fd03..b2ce5ca 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -371,11 +371,18 @@ void tst_NetworkSelfTest::initTestCase() { #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + if (networkConfiguration.isValid()) { + networkSession.reset(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); } #endif } diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index e4372c5..aefe0b9 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -141,11 +141,18 @@ void tst_QAbstractNetworkCache::initTestCase() { #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + if (networkConfiguration.isValid()) { + networkSession.reset(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); } #endif } diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 1fa0787..7e431cf 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -155,6 +155,7 @@ private: QFtp *ftp; #ifndef QT_NO_BEARERMANAGEMENT + QNetworkConfigurationManager *netConfMan; QSharedPointer<QNetworkSession> networkSessionExplicit; QSharedPointer<QNetworkSession> networkSessionImplicit; #endif @@ -225,10 +226,20 @@ void tst_QFtp::initTestCase_data() void tst_QFtp::initTestCase() { #ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager manager; - networkSessionImplicit = QSharedPointer<QNetworkSession>(new QNetworkSession(manager.defaultConfiguration())); - networkSessionImplicit->open(); - QVERIFY(networkSessionImplicit->waitForOpened(60000)); //there may be user prompt on 1st connect + netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QNetworkConfiguration networkConfiguration = netConfMan->defaultConfiguration(); + if (networkConfiguration.isValid()) { + networkSessionImplicit = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration)); + if (!networkSessionImplicit->isOpen()) { + networkSessionImplicit->open(); + QVERIFY(networkSessionImplicit->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); + } #endif } @@ -254,6 +265,8 @@ void tst_QFtp::init() } #ifndef QT_NO_BEARERMANAGEMENT if (setSession) { + if (!networkSessionImplicit) + QSKIP("test requires a valid default network configuration", SkipSingle); networkSessionExplicit = networkSessionImplicit; if (!networkSessionExplicit->isOpen()) { networkSessionExplicit->open(); diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index c528a5c..2fa5e76 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -197,13 +197,19 @@ tst_QHostInfo::~tst_QHostInfo() void tst_QHostInfo::initTestCase() { #ifndef QT_NO_BEARERMANAGEMENT - //start the default network netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + if (networkConfiguration.isValid()) { + networkSession.reset(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); } #endif @@ -213,6 +219,13 @@ void tst_QHostInfo::initTestCase() #else ipv6Available = false; ipv6LookupsAvailable = false; + + QTcpServer server; + if (server.listen(QHostAddress("::1"))) { + // We have IPv6 support + ipv6Available = true; + } + #if !defined(QT_NO_GETADDRINFO) // check if the system getaddrinfo can do IPv6 lookups struct addrinfo hint, *result = 0; @@ -235,13 +248,6 @@ void tst_QHostInfo::initTestCase() #endif #endif - QTcpServer server; - if (server.listen(QHostAddress("::1"))) { - // We have IPv6 support - ipv6Available = true; - } - - // run each testcase with and without test enabled QTest::addColumn<bool>("cache"); QTest::newRow("WithCache") << true; diff --git a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index d59a510..1b4256b 100644 --- a/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -42,7 +42,7 @@ #include <QtTest/QtTest> #include <QtNetwork/QNetworkCookieJar> -#include "private/qnetworkcookiejar_p.h" +#include "private/qtldurl_p.h" class tst_QNetworkCookieJar: public QObject { @@ -438,7 +438,7 @@ void tst_QNetworkCookieJar::effectiveTLDs() #endif QFETCH(QString, domain); QFETCH(bool, isTLD); - QCOMPARE(QNetworkCookieJarPrivate::isEffectiveTLD(domain), isTLD); + QCOMPARE(qIsEffectiveTLD(domain), isTLD); } QTEST_MAIN(tst_QNetworkCookieJar) diff --git a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp index ae3436d..2077717 100644 --- a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp @@ -89,11 +89,18 @@ void tst_QNetworkInterface::initTestCase() { #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + if (networkConfiguration.isValid()) { + networkSession.reset(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); } #endif } diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 782e2a0..25925bd 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1290,11 +1290,18 @@ void tst_QNetworkReply::initTestCase() #endif #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); networkConfiguration = netConfMan->defaultConfiguration(); - networkSession.reset(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + if (networkConfiguration.isValid()) { + networkSession.reset(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); } #endif } diff --git a/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem new file mode 100644 index 0000000..e1b731d --- /dev/null +++ b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem @@ -0,0 +1,16 @@ +-----BEGIN CERTIFICATE----- +MIICkTCCAfqgAwIBAgIJAL1nF+PLAF2KMA0GCSqGSIb3DQEBBQUAMGkxKzApBgNV +BAoMIkjElcSCxrLDvyDKjeG6v8qI4bq34bi7IFLDqWPDtnJkxZ0xFTATBgNVBAsM +DOOIp0HjiYHvvatCQzEWMBQGA1UEAwwNSm9obm55IEd1aXRhcjELMAkGA1UEBhMC +Tk8wHhcNMTEwNTA1MDgxMzEwWhcNMTEwNjA0MDgxMzEwWjBpMSswKQYDVQQKDCJI +xJXEgsayw78gyo3hur/KiOG6t+G4uyBSw6ljw7ZyZMWdMRUwEwYDVQQLDAzjiKdB +44mB772rQkMxFjAUBgNVBAMMDUpvaG5ueSBHdWl0YXIxCzAJBgNVBAYTAk5PMIGf +MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zSxS17I6596dJE/VAmGz+06D9S8n +3C0hnIGNVu+LwbgDJTvOw0SzNj4UP72UGgd3UI1KLBg5XWIsRNmE3COJMMh6syjI +L1Ept+tVXxGL6n4gl+0nZ7dkUyxJmeFtigYrL+qCH1yd5rmf3sC3jO4IosuAiG66 +IDkJEVo64NT8ZQIDAQABo0EwPzA9BgNVHREENjA0gQ9hcm5lQGZvb2Jhci5vcmeC +Dnd3dy5mb29iYXIub3JngRFiamFybmVAZm9vYmFyLm9yZzANBgkqhkiG9w0BAQUF +AAOBgQAqVhbC0/EUFdnKlYV3PrknwGX1dPEPGJuIQHa0KpoicvNiOhs1HxBDYbzc +F6wcAMEynq4YwGKhcQLZOs2mo0LreAjA9rU/yBnqrnUW/4gxtUUvmJKK+62IjfLp +eO1L+1NcEMJiaZf8fip4VXhXdOYUhgE8WUZ1UJRC6w3T/yAgcQ== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san new file mode 100644 index 0000000..f46a637 --- /dev/null +++ b/tests/auto/qsslcertificate/certificates/cert-ss-san-utf8.pem.san @@ -0,0 +1,5 @@ +[subj_alt_name] +subjectAltName=\ + email:arne@foobar.org,\ + DNS:www.foobar.org,\ + email:bjarne@foobar.org diff --git a/tests/auto/qsslcertificate/certificates/gencertificates.sh b/tests/auto/qsslcertificate/certificates/gencertificates.sh index 9f873d9..0bac191 100755 --- a/tests/auto/qsslcertificate/certificates/gencertificates.sh +++ b/tests/auto/qsslcertificate/certificates/gencertificates.sh @@ -90,5 +90,15 @@ openssl req -x509 -in req-san.pem -out $outname -key rsa-pri-1024.pem \ -config san.cnf -extensions subj_alt_name /bin/cp san.cnf $outname.san +#--- Non-ASCII Subject --------------------------------------------------------------------- +echo -e "\n generating self signed root cert. with Subject containing UTF-8 characters ..." +outname=cert-ss-san-utf8.pem +#subject="/O=HĕĂƲÿ ʍếʈặḻ Récördŝ/OU=㈧A㉁ォBC/CN=Johnny Guitar/C=NO" +subject=$'/O=H\xc4\x95\xc4\x82\xc6\xb2\xc3\xbf \xca\x8d\xe1\xba\xbf\xca\x88\xe1\xba\xb7\xe1\xb8\xbb R\xc3\xa9c\xc3\xb6rd\xc5\x9d/OU=\xe3\x88\xa7A\xe3\x89\x81\xef\xbd\xabBC/CN=Johnny Guitar/C=NO' +openssl req -out req-san.pem -new -key rsa-pri-1024.pem -utf8 -subj "$subject" +openssl req -x509 -in req-san.pem -out $outname -key rsa-pri-1024.pem \ + -config san.cnf -extensions subj_alt_name -nameopt multiline,utf8,-esc_msb +/bin/cp san.cnf $outname.san + echo -e "\n cleaning up ..." /bin/rm rsa-pri-1024.pem rsa-pub-1024.* req*.pem diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index c38147d..9276685 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -96,6 +96,7 @@ private slots: void digest_data(); void digest(); void alternateSubjectNames_data(); + void utf8SubjectNames(); void alternateSubjectNames(); void publicKey_data(); void publicKey(); @@ -407,6 +408,27 @@ void tst_QSslCertificate::alternateSubjectNames() } } +void tst_QSslCertificate::utf8SubjectNames() +{ + QSslCertificate cert = QSslCertificate::fromPath("certificates/cert-ss-san-utf8.pem", QSsl::Pem, + QRegExp::FixedString).first(); + QVERIFY(!cert.isNull()); + + // O is "Heavy Metal Records" with heavy use of "decorations" like accents, umlauts etc., + // OU uses arabian / asian script letters near codepoint 64K. + // strings split where the compiler would otherwise find three-digit hex numbers + static const char *o = "H\xc4\x95\xc4\x82\xc6\xb2\xc3\xbf \xca\x8d\xe1\xba\xbf\xca\x88\xe1\xba" + "\xb7\xe1\xb8\xbb R\xc3\xa9" "c" "\xc3\xb6rd\xc5\x9d"; + static const char *ou = "\xe3\x88\xa7" "A" "\xe3\x89\x81\xef\xbd\xab" "BC"; + + // the following two tests should help find "\x"-literal encoding bugs in the test itself + QCOMPARE(cert.subjectInfo("O").length(), QString::fromUtf8(o).length()); + QCOMPARE (cert.subjectInfo("O").toUtf8().toHex(), QByteArray(o).toHex()); + + QCOMPARE(cert.subjectInfo("O"), QString::fromUtf8(o)); + QCOMPARE(cert.subjectInfo("OU"), QString::fromUtf8(ou)); +} + void tst_QSslCertificate::publicKey_data() { QTest::addColumn<QString>("certFilePath"); @@ -519,13 +541,13 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"certificates/*\" fixed der") << QString("certificates/*") << int(QRegExp::FixedString) << false << 0; QTest::newRow("\"certificates/*\" regexp pem") << QString("certificates/*") << int(QRegExp::RegExp) << true << 0; QTest::newRow("\"certificates/*\" regexp der") << QString("certificates/*") << int(QRegExp::RegExp) << false << 0; - QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("\"certificates/*\" wildcard pem") << QString("certificates/*") << int(QRegExp::Wildcard) << true << 5; QTest::newRow("\"certificates/*\" wildcard der") << QString("certificates/*") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"c*/c*.pem\" fixed pem") << QString("c*/c*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"c*/c*.pem\" fixed der") << QString("c*/c*.pem") << int(QRegExp::FixedString) << false << 0; QTest::newRow("\"c*/c*.pem\" regexp pem") << QString("c*/c*.pem") << int(QRegExp::RegExp) << true << 0; QTest::newRow("\"c*/c*.pem\" regexp der") << QString("c*/c*.pem") << int(QRegExp::RegExp) << false << 0; - QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("\"c*/c*.pem\" wildcard pem") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << true << 5; QTest::newRow("\"c*/c*.pem\" wildcard der") << QString("c*/c*.pem") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"d*/c*.pem\" fixed pem") << QString("d*/c*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"d*/c*.pem\" fixed der") << QString("d*/c*.pem") << int(QRegExp::FixedString) << false << 0; @@ -535,7 +557,7 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d*/c*.pem\" wildcard der") << QString("d*/c*.pem") << int(QRegExp::Wildcard) << false << 0; QTest::newRow("\"c.*/c.*.pem\" fixed pem") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << true << 0; QTest::newRow("\"c.*/c.*.pem\" fixed der") << QString("c.*/c.*.pem") << int(QRegExp::FixedString) << false << 0; - QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 4; + QTest::newRow("\"c.*/c.*.pem\" regexp pem") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << true << 5; QTest::newRow("\"c.*/c.*.pem\" regexp der") << QString("c.*/c.*.pem") << int(QRegExp::RegExp) << false << 0; QTest::newRow("\"c.*/c.*.pem\" wildcard pem") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"c.*/c.*.pem\" wildcard der") << QString("c.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; @@ -546,7 +568,7 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard der") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; #ifdef Q_OS_LINUX - QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 4; + QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 5; #endif QTest::newRow("trailing-whitespace") << QString("more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1; @@ -769,7 +791,7 @@ void tst_QSslCertificate::nulInCN() QString cn = cert.subjectInfo(QSslCertificate::CommonName); QVERIFY(cn != "www.bank.com"); - static const char realCN[] = "www.bank.com\\x00.badguy.com"; + static const char realCN[] = "www.bank.com\0.badguy.com"; QCOMPARE(cn, QString::fromLatin1(realCN, sizeof realCN - 1)); } diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp index 22a90cf..f4249ab 100644 --- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -146,6 +146,15 @@ void tst_QtConcurrentMap::map() QCOMPARE(numberList, QList<Number>() << 2 << 4 << 6); QtConcurrent::map(numberList.begin(), numberList.end(), &Number::multiplyBy2).waitForFinished(); QCOMPARE(numberList, QList<Number>() << 4 << 8 << 12); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 128 << 256 << 384); + QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 256 << 512 << 768); +#endif + } // functors don't take arguments by reference, making these no-ops @@ -170,6 +179,14 @@ void tst_QtConcurrentMap::map() QCOMPARE(list, QList<int>() << 1 << 2 << 3); QtConcurrent::map(list.begin(), list.end(), multiplyBy2Immutable).waitForFinished(); QCOMPARE(list, QList<int>() << 1 << 2 << 3); + +#ifdef Q_COMPILER_LAMBDA + // lambda + QtConcurrent::map(list, [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 1 << 2 << 3); + QtConcurrent::map(list.begin(), list.end(), [](int x){x *= 2;}).waitForFinished(); + QCOMPARE(list, QList<int>() << 1 << 2 << 3); +#endif } // Linked lists and forward iterators @@ -2303,6 +2320,10 @@ void tst_QtConcurrentMap::stlContainers() { #ifdef QT_NO_STL QSKIP("Qt compiled without STL support", SkipAll); +#elif defined(Q_COMPILER_RVALUE_REFS) + //mapped uses &Container::push_back, but in c++0x, std::vector has two overload of it + // meaning it is not possible to take the address of that function anymore. + QSKIP("mapped do not work with c++0x stl vector", SkipAll); #else std::vector<int> vector; vector.push_back(1); diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index e4e9479..cacb09a 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -67,6 +67,8 @@ private slots: #if 0 void createFunctor(); #endif + void functor(); + void lambda(); }; #if 0 @@ -444,6 +446,71 @@ void tst_QtConcurrentRun::createFunctor() } #endif +struct Functor { + int operator()() { return 42; } + double operator()(double a, double b) { return a/b; } + int operator()(int a, int b) { return a/b; } + void operator()(int) { } + void operator()(int, int, int) { } + void operator()(int, int, int, int) { } + void operator()(int, int, int, int, int) { } + void operator()(int, int, int, int, int, int) { } +}; + +void tst_QtConcurrentRun::functor() +{ + //this test functor without result_type, decltype need to be supported by the compiler +#ifndef Q_COMPILER_DECLTYPE + QSKIP("Compiler do not suport decltype", SkipAll); +#else + Functor f; + { + QFuture<int> fut = QtConcurrent::run(f); + QCOMPARE(fut.result(), 42); + } + { + QFuture<double> fut = QtConcurrent::run(f, 8.5, 1.8); + QCOMPARE(fut.result(), (8.5/1.8)); + } + { + QFuture<int> fut = QtConcurrent::run(f, 19, 3); + QCOMPARE(fut.result(), int(19/3)); + } + { + QtConcurrent::run(f, 1).waitForFinished(); + QtConcurrent::run(f, 1,2).waitForFinished(); + QtConcurrent::run(f, 1,2,3).waitForFinished(); + QtConcurrent::run(f, 1,2,3,4).waitForFinished(); + QtConcurrent::run(f, 1,2,3,4,5).waitForFinished(); + } +#endif +} + + +void tst_QtConcurrentRun::lambda() +{ +#ifndef Q_COMPILER_LAMBDA + QSKIP("Compiler do not suport lambda", SkipAll); +#else + + QCOMPARE(QtConcurrent::run([](){ return 45; }).result(), 45); + QCOMPARE(QtConcurrent::run([](int a){ return a+15; }, 12).result(), 12+15); + QCOMPARE(QtConcurrent::run([](int a, double b){ return a + b; }, 12, 15).result(), double(12+15)); + QCOMPARE(QtConcurrent::run([](int a , int, int, int, int b){ return a + b; }, 1, 2, 3, 4, 5).result(), 1 + 5); + +#ifdef Q_COMPILER_INITIALIZER_LISTS + { + QString str { "Hello World Foo" }; + QFuture<QStringList> f1 = QtConcurrent::run([&](){ return str.split(' '); }); + auto r = f1.result(); + QCOMPARE(r, QStringList({"Hello", "World", "Foo"})); + } +#endif + +#endif +} + + #include "tst_qtconcurrentrun.moc" #else diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index 3416a7c..a7c2604 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -116,6 +116,7 @@ private slots: private: #ifndef QT_NO_BEARERMANAGEMENT QNetworkSession *networkSession; + QNetworkConfigurationManager *netConfMan; #endif }; @@ -154,10 +155,20 @@ void tst_QTcpServer::initTestCase_data() void tst_QTcpServer::initTestCase() { #ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager man; - networkSession = new QNetworkSession(man.defaultConfiguration(), this); - networkSession->open(); - QVERIFY(networkSession->waitForOpened()); + netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QNetworkConfiguration networkConfiguration = netConfMan->defaultConfiguration(); + if (networkConfiguration.isValid()) { + networkSession = new QNetworkSession(networkConfiguration); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); + } #endif } diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 9ca049b..a38082e 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -148,11 +148,18 @@ void tst_QUdpSocket::initTestCase_data() #ifndef QT_NO_BEARERMANAGEMENT netConfMan = new QNetworkConfigurationManager(this); + netConfMan->updateConfigurations(); + connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); networkConfiguration = netConfMan->defaultConfiguration(); - networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration)); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); + if (networkConfiguration.isValid()) { + networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration)); + if (!networkSession->isOpen()) { + networkSession->open(); + QVERIFY(networkSession->waitForOpened(30000)); + } + } else { + QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)); } #endif } diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 613053b..ae27c4a 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -49,6 +49,7 @@ #include <qurl.h> #include <qtextcodec.h> #include <qmap.h> +#include "private/qtldurl_p.h" // For testsuites #define IDNA_ACE_PREFIX "xn--" @@ -88,6 +89,8 @@ public slots: void init(); void cleanup(); private slots: + void effectiveTLDs_data(); + void effectiveTLDs(); void getSetCheck(); void constructing(); void assignment(); @@ -4005,5 +4008,28 @@ void tst_QUrl::taskQTBUG_8701() QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar, QUrl::StrictMode).toString()); } +void tst_QUrl::effectiveTLDs_data() +{ + QTest::addColumn<QUrl>("domain"); + QTest::addColumn<QString>("TLD"); + + QTest::newRow("yes0") << QUrl::fromEncoded("http://test.co.uk") << ".co.uk"; + QTest::newRow("yes1") << QUrl::fromEncoded("http://test.com") << ".com"; + QTest::newRow("yes2") << QUrl::fromEncoded("http://www.test.de") << ".de"; + QTest::newRow("yes3") << QUrl::fromEncoded("http://test.ulm.museum") << ".ulm.museum"; + QTest::newRow("yes4") << QUrl::fromEncoded("http://www.com.krodsherad.no") << ".krodsherad.no"; + QTest::newRow("yes5") << QUrl::fromEncoded("http://www.co.uk.1.bg") << ".1.bg"; + QTest::newRow("yes6") << QUrl::fromEncoded("http://www.com.com.cn") << ".com.cn"; + QTest::newRow("yes7") << QUrl::fromEncoded("http://www.test.org.ws") << ".org.ws"; + QTest::newRow("yes9") << QUrl::fromEncoded("http://www.com.co.uk.wallonie.museum") << ".wallonie.museum"; +} + +void tst_QUrl::effectiveTLDs() +{ + QFETCH(QUrl, domain); + QFETCH(QString, TLD); + QCOMPARE(domain.topLevelDomain(), TLD); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" diff --git a/tests/auto/quuid/tst_quuid.cpp b/tests/auto/quuid/tst_quuid.cpp index 6333e83..4948312 100644 --- a/tests/auto/quuid/tst_quuid.cpp +++ b/tests/auto/quuid/tst_quuid.cpp @@ -60,7 +60,14 @@ public: tst_QUuid(); private slots: + void fromChar(); void toString(); + void fromString(); + void toByteArray(); + void fromByteArray(); + void toRfc4122(); + void fromRfc4122(); + void check_QDataStream(); void isNull(); void equal(); void notEqual(); @@ -83,16 +90,106 @@ public: tst_QUuid::tst_QUuid() { - uuidA = "{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; - uuidB = "{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; + //"{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"; + uuidA = QUuid(0xfc69b59e, 0xcc34 ,0x4436 ,0xa4 ,0x3c ,0xee ,0x95 ,0xd1 ,0x28 ,0xb8 ,0xc5); + + //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; + uuidB = QUuid(0x1ab6e93a ,0xb1cb ,0x4a87 ,0xba ,0x47 ,0xec ,0x7e ,0x99 ,0x03 ,0x9a ,0x7b); } +void tst_QUuid::fromChar() +{ + QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + QCOMPARE(uuidA, QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(uuidA, QUuid("fc69b59e-cc34-4436-a43c-ee95d128b8c5")); + QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34-4436-a43c-ee95d128b8c")); + QCOMPARE(QUuid(), QUuid("{fc69b59e-cc34")); + QCOMPARE(QUuid(), QUuid("fc69b59e-cc34-")); + QCOMPARE(QUuid(), QUuid("fc69b59e-cc34")); + QCOMPARE(QUuid(), QUuid("cc34")); + QCOMPARE(QUuid(), QUuid(NULL)); + + QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} void tst_QUuid::toString() { QCOMPARE(uuidA.toString(), QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + + QCOMPARE(uuidB.toString(), QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); +} + +void tst_QUuid::fromString() +{ + QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(uuidA, QUuid(QString("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(QUuid(), QUuid(QString("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + + QCOMPARE(uuidB, QUuid(QString("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} + +void tst_QUuid::toByteArray() +{ + QCOMPARE(uuidA.toByteArray(), QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}")); + + QCOMPARE(uuidB.toByteArray(), QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}")); +} + +void tst_QUuid::fromByteArray() +{ + QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5}"))); + QCOMPARE(uuidA, QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(uuidA, QUuid(QByteArray("fc69b59e-cc34-4436-a43c-ee95d128b8c5"))); + QCOMPARE(QUuid(), QUuid(QByteArray("{fc69b59e-cc34-4436-a43c-ee95d128b8c"))); + + QCOMPARE(uuidB, QUuid(QByteArray("{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"))); +} + +void tst_QUuid::toRfc4122() +{ + QCOMPARE(uuidA.toRfc4122(), QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5")); + + QCOMPARE(uuidB.toRfc4122(), QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b")); } +void tst_QUuid::fromRfc4122() +{ + QCOMPARE(uuidA, QUuid::fromRfc4122(QByteArray::fromHex("fc69b59ecc344436a43cee95d128b8c5"))); + + QCOMPARE(uuidB, QUuid::fromRfc4122(QByteArray::fromHex("1ab6e93ab1cb4a87ba47ec7e99039a7b"))); +} + +void tst_QUuid::check_QDataStream() +{ + QUuid tmp; + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + out.setByteOrder(QDataStream::BigEndian); + out << uuidA; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + in.setByteOrder(QDataStream::BigEndian); + in >> tmp; + QCOMPARE(uuidA, tmp); + } + { + QDataStream out(&ar,QIODevice::WriteOnly); + out.setByteOrder(QDataStream::LittleEndian); + out << uuidA; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + in.setByteOrder(QDataStream::LittleEndian); + in >> tmp; + QCOMPARE(uuidA, tmp); + } +} void tst_QUuid::isNull() { diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp index dbec65c..a035cf3 100644 --- a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp @@ -53,6 +53,18 @@ public: private slots: void createUuid(); + void fromChar(); + void toString(); + void fromString(); + void toByteArray(); + void fromByteArray(); + void toRfc4122(); + void fromRfc4122(); + void toDataStream(); + void fromDataStream(); + void isNull(); + void operatorLess(); + void operatorMore(); }; void tst_bench_QUuid::createUuid() @@ -62,5 +74,118 @@ void tst_bench_QUuid::createUuid() } } +void tst_bench_QUuid::fromChar() +{ + QBENCHMARK { + QUuid uuid("{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"); + } +} + +void tst_bench_QUuid::toString() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toString(); + } +} + +void tst_bench_QUuid::fromString() +{ + QString string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"; + QBENCHMARK { + QUuid uuid(string); + } +} + +void tst_bench_QUuid::toByteArray() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toByteArray(); + } +} + +void tst_bench_QUuid::fromByteArray() +{ + QByteArray string = "{67C8770B-44F1-410A-AB9A-F9B5446F13EE}"; + QBENCHMARK { + QUuid uuid(string); + } +} + +void tst_bench_QUuid::toRfc4122() +{ + QUuid uuid = QUuid::createUuid(); + QBENCHMARK { + uuid.toRfc4122(); + } +} + +void tst_bench_QUuid::fromRfc4122() +{ + QByteArray string = QByteArray::fromHex("67C8770B44F1410AAB9AF9B5446F13EE"); + QBENCHMARK { + QUuid uuid = QUuid::fromRfc4122(string); + } +} + +void tst_bench_QUuid::toDataStream() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + QBENCHMARK { + out << uuid1; + } + } +} + +void tst_bench_QUuid::fromDataStream() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + QByteArray ar; + { + QDataStream out(&ar,QIODevice::WriteOnly); + out << uuid1; + } + { + QDataStream in(&ar,QIODevice::ReadOnly); + QBENCHMARK { + in >> uuid2; + } + } +} + +void tst_bench_QUuid::isNull() +{ + QUuid uuid = QUuid(); + QBENCHMARK { + uuid.isNull(); + } +} + +void tst_bench_QUuid::operatorLess() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + uuid2 = QUuid::createUuid(); + QBENCHMARK { + uuid1 < uuid2; + } +} + +void tst_bench_QUuid::operatorMore() +{ + QUuid uuid1, uuid2; + uuid1 = QUuid::createUuid(); + uuid2 = QUuid::createUuid(); + QBENCHMARK { + uuid1 > uuid2; + } +} + QTEST_MAIN(tst_bench_QUuid); #include "tst_quuid.moc" |