From 12520e83009fb8bd694d9768801875558bcc6321 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 17 Feb 2012 22:45:08 +0100 Subject: Port badxml autotest to QMetaObjectBuilder The meta-object format is going to change for Qt5. Use QMOB to insulate the badxml test from such changes. (It just so happens that the QFAIL("a failure") statement is still on line 109 after the refactoring, so the expected_badxml.* files' location tags did not have to be changed.) Change-Id: I04421d13c4df71c8004fa71cafc4823a59079a41 Reviewed-by: Thiago Macieira Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- tests/auto/testlib/selftests/badxml/badxml.pro | 2 +- tests/auto/testlib/selftests/badxml/tst_badxml.cpp | 30 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/badxml/badxml.pro b/tests/auto/testlib/selftests/badxml/badxml.pro index 5eaa1c3216..7b3b0f701c 100644 --- a/tests/auto/testlib/selftests/badxml/badxml.pro +++ b/tests/auto/testlib/selftests/badxml/badxml.pro @@ -1,5 +1,5 @@ SOURCES += tst_badxml.cpp -QT = core testlib +QT = core-private testlib mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target diff --git a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp index 1a143e5243..2fb9e5ea90 100644 --- a/tests/auto/testlib/selftests/badxml/tst_badxml.cpp +++ b/tests/auto/testlib/selftests/badxml/tst_badxml.cpp @@ -42,6 +42,7 @@ #include #include +#include /* This test makes a testlog containing lots of characters which have a special meaning in @@ -73,27 +74,26 @@ class EmptyClass : public tst_BadXml class tst_BadXmlSub : public tst_BadXml { public: + tst_BadXmlSub() + : className("tst_BadXml"), mo(0) {} + ~tst_BadXmlSub() { qFree(mo); } + const QMetaObject* metaObject() const; - static char const* className; + QByteArray className; +private: + QMetaObject *mo; }; -char const* tst_BadXmlSub::className = "tst_BadXml"; const QMetaObject* tst_BadXmlSub::metaObject() const { - const QMetaObject& empty = EmptyClass::staticMetaObject; - static QMetaObject mo = { - { empty.d.superdata, empty.d.stringdata, empty.d.data, empty.d.extradata } - }; - static char currentClassName[1024]; - qstrcpy(currentClassName, className); - int len = qstrlen(className); - currentClassName[len] = 0; - currentClassName[len+1] = 0; - - mo.d.stringdata = currentClassName; - - return &mo; + if (!mo || (mo->className() != className)) { + qFree(mo); + QMetaObjectBuilder builder(&EmptyClass::staticMetaObject); + builder.setClassName(className); + const_cast(this)->mo = builder.toMetaObject(); + } + return mo; } /* -- cgit v1.2.3 From 5d6b2d5e343e27940e5fd78cb2aa897aac6bc2ed Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 18 Feb 2012 08:52:13 +0100 Subject: QEasingCurve: add member-swap Implementated as in QPen etc. Change-Id: Ia08551bf7902b60e115d1b1d2353030597e34841 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 0a006ab5b4..d5d7ddeb1d 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -445,6 +445,13 @@ void tst_QEasingCurve::setCustomType() void tst_QEasingCurve::operators() { + { // member-swap() + QEasingCurve ec1, ec2; + ec2.setCustomType(&discreteEase); + ec1.swap(ec2); + QCOMPARE(ec1.type(), QEasingCurve::Custom); + } + // operator= QEasingCurve curve; QEasingCurve curve2; -- cgit v1.2.3 From 6a6178702e8af97b943c728f1cb4ab20233835a2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 18 Feb 2012 08:52:51 +0100 Subject: QEasingCurve: implement move-assignment operator Implemented as in QPen etc. Change-Id: I65b43c6ec7308ca4b44f614594c15c41ab2f89f9 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- .../corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index d5d7ddeb1d..1d4e91dc00 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -43,6 +43,10 @@ #include +#ifdef Q_COMPILER_RVALUE_REFS // cpp11() slot +# include // for std::move() +#endif + class tst_QEasingCurve : public QObject { Q_OBJECT @@ -61,6 +65,7 @@ private slots: void tcbSpline(); void testCbrtDouble(); void testCbrtFloat(); + void cpp11(); }; void tst_QEasingCurve::type() @@ -770,5 +775,19 @@ void tst_QEasingCurve::testCbrtFloat() } } +void tst_QEasingCurve::cpp11() +{ +#ifdef Q_COMPILER_RVALUE_REFS + { + QEasingCurve ec( QEasingCurve::InOutBack ); + QEasingCurve copy; + const QEasingCurve::Type type = copy.type(); + copy = std::move(ec); // move assignment op + QCOMPARE( copy.type(), QEasingCurve::InOutBack ); + QCOMPARE( ec.type(), type ); + } +#endif +} + QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" -- cgit v1.2.3 From 3a8da4a4843d787e9bf12973bf1fcf4da793558d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 18 Feb 2012 11:45:45 +0100 Subject: QEasingCurve: implement move constructor The move constructor sets other.d_ptr to zero. This is safe, because after being moved from, the object is left in a state in which it can be safely destroyed (delete nullptr is a no-op). It cannot meaningfully be used anymore (most members will crash with a nullptr dereference), but in most cases, the moved-from object cannot be accessed anyway (not a named object), and if a named object is moved from, it must have been through explicit std::move(), as in the test case. The STL makes better guarantees (moved-from containers are .empty()), but I don't think it's worth introducing a null state into QEasingCurve just for supporting a use-case that should be considered a bug anyway. Change-Id: I4115b7386cdea6960507da6843a0d0196d8e4139 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp index 1d4e91dc00..40e3cd08b6 100644 --- a/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp @@ -778,6 +778,12 @@ void tst_QEasingCurve::testCbrtFloat() void tst_QEasingCurve::cpp11() { #ifdef Q_COMPILER_RVALUE_REFS + { + QEasingCurve ec( QEasingCurve::InOutBack ); + QEasingCurve copy = std::move(ec); // move ctor + QCOMPARE( copy.type(), QEasingCurve::InOutBack ); + QVERIFY( *reinterpret_cast(&ec) == 0 ); + } { QEasingCurve ec( QEasingCurve::InOutBack ); QEasingCurve copy; -- cgit v1.2.3 From 3f91cde588ad32277ba06d625ed36256ec65f88e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 20 Feb 2012 17:02:41 +0000 Subject: Test for QT_NO_SSL instead of QT_NO_OPENSSL Change the ifdefs in our own code (except openssl backend) to use the new configure flag. Change-Id: I8774734771c66b22164b5fae8fdb27814ac3df7b Reviewed-by: Richard J. Moore --- .../tst_qhttpnetworkconnection.cpp | 10 ++-- .../access/qnetworkreply/tst_qnetworkreply.cpp | 64 +++++++++++----------- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 10 ++-- .../ssl/qsslcertificate/tst_qsslcertificate.cpp | 8 +-- .../auto/network/ssl/qsslcipher/tst_qsslcipher.cpp | 6 +- tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp | 6 +- tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp | 4 +- .../auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 20 +++---- .../other/networkselftest/tst_networkselftest.cpp | 14 ++--- 9 files changed, 71 insertions(+), 71 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 94346f726d..f9f3b26898 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -58,7 +58,7 @@ public Q_SLOTS: void finishedReply(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail); void challenge401(const QHttpNetworkRequest &request, QAuthenticator *authenticator); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void sslErrors(const QList &errors); #endif private: @@ -92,11 +92,11 @@ private Q_SLOTS: void compression_data(); void compression(); #endif -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void ignoresslerror_data(); void ignoresslerror(); #endif -#ifdef QT_NO_OPENSSL +#ifdef QT_NO_SSL void nossl_data(); void nossl(); #endif @@ -665,7 +665,7 @@ void tst_QHttpNetworkConnection::compression() } #endif -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QHttpNetworkConnection::sslErrors(const QList &errors) { Q_UNUSED(errors) @@ -745,7 +745,7 @@ void tst_QHttpNetworkConnection::ignoresslerror() } #endif -#ifdef QT_NO_OPENSSL +#ifdef QT_NO_SSL Q_DECLARE_METATYPE(QNetworkReply::NetworkError) void tst_QHttpNetworkConnection::nossl_data() { diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 279570b547..671d03cf84 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -67,7 +67,7 @@ #include #include #include -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL #include #include #endif @@ -93,7 +93,7 @@ Q_DECLARE_METATYPE(QNetworkReply::NetworkError) Q_DECLARE_METATYPE(QBuffer*) Q_DECLARE_METATYPE(QHttpMultiPart *) Q_DECLARE_METATYPE(QList) // for multiparts -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL Q_DECLARE_METATYPE(QSslConfiguration) #endif @@ -143,7 +143,7 @@ class tst_QNetworkReply: public QObject QList proxies; QNetworkAccessManager manager; MyCookieJar *cookieJar; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslConfiguration storedSslConfiguration; QList storedExpectedSslErrors; #endif @@ -172,7 +172,7 @@ public Q_SLOTS: void proxyAuthenticationRequired(const QNetworkProxy &,QAuthenticator*); void pipeliningHelperSlot(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void sslErrors(QNetworkReply*,const QList &); void storeSslConfiguration(); void ignoreSslErrorListSlot(QNetworkReply *reply, const QList &); @@ -248,7 +248,7 @@ private Q_SLOTS: void ioGetFromHttpWithProxyAuth(); void ioGetFromHttpWithProxyAuthSynchronous(); void ioGetFromHttpWithSocksProxy(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void ioGetFromHttpsWithSslErrors(); void ioGetFromHttpsWithIgnoreSslErrors(); void ioGetFromHttpsWithSslHandshakeError(); @@ -336,7 +336,7 @@ private Q_SLOTS: void httpRecursiveCreation(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void ioPostToHttpsUploadProgress(); void ignoreSslErrorsList_data(); void ignoreSslErrorsList(); @@ -378,7 +378,7 @@ private Q_SLOTS: void synchronousRequest_data(); void synchronousRequest(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void synchronousRequestSslFailure(); #endif @@ -450,7 +450,7 @@ QT_END_NAMESPACE QFAIL(qPrintable(errorMsg)); \ } while (0); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL static void setupSslServer(QSslSocket* serverSocket) { QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath(); @@ -504,7 +504,7 @@ protected: client->setSocketDescriptor(socketDescriptor); connectSocketSignals(); } else { -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslSocket *serverSocket = new QSslSocket; serverSocket->setParent(this); if (serverSocket->setSocketDescriptor(socketDescriptor)) { @@ -541,7 +541,7 @@ private: } private slots: -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void slotSslErrors(const QList& errors) { qDebug() << "slotSslErrors" << client->errorString() << errors; @@ -820,7 +820,7 @@ public: } virtual void incomingConnection(qintptr socketDescriptor) { -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL if (doSsl) { QSslSocket *serverSocket = new QSslSocket; serverSocket->setParent(this); @@ -837,7 +837,7 @@ public: } private slots: -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void slotSslErrors(const QList& errors) { qDebug() << "slotSslErrors" << sslSocket->errorString() << errors; @@ -1104,7 +1104,7 @@ tst_QNetworkReply::tst_QNetworkReply() qRegisterMetaType(); // for QSignalSpy qRegisterMetaType(); qRegisterMetaType(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL qRegisterMetaType >(); #endif qRegisterMetaType(); @@ -1150,7 +1150,7 @@ void tst_QNetworkReply::proxyAuthenticationRequired(const QNetworkProxy &, QAuth auth->setPassword("password"); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QNetworkReply::sslErrors(QNetworkReply *reply, const QList &errors) { reply->ignoreSslErrors(); @@ -1345,7 +1345,7 @@ void tst_QNetworkReply::initTestCase() #endif QDir::setSearchPaths("testdata", QStringList() << testDataDir); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslSocket::defaultCaCertificates(); //preload certificates #endif #ifndef QT_NO_BEARERMANAGEMENT @@ -3135,7 +3135,7 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy() } } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QNetworkReply::ioGetFromHttpsWithSslErrors() { qRegisterMetaType(); // for QSignalSpy @@ -3559,7 +3559,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data() << "ftp://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt" << QNetworkReply::NoError; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL // HTTPS with HTTP transparent proxy proxyList.clear(); proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3129); @@ -3604,7 +3604,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data() << "ftp://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt" << QNetworkReply::ProxyNotFoundError; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL // HTTPS with HTTP caching proxy proxyList.clear(); proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); @@ -3679,7 +3679,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data() << "ftp://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt" << QNetworkReply::NoError; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL // HTTPS request with HTTP Caching + HTTP transparent proxyList.clear(); proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) @@ -3726,7 +3726,7 @@ void tst_QNetworkReply::ioGetWithManyProxies() QSignalSpy authspy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList)), SLOT(sslErrors(QNetworkReply*,QList))); #endif @@ -3735,7 +3735,7 @@ void tst_QNetworkReply::ioGetWithManyProxies() manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL manager.disconnect(SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(sslErrors(QNetworkReply*,QList))); #endif @@ -4324,7 +4324,7 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag() QCOMPARE(reply->error(), QNetworkReply::ContentReSendError); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL class SslServer : public QTcpServer { Q_OBJECT public: @@ -4437,7 +4437,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp_data() QTest::addColumn("bufferSize"); QTest::newRow("http+unlimited") << false << 0; QTest::newRow("http+limited") << false << 4096; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QTest::newRow("https+unlimited") << true << 0; QTest::newRow("https+limited") << true << 4096; #endif @@ -5123,7 +5123,7 @@ void tst_QNetworkReply::httpProxyCommands_data() << QUrl("http://0.0.0.0:4443/http-request") << QByteArray("HTTP/1.0 200 OK\r\nProxy-Connection: close\r\nContent-Length: 1\r\n\r\n1") << "GET http://0.0.0.0:4443/http-request HTTP/1."; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QTest::newRow("https") << QUrl("https://0.0.0.0:4443/https-request") << QByteArray("HTTP/1.0 200 Connection Established\r\n\r\n") @@ -5539,7 +5539,7 @@ void tst_QNetworkReply::httpRecursiveCreation() QVERIFY(!QTestEventLoop::instance().timeout()); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QNetworkReply::ignoreSslErrorsList_data() { QTest::addColumn("url"); @@ -5637,7 +5637,7 @@ void tst_QNetworkReply::sslConfiguration() QCOMPARE(reply->error(), expectedError); } -#endif // QT_NO_OPENSSL +#endif // QT_NO_SSL void tst_QNetworkReply::getAndThenDeleteObject_data() { @@ -6071,7 +6071,7 @@ void tst_QNetworkReply::authenticationCacheAfterCancel_data() QTest::addColumn("url"); for (int i = 0; i < proxies.count(); ++i) { QTest::newRow("http" + proxies.at(i).tag) << proxies.at(i).proxy << proxies.at(i).requiresAuthentication << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt"); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QTest::newRow("https" + proxies.at(i).tag) << proxies.at(i).proxy << proxies.at(i).requiresAuthentication << QUrl("https://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt"); #endif } @@ -6124,7 +6124,7 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() QFETCH(bool, proxyAuth); QFETCH(QUrl, url); QNetworkAccessManager manager; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList)), SLOT(sslErrors(QNetworkReply*,QList))); #endif @@ -6251,7 +6251,7 @@ void tst_QNetworkReply::authenticationWithDifferentRealm() { AuthenticationCacheHelper helper; QNetworkAccessManager manager; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList)), SLOT(sslErrors(QNetworkReply*,QList))); #endif @@ -6436,7 +6436,7 @@ void tst_QNetworkReply::synchronousRequest_data() // ### we would need to enflate (un-deflate) the file content and compare the sizes << QString("text/plain"); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QTest::newRow("https") << QUrl("https://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt") << QString("file:" + testDataDir + "/rfc3252.txt") @@ -6467,7 +6467,7 @@ void tst_QNetworkReply::synchronousRequest() QNetworkRequest request(url); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL // workaround for HTTPS requests: add self-signed server cert to list of CA certs, // since we cannot react to the sslErrors() signal // to fix this properly we would need to have an ignoreSslErrors() method in the @@ -6512,7 +6512,7 @@ void tst_QNetworkReply::synchronousRequest() reply->deleteLater(); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QNetworkReply::synchronousRequestSslFailure() { // test that SSL won't be accepted with self-signed certificate, diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index abeb1ed06d..2c2b551257 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -68,7 +68,7 @@ #include #include #include -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL #include #endif #include @@ -332,7 +332,7 @@ void tst_QTcpSocket::initTestCase_data() QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; // QTest::newRow("WithHttpProxyNtlmAuth") << true << int(HttpProxy | AuthNtlm) << false; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; @@ -392,7 +392,7 @@ void tst_QTcpSocket::init() QTcpSocket *tst_QTcpSocket::newSocket() const { QTcpSocket *socket; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QFETCH_GLOBAL(bool, ssl); socket = ssl ? new QSslSocket : new QTcpSocket; #else @@ -1640,7 +1640,7 @@ public: protected: inline void run() { -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QFETCH_GLOBAL(bool, ssl); if (ssl) socket = new QSslSocket; @@ -1924,7 +1924,7 @@ public: attemptedToConnect = false; networkTimeout = false; count = 0; -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QFETCH_GLOBAL(bool, ssl); if (ssl) sock = new QSslSocket; diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index da2dd989c7..5da9ff0476 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -66,7 +66,7 @@ class tst_QSslCertificate : public QObject QMap sha1Map; void createTestRows(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void compareCertificates(const QSslCertificate & cert1, const QSslCertificate & cert2); #endif @@ -76,7 +76,7 @@ public slots: void initTestCase(); void cleanupTestCase(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL private slots: void emptyConstructor(); void constructor_data(); @@ -173,7 +173,7 @@ static QByteArray readFile(const QString &absFilePath) return file.readAll(); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QSslCertificate::emptyConstructor() { @@ -1060,7 +1060,7 @@ void tst_QSslCertificate::extensions() } -#endif // QT_NO_OPENSSL +#endif // QT_NO_SSL QTEST_MAIN(tst_QSslCertificate) #include "tst_qsslcertificate.moc" diff --git a/tests/auto/network/ssl/qsslcipher/tst_qsslcipher.cpp b/tests/auto/network/ssl/qsslcipher/tst_qsslcipher.cpp index 25d5f00e95..52f603d3c6 100644 --- a/tests/auto/network/ssl/qsslcipher/tst_qsslcipher.cpp +++ b/tests/auto/network/ssl/qsslcipher/tst_qsslcipher.cpp @@ -59,7 +59,7 @@ public slots: void init(); void cleanup(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL private slots: void constructing(); @@ -88,14 +88,14 @@ void tst_QSslCipher::cleanup() { } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QSslCipher::constructing() { QSslCipher cipher; } -#endif // QT_NO_OPENSSL +#endif // QT_NO_SSL QTEST_MAIN(tst_QSslCipher) #include "tst_qsslcipher.moc" diff --git a/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp b/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp index e57c5fa7f4..bf5ae9c35b 100644 --- a/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp +++ b/tests/auto/network/ssl/qsslerror/tst_qsslerror.cpp @@ -77,7 +77,7 @@ public slots: void init(); void cleanup(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL private slots: void constructing(); #endif @@ -109,14 +109,14 @@ void tst_QSslError::cleanup() { } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QSslError::constructing() { QSslError error; } -#endif // QT_NO_OPENSSL +#endif // QT_NO_SSL QTEST_MAIN(tst_QSslError) #include "tst_qsslerror.moc" diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index e8941a2642..ed3deb49ec 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -71,7 +71,7 @@ class tst_QSslKey : public QObject public slots: void initTestCase(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL private slots: void emptyConstructor(); @@ -123,7 +123,7 @@ static QByteArray readFile(const QString &absFilePath) return file.readAll(); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QSslKey::emptyConstructor() { diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 83060e27e4..cdb397ccd4 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -55,7 +55,7 @@ #include #include "private/qhostinfo_p.h" -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL #include "private/qsslsocket_openssl_p.h" #include "private/qsslsocket_openssl_symbols_p.h" #include "private/qsslconfiguration_p.h" @@ -65,7 +65,7 @@ Q_DECLARE_METATYPE(QAbstractSocket::SocketState) Q_DECLARE_METATYPE(QAbstractSocket::SocketError) -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL Q_DECLARE_METATYPE(QSslSocket::SslMode) typedef QList SslErrorList; Q_DECLARE_METATYPE(SslErrorList) @@ -80,7 +80,7 @@ Q_DECLARE_METATYPE(QSslConfiguration) #define QSSLSOCKET_CERTUNTRUSTED_WORKAROUND #endif -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL class QSslSocketPtr: public QSharedPointer { public: @@ -113,7 +113,7 @@ public: return QTestEventLoop::instance().timeout(); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslSocketPtr newSocket(); #endif @@ -124,7 +124,7 @@ public slots: void cleanup(); void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *auth); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL private slots: void constructing(); void simpleConnect(); @@ -226,7 +226,7 @@ protected slots: private: QSslSocket *socket; QList storedExpectedSslErrors; -#endif // QT_NO_OPENSSL +#endif // QT_NO_SSL private: static int loopLevel; }; @@ -235,7 +235,7 @@ int tst_QSslSocket::loopLevel = 0; tst_QSslSocket::tst_QSslSocket() { -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL qRegisterMetaType >("QList"); qRegisterMetaType("QSslError"); qRegisterMetaType("QAbstractSocket::SocketState"); @@ -320,7 +320,7 @@ void tst_QSslSocket::cleanup() QNetworkProxy::setApplicationProxy(QNetworkProxy::DefaultProxy); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslSocketPtr tst_QSslSocket::newSocket() { QSslSocket *socket = new QSslSocket; @@ -341,7 +341,7 @@ void tst_QSslSocket::proxyAuthenticationRequired(const QNetworkProxy &, QAuthent auth->setPassword("password"); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_QSslSocket::constructing() { @@ -2216,7 +2216,7 @@ void tst_QSslSocket::setEmptyDefaultConfiguration() // this test should be last, QVERIFY2(!socket->waitForEncrypted(4000), qPrintable(socket->errorString())); } -#endif // QT_NO_OPENSSL +#endif // QT_NO_SSL QTEST_MAIN(tst_QSslSocket) diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 99d4ac9522..841df6e1f0 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -80,7 +80,7 @@ private slots: void httpServerFiles(); void httpServerCGI_data(); void httpServerCGI(); -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void httpsServer(); #endif void httpProxy(); @@ -188,14 +188,14 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) { -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslSocket *sslSocket = qobject_cast(socket); #endif QTime timer; timer.start(); forever { if (socket->bytesToWrite() == 0 -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL && sslSocket->encryptedBytesToWrite() == 0 #endif ) @@ -210,7 +210,7 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) static void netChat(int port, const QList &chat) { -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL QSslSocket socket; #else QTcpSocket socket; @@ -322,7 +322,7 @@ static void netChat(int port, const QList &chat) break; case Chat::StartEncryption: -#ifdef QT_NO_OPENSSL +#ifdef QT_NO_SSL QFAIL("Internal error: SSL required for this test"); #else qDebug() << i << "Starting client encryption"; @@ -745,7 +745,7 @@ void tst_NetworkSelfTest::httpServerCGI() netChat(80, chat); } -#ifndef QT_NO_OPENSSL +#ifndef QT_NO_SSL void tst_NetworkSelfTest::httpsServer() { netChat(443, QList() @@ -937,7 +937,7 @@ void tst_NetworkSelfTest::socks5ProxyAuth() void tst_NetworkSelfTest::supportsSsl() { -#ifdef QT_NO_OPENSSL +#ifdef QT_NO_SSL QFAIL("SSL not compiled in"); #else QVERIFY2(QSslSocket::supportsSsl(), "Could not load SSL libraries"); -- cgit v1.2.3 From 848d3694f6603a5dd90977c0a0d73f7140633f33 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 20 Feb 2012 18:14:55 +0100 Subject: qmimetype: Fix test failure when LC_ALL is set. This code sets LANG=en_US so that the method comment(), which returns a translated name, can be compared with an expected result in English. (QMimeType::comment uses QLocale::system().name() and QLocale::system().uiLanguages()) But LANG= has no effect if LC_ALL is set, so LC_ALL needs to be cleared (or set to en_US) for the test to work. Change-Id: Icb031057769be9bc8c0fcab65daa45e7bf1d5b18 Reviewed-by: Thiago Macieira --- tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index fc86fa5431..858f977a72 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -51,6 +51,7 @@ void initializeLang() { + qputenv("LC_ALL", ""); qputenv("LANG", "en_US"); } -- cgit v1.2.3 From 511e447b70999089b8212967616b1f2962d59e96 Mon Sep 17 00:00:00 2001 From: Andrew Stanley-Jones Date: Wed, 15 Feb 2012 13:58:29 +0100 Subject: Enable qlocalsocket auto test Due to recent changes in the test it should now compile and run properly. This re-enables the test. Change-Id: I6c647d99fa1f1b1c53e006fef2865d6be08ec16c Reviewed-by: Alex --- tests/auto/network/socket/socket.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/socket.pro b/tests/auto/network/socket/socket.pro index 426dca2277..6d86eab209 100644 --- a/tests/auto/network/socket/socket.pro +++ b/tests/auto/network/socket/socket.pro @@ -3,7 +3,7 @@ SUBDIRS=\ qhttpsocketengine \ qudpsocket \ qtcpsocket \ - #qlocalsocket \ # FIXME: uses qtscript (QTBUG-19242) + qlocalsocket \ qtcpserver \ qsocks5socketengine \ qabstractsocket \ -- cgit v1.2.3 From d1abf3e3e7108071fec2075301310ac2c19c878d Mon Sep 17 00:00:00 2001 From: Andrew Stanley-Jones Date: Tue, 21 Feb 2012 08:11:49 +0100 Subject: Fix the qlocalsocket test This test is broken in a couple of ways. A few one line fixes combined into a single patch. 1. Linux is the only OS that does abstract unix domain sockets by prepending a null as the first character. Don't test this on non-Linux platforms and expect it to pass. 2. Change QVERIFY2 to QCOMPARE so we can see why this fails in CI but no on the local system. Use QCOMPARE where possible. Change-Id: Ic3d2cf9696730dc4d6589539fdfe8a48ccf28de5 Reviewed-by: Alex --- tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 72fa9f74a4..70da67455e 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -1129,7 +1129,7 @@ void tst_QLocalSocket::verifyListenWithDescriptor() } else if (abstract) { QVERIFY2(server.fullServerName().at(0) == QLatin1Char('@'), "abstract sockets should start with a '@'"); } else { - QVERIFY2(server.fullServerName() == path, "full server path doesn't match patch provided"); + QCOMPARE(server.fullServerName(), path); if (path.contains(QLatin1String("/"))) { QVERIFY2(server.serverName() == path.mid(path.lastIndexOf(QLatin1Char('/'))+1), "server name invalid short name"); } else { @@ -1153,8 +1153,10 @@ void tst_QLocalSocket::verifyListenWithDescriptor_data() QTest::addColumn("bound"); QTest::newRow("normal") << QDir::tempPath() + QLatin1Literal("/testsocket") << false << true; +#ifdef Q_OS_LINUX QTest::newRow("absrtact") << QString::fromLatin1("abstractsocketname") << true << true; QTest::newRow("abstractwithslash") << QString::fromLatin1("abstractsocketwitha/inthename") << true << true; +#endif QTest::newRow("no path") << QString::fromLatin1("/invalid/no path name speficied") << true << false; #endif -- cgit v1.2.3 From 7bbe79fe5f54ed7542d935600036d3c8b401505f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 17 Feb 2012 20:09:17 +0100 Subject: Drop file-engine abstraction from public API This abstraction imposed serious performance penalties and is being dropped from the public API. In particular, by allowing file names to be arbitrarily hijacked by different file engines, and requiring engines to be instantiated in order to decide, it imposed unnecessary overhead on all file operations. Another flaw in the design with direct impact on performance is how engines have no way to provide (or retain) additional information obtained when querying the filesystem. In many places this has meant repeated operations on the file system, where useful information is immediately discarded to be queried again subsequently. For Qt 4.8 a major refactoring of the code base took place to allow bypassing the file-engine abstraction in select places, with considerable performance gains observed. In Qt 5 it is expected we'll be able to take this further, reaping even more benefits, but the abstraction has to go. [Dropping this now does not preclude that virtual file systems make an appearance in Qt at a later point in Qt 5's lifecycle. Hopefully with a new and improved abstraction.] Forward declarations for QFileExtension(Result) were dropped, as the classes were never used or defined. Tests using "internalized" classes will only fully run on developer builds. QFSFileEngine was removed altogether from exception safety test, as it isn't its intent to test internal API. Change-Id: Ie910e6c2628be202ea9e05366b091d6d529b246b Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- tests/auto/corelib/io/io.pro | 1 + .../io/qabstractfileengine/qabstractfileengine.pro | 2 +- .../io/qabstractfileengine/tst_qabstractfileengine.cpp | 4 ++-- tests/auto/corelib/io/qdir/qdir.pro | 2 +- tests/auto/corelib/io/qdir/tst_qdir.cpp | 3 +++ tests/auto/corelib/io/qdiriterator/qdiriterator.pro | 2 +- .../auto/corelib/io/qdiriterator/tst_qdiriterator.cpp | 8 ++++++++ tests/auto/corelib/io/qfile/test/test.pro | 2 +- tests/auto/corelib/io/qfile/tst_qfile.cpp | 18 ++++++++++++++---- .../tst_exceptionsafety_objects.cpp | 1 - 10 files changed, 32 insertions(+), 11 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index 095aa7a77d..84a885f5b6 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -30,6 +30,7 @@ SUBDIRS=\ } !contains(QT_CONFIG, private_tests): SUBDIRS -= \ + qabstractfileengine \ qfileinfo win32:!contains(QT_CONFIG, private_tests): SUBDIRS -= \ diff --git a/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.pro b/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.pro index d7565b5429..641bb7341b 100644 --- a/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.pro +++ b/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.pro @@ -1,5 +1,5 @@ CONFIG += testcase TARGET = tst_qabstractfileengine -QT = core testlib +QT = core-private core testlib SOURCES = tst_qabstractfileengine.cpp RESOURCES += qabstractfileengine.qrc diff --git a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp index 776ad4d0a7..c6ccc9308a 100644 --- a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include -#include +#include +#include #include #include diff --git a/tests/auto/corelib/io/qdir/qdir.pro b/tests/auto/corelib/io/qdir/qdir.pro index 14f2d8812a..94ee14b51e 100644 --- a/tests/auto/corelib/io/qdir/qdir.pro +++ b/tests/auto/corelib/io/qdir/qdir.pro @@ -1,6 +1,6 @@ CONFIG += testcase parallel_test TARGET = tst_qdir -QT = core testlib +QT = core core-private testlib SOURCES = tst_qdir.cpp RESOURCES += qdir.qrc diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 6a48d7e60f..04967d8313 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -49,6 +49,7 @@ #include #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) +#include #include "../../../network-settings.h" #endif @@ -471,6 +472,7 @@ void tst_QDir::exists_data() #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) QTest::newRow("This drive should exist") << "C:/" << true; // find a non-existing drive and check if it does not exist +#ifdef QT_BUILD_INTERNAL QFileInfoList drives = QFSFileEngine::drives(); QStringList driveLetters; for (int i = 0; i < drives.count(); ++i) { @@ -487,6 +489,7 @@ void tst_QDir::exists_data() QTest::newRow("This drive should not exist") << driv << false; } #endif +#endif } void tst_QDir::exists() diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro index cfb3201c43..ef59fc48e3 100644 --- a/tests/auto/corelib/io/qdiriterator/qdiriterator.pro +++ b/tests/auto/corelib/io/qdiriterator/qdiriterator.pro @@ -1,6 +1,6 @@ CONFIG += testcase parallel_test TARGET = tst_qdiriterator -QT = core testlib +QT = core-private core testlib SOURCES = tst_qdiriterator.cpp RESOURCES += qdiriterator.qrc diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index d5d490dc29..37d3e1ab68 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -48,6 +48,8 @@ #include #include +#include + #if defined(Q_OS_VXWORKS) #define Q_NO_SYMLINKS #endif @@ -454,6 +456,7 @@ void tst_QDirIterator::stopLinkLoop() // The goal of this test is only to ensure that the test above don't malfunction } +#ifdef QT_BUILD_INTERNAL class EngineWithNoIterator : public QFSFileEngine { public: @@ -473,13 +476,18 @@ public: return new EngineWithNoIterator(fileName); } }; +#endif void tst_QDirIterator::engineWithNoIterator() { +#ifdef QT_BUILD_INTERNAL EngineWithNoIteratorHandler handler; QDir("entrylist").entryList(); QVERIFY(true); // test that the above line doesn't crash +#else + QSKIP("This test requires -developer-build."); +#endif } void tst_QDirIterator::absoluteFilePathsFromRelativeIteratorPath() diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro index 2611ff39bd..dab5e4a3a5 100644 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ b/tests/auto/corelib/io/qfile/test/test.pro @@ -1,5 +1,5 @@ CONFIG += testcase -QT = core network testlib +QT = core-private core network testlib TARGET = ../tst_qfile SOURCES = ../tst_qfile.cpp RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index d1a0debf4d..87d2cf83f7 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -42,13 +42,15 @@ #include #include -#include -#include #include #include #include #include #include + +#include +#include + #if !defined(Q_OS_WINCE) #include #endif @@ -70,7 +72,6 @@ # include #elif defined(Q_OS_WINCE) # include -# include #endif #include @@ -1943,6 +1944,7 @@ void tst_QFile::longFileName() QVERIFY(QFile::remove(newName)); } +#ifdef QT_BUILD_INTERNAL class MyEngine : public QAbstractFileEngine { public: @@ -1998,6 +2000,7 @@ public: return new MyEngine(2); } }; +#endif void tst_QFile::fileEngineHandler() { @@ -2006,6 +2009,7 @@ void tst_QFile::fileEngineHandler() QFile file("ole.bull"); QCOMPARE(file.size(), qint64(0)); +#ifdef QT_BUILD_INTERNAL // Instantiating our handler will enable the new engine. MyHandler handler; file.setFileName("ole.bull"); @@ -2015,9 +2019,10 @@ void tst_QFile::fileEngineHandler() MyHandler2 handler2; file.setFileName("ole.bull"); QCOMPARE(file.size(), qint64(125)); - +#endif } +#ifdef QT_BUILD_INTERNAL class MyRecursiveHandler : public QAbstractFileEngineHandler { public: @@ -2032,13 +2037,18 @@ public: return 0; } }; +#endif void tst_QFile::useQFileInAFileHandler() { +#ifdef QT_BUILD_INTERNAL // This test should not dead-lock MyRecursiveHandler handler; QFile file(":!tst_qfile.cpp"); QVERIFY(file.exists()); +#else + QSKIP("This test requires -developer-build."); +#endif } void tst_QFile::getCharFF() diff --git a/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 71a70384fc..a426a90976 100644 --- a/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -166,7 +166,6 @@ void tst_ExceptionSafety_Objects::objects_data() NEWROW(QObject); NEWROW(QBuffer); NEWROW(QFile); - NEWROW(QFSFileEngine); NEWROW(QProcess); NEWROW(QSettings); NEWROW(QThread); -- cgit v1.2.3 From 4c577aead97abb4e22fedcf57cb9aea6c5bfa623 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Tue, 21 Feb 2012 14:55:13 +1000 Subject: Flag QGraphicsView test as unstable on Mac. Task-number: QTBUG-24296 Change-Id: I9f748c368fbc0cc2b272be9400da95d774d51bde Reviewed-by: Rohan McGovern --- tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro index 439cf547ef..2f479151dc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro +++ b/tests/auto/widgets/graphicsview/qgraphicsview/qgraphicsview.pro @@ -9,4 +9,4 @@ DEFINES += QT_NO_CAST_TO_ASCII linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG+=insignificant_test -win32:CONFIG += insignificant_test # QTBUG-24296 +win32|mac:CONFIG += insignificant_test # QTBUG-24296 -- cgit v1.2.3 From e9015b3bc8827a8276f58bdd41adcac1bcbf2137 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 22 Feb 2012 10:07:01 +1000 Subject: Fixed tst_qlogging app silently not compiled in some -fast builds. When configuring with -fast on Windows, a directory which contains two .pro files, one SUBDIRS and one not, will have the SUBDIRS Makefile silently clobbered by the non-SUBDIRS Makefile. In practice, this may cause various subdirectories to be silently excluded from the build. Rearrange .pro files for this test to avoid triggering this bug. Task-number: QTBUG-21168 Change-Id: Ic51941db497d7b8fb004f3c50f5ea24d90ff3114 Reviewed-by: Toby Tomkins --- tests/auto/corelib/global/qlogging/qlogging.pro | 2 +- tests/auto/corelib/global/qlogging/test/test.pro | 4 ++++ tests/auto/corelib/global/qlogging/tst_qlogging.pro | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 tests/auto/corelib/global/qlogging/test/test.pro delete mode 100644 tests/auto/corelib/global/qlogging/tst_qlogging.pro (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qlogging/qlogging.pro b/tests/auto/corelib/global/qlogging/qlogging.pro index 1d5e7681df..4d3823cdbe 100644 --- a/tests/auto/corelib/global/qlogging/qlogging.pro +++ b/tests/auto/corelib/global/qlogging/qlogging.pro @@ -3,4 +3,4 @@ CONFIG += ordered SUBDIRS += \ app \ - tst_qlogging.pro + test diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro new file mode 100644 index 0000000000..6e4939ffc9 --- /dev/null +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = ../tst_qlogging +QT = core testlib +SOURCES = ../tst_qlogging.cpp diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.pro b/tests/auto/corelib/global/qlogging/tst_qlogging.pro deleted file mode 100644 index 60377e0fdc..0000000000 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase parallel_test -TARGET = tst_qlogging -QT = core testlib -SOURCES = tst_qlogging.cpp -- cgit v1.2.3 From 82fb03546bdc5d71b9cb389b68b3c0d4d5a0b241 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 22 Feb 2012 09:26:27 +0100 Subject: Fix QJson autotest on Windows. - Fix warning: "Character represented by universal-character-name '\uFFFF' cannot be represented in the current code page (1252). - Fix character conversion - Change source file to plain ASCII, add defines for special characters. Change-Id: I8557e6ba7488f746247f0d78181f14bfb7d5aaae Reviewed-by: Miikka Heikkinen Reviewed-by: Lars Knoll --- tests/auto/corelib/json/tst_qtjson.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 2ac0574ec5..4edbd14305 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -45,6 +45,9 @@ #include "qjsonvalue.h" #include "qjsondocument.h" +#define INVALID_UNICODE "\357\277\277" // "\uffff" +#define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet + class TestQtJson: public QObject { Q_OBJECT @@ -1205,7 +1208,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"foo\uffffbar\"]"; + QByteArray json = "[\n \"foo"INVALID_UNICODE"bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1221,7 +1224,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa\\u12\"]"; + QByteArray json = "[\n \"c"UNICODE_DJE"a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); @@ -1229,7 +1232,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa\uffffbar\"]"; + QByteArray json = "[\n \"c"UNICODE_DJE"a"INVALID_UNICODE"bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1237,7 +1240,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"cЂa ]"; + QByteArray json = "[\n \"c"UNICODE_DJE"a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::EndOfString); @@ -1378,7 +1381,7 @@ void TestQtJson::parseStrings() "abc\\rabc", "abc\\tabc", "abc\\u0019abc", - "abcЂabc", + "abc"UNICODE_DJE"abc", }; int size = sizeof(strings)/sizeof(const char *); @@ -1404,7 +1407,7 @@ void TestQtJson::parseStrings() }; Pairs pairs [] = { { "abc\\/abc", "abc/abc" }, - { "abc\\u0402abc", "abcЂabc" }, + { "abc\\u0402abc", "abc"UNICODE_DJE"abc" }, { "abc\\u0065abc", "abceabc" } }; size = sizeof(pairs)/sizeof(Pairs); @@ -1547,7 +1550,7 @@ void TestQtJson::validation() // only test the first 1000 bytes. Testing the full file takes too long for (int i = 0; i < 1000; ++i) { QByteArray corrupted = binary; - corrupted[i] = 0xff; + corrupted[i] = char(0xff); QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); if (doc.isNull()) continue; @@ -1567,7 +1570,7 @@ void TestQtJson::validation() for (int i = 0; i < binary.size(); ++i) { QByteArray corrupted = binary; - corrupted[i] = 0xff; + corrupted[i] = char(0xff); QJsonDocument doc = QJsonDocument::fromBinaryData(corrupted); if (doc.isNull()) continue; -- cgit v1.2.3 From 7401832a7d45de99562b94340375393a39267f41 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Wed, 22 Feb 2012 11:34:37 +0200 Subject: Refactor input context tests Combined test input context instances and adapted changed interfaces a bit. Change-Id: Id5422cac5967d45dcaf2eb71b941d9c45e3b4dee Reviewed-by: Joona Petrell --- .../gui/kernel/qinputmethod/tst_qinputmethod.cpp | 128 ++++++++------------- tests/auto/shared/platforminputcontext.h | 115 ++++++++++++++++++ .../qgraphicsscene/tst_qgraphicsscene.cpp | 2 +- .../qgraphicsview/tst_qgraphicsview.cpp | 2 +- tests/auto/widgets/shared/platforminputcontext.h | 101 ---------------- 5 files changed, 166 insertions(+), 182 deletions(-) create mode 100644 tests/auto/shared/platforminputcontext.h delete mode 100644 tests/auto/widgets/shared/platforminputcontext.h (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index c10d954489..2ca921b557 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -44,88 +44,20 @@ #include #include #include - -class PlatformInputContext : public QPlatformInputContext -{ -public: - PlatformInputContext() : - m_animating(false), - m_visible(false), - m_updateCallCount(0), - m_resetCallCount(0), - m_commitCallCount(0), - m_localeCallCount(0), - m_inputDirectionCallCount(0), - m_lastQueries(Qt::ImhNone), - m_action(QInputMethod::Click), - m_cursorPosition(0), - m_lastEventType(QEvent::None) - {} - - virtual QRectF keyboardRect() const { return m_keyboardRect; } - virtual bool isAnimating() const { return m_animating; } - virtual void reset() { m_resetCallCount++; } - virtual void commit() { m_commitCallCount++; } - - virtual void update(Qt::InputMethodQueries queries) - { - m_updateCallCount++; - m_lastQueries = queries; - } - virtual void invokeAction(QInputMethod::Action action, int cursorPosition) - { - m_action = action; - m_cursorPosition = cursorPosition; - } - virtual bool filterEvent(const QEvent *event) - { - m_lastEventType = event->type(); return false; - } - virtual void showInputPanel() - { - m_visible = true; - } - virtual void hideInputPanel() - { - m_visible = false; - } - virtual bool isInputPanelVisible() const - { - return m_visible; - } - virtual QLocale locale() const - { - m_localeCallCount++; - return QLocale::c(); - } - virtual Qt::LayoutDirection inputDirection() const - { - m_inputDirectionCallCount++; - return Qt::LeftToRight; - } - - bool m_animating; - bool m_visible; - int m_updateCallCount; - int m_resetCallCount; - int m_commitCallCount; - mutable int m_localeCallCount; - mutable int m_inputDirectionCallCount; - Qt::InputMethodQueries m_lastQueries; - QInputMethod::Action m_action; - int m_cursorPosition; - int m_lastEventType; - QRectF m_keyboardRect; -}; +#include "../../../shared/platforminputcontext.h" class InputItem : public QObject { Q_OBJECT public: + InputItem() : m_enabled(true) {} + bool event(QEvent *event) { if (event->type() == QEvent::InputMethodQuery) { QInputMethodQueryEvent *query = static_cast(event); + if (query->queries() & Qt::ImEnabled) + query->setValue(Qt::ImEnabled, m_enabled); if (query->queries() & Qt::ImCursorRectangle) query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4)); if (query->queries() & Qt::ImPreferredLanguage) @@ -136,9 +68,39 @@ public: } return false; } + + void setEnabled(bool enabled) { + if (enabled != m_enabled) { + m_enabled = enabled; + qApp->inputMethod()->update(Qt::ImEnabled); + } + } + Qt::InputMethodQueries m_lastQueries; + bool m_enabled; +}; + + +class DummyWindow : public QWindow +{ +public: + DummyWindow() : m_focusObject(0) {} + + virtual QObject *focusObject() const + { + return m_focusObject; + } + + void setFocusObject(QObject *object) + { + m_focusObject = object; + emit focusObjectChanged(object); + } + + QObject *m_focusObject; }; + class tst_qinputmethod : public QObject { Q_OBJECT @@ -249,17 +211,22 @@ void tst_qinputmethod::cursorRectangle() { QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF()); + DummyWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qApp->focusWindow(), &window); + window.setFocusObject(&m_inputItem); + QTransform transform; transform.translate(10, 10); transform.scale(2, 2); transform.shear(2, 2); qApp->inputMethod()->setInputItemTransform(transform); - qApp->inputMethod()->setInputItem(&m_inputItem); QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); // reset - qApp->inputMethod()->setInputItem(0); qApp->inputMethod()->setInputItemTransform(QTransform()); } @@ -297,7 +264,13 @@ void tst_qinputmethod::commit() void tst_qinputmethod::update() { - qApp->inputMethod()->setInputItem(&m_inputItem); + DummyWindow window; + window.show(); + QTest::qWaitForWindowShown(&window); + window.requestActivateWindow(); + QTRY_COMPARE(qApp->focusWindow(), &window); + window.setFocusObject(&m_inputItem); + QCOMPARE(m_platformInputContext.m_updateCallCount, 0); QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone)); @@ -310,9 +283,6 @@ void tst_qinputmethod::update() QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryAll)); QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40)); - - // reset - qApp->inputMethod()->setInputItem(0); } void tst_qinputmethod::query() diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h new file mode 100644 index 0000000000..cddeca3945 --- /dev/null +++ b/tests/auto/shared/platforminputcontext.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class PlatformInputContext : public QPlatformInputContext +{ +public: + PlatformInputContext() : + m_animating(false), + m_visible(false), + m_updateCallCount(0), + m_resetCallCount(0), + m_commitCallCount(0), + m_localeCallCount(0), + m_inputDirectionCallCount(0), + m_lastQueries(Qt::ImhNone), + m_action(QInputMethod::Click), + m_cursorPosition(0), + m_lastEventType(QEvent::None) + {} + + virtual QRectF keyboardRect() const { return m_keyboardRect; } + virtual bool isAnimating() const { return m_animating; } + virtual void reset() { m_resetCallCount++; } + virtual void commit() { m_commitCallCount++; } + + virtual void update(Qt::InputMethodQueries queries) + { + m_updateCallCount++; + m_lastQueries = queries; + } + virtual void invokeAction(QInputMethod::Action action, int cursorPosition) + { + m_action = action; + m_cursorPosition = cursorPosition; + } + virtual bool filterEvent(const QEvent *event) + { + m_lastEventType = event->type(); return false; + } + virtual void showInputPanel() + { + m_visible = true; + } + virtual void hideInputPanel() + { + m_visible = false; + } + virtual bool isInputPanelVisible() const + { + return m_visible; + } + virtual QLocale locale() const + { + m_localeCallCount++; + return QLocale::c(); + } + virtual Qt::LayoutDirection inputDirection() const + { + m_inputDirectionCallCount++; + return Qt::LeftToRight; + } + + bool m_animating; + bool m_visible; + int m_updateCallCount; + int m_resetCallCount; + int m_commitCallCount; + mutable int m_localeCallCount; + mutable int m_inputDirectionCallCount; + Qt::InputMethodQueries m_lastQueries; + QInputMethod::Action m_action; + int m_cursorPosition; + int m_lastEventType; + QRectF m_keyboardRect; +}; diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 3257e7efea..220c89ec2f 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -51,7 +51,7 @@ #include #include #include "../../../gui/painting/qpathclipper/pathcompare.h" -#include "../../shared/platforminputcontext.h" +#include "../../../shared/platforminputcontext.h" #include #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 7ceeaaa0d3..84dea04c45 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -71,7 +71,7 @@ #include #include #include "../../../platformquirks.h" -#include "../../shared/platforminputcontext.h" +#include "../../../shared/platforminputcontext.h" #include Q_DECLARE_METATYPE(QList) diff --git a/tests/auto/widgets/shared/platforminputcontext.h b/tests/auto/widgets/shared/platforminputcontext.h deleted file mode 100644 index 759123a4a6..0000000000 --- a/tests/auto/widgets/shared/platforminputcontext.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -class PlatformInputContext : public QPlatformInputContext -{ -public: - PlatformInputContext() : - m_animating(false), - m_visible(false), - m_updateCallCount(0), - m_resetCallCount(0), - m_commitCallCount(0), - m_lastQueries(Qt::ImhNone), - m_action(QInputPanel::Click), - m_cursorPosition(0), - m_lastEventType(QEvent::None) - {} - - virtual QRectF keyboardRect() const { return m_keyboardRect; } - virtual bool isAnimating() const { return m_animating; } - virtual void reset() { m_resetCallCount++; } - virtual void commit() { m_commitCallCount++; } - - virtual void update(Qt::InputMethodQueries queries) - { - m_updateCallCount++; - m_lastQueries = queries; - } - virtual void invokeAction(QInputPanel::Action action, int cursorPosition) - { - m_action = action; - m_cursorPosition = cursorPosition; - } - virtual bool filterEvent(const QEvent *event) - { - m_lastEventType = event->type(); return false; - } - virtual void showInputPanel() - { - m_visible = true; - } - virtual void hideInputPanel() - { - m_visible = false; - } - virtual bool isInputPanelVisible() const - { - return m_visible; - } - - bool m_animating; - bool m_visible; - int m_updateCallCount; - int m_resetCallCount; - int m_commitCallCount; - Qt::InputMethodQueries m_lastQueries; - QInputPanel::Action m_action; - int m_cursorPosition; - int m_lastEventType; - QRectF m_keyboardRect; -}; -- cgit v1.2.3 From 186692f81f2612c3cf3a4090cbf949f2fb1558f8 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 30 Jan 2012 14:23:22 +0200 Subject: Remove custom text codec for C strings. This setting is extremely harmful, as code cannot know whether or not to expect it. It also made the behaviour of QString::fromAscii and ::toAscii unintuitive, and caused a lot of people to make mistakes with it. Change-Id: I2f429fa7ef93bd75bb93a7f64c56db15b7283388 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qstring/tst_qstring.cpp | 18 ++---------------- .../qstringbuilder/qstringbuilder1/stringbuilder.cpp | 16 ++++++++++++---- tests/auto/other/collections/tst_collections.cpp | 7 +++---- 3 files changed, 17 insertions(+), 24 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 3fb253c646..7e4f591f47 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -808,10 +808,7 @@ void tst_QString::constructorQByteArray() QCOMPARE(str1.length(), expected.length()); QCOMPARE( str1, expected ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 QString strBA(src); - QTextCodec::setCodecForCStrings( 0 ); - QCOMPARE( strBA, expected ); } @@ -928,12 +925,7 @@ void tst_QString::sprintf() QCOMPARE(a.sprintf("%-5.5s", "Hello" ),(QString)"Hello"); // Check utf8 conversion for %s - QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString("\366\344\374\326\304\334\370\346\345\330\306\305")); - - // Check codecForCStrings is used to read non-modifier sequences in the format string - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - QCOMPARE(a.sprintf("\303\251\303\250\303\240 %s", "\303\251\303\250\303\240"), QString("\303\251\303\250\303\240 \303\251\303\250\303\240")); - QTextCodec::setCodecForCStrings(0); + QCOMPARE(a.sprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305")); int n1; a.sprintf("%s%n%s", "hello", &n1, "goodbye"); @@ -1871,9 +1863,7 @@ void tst_QString::append_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str.append( ba ); - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -1898,9 +1888,7 @@ void tst_QString::operator_pluseq_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str += ba; - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -1960,9 +1948,7 @@ void tst_QString::prepend_bytearray() QFETCH( QString, str ); QFETCH( QByteArray, ba ); - QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 str.prepend( ba ); - QTextCodec::setCodecForCStrings( 0 ); QTEST( str, "res" ); } @@ -3211,7 +3197,7 @@ void tst_QString::utf8() QFETCH( QByteArray, utf8 ); QFETCH( QString, res ); - QCOMPARE( utf8, QByteArray(res.toUtf8()) ); + QCOMPARE(res.toUtf8(), utf8); } void tst_QString::stringRef_utf8_data() diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index 95e24b22fb..afc16078b8 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -66,10 +66,8 @@ void runScenario() { - // set codec for C strings to 0, enforcing Latin1 - QTextCodec::setCodecForCStrings(0); - QVERIFY(!QTextCodec::codecForCStrings()); - + // this code is latin1. TODO: replace it with the utf8 block below, once + // strings default to utf8. QLatin1Literal l1literal(LITERAL); QLatin1String l1string(LITERAL); QString string(l1string); @@ -130,7 +128,10 @@ void runScenario() r = string P ba; QCOMPARE(r, r2); +#if 0 // now test with codec for C strings set + // TODO: to be re-enabled once strings default to utf8, in place of the + // latin1 code above. QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QVERIFY(QTextCodec::codecForCStrings()); QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8")); @@ -153,6 +154,7 @@ void runScenario() QCOMPARE(r, r3); r = string P ba; QCOMPARE(r, r3); +#endif ba = QByteArray(); // empty r = ba P string; @@ -212,8 +214,11 @@ void runScenario() str += QLatin1String(LITERAL) P str; QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); #ifndef QT_NO_CAST_FROM_ASCII +#if 0 + // TODO: this relies on strings defaulting to utf8, so disable this for now. str = (QString::fromUtf8(UTF8_LITERAL) += QLatin1String(LITERAL) P UTF8_LITERAL); QCOMPARE(str, QString::fromUtf8(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#endif #endif } @@ -229,10 +234,13 @@ void runScenario() ba2 += ba2 P withZero; QCOMPARE(ba2, QByteArray(withZero + withZero + withZero)); #ifndef QT_NO_CAST_TO_ASCII +#if 0 + // TODO: this relies on strings defaulting to utf8, so disable this for now. ba = UTF8_LITERAL; ba2 = (ba += QLatin1String(LITERAL) + QString::fromUtf8(UTF8_LITERAL)); QCOMPARE(ba2, ba); QCOMPARE(ba, QByteArray(UTF8_LITERAL LITERAL UTF8_LITERAL)); +#endif #endif } diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp index 9bfed15fc4..dc6d7f4b55 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/other/collections/tst_collections.cpp @@ -2124,11 +2124,10 @@ void tst_Collections::qstring() QVERIFY(s.toAscii().isNull()); s = "ascii"; - s += (uchar) 0xb0; + s += QChar((uchar) 0xb0); QVERIFY(s.toUtf8() != s.toLatin1()); - QString sa = s.toLatin1().constData(); - QVERIFY(sa[sa.length()-1] == (ushort) 0xb0); - QVERIFY(sa.left(sa.length()-1) == "ascii"); + QCOMPARE(s[s.length()-1].unicode(), (ushort)0xb0); + QVERIFY(s.left(s.length()-1) == "ascii"); QVERIFY(s == QString::fromUtf8(s.toUtf8().constData())); -- cgit v1.2.3 From 541949aed23ea14a71a7d4391bac244b623add0a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 15:36:01 +0100 Subject: Add further theme hints to QPlatformTheme. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add hints for QDialog/QDialogButtonBox. - Add hint for available popup-menu area. - Add keyboard scheme hint replacing QGuiApplicationPrivate::currentKeyPlatform() Reviewed-by: Samuel Rødal Reviewed-by: Morten Johan Sørvig Task-number: QTBUG-24204 Task-number: QTBUG-24315 Change-Id: I6653786b0dcb49a6fc264d3b9891dbfee502bd3e Reviewed-by: Friedemann Kleint --- .../auto/gui/kernel/qkeysequence/qkeysequence.pro | 2 +- .../gui/kernel/qkeysequence/tst_qkeysequence.cpp | 59 +++++++++++++--------- tests/auto/other/languagechange/languagechange.pro | 2 +- .../other/languagechange/tst_languagechange.cpp | 14 ++++- .../widgets/dialogs/qmessagebox/qmessagebox.pro | 2 +- .../dialogs/qmessagebox/tst_qmessagebox.cpp | 15 +++--- tests/auto/widgets/kernel/qaction/qaction.pro | 2 +- tests/auto/widgets/kernel/qaction/tst_qaction.cpp | 29 ++++++++--- 8 files changed, 80 insertions(+), 45 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro index 1e0baafd09..cf4337b156 100644 --- a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro +++ b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qkeysequence -QT += widgets widgets-private testlib +QT += widgets testlib QT += core-private gui-private SOURCES += tst_qkeysequence.cpp diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index 29588e2ee9..861ad3835d 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -41,9 +41,10 @@ #include -#include #include +#include #include +#include #include #include @@ -142,6 +143,7 @@ private slots: void initTestCase(); private: + int m_keyboardScheme; QTranslator *ourTranslator; QTranslator *qtTranslator; #ifdef Q_OS_MAC @@ -161,8 +163,10 @@ const QString tst_QKeySequence::MacAlt = QString(QChar(0x2325)); const QString tst_QKeySequence::MacShift = QString(QChar(0x21E7)); #endif -tst_QKeySequence::tst_QKeySequence() +tst_QKeySequence::tst_QKeySequence() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } tst_QKeySequence::~tst_QKeySequence() @@ -297,8 +301,7 @@ void tst_QKeySequence::checkMultipleCodes() */ void tst_QKeySequence::ensureSorted() { -//### accessing static members from private classes does not work on msvc at the moment -#if defined(QT_BUILD_INTERNAL) && !defined(Q_WS_WIN) +#if defined(QT_BUILD_INTERNAL) uint N = QKeySequencePrivate::numberOfKeyBindings; uint val = QKeySequencePrivate::keyBindings[0].shortcut; for ( uint i = 1 ; i < N ; ++i) { @@ -322,13 +325,13 @@ void tst_QKeySequence::standardKeys_data() QTest::newRow("delete") << (int)QKeySequence::Delete<< QString("DEL"); QTest::newRow("open") << (int)QKeySequence::Open << QString("CTRL+O"); QTest::newRow("find") << (int)QKeySequence::Find<< QString("CTRL+F"); -#ifdef Q_WS_WIN - QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); - QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); - QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); - QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); - QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); -#endif + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); + QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); + QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); + QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); + QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); + } QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B"); QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I"); QTest::newRow("underline") << (int)QKeySequence::Underline << QString("CTRL+U"); @@ -362,23 +365,33 @@ void tst_QKeySequence::standardKeys() { QFETCH(int, standardKey); QFETCH(QString, expected); - QKeySequence ks((QKeySequence::StandardKey)standardKey); - QKeySequence ks2(expected); - QVERIFY(ks == ks2); + QKeySequence actualKeySequence((QKeySequence::StandardKey)standardKey); + QKeySequence expectedKeySequence(expected); + QVERIFY2(actualKeySequence == expectedKeySequence, + qPrintable(QString::fromLatin1("Key mismatch, expected '%1', got '%2' for standard key %3"). + arg(expected, actualKeySequence.toString()).arg(standardKey))); } void tst_QKeySequence::keyBindings() { - QList bindings = QKeySequence::keyBindings(QKeySequence::Copy); + const QList bindings = + QKeySequence::keyBindings(QKeySequence::Copy); + QList expected; -#if defined(Q_OS_MAC) - expected << QKeySequence("CTRL+C"); -#elif defined Q_WS_X11 - expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); -#else - expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); -#endif - QVERIFY(bindings == expected); + const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); + const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); + switch (m_keyboardScheme) { + case QPlatformTheme::MacKeyboardScheme: + expected << ctrlC; + break; + case QPlatformTheme::WindowsKeyboardScheme: + expected << ctrlC << ctrlInsert; + break; + default: // X11 + expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert; + break; + } + QCOMPARE(bindings, expected); } void tst_QKeySequence::mnemonic_data() diff --git a/tests/auto/other/languagechange/languagechange.pro b/tests/auto/other/languagechange/languagechange.pro index efbc524556..b115c01641 100644 --- a/tests/auto/other/languagechange/languagechange.pro +++ b/tests/auto/other/languagechange/languagechange.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_languagechange -QT += widgets core-private testlib +QT += widgets core-private gui-private testlib SOURCES += tst_languagechange.cpp diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp index b4bd766df7..663f2ef798 100644 --- a/tests/auto/other/languagechange/tst_languagechange.cpp +++ b/tests/auto/other/languagechange/tst_languagechange.cpp @@ -43,13 +43,16 @@ #include #include +#include #include #include #include #include #include +#include #include #include +#include #include #include @@ -66,12 +69,16 @@ private slots: void retranslatability_data(); void retranslatability(); +private: + QDialogButtonBox::ButtonLayout m_layout; }; -tst_languageChange::tst_languageChange() - +tst_languageChange::tst_languageChange() : + m_layout(QDialogButtonBox::WinLayout) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_layout = static_cast(theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt()); } void tst_languageChange::initTestCase() @@ -240,6 +247,9 @@ void tst_languageChange::retranslatability() QFETCH( int, dialogType); QFETCH( TranslationSet, expected); + if (m_layout == QDialogButtonBox::GnomeLayout) + QSKIP("The input data are not suitable for this layout (QDialogButtonBox::GnomeLayout)"); + // This will always be queried for when a language changes expected.insert("QCoreApplication::QT_LAYOUT_DIRECTION::Translate this string to the string 'LTR' in left-to-right " "languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to " diff --git a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro index f25ed650c3..5b8f796485 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro +++ b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro @@ -1,7 +1,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qmessagebox -QT += widgets testlib +QT += gui-private core-private widgets testlib DEPENDPATH += . INCLUDEPATH += . diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index 7fc752488d..1d391a1c09 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include #if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) #include #endif @@ -407,15 +409,12 @@ void tst_QMessageBox::staticSourceCompat() sendKeySoon(); ret = QMessageBox::information(0, "title", "text", QMessageBox::Yes, QMessageBox::No); int expectedButton = int(QMessageBox::Yes); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - if (qobject_cast(qApp->style())) - expectedButton = int(QMessageBox::No); -#elif !defined(QT_NO_STYLE_CLEANLOOKS) - if (qobject_cast(qApp->style())) { - QEXPECT_FAIL("", "Special handling of QMessageBox::information buttons for Cleanlooks not implemented yet, QTBUG-24315", Continue); - expectedButton = int(QMessageBox::No); + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { + const int dialogButtonBoxLayout = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt(); + if (dialogButtonBoxLayout == QDialogButtonBox::MacLayout + || dialogButtonBoxLayout == QDialogButtonBox::GnomeLayout) + expectedButton = int(QMessageBox::No); } -#endif QCOMPARE(ret, expectedButton); QCOMPARE(keyToSend, -1); diff --git a/tests/auto/widgets/kernel/qaction/qaction.pro b/tests/auto/widgets/kernel/qaction/qaction.pro index e6f0735394..c57107b1b0 100644 --- a/tests/auto/widgets/kernel/qaction/qaction.pro +++ b/tests/auto/widgets/kernel/qaction/qaction.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qaction -QT += widgets testlib +QT += gui-private core-private widgets testlib SOURCES += tst_qaction.cpp diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp index 47aad21074..51123af953 100644 --- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp +++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include class tst_QAction : public QObject { @@ -77,6 +79,7 @@ private slots: private: int m_lastEventType; + int m_keyboardScheme; QAction *m_lastAction; QWidget *m_tstWidget; }; @@ -121,8 +124,10 @@ private: tst_QAction *tst; }; -tst_QAction::tst_QAction() +tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme) { + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); } tst_QAction::~tst_QAction() @@ -237,13 +242,21 @@ void tst_QAction::setStandardKeys() QVERIFY(act.shortcut() == act.shortcuts().first()); QList expected; -#if defined(Q_OS_MAC) - expected << QKeySequence("CTRL+C"); -#else - expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); -#endif -// Qt/Embedded on Windows: expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); - QVERIFY(act.shortcuts() == expected); + const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C")); + const QKeySequence ctrlInsert = QKeySequence(QStringLiteral("CTRL+INSERT")); + switch (m_keyboardScheme) { + case QPlatformTheme::MacKeyboardScheme: + expected << ctrlC; + break; + case QPlatformTheme::WindowsKeyboardScheme: + expected << ctrlC << ctrlInsert; + break; + default: // X11 + expected << ctrlC << QKeySequence(QStringLiteral("F16")) << ctrlInsert; + break; + } + + QCOMPARE(act.shortcuts(), expected); } -- cgit v1.2.3 From 194898bab9a02c442627714af569c8fa4d981df2 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 21 Feb 2012 22:44:08 +0000 Subject: Fix breakage in dead code Change-Id: Ibcddfb711a3f47bf957a4b010330e8a775f1a2e8 Reviewed-by: Rohan McGovern --- tests/auto/xml/dom/qdom/tst_qdom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index d79044157a..1533e6a139 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1845,7 +1845,7 @@ void tst_QDom::checkIntOverflow() const QVERIFY(doc.setContent(xmlMessage)); const QDomNodeList nl(doc.elementsByTagName(QLatin1String("test"))); - QCOMPARE(nl.length(), uint(1)); + QCOMPARE(nl.length(), 1); } } -- cgit v1.2.3 From 4a7be92f06d81b93264e998d5f98480cf5bc58ba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 08:53:04 +0100 Subject: Fixed tst_qobject signalbug silently not compiled in -fast builds. When configuring with -fast on Windows, a directory which contains two .pro files, one SUBDIRS and one not, will have the SUBDIRS Makefile silently clobbered by the non-SUBDIRS Makefile. In practice, this may cause various subdirectories to be silently excluded from the build. Rearrange .pro files for this test to avoid triggering this bug. See also e9015b3bc8827a8276f58bdd41adcac1bcbf2137. Task-number: QTBUG-21168 Change-Id: I18fac1ac636fdc6b2aaee1b4cdfee9c4bc2a77ff Reviewed-by: Rohan McGovern --- tests/auto/corelib/kernel/qobject/qobject.pro | 8 +++++--- tests/auto/corelib/kernel/qobject/test/test.pro | 11 +++++++++++ tests/auto/corelib/kernel/qobject/tst_qobject.pro | 11 ----------- 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 tests/auto/corelib/kernel/qobject/test/test.pro delete mode 100644 tests/auto/corelib/kernel/qobject/tst_qobject.pro (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qobject/qobject.pro b/tests/auto/corelib/kernel/qobject/qobject.pro index 0f86408fc9..6a7cf07f51 100644 --- a/tests/auto/corelib/kernel/qobject/qobject.pro +++ b/tests/auto/corelib/kernel/qobject/qobject.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs -SUBDIRS = signalbug -tst_qobject.pro.depends = $$SUBDIRS -SUBDIRS += tst_qobject.pro +CONFIG += ordered + +SUBDIRS += \ + signalbug \ + test diff --git a/tests/auto/corelib/kernel/qobject/test/test.pro b/tests/auto/corelib/kernel/qobject/test/test.pro new file mode 100644 index 0000000000..9443b2e2c7 --- /dev/null +++ b/tests/auto/corelib/kernel/qobject/test/test.pro @@ -0,0 +1,11 @@ +CONFIG += testcase console +TARGET = ../tst_qobject +QT = core-private network testlib +SOURCES = ../tst_qobject.cpp + +# this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by +# moc from Qt 4.6, and should *not* be generated by the current moc +SOURCES += ../moc_oldnormalizeobject.cpp + +load(testcase) # for target.path and installTestHelperApp() +installTestHelperApp("signalbug/signalbug",signalbug,signalbug) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.pro b/tests/auto/corelib/kernel/qobject/tst_qobject.pro deleted file mode 100644 index 30fd810a2e..0000000000 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase console -TARGET = tst_qobject -QT = core-private network testlib -SOURCES = tst_qobject.cpp - -# this is here for a reason, moc_oldnormalizedobject.cpp is not auto-generated, it was generated by -# moc from Qt 4.6, and should *not* be generated by the current moc -SOURCES += moc_oldnormalizeobject.cpp - -load(testcase) # for target.path and installTestHelperApp() -installTestHelperApp("signalbug/signalbug",signalbug,signalbug) -- cgit v1.2.3 From 1501f1ddd499320c264dc3ab16d4ce8b408991bb Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 22 Feb 2012 18:29:51 -0800 Subject: QMenuBar: Clean up Q_WS_WIN - Replace Q_WS_WIN with Q_OS_WIN - Remove useless #ifdef Q_OS_WINCE which located in another #ifdef Q_OS_WINCE Change-Id: I6279b6d74902ab3ca6bdb7292c2936a76e3e6952 Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index 9989e5e7aa..6a1f418739 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -50,10 +50,6 @@ #include #include -#ifdef Q_WS_WIN -#include -#endif - #include QT_FORWARD_DECLARE_CLASS(QMainWindow) -- cgit v1.2.3 From ef9a86db5615a438c72a78745a8e558e687bf829 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 23 Feb 2012 15:02:23 +1000 Subject: Fix rounding error in QInputMethod::cursorRectangle(). Use QRectF consistently to avoid the rounding done in the conversion to QRect. Task-number: QTBUG-24463 Change-Id: If9ea858ebabf8c449ea058b9d379d4a57cb6c82d Reviewed-by: Joona Petrell --- tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index 2ca921b557..c906ebaabe 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -50,7 +50,7 @@ class InputItem : public QObject { Q_OBJECT public: - InputItem() : m_enabled(true) {} + InputItem() : cursorRectangle(1, 2, 3, 4), m_enabled(true) {} bool event(QEvent *event) { @@ -59,7 +59,7 @@ public: if (query->queries() & Qt::ImEnabled) query->setValue(Qt::ImEnabled, m_enabled); if (query->queries() & Qt::ImCursorRectangle) - query->setValue(Qt::ImCursorRectangle, QRectF(1, 2, 3, 4)); + query->setValue(Qt::ImCursorRectangle, cursorRectangle); if (query->queries() & Qt::ImPreferredLanguage) query->setValue(Qt::ImPreferredLanguage, QString("English")); m_lastQueries = query->queries(); @@ -76,6 +76,7 @@ public: } } + QRectF cursorRectangle; Qt::InputMethodQueries m_lastQueries; bool m_enabled; }; @@ -226,7 +227,11 @@ void tst_qinputmethod::cursorRectangle() QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); + m_inputItem.cursorRectangle = QRectF(1.5, 2, 1, 8); + QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1.5, 2, 1, 8))); + // reset + m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4); qApp->inputMethod()->setInputItemTransform(QTransform()); } -- cgit v1.2.3 From d2f65aa470fe30849a01380e4a50e8a4ebbce07e Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Sun, 25 Dec 2011 00:47:41 +0800 Subject: Fix conflict between QMainWindow::restoreState() and QWidget::setStylesheet() If QMainWindow::restoreState() then QWidget::setStylesheet() were called before the QMainWindow is shown, the size of QDockWidget can not be restored. QWidget::setStylesheet() will generate QEvent::StyleChange event, which will cause the function QDockAreaLayout::fitLayout() to be called before the layout of MainWindow is activated. Although the state info has been stored in a QMainWindowLayoutState variable by QMainWindow::restoreState(), but QMainWindowLayout::setGeometry() still isn't called at present. So QDockAreaLayout::fitLayout() will force the size of dockwidgets and centralwidget to be calculated using the wrong geometry, which will break the state restored by QMainWindow::restoreState(). This is a side effect of 692e9103ebb85b90e79377206d5d03b704d43d42. Task-number: QTBUG-15080 Change-Id: I8cda6a529d178f7467a59b780db80df0a44d4769 Reviewed-by: Olivier Goffart --- .../widgets/qmainwindow/tst_qmainwindow.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp index 13540355c7..0f07546559 100644 --- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp +++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp @@ -101,6 +101,7 @@ private slots: void centralWidgetSize(); void dockWidgetSize(); void QTBUG2774_stylechange(); + void QTBUG15080_restoreState(); void toggleUnifiedTitleAndToolBarOnMac(); }; @@ -1705,6 +1706,41 @@ void tst_QMainWindow::QTBUG2774_stylechange() } } +void tst_QMainWindow::QTBUG15080_restoreState() +{ + QByteArray state; + + //save state + { + QMainWindow mw1; + QDockWidget * dw1 = new QDockWidget(); + dw1->setObjectName("Left DockWidget"); + mw1.addDockWidget(Qt::LeftDockWidgetArea, dw1); + mw1.setCentralWidget(new QTextEdit()); + mw1.show(); + QApplication::processEvents(); + dw1->setFixedWidth(101); + QApplication::processEvents(); + + state = mw1.saveState(); + } + + //restore state + + QMainWindow mw2; + QDockWidget * dw2 = new QDockWidget(); + dw2->setObjectName("Left DockWidget"); + mw2.addDockWidget(Qt::LeftDockWidgetArea, dw2); + mw2.setCentralWidget(new QTextEdit()); + mw2.restoreState(state); + //QTBUG15080 caused by setStyleSheet + mw2.setStyleSheet("color:red"); + mw2.show(); + QApplication::processEvents(); + + QCOMPARE(dw2->width(), 101); +} + void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac() { #ifdef Q_OS_MAC -- cgit v1.2.3 From 660af10dee503729025952ed2374b8a081f941a2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 23 Feb 2012 10:13:41 +0100 Subject: Update tst_QTextEdit::fullWidthSelection Since we would add 1 to the height of script lines in the layout before and there was no compensation for this in the box font engine, which is used by this test, the selection rect in the test images was one pixel too high. Now that the +1 has been removed from the height, the images have to be updated. Change-Id: Ic9ea0ace6b61be496846c7f757ae309756cd9f5f Reviewed-by: Bradley T. Hughes --- .../fullWidthSelection/centered-fully-selected.png | Bin 1232 -> 1247 bytes .../fullWidthSelection/centered-partly-selected.png | Bin 1231 -> 1246 bytes .../fullWidthSelection/last-char-on-line.png | Bin 1226 -> 1241 bytes .../fullWidthSelection/last-char-on-parag.png | Bin 1223 -> 1238 bytes .../fullWidthSelection/multiple-full-width-lines.png | Bin 1236 -> 1250 bytes .../qtextedit/fullWidthSelection/nowrap_long.png | Bin 1199 -> 1214 bytes .../fullWidthSelection/single-full-width-line.png | Bin 1225 -> 1240 bytes 7 files changed, 0 insertions(+), 0 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png index ced6eb6e5b..b9df19eeb3 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png differ diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png index 481b99c7fc..792593ff12 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png differ diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png index 292d3f9d4c..02e5e93380 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png differ diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png index 69b72ede09..5ef32d2d19 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png differ diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png index 467b91e6e0..d877e1b656 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png differ diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png index cce921b0cc..411c0859aa 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png differ diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png index 937494ac3c..55d060af1f 100644 Binary files a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png and b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png differ -- cgit v1.2.3 From 8d10d9a444cbb3ad4535444272870c4c71279dba Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 12:23:25 +0100 Subject: compile fix: missing #include s Change-Id: I3bd34f67033fb921c49da97419c107811d8da6ff Reviewed-by: David Faure --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 5 +++++ tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 1 + 2 files changed, 6 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 671d03cf84..c214b5fc57 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -79,6 +79,11 @@ #ifdef QT_BUILD_INTERNAL #include #endif + +#ifdef Q_OS_UNIX +# include +# include // for getuid() +#endif #include #include "../../../network-settings.h" diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 70da67455e..2715bfc5dc 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -50,6 +50,7 @@ #include #include #include +#include // for unlink() #endif Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError) -- cgit v1.2.3 From b067f6cfe30a5a687316130d04678ac406837d09 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 8 Feb 2012 15:55:29 +0100 Subject: Add the quitlock feature to QThread. Change-Id: Ib44ee9739499ba4c5f0fecbef3976251ea22836d Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 49 +++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 25e1a0587c..8eccd17376 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -107,6 +107,8 @@ private slots: void customEventDispatcher(); void stressTest(); + + void quitLock(); }; enum { one_minute = 60 * 1000, five_minutes = 5 * one_minute }; @@ -1285,5 +1287,52 @@ void tst_QThread::customEventDispatcher() QVERIFY(weak_ed.isNull()); } +class Job : public QObject +{ + Q_OBJECT +public: + Job(QThread *thread, int deleteDelay, QObject *parent = 0) + : QObject(parent), quitLocker(thread), exitThreadCalled(false) + { + moveToThread(thread); + QTimer::singleShot(deleteDelay, this, SLOT(deleteLater())); + QTimer::singleShot(1000, this, SLOT(exitThread())); + } + +private slots: + void exitThread() + { + exitThreadCalled = true; + thread()->exit(1); + } + +private: + QEventLoopLocker quitLocker; +public: + bool exitThreadCalled; +}; + +void tst_QThread::quitLock() +{ + QThread thread; + + QEventLoop loop; + connect(&thread, SIGNAL(finished()), &loop, SLOT(quit())); + + Job *job; + + thread.start(); + job = new Job(&thread, 500); + QCOMPARE(job->thread(), &thread); + loop.exec(); + QVERIFY(!job->exitThreadCalled); + + thread.start(); + job = new Job(&thread, 2500); + QCOMPARE(job->thread(), &thread); + loop.exec(); + QVERIFY(job->exitThreadCalled); +} + QTEST_MAIN(tst_QThread) #include "tst_qthread.moc" -- cgit v1.2.3 From 785e95ef0a95ca8fb39ef57678cd4876ee657c43 Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 8 Feb 2012 10:12:13 +0000 Subject: Harfbuzz-thai: Hide ZWJ and ZWNJ characters and show Inherited characters Thai is not supposed to have ZWJ and ZWNJ characters or any other of the Inherited Unicode Scripts (http://www.verisigninc.com/assets/idn-inherited-unicode-script.pdf) - they don't have a mapping to the thai encoding tis620 which libthai requires. However it is an unfortunate fact that there are many websites etc that liberally place these ZWJ and ZWNJ characters throughout thai text to force word boundaries, so we must also deal with them. We deal with all Inherited characters by mapping them to the invalid code ~0 in tis620 encoding, following what libthai does internally in its own tis620 encoding functions, and then replacing this character with the original unicode and setting dontPrint to true to hide the ZWJ and ZWNJ characters. Includes a unit test to check the behaviour. Change-Id: I1ee8388b650cb5fc61bcb265efb9843c73f327ac Reviewed-by: Adrian Yanes Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qtextscriptengine/tst_qtextscriptengine.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index cf02d1af50..7db12ed2b4 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -104,6 +104,7 @@ private slots: void mirroredChars(); void thaiIsolatedSaraAm(); + void thaiWithZWJ(); private: bool haveTestFonts; @@ -1280,5 +1281,46 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm() QSKIP("Cannot find Waree."); } +void tst_QTextScriptEngine::thaiWithZWJ() +{ + QString s(QString::fromUtf8("ร‍ร‌ร“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); + QTextLayout layout(s); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QTextEngine *e = layout.engine(); + e->width(0, s.length()); //force itemize and shape + + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. + // But make sure that we don't hide anything else + QCOMPARE(e->layoutData->items.size(), 11); + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(5)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script + QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a seperate item + QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis + QCOMPARE(e->layoutData->items[4].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[5].num_glyphs, ushort(1)); // Common: Smart quote + QCOMPARE(e->layoutData->items[6].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[7].num_glyphs, ushort(1)); // Common: \xA0 = non-breaking space. Could be useful to have in thai, but not currently implemented + QCOMPARE(e->layoutData->items[8].num_glyphs, ushort(1)); // Thai: Thai character + QCOMPARE(e->layoutData->items[9].num_glyphs, ushort(1)); // Japanese: Kanji for tree + QCOMPARE(e->layoutData->items[10].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type + + //A quick sanity check - check all the characters are individual clusters + unsigned short *logClusters = e->layoutData->logClustersPtr; + for (int i = 0; i < 5; i++) + QCOMPARE(logClusters[i], ushort(i)); + for (int i = 0; i < 10; i++) + QCOMPARE(logClusters[i+5], ushort(0)); + QCOMPARE(logClusters[15], ushort(1)); + + // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 + // and 3. + for (int i = 0; i < 16; i++) + QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" -- cgit v1.2.3 From 2b23d7214f1bb90369ee418a30958fcc5d96cd8f Mon Sep 17 00:00:00 2001 From: John Tapsell Date: Wed, 8 Feb 2012 10:12:16 +0000 Subject: QTextEngine - treat a fullstop (0x2E) as the same script as the preceeding text when dividing up strings Many languages use a fullstop to indicate an abbreviation, making the fullstop part of the word. For languages like thai, it is required to pass the fullstop along for correct word breaking. Change-Id: I5ad0ddbc66ea96e08913446dad8fd3c5d5dd0905 Reviewed-by: Lars Knoll Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../gui/text/qtextscriptengine/tst_qtextscriptengine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 7db12ed2b4..7c9a83eaa4 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1283,7 +1283,7 @@ void tst_QTextScriptEngine::thaiIsolatedSaraAm() void tst_QTextScriptEngine::thaiWithZWJ() { - QString s(QString::fromUtf8("ร‍ร‌ร“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); + QString s(QString::fromUtf8("ร‍ร‌.ร.“ร…ร”ร\xA0ร本ร") + QChar(0x0363)/*superscript 'a', for testing Inherited class*/); QTextLayout layout(s); layout.beginLayout(); layout.createLine(); @@ -1296,7 +1296,7 @@ void tst_QTextScriptEngine::thaiWithZWJ() // The current implementation hides them, so we test for that. // But make sure that we don't hide anything else QCOMPARE(e->layoutData->items.size(), 11); - QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(5)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script + QCOMPARE(e->layoutData->items[0].num_glyphs, ushort(7)); // Thai: The ZWJ and ZWNJ characters are inherited, so should be part of the thai script QCOMPARE(e->layoutData->items[1].num_glyphs, ushort(1)); // Common: The smart quotes cannot be handled by thai, so should be a seperate item QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(1)); // Thai: Thai character QCOMPARE(e->layoutData->items[3].num_glyphs, ushort(1)); // Common: Ellipsis @@ -1310,15 +1310,15 @@ void tst_QTextScriptEngine::thaiWithZWJ() //A quick sanity check - check all the characters are individual clusters unsigned short *logClusters = e->layoutData->logClustersPtr; - for (int i = 0; i < 5; i++) + for (int i = 0; i < 7; i++) QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 10; i++) - QCOMPARE(logClusters[i+5], ushort(0)); - QCOMPARE(logClusters[15], ushort(1)); + QCOMPARE(logClusters[i+7], ushort(0)); + QCOMPARE(logClusters[17], ushort(1)); // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 // and 3. - for (int i = 0; i < 16; i++) + for (int i = 0; i < 18; i++) QCOMPARE((bool)e->layoutData->glyphLayout.attributes[i].dontPrint, (i == 1 || i == 3)); } -- cgit v1.2.3 From 5e7a4d6bed8ab6c87ce530680e31aff2f7fdd408 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 13:51:12 +0100 Subject: Use new plugin system in plugin autotest. Fix up test use QFINDTESTDATA for shadow builds. Change-Id: I64731baa44f446ce360631ed6a638cea098d78a0 Reviewed-by: Lars Knoll --- tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp | 11 ++++++++++- tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp | 11 ++++++++++- tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp | 10 +++++++++- .../plugin/qpluginloader/almostplugin/almostplugin.cpp | 2 -- .../corelib/plugin/qpluginloader/almostplugin/almostplugin.h | 2 ++ tests/auto/corelib/plugin/qpluginloader/empty.json | 1 + .../corelib/plugin/qpluginloader/theplugin/plugininterface.h | 8 +++++++- .../auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp | 3 --- tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h | 2 ++ 9 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/auto/corelib/plugin/qpluginloader/empty.json (limited to 'tests/auto') diff --git a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp index 057db69174..e27085c293 100644 --- a/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/debugplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include +#include -Q_EXPORT_PLUGIN2(DebugPlugin, QObject) +class DebugPlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + DebugPlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp index 9542695112..d0875d2902 100644 --- a/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp +++ b/tests/auto/corelib/plugin/qplugin/releaseplugin/main.cpp @@ -39,5 +39,14 @@ ** ****************************************************************************/ #include +#include -Q_EXPORT_PLUGIN2(ReleasePlugin, QObject) +class ReleasePlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + ReleasePlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp index e6a83cf3d7..af76fcc4a2 100644 --- a/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp +++ b/tests/auto/corelib/plugin/qplugin/tst_qplugin.cpp @@ -55,15 +55,23 @@ public: tst_QPlugin(); private slots: + void initTestCase(); void loadDebugPlugin(); void loadReleasePlugin(); }; tst_QPlugin::tst_QPlugin() - : dir("plugins") + : dir(QFINDTESTDATA("plugins")) { } +void tst_QPlugin::initTestCase() +{ + QVERIFY2(dir.exists(), + qPrintable(QString::fromLatin1("Cannot find the 'plugins' directory starting from '%1'"). + arg(QDir::toNativeSeparators(QDir::currentPath())))); +} + void tst_QPlugin::loadDebugPlugin() { foreach (QString fileName, dir.entryList(QStringList() << "*debug*", QDir::Files)) { diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp index 4b2057087a..eaad3ceff5 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp @@ -47,5 +47,3 @@ QString AlmostPlugin::pluginName() const unresolvedSymbol(); return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(almostplugin, AlmostPlugin) diff --git a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h index 6658a5be8d..d64f5985ec 100644 --- a/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.h @@ -42,11 +42,13 @@ #define ALMOSTPLUGIN_H #include +#include #include "../theplugin/plugininterface.h" class AlmostPlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: diff --git a/tests/auto/corelib/plugin/qpluginloader/empty.json b/tests/auto/corelib/plugin/qpluginloader/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h index a568dd118d..fe0892c0fe 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/plugininterface.h @@ -41,13 +41,19 @@ #ifndef PLUGININTERFACE_H #define PLUGININTERFACE_H +#include + struct PluginInterface { virtual ~PluginInterface() {} virtual QString pluginName() const = 0; }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(PluginInterface, "com.trolltect.autotests.plugininterface/1.0") + +#define PluginInterface_iid "org.qt-project.Qt.autotests.plugininterface" + +Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid) + QT_END_NAMESPACE #endif // PLUGININTERFACE_H diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp index b064901a4d..8c97956a5f 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.cpp @@ -46,6 +46,3 @@ QString ThePlugin::pluginName() const { return QLatin1String("Plugin ok"); } - -Q_EXPORT_PLUGIN2(theplugin, ThePlugin) - diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h index b769aa6eed..3b8f12140e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.h @@ -42,11 +42,13 @@ #define THEPLUGIN_H #include +#include #include "plugininterface.h" class ThePlugin : public QObject, public PluginInterface { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.autotests.plugininterface" FILE "../empty.json") Q_INTERFACES(PluginInterface) public: -- cgit v1.2.3 From 194899df2443c72ff38aaed9b1b26fc3a192a6f0 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Thu, 23 Feb 2012 15:49:11 +0200 Subject: Reverted part of "Refactor input context tests" This commit reverts partly 7401832a7d45de99562b94340375393a39267f41 There is something wrong with DummyWindow/XCB/Metacity, Metacity crashes quite often when QWindow is activated. Change-Id: I611af2678814f41c941cb697054135f561a77878 Reviewed-by: Joona Petrell --- .../auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp index c906ebaabe..bc364e37f1 100644 --- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp +++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp @@ -212,18 +212,12 @@ void tst_qinputmethod::cursorRectangle() { QCOMPARE(qApp->inputMethod()->cursorRectangle(), QRectF()); - DummyWindow window; - window.show(); - QTest::qWaitForWindowShown(&window); - window.requestActivateWindow(); - QTRY_COMPARE(qApp->focusWindow(), &window); - window.setFocusObject(&m_inputItem); - QTransform transform; transform.translate(10, 10); transform.scale(2, 2); transform.shear(2, 2); qApp->inputMethod()->setInputItemTransform(transform); + qApp->inputMethod()->setInputItem(&m_inputItem); QCOMPARE(qApp->inputMethod()->cursorRectangle(), transform.mapRect(QRectF(1, 2, 3, 4))); @@ -232,6 +226,7 @@ void tst_qinputmethod::cursorRectangle() // reset m_inputItem.cursorRectangle = QRectF(1, 2, 3, 4); + qApp->inputMethod()->setInputItem(0); qApp->inputMethod()->setInputItemTransform(QTransform()); } @@ -269,13 +264,6 @@ void tst_qinputmethod::commit() void tst_qinputmethod::update() { - DummyWindow window; - window.show(); - QTest::qWaitForWindowShown(&window); - window.requestActivateWindow(); - QTRY_COMPARE(qApp->focusWindow(), &window); - window.setFocusObject(&m_inputItem); - QCOMPARE(m_platformInputContext.m_updateCallCount, 0); QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImhNone)); @@ -288,6 +276,9 @@ void tst_qinputmethod::update() QCOMPARE(int(m_platformInputContext.m_lastQueries), int(Qt::ImQueryAll)); QCOMPARE(qApp->inputMethod()->keyboardRectangle(), QRectF(10, 20, 30, 40)); + + // reset + qApp->inputMethod()->setInputItem(0); } void tst_qinputmethod::query() -- cgit v1.2.3 From d91cf1e53b450483d92c50965fd3c33ab1da4300 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Feb 2012 16:09:30 +0100 Subject: clean up qmake-generated projects remove "header" and assignmets which are defaults or bogus, reorder some assignments. Change-Id: I67403872168c890ca3b696753ceb01c605d19be7 Reviewed-by: Rohan McGovern --- tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro | 5 +---- tests/auto/gui/kernel/qclipboard/copier/copier.pro | 7 +------ tests/auto/gui/kernel/qclipboard/paster/paster.pro | 8 +------- .../painting/qpainter/utils/createImages/createImages.pro | 8 -------- tests/auto/gui/text/qtextscriptengine/generate/generate.pro | 9 --------- .../network/socket/qlocalsocket/example/client/client.pro | 6 ------ .../network/socket/qlocalsocket/example/server/server.pro | 8 -------- tests/auto/other/atwrapper/atWrapper.pro | 4 ---- tests/auto/other/macgui/macgui.pro | 4 ---- tests/auto/other/macnativeevents/macnativeevents.pro | 4 ---- tests/auto/other/macplist/app/app.pro | 11 +---------- .../tools/qmake/testdata/bundle-spaces/bundle-spaces.pro | 6 ------ tests/auto/tools/qmake/testdata/findDeps/findDeps.pro | 5 ----- tests/auto/tools/qmake/testdata/findMocs/findMocs.pro | 5 ----- tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro | 3 --- tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro | 5 +---- .../desktopsettingsaware/desktopsettingsaware.pro | 13 ++----------- tests/auto/widgets/styles/qstyleoption/qstyleoption.pro | 11 +++-------- .../widgets/styles/qstylesheetstyle/qstylesheetstyle.pro | 6 +++--- tests/auto/widgets/util/qcompleter/qcompleter.pro | 3 --- tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro | 13 +------------ tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro | 1 - 22 files changed, 14 insertions(+), 131 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro index 19d36a63a1..799ef34559 100644 --- a/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro +++ b/tests/auto/corelib/kernel/qobject/signalbug/signalbug.pro @@ -1,6 +1,3 @@ -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . CONFIG -= app_bundle debug_and_release CONFIG += console DESTDIR = ./ @@ -8,7 +5,7 @@ QT -= gui wince*: { LIBS += coredll.lib } -# Input + HEADERS += signalbug.h SOURCES += signalbug.cpp diff --git a/tests/auto/gui/kernel/qclipboard/copier/copier.pro b/tests/auto/gui/kernel/qclipboard/copier/copier.pro index 1c188ca7de..def50b6476 100644 --- a/tests/auto/gui/kernel/qclipboard/copier/copier.pro +++ b/tests/auto/gui/kernel/qclipboard/copier/copier.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . CONFIG -= app_bundle win32: DESTDIR = ../copier -# Input -SOURCES += main.cpp +SOURCES += main.cpp diff --git a/tests/auto/gui/kernel/qclipboard/paster/paster.pro b/tests/auto/gui/kernel/qclipboard/paster/paster.pro index 2f50eefb1e..ef91e77b6e 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/paster.pro +++ b/tests/auto/gui/kernel/qclipboard/paster/paster.pro @@ -1,10 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . win32: DESTDIR = ../paster CONFIG -= app_bundle -# Input -SOURCES += main.cpp - +SOURCES += main.cpp diff --git a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro index ce2d341e92..36661c7d63 100644 --- a/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro +++ b/tests/auto/gui/painting/qpainter/utils/createImages/createImages.pro @@ -1,11 +1,3 @@ -###################################################################### -# Automatically generated by qmake (1.02a) Thu Apr 18 18:56:53 2002 -###################################################################### - -TEMPLATE = app CONFIG -= moc -# Input SOURCES += main.cpp - - diff --git a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro index 354e0e5cdf..101b7451de 100644 --- a/tests/auto/gui/text/qtextscriptengine/generate/generate.pro +++ b/tests/auto/gui/text/qtextscriptengine/generate/generate.pro @@ -1,14 +1,5 @@ -###################################################################### -# Automatically generated by qmake (1.07a) Fri Sep 30 15:20:45 2005 -###################################################################### - -TEMPLATE = app CONFIG -= moc INCLUDEPATH += . /usr/include/freetype2 INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src -# Input SOURCES += main.cpp -CONFIG += qt warn_on debug thread create_prl link_prl - - diff --git a/tests/auto/network/socket/qlocalsocket/example/client/client.pro b/tests/auto/network/socket/qlocalsocket/example/client/client.pro index 84f20d6ec0..4b6585ff10 100644 --- a/tests/auto/network/socket/qlocalsocket/example/client/client.pro +++ b/tests/auto/network/socket/qlocalsocket/example/client/client.pro @@ -1,10 +1,4 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . CONFIG += console QT = core network SOURCES += main.cpp - - diff --git a/tests/auto/network/socket/qlocalsocket/example/server/server.pro b/tests/auto/network/socket/qlocalsocket/example/server/server.pro index bfd14d2bb7..b78e63d0a7 100644 --- a/tests/auto/network/socket/qlocalsocket/example/server/server.pro +++ b/tests/auto/network/socket/qlocalsocket/example/server/server.pro @@ -1,13 +1,5 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - CONFIG += console QT = core network -# Input SOURCES += main.cpp - - diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro index 5dcbdb98ce..9de320b364 100644 --- a/tests/auto/other/atwrapper/atWrapper.pro +++ b/tests/auto/other/atwrapper/atWrapper.pro @@ -1,9 +1,6 @@ -# -*- Mode: makefile -*- - ARTHUR=$$QT_SOURCE_TREE/tests/arthur COMMON_FOLDER = $$ARTHUR/common include($$ARTHUR/arthurtester.pri) -TEMPLATE = app INCLUDEPATH += $$ARTHUR DEFINES += SRCDIR=\\\"$$PWD\\\" @@ -15,7 +12,6 @@ include($$ARTHUR/datagenerator/datagenerator.pri) CONFIG += testcase -# Input HEADERS += atWrapper.h SOURCES += atWrapperAutotest.cpp atWrapper.cpp diff --git a/tests/auto/other/macgui/macgui.pro b/tests/auto/other/macgui/macgui.pro index 5632450a3a..b7adbb470e 100644 --- a/tests/auto/other/macgui/macgui.pro +++ b/tests/auto/other/macgui/macgui.pro @@ -1,10 +1,6 @@ CONFIG += testcase TARGET = tst_macgui -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . -# Input SOURCES += tst_macgui.cpp guitest.cpp HEADERS += guitest.h diff --git a/tests/auto/other/macnativeevents/macnativeevents.pro b/tests/auto/other/macnativeevents/macnativeevents.pro index efe091f9f0..6ec0942222 100644 --- a/tests/auto/other/macnativeevents/macnativeevents.pro +++ b/tests/auto/other/macnativeevents/macnativeevents.pro @@ -1,7 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Nov 29 22:24:47 2006 -###################################################################### - CONFIG += testcase TARGET = tst_macnativeevents TEMPLATE = app diff --git a/tests/auto/other/macplist/app/app.pro b/tests/auto/other/macplist/app/app.pro index b4b895197c..9ccac831d0 100644 --- a/tests/auto/other/macplist/app/app.pro +++ b/tests/auto/other/macplist/app/app.pro @@ -1,12 +1,3 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Jan 7 13:01:11 2009 -###################################################################### - -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . +QT += widgets -# Input SOURCES += main.cpp -QT += widgets diff --git a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro index 644a817a8e..e4f81e6e1e 100644 --- a/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro +++ b/tests/auto/tools/qmake/testdata/bundle-spaces/bundle-spaces.pro @@ -1,9 +1,3 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . - -# Input SOURCES += main.cpp QWERTY_BUNDLE.version = Bogus.78 diff --git a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro index 43577b5122..442c9c767f 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro @@ -1,10 +1,5 @@ -TEMPLATE = app -TARGET = findDeps -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h \ object2.h \ object3.h \ diff --git a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro index 1469b4c5c3..a4a7dc987d 100644 --- a/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro +++ b/tests/auto/tools/qmake/testdata/findMocs/findMocs.pro @@ -1,9 +1,4 @@ -TEMPLATE = app -TARGET = findMocs -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input HEADERS += object1.h object2.h object3.h object4.h object5.h object6.h object7.h SOURCES += main.cpp diff --git a/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro b/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro index 730932d83d..b4cf05e347 100644 --- a/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro +++ b/tests/auto/widgets/dialogs/qerrormessage/qerrormessage.pro @@ -1,10 +1,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qerrormessage -DEPENDPATH += . -INCLUDEPATH += . QT += widgets testlib -# Input SOURCES += tst_qerrormessage.cpp diff --git a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro index 5b8f796485..91848fee24 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro +++ b/tests/auto/widgets/dialogs/qmessagebox/qmessagebox.pro @@ -1,9 +1,6 @@ -CONFIG += testcase TEMPLATE = app TARGET = tst_qmessagebox QT += gui-private core-private widgets testlib -DEPENDPATH += . -INCLUDEPATH += . +CONFIG += testcase -# Input SOURCES += tst_qmessagebox.cpp diff --git a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro index 3b229e31cb..97768eac74 100644 --- a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro +++ b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro @@ -1,15 +1,6 @@ -###################################################################### -# Automatically generated by qmake (2.00a) Mon Jul 11 11:30:34 2005 -###################################################################### +QT += widgets +CONFIG -= app_bundle -TEMPLATE = app -DEPENDPATH += . -INCLUDEPATH += . DESTDIR = ./ -# Input -QT += widgets SOURCES += main.cpp -CONFIG += qt warn_on create_prl link_prl -CONFIG -= app_bundle - diff --git a/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro b/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro index cadc6d6ddc..bf12a6b30f 100644 --- a/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro +++ b/tests/auto/widgets/styles/qstyleoption/qstyleoption.pro @@ -1,12 +1,7 @@ -###################################################################### -# Automatically generated by qmake (2.00a) ti 8. mar 16:20:21 2005 -###################################################################### +TEMPLATE = app +TARGET = tst_qstyleoption CONFIG += testcase -TARGET = tst_qstyleoption -TEMPLATE = app QT += widgets testlib -# Input -SOURCES += tst_qstyleoption.cpp - +SOURCES += tst_qstyleoption.cpp diff --git a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro index f908c3ab7d..dd17183b30 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -1,10 +1,10 @@ CONFIG += testcase TARGET = tst_qstylesheetstyle -QT += widgets widgets-private testlib -QT += gui-private -# Input +QT += widgets widgets-private gui-private testlib + SOURCES += tst_qstylesheetstyle.cpp RESOURCES += resources.qrc + requires(contains(QT_CONFIG,private_tests)) win32:CONFIG += insignificant_test # QTBUG-24323 diff --git a/tests/auto/widgets/util/qcompleter/qcompleter.pro b/tests/auto/widgets/util/qcompleter/qcompleter.pro index 63b137eb7c..6a817a89ac 100644 --- a/tests/auto/widgets/util/qcompleter/qcompleter.pro +++ b/tests/auto/widgets/util/qcompleter/qcompleter.pro @@ -2,10 +2,7 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_qcompleter QT += widgets testlib -DEPENDPATH += . -INCLUDEPATH += . .. -# Input SOURCES += tst_qcompleter.cpp CONFIG += insignificant_test # QTBUG-21424 diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro index 93167f81c8..f801200942 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro +++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.pro @@ -1,15 +1,4 @@ -###################################################################### -# Automatically generated by qmake (1.06a) Thu Jun 5 19:00:42 2003 -###################################################################### - -TEMPLATE = app -INCLUDEPATH += . +QT += xml -# Input HEADERS += parser.h SOURCES += main.cpp parser.cpp - -CONFIG += qt warn_on debug -QT += xml - - diff --git a/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro b/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro index cec33ded18..dc579ab742 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro +++ b/tests/auto/xml/sax/qxmlsimplereader/qxmlsimplereader.pro @@ -4,7 +4,6 @@ TEMPLATE = app DEPENDPATH += parser INCLUDEPATH += . parser -# Input HEADERS += parser/parser.h SOURCES += tst_qxmlsimplereader.cpp parser/parser.cpp -- cgit v1.2.3 From 4ee14d6f87688492e64db77fd89b48c7fcc98a63 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 23 Feb 2012 10:41:50 +0100 Subject: CodeCoverage: Skip headersclean test. The code coverage tool adds #line when instrumenting the code using the gcc syntax. Since tst_headersclean now uses the -pedantic-errors flag (qtbase commit 7e970eb58c71dc089815), it causes a fatal error when the code is instrumented with the coverage tool. Change-Id: Icb1888d1c1f0a982c0c56aa168e70a76a246a18c Reviewed-by: Rohan McGovern --- tests/auto/other/other.pro | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 69fe00dc19..9ec5ea8e34 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -26,6 +26,8 @@ SUBDIRS=\ qtokenautomaton \ windowsmobile \ +testcocoon: SUBDIRS -= headersclean + cross_compile: SUBDIRS -= \ atwrapper \ compiler \ -- cgit v1.2.3 From 12c2a3d85256abcc5a69f05a7504e01e72f24593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 12 Feb 2012 21:11:04 +0100 Subject: QHeaderView - fix setOffsetToSectionPosition a bit It might be silly to have sections with size 0 without using hideSection. Nevertheless we should still use the principle of least surprise. It does not make sense that hiding a row 'far' away should affect the semantics of setOffsetToSectionPosition on lower indexes. Change-Id: Iaf847eba2ea4d28fc7bcfe3a27d62f432f6f61e0 Reviewed-by: Stephen Kelly --- .../itemviews/qheaderview/tst_qheaderview.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 4dd57e1b90..3edc125b5a 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -205,6 +205,7 @@ private slots: void QTBUG12268_hiddenMovedSectionSorting(); void QTBUG14242_hideSectionAutoSize(); void ensureNoIndexAtLength(); + void offsetConsistent(); void initialSortOrderRole(); @@ -2168,6 +2169,33 @@ void tst_QHeaderView::ensureNoIndexAtLength() QVERIFY(hv->visualIndexAt(hv->length()) == -1); } +void tst_QHeaderView::offsetConsistent() +{ + // Ensure that a hidden section 'far away' + // does not affect setOffsetToSectionPosition .. + const int sectionToHide = 513; + QTableView qtv; + QStandardItemModel amodel(1000, 4); + qtv.setModel(&amodel); + QHeaderView *hv = qtv.verticalHeader(); + for (int u = 0; u < 100; u += 2) + hv->resizeSection(u, 0); + hv->setOffsetToSectionPosition(150); + int offset1 = hv->offset(); + hv->hideSection(sectionToHide); + hv->setOffsetToSectionPosition(150); + int offset2 = hv->offset(); + QVERIFY(offset1 == offset2); + // Ensure that hidden indexes (still) is considered. + hv->resizeSection(sectionToHide, hv->sectionSize(200) * 2); + hv->setOffsetToSectionPosition(800); + offset1 = hv->offset(); + hv->showSection(sectionToHide); + hv->setOffsetToSectionPosition(800); + offset2 = hv->offset(); + QVERIFY(offset2 > offset1); +} + void tst_QHeaderView::initialSortOrderRole() { QTableView view; // ### Shadowing member view (of type QHeaderView) -- cgit v1.2.3 From ed7f78acba45e1142157e39154466a13f9d3ce4e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Feb 2012 17:27:47 +0100 Subject: Fix tst_qlineedit. - Fix key handling in QWidgetLineControl according to the keyboard scheme returned by the QPlatformTheme, remove #ifdefs. - Do the same in the test. Task-number: QTBUG-21402 Change-Id: I36d836584e7122309061af72819a4147cadd0a74 Reviewed-by: Miikka Heikkinen Reviewed-by: Bradley T. Hughes --- tests/auto/widgets/widgets/qlineedit/qlineedit.pro | 4 +- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 82 +++++++++++++--------- 2 files changed, 48 insertions(+), 38 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index 77b2ae537c..f674ea3f05 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -1,6 +1,4 @@ CONFIG += testcase TARGET = tst_qlineedit -QT += widgets testlib +QT += gui-private core-private widgets testlib SOURCES += tst_qlineedit.cpp - -CONFIG += insignificant_test # QTBUG-21402 diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 645f47fc72..17632ec458 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -48,6 +48,8 @@ #include "qvalidator.h" #include "qcompleter.h" #include "qstandarditemmodel.h" +#include "qplatformtheme_qpa.h" +#include #ifndef QT_NO_CLIPBOARD #include "qclipboard.h" @@ -300,6 +302,7 @@ private: int lastCursorPos; int newCursorPos; QLineEdit *testWidget; + int m_keyboardScheme; }; typedef QList IntList; @@ -327,9 +330,16 @@ void tst_QLineEdit::getSetCheck() QCOMPARE(true, obj1.dragEnabled()); } -tst_QLineEdit::tst_QLineEdit() +tst_QLineEdit::tst_QLineEdit() : validInput(false), m_keyboardScheme(0) { - validInput = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt(); + // Generalize for X11 + if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme + || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) { + m_keyboardScheme = QPlatformTheme::X11KeyboardScheme; + } } tst_QLineEdit::~tst_QLineEdit() @@ -1071,25 +1081,26 @@ void tst_QLineEdit::undo() QVERIFY(!testWidget->isUndoAvailable()); QVERIFY(testWidget->text().isEmpty()); -#ifdef Q_WS_WIN - // Repeat the test using shortcut instead of undo() - for (i=0; i -1) - testWidget->setCursorPosition(insertIndex[i]); - if (insertMode[i] == REPLACE_UNTIL_END) { - testWidget->setSelection(insertIndex[i], 8); + + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + // Repeat the test using shortcut instead of undo() + for (i=0; i -1) + testWidget->setCursorPosition(insertIndex[i]); + if (insertMode[i] == REPLACE_UNTIL_END) + testWidget->setSelection(insertIndex[i], 8); + if (use_keys) + QTest::keyClicks(testWidget, insertString[i]); + else + testWidget->insert(insertString[i]); + } + for (i=0; itext(), expectedString[i]); + QVERIFY(testWidget->isUndoAvailable()); + QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); } - if (use_keys) - QTest::keyClicks(testWidget, insertString[i]); - else - testWidget->insert(insertString[i]); - } - for (i=0; itext(), expectedString[i]); - QVERIFY(testWidget->isUndoAvailable()); - QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); } -#endif + } void tst_QLineEdit::redo_data() @@ -1152,21 +1163,22 @@ void tst_QLineEdit::redo() QVERIFY(!testWidget->isRedoAvailable()); -#ifdef Q_WS_WIN - // repeat test, this time using shortcuts instead of undo()/redo() - while (!testWidget->text().isEmpty()) - QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); + if (m_keyboardScheme == QPlatformTheme::WindowsKeyboardScheme) { + // repeat test, this time using shortcuts instead of undo()/redo() - for (i = 0; i < expectedString.size(); ++i) { - QVERIFY(testWidget->isRedoAvailable()); - QTest::keyClick(testWidget, Qt::Key_Backspace, - Qt::ShiftModifier | Qt::AltModifier); - QCOMPARE(testWidget->text() , expectedString[i]); - } + while (!testWidget->text().isEmpty()) + QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier); - QVERIFY(!testWidget->isRedoAvailable()); -#endif + for (i = 0; i < expectedString.size(); ++i) { + QVERIFY(testWidget->isRedoAvailable()); + QTest::keyClick(testWidget, Qt::Key_Backspace, + Qt::ShiftModifier | Qt::AltModifier); + QCOMPARE(testWidget->text() , expectedString[i]); + } + + QVERIFY(!testWidget->isRedoAvailable()); + } } void tst_QLineEdit::undo_keypressevents_data() @@ -1263,7 +1275,7 @@ void tst_QLineEdit::undo_keypressevents_data() // unselect any current selection keys.addKeyClick(Qt::Key_Right); -#ifdef Q_WS_WIN //Mac has a specialcase to handle jumping to the end of a selection +#ifdef Q_OS_WIN //Mac has a specialcase to handle jumping to the end of a selection keys.addKeyClick(Qt::Key_Left); #endif @@ -3080,6 +3092,7 @@ void tst_QLineEdit::leftKeyOnSelectedText() #ifdef Q_OS_WIN QCOMPARE(testWidget->cursorPosition(), 1); #else + // Selection is cleared ands cursor remains at position 2. // X11 used to behave like window prior to 4.2. Changes caused by QKeySequence // resulted in an inadvertant change in behavior QCOMPARE(testWidget->cursorPosition(), 2); @@ -3624,9 +3637,8 @@ void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup() { -#ifndef Q_WS_X11 - QSKIP("Only tested on X11"); -#endif + if (m_keyboardScheme != QPlatformTheme::X11KeyboardScheme) + QSKIP("Only tested on X11"); QLineEdit le; le.setText(" "); QPalette p = le.palette(); -- cgit v1.2.3 From 77772f21deeadde6eee0a51cb87bf5ee07f67966 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 12:24:49 +0100 Subject: compile fix: parse under C++11 See d94ab97b7741de7c73d4d203b9cca7bd150d581f for details. Change-Id: Ifc015be6575bd8f469f257d71fbbf79e07226729 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll Reviewed-by: Denis Dzyubenko --- tests/auto/corelib/json/tst_qtjson.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 4edbd14305..f5b4f17732 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -1208,7 +1208,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"foo"INVALID_UNICODE"bar\"]"; + QByteArray json = "[\n \"foo" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1224,7 +1224,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"c"UNICODE_DJE"a\\u12\"]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a\\u12\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringEscapeSequence); @@ -1232,7 +1232,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"c"UNICODE_DJE"a"INVALID_UNICODE"bar\"]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a" INVALID_UNICODE "bar\"]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::StringUTF8Scan); @@ -1240,7 +1240,7 @@ void TestQtJson::fromJsonErrors() } { QJsonParseError error; - QByteArray json = "[\n \"c"UNICODE_DJE"a ]"; + QByteArray json = "[\n \"c" UNICODE_DJE "a ]"; QJsonDocument doc = QJsonDocument::fromJson(json, &error); QVERIFY(doc.isEmpty()); QCOMPARE(error.error, QJsonParseError::EndOfString); @@ -1381,7 +1381,7 @@ void TestQtJson::parseStrings() "abc\\rabc", "abc\\tabc", "abc\\u0019abc", - "abc"UNICODE_DJE"abc", + "abc" UNICODE_DJE "abc", }; int size = sizeof(strings)/sizeof(const char *); @@ -1407,7 +1407,7 @@ void TestQtJson::parseStrings() }; Pairs pairs [] = { { "abc\\/abc", "abc/abc" }, - { "abc\\u0402abc", "abc"UNICODE_DJE"abc" }, + { "abc\\u0402abc", "abc" UNICODE_DJE "abc" }, { "abc\\u0065abc", "abceabc" } }; size = sizeof(pairs)/sizeof(Pairs); -- cgit v1.2.3 From efb5a3a52e72a69309c10b6da704fb91258a9cc7 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 21 Feb 2012 13:54:11 +1000 Subject: Changed qnetworkreply unittest to return correct code - Changed waitForFinished() to return correct return code Change-Id: Ic6b0dfa195254783a2106011c4a108d907d73557 Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- .../auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index c214b5fc57..5b34fa7c29 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -1300,19 +1300,17 @@ QString tst_QNetworkReply::runCustomRequest(const QNetworkRequest &request, int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) { - int code = Success; int count = 0; connect(reply, SIGNAL(finished()), SLOT(finished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(gotError())); - + returnCode = Success; loop = new QEventLoop; QSignalSpy spy(reply, SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { - QTimer::singleShot(10000, loop, SLOT(quit())); - code = loop->exec(); - if (count == spy.count() && !reply->isFinished()) { - code = Timeout; + QTimer::singleShot(5000, loop, SLOT(quit())); + if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + returnCode = Timeout; break; } count = spy.count(); @@ -1320,7 +1318,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) delete loop; loop = 0; - return code; + return returnCode; } void tst_QNetworkReply::finished() -- cgit v1.2.3 From 35ef771d5a2b625ec057e3f60c3e7260b66741f7 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Fri, 24 Feb 2012 17:16:32 +1000 Subject: qfiledialog2: Skip test that is passing on CI and failing otherwise. Task-number: QTBUG-23602 Change-Id: Id5dfb85956048c60849d865161212b0764e8f250 Reviewed-by: Rohan McGovern Reviewed-by: Bradley T. Hughes --- tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 7ab3100cab..4a6f714a7c 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -489,6 +489,9 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog() void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() { +#ifdef Q_OS_MAC + QSKIP("This test currently fails on Mac OS X, see QTBUG-23602"); +#endif QDir current = QDir::currentPath(); current.mkdir("test"); current.cd("test"); @@ -515,9 +518,6 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior() QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Return); QTest::qWait(200); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "This test currently fails on Mac OS X, see QTBUG-23602", Continue); -#endif QCOMPARE(fd.isVisible(), true); QTest::qWait(200); file.close(); -- cgit v1.2.3 From 472b06d63a591c8caba2b5b3227881a41c589f78 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Mon, 27 Feb 2012 13:26:56 +1000 Subject: Skip unstable qlineedit autotest on Ubuntu 11.10. Task-number: QTBUG-24518 Change-Id: Ia271a820613c1f8a885779eddd20e261716afc6d Reviewed-by: Rohan McGovern Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qlineedit/qlineedit.pro | 3 +++ tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro index f674ea3f05..83f93f0ba0 100644 --- a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro +++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro @@ -2,3 +2,6 @@ CONFIG += testcase TARGET = tst_qlineedit QT += gui-private core-private widgets testlib SOURCES += tst_qlineedit.cpp + +# QTBUG-24518 - unstable test +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 17632ec458..81dc940c00 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3616,6 +3616,9 @@ void tst_QLineEdit::taskQTBUG_7902_contextMenuCrash() void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut() { +#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) + QSKIP("QTBUG-24518 - Unstable test for Ubuntu 11.10"); +#endif //ReadOnly QLineEdit should not intercept shortcut. QLineEdit le; le.setReadOnly(true); -- cgit v1.2.3 From 51f2a0c3318549a6f9388e3d4920eb23a60f8b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 10 Feb 2012 12:21:25 +0100 Subject: Cleanup usage of QVariant::Type. QVariant::Type is marked as obsolete. It is not possible to get rid of it completely, in a source compatible way, but at least we can remove it safely from a method arguments list. Change-Id: I26b58099bfa6d32f3a583a8ae0047f0bb36bcd0d Reviewed-by: Thiago Macieira --- tests/auto/dbus/qdbusmarshall/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/dbus/qdbusmarshall/common.h b/tests/auto/dbus/qdbusmarshall/common.h index 87c434b71e..025641531d 100644 --- a/tests/auto/dbus/qdbusmarshall/common.h +++ b/tests/auto/dbus/qdbusmarshall/common.h @@ -581,7 +581,7 @@ bool compareToArgument(const QDBusArgument &arg, const QVariant &v2) qWarning() << "Unexpected QVariant type" << v2.userType() << QByteArray(QDBusMetaType::typeToSignature(v2.userType())) - << QVariant::typeToName(QVariant::Type(v2.userType())); + << QMetaType::typeName(v2.userType()); return false; } -- cgit v1.2.3 From df055acc81f555011524a79cae3509669bbd0b8b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 17:54:00 +0100 Subject: Fix selftests while using QStringBuilder Change-Id: I6dcd830b96023765447c9683fd95209d4312fb1b Reviewed-by: Jason McDonald --- tests/auto/testlib/selftests/tst_selftests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index decaa55386..7367d664b2 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -155,7 +155,7 @@ static inline QString logFormat(const QString &logger) // Return the log file name, or an empty string if the log goes to stdout. static inline QString logName(const QString &logger) { - return (logger.startsWith("stdout") ? "" : "test_output." + logger); + return (logger.startsWith("stdout") ? "" : QString("test_output." + logger)); } // Load the expected test output for the nominated test (subdir) and logger -- cgit v1.2.3 From beab403d9fcf1fb41f3c133fc6d58e1e864a8d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 10 Feb 2012 09:14:41 +0100 Subject: Reduce QtCore lib binary size by around ~3KB, by removing template code Reusing a template is much better then creating a new one, even if it should inline the same code. For some reason replacing T* by void* force gcc to remove a few bytes per template instantiation too, it is not really significant, but it alows us to simplify the code. Benchmarks don't show any regressions. Change-Id: I4fdf1e4dc311b23021eb5758605602937d05b183 Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- tests/auto/other/compiler/tst_compiler.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index 43e3788098..d72a04c8aa 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -268,9 +268,7 @@ namespace QtTestInternal struct Getter { static QMetaType::SaveOperator saveOp() { - typedef void(*SavePtr)(QDataStream &, const T *); - SavePtr op = ::qMetaTypeSaveHelper; - return reinterpret_cast(op); + return ::qMetaTypeSaveHelper; } }; -- cgit v1.2.3 From 136c2bf18446f2bbe7052d638c29edbc0b8ef6bc Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 26 Feb 2012 01:45:53 +0000 Subject: QRegExp: fix crash Fixes a crash when invoking various QRegExp methods on an object *before* doing any match. For instance fixes: QRegExp re; re.matchedLength(); // crash Task-number: QTBUG-23352 Change-Id: I9c239ff790a139c7820ef1aeced89d31320ae6b0 Reviewed-by: Andy Shaw Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qregexp/tst_qregexp.cpp | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp index 0148e933e4..a697e23270 100644 --- a/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp +++ b/tests/auto/corelib/tools/qregexp/tst_qregexp.cpp @@ -79,6 +79,8 @@ private slots: void posAndCapConsistency_data(); void posAndCapConsistency(); void interval(); + void validityCheck_data(); + void validityCheck(); }; // Testing get/set functions @@ -1344,6 +1346,33 @@ void tst_QRegExp::interval() } } +void tst_QRegExp::validityCheck_data() +{ + QTest::addColumn("pattern"); + QTest::addColumn("validity"); + QTest::newRow("validity01") << QString() << true; + QTest::newRow("validity02") << QString("abc.*abc") << true; + QTest::newRow("validity03") << QString("[a-z") << false; + QTest::newRow("validity04") << QString("a(b") << false; +} + +void tst_QRegExp::validityCheck() +{ + QFETCH(QString, pattern); + + QRegExp rx(pattern); + QTEST(rx.isValid(), "validity"); + QCOMPARE(rx.matchedLength(), -1); + QCOMPARE(rx.pos(), -1); + QCOMPARE(rx.cap(), QString("")); + + QRegExp rx2(rx); + QTEST(rx2.isValid(), "validity"); + QCOMPARE(rx2.matchedLength(), -1); + QCOMPARE(rx2.pos(), -1); + QCOMPARE(rx2.cap(), QString("")); +} + QTEST_APPLESS_MAIN(tst_QRegExp) #include "tst_qregexp.moc" -- cgit v1.2.3 From 7a4b6f8cdd932c193ac027438fc48f0ce7732339 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 26 Feb 2012 10:51:52 +0100 Subject: Fix inconsistent auto test executable names Change-Id: I3b6b5b37e32be25d1b9933395c43f6d5aa5b8810 Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- tests/auto/corelib/io/qresourceengine/qresourceengine.pro | 1 + tests/auto/widgets/itemviews/qtableview/qtableview.pro | 2 +- tests/auto/widgets/styles/qstyle/qstyle.pro | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro index d6e2cb3171..e59746c158 100644 --- a/tests/auto/corelib/io/qresourceengine/qresourceengine.pro +++ b/tests/auto/corelib/io/qresourceengine/qresourceengine.pro @@ -1,4 +1,5 @@ CONFIG += testcase parallel_test +TARGET = tst_qresourceengine load(resources) QT = core testlib SOURCES = tst_qresourceengine.cpp diff --git a/tests/auto/widgets/itemviews/qtableview/qtableview.pro b/tests/auto/widgets/itemviews/qtableview/qtableview.pro index 528fa7d014..889caaf3c8 100644 --- a/tests/auto/widgets/itemviews/qtableview/qtableview.pro +++ b/tests/auto/widgets/itemviews/qtableview/qtableview.pro @@ -1,5 +1,5 @@ CONFIG += testcase - +TARGET = tst_qtableview QT += widgets widgets-private testlib QT += core-private gui-private diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 5a18a70d9e..842fd11062 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -1,4 +1,5 @@ CONFIG += testcase +TARGET = tst_qstyle TARGET.EPOCHEAPSIZE = 0x200000 0x800000 QT += widgets testlib SOURCES += tst_qstyle.cpp -- cgit v1.2.3 From ed8d8451c4174d9f200445c8476a9216be51af70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Feb 2012 11:09:27 +0100 Subject: Fix QThreadstorage test. - Create subdirectories containing profiles to avoid problems with -fast. - Use QFINDTESTDATA to locate binary. - Make it a console application, no Mac-bundle. - Add error messages to the test, give it a longer time-out and ensure sub-process is killed if it hangs. Change-Id: Ibc177b786c4bc8fdbc068a8c45f4801a41c9f660 Reviewed-by: Sergio Ahumada --- .../corelib/thread/qthreadstorage/crashOnExit.cpp | 65 ---------------------- .../corelib/thread/qthreadstorage/crashOnExit.pro | 8 --- .../qthreadstorage/crashonexit/crashOnExit.cpp | 65 ++++++++++++++++++++++ .../qthreadstorage/crashonexit/crashonexit.pro | 9 +++ .../thread/qthreadstorage/qthreadstorage.pro | 6 +- .../corelib/thread/qthreadstorage/test/test.pro | 6 ++ .../thread/qthreadstorage/tst_qthreadstorage.cpp | 54 ++++++++++++++---- .../thread/qthreadstorage/tst_qthreadstorage.pro | 4 -- 8 files changed, 127 insertions(+), 90 deletions(-) delete mode 100644 tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp delete mode 100644 tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro create mode 100644 tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp create mode 100644 tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro create mode 100644 tests/auto/corelib/thread/qthreadstorage/test/test.pro delete mode 100644 tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro (limited to 'tests/auto') diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp deleted file mode 100644 index 388c233d84..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -class Class -{ -public: - ~Class() - { - // trigger creation of a new QThreadStorage, after the previous QThreadStorage from main() was destructed - static QThreadStorage threadstorage; - threadstorage.setLocalData(new int); - threadstorage.setLocalData(new int); - } -}; - -int main() -{ - // instantiate the class that will use QThreadStorage from its destructor, it's destructor will be run last - static Class instance; - // instantiate QThreadStorage, it's destructor (and the global destructors for QThreadStorages internals) will run first - static QThreadStorage threadstorage; - threadstorage.setLocalData(new int); - threadstorage.setLocalData(new int); -} diff --git a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro b/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro deleted file mode 100644 index 68d0f1202b..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/crashOnExit.pro +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES += crashOnExit.cpp -QT = core -CONFIG-=app_bundle -CONFIG+=console - -# This app is testdata for tst_qthreadstorage -target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage -INSTALLS += target diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp new file mode 100644 index 0000000000..388c233d84 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashOnExit.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class Class +{ +public: + ~Class() + { + // trigger creation of a new QThreadStorage, after the previous QThreadStorage from main() was destructed + static QThreadStorage threadstorage; + threadstorage.setLocalData(new int); + threadstorage.setLocalData(new int); + } +}; + +int main() +{ + // instantiate the class that will use QThreadStorage from its destructor, it's destructor will be run last + static Class instance; + // instantiate QThreadStorage, it's destructor (and the global destructors for QThreadStorages internals) will run first + static QThreadStorage threadstorage; + threadstorage.setLocalData(new int); + threadstorage.setLocalData(new int); +} diff --git a/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro new file mode 100644 index 0000000000..94a0a01e94 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/crashonexit/crashonexit.pro @@ -0,0 +1,9 @@ +SOURCES += crashOnExit.cpp +DESTDIR = ./ +QT = core +CONFIG -= app_bundle +CONFIG += console + +# This app is testdata for tst_qthreadstorage +target.path = $$[QT_INSTALL_TESTS]/tst_qthreadstorage/$$TARGET +INSTALLS += target diff --git a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro index 0dc8d086df..2fa973d2f7 100644 --- a/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro +++ b/tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs SUBDIRS = \ - tst_qthreadstorage.pro \ - crashOnExit.pro -CONFIG += parallel_test + crashonexit \ + test +CONFIG += ordered parallel_test diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro new file mode 100644 index 0000000000..a7d8eb0106 --- /dev/null +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = ../tst_qthreadstorage +CONFIG -= app_bundle +CONFIG += console +QT = core testlib +SOURCES = ../tst_qthreadstorage.cpp diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index fff361ea2a..0529e67e0f 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include #ifdef Q_OS_UNIX #include @@ -61,6 +63,7 @@ class tst_QThreadStorage : public QObject { Q_OBJECT private slots: + void initTestCase(); void hasLocalData(); void localData(); void localData_const(); @@ -72,6 +75,9 @@ private slots: void leakInDestructor(); void resetInDestructor(); void valueBased(); + +private: + QString m_crashOnExit; }; class Pointer @@ -83,6 +89,20 @@ public: }; int Pointer::count = 0; +void tst_QThreadStorage::initTestCase() +{ + const QString crashOnExitDir = QFINDTESTDATA("crashonexit"); + QVERIFY2(!crashOnExitDir.isEmpty(), + qPrintable(QString::fromLatin1("Could not find 'crashonexit' starting from '%1'") + .arg(QDir::toNativeSeparators(QDir::currentPath())))); + m_crashOnExit = crashOnExitDir + QStringLiteral("/crashonexit"); +#ifdef Q_OS_WIN + m_crashOnExit += QStringLiteral(".exe"); +#endif + QVERIFY2(QFileInfo(m_crashOnExit).isExecutable(), + qPrintable(QDir::toNativeSeparators(m_crashOnExit) + QStringLiteral(" does not exist or is not executable."))); +} + void tst_QThreadStorage::hasLocalData() { QThreadStorage pointers; @@ -285,18 +305,32 @@ void tst_QThreadStorage::ensureCleanupOrder() QVERIFY(First::order < Second::order); } -void tst_QThreadStorage::crashOnExit() +static inline bool runCrashOnExit(const QString &binary, QString *errorMessage) { + const int timeout = 60000; QProcess process; - // crashOnExit is always expected to be in the same directory - // as this test binary -#ifdef Q_OS_MAC - process.start(QCoreApplication::applicationDirPath() + "/../../../crashOnExit"); -#else - process.start(QCoreApplication::applicationDirPath() + "/crashOnExit"); -#endif - QVERIFY(process.waitForFinished()); - QVERIFY(process.exitStatus() != QProcess::CrashExit); + process.start(binary); + if (!process.waitForStarted()) { + *errorMessage = QString::fromLatin1("Could not start '%1': %2").arg(binary, process.errorString()); + return false; + } + if (!process.waitForFinished(timeout)) { + process.kill(); + *errorMessage = QString::fromLatin1("Timeout (%1ms) waiting for %2.").arg(timeout).arg(binary); + return false; + } + if (process.exitStatus() != QProcess::NormalExit) { + *errorMessage = binary + QStringLiteral(" crashed."); + return false; + } + return true; +} + +void tst_QThreadStorage::crashOnExit() +{ + QString errorMessage; + QVERIFY2(runCrashOnExit(m_crashOnExit, &errorMessage), + qPrintable(errorMessage)); } // S stands for thread Safe. diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro deleted file mode 100644 index 15ced107d3..0000000000 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += testcase -TARGET = tst_qthreadstorage -QT = core testlib -SOURCES = tst_qthreadstorage.cpp -- cgit v1.2.3 From 63017136a1a6625c3528f9b237468a55b7fab12c Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 24 Feb 2012 10:51:18 -0800 Subject: QClipboard: Fix autotest fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tst_qclipboard.cpp still has Q_WS_WIN which must be clear away. After clean up, auto test will fail under windows: When setMimeData() is called, dataChanged() signal will be emited twice. The solution for QTBUG-24184 has partially solved the problem, but it still there. Make sure emitChanged() only called by QPlatformClipboard will give our more control for this. Task-number: QTBUG-24484 Change-Id: I23566c6d3b32828b6865234c311af3635fe9e299 Reviewed-by: Friedemann Kleint Reviewed-by: Samuel Rødal --- .../auto/gui/kernel/qclipboard/tst_qclipboard.cpp | 44 ++++++++++------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index e1b0535e2f..7f41f0651e 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -291,19 +291,17 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->clear(QClipboard::Selection); // used to crash on X11 QGuiApplication::clipboard()->clear(QClipboard::FindBuffer); -#if defined(Q_WS_X11) - QCOMPARE(spySelection.count(), 1); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#elif defined(Q_OS_MAC) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 1); -#elif defined(Q_WS_WIN) - QCOMPARE(spySelection.count(), 0); + if (QGuiApplication::clipboard()->supportsSelection()) + QCOMPARE(spySelection.count(), 1); + else + QCOMPARE(spySelection.count(), 0); + + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QCOMPARE(spyFindBuffer.count(), 1); + else + QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#endif // an other crash test data = new QMimeData; @@ -324,19 +322,17 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11 QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); -#if defined(Q_WS_X11) - QCOMPARE(spySelection.count(), 1); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#elif defined(Q_OS_MAC) - QCOMPARE(spySelection.count(), 0); - QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 1); -#elif defined(Q_WS_WIN) - QCOMPARE(spySelection.count(), 0); + if (QGuiApplication::clipboard()->supportsSelection()) + QCOMPARE(spySelection.count(), 1); + else + QCOMPARE(spySelection.count(), 0); + + if (QGuiApplication::clipboard()->supportsFindBuffer()) + QCOMPARE(spyFindBuffer.count(), 1); + else + QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyData.count(), 1); - QCOMPARE(spyFindBuffer.count(), 0); -#endif } void tst_QClipboard::clearBeforeSetText() -- cgit v1.2.3 From 446d63be1b85284d6175b4781859d14668755ae3 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 24 Feb 2012 13:46:33 -0800 Subject: Fix tst_qmenu. Clear away Q_WS_WIN/Q_WS_X11 from QMenu. Using the hint returned by the QPlatformTheme. Task-number: QTBUG-24325 Change-Id: Iaa4da26c74273d7cfc1fbec6519c52d09e10f7bb Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qmenu/qmenu.pro | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro index 55099f1c54..9efd0302bf 100644 --- a/tests/auto/widgets/widgets/qmenu/qmenu.pro +++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro @@ -3,4 +3,3 @@ TARGET = tst_qmenu QT += widgets testlib SOURCES += tst_qmenu.cpp -win32:CONFIG += insignificant_test # QTBUG-24325 -- cgit v1.2.3 From 091dd54a6c145c477ade2b910519fc4d6d0e3591 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 14:46:08 +0100 Subject: don't rely on $PATH for finding rcc Change-Id: I7e6ffad6d84cca0b548920b3e620375fb5e314e9 Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro index 7f22f437c2..13d4d6c4ad 100644 --- a/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro +++ b/tests/auto/tools/qmake/testdata/quotedfilenames/quotedfilenames.pro @@ -6,7 +6,9 @@ SOURCES = main.cpp RCCINPUT = "rc folder/test.qrc" RCCOUTPUT = test.cpp -rcc_test.commands = rcc -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} +qtPrepareTool(QMAKE_RCC, rcc) + +rcc_test.commands = $$QMAKE_RCC -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} rcc_test.output = $$RCCOUTPUT rcc_test.input = RCCINPUT rcc_test.variable_out = SOURCES -- cgit v1.2.3 From edde6152094702aa4c3415920d2c962009619743 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:35:04 +0100 Subject: TestCompiler: split commands from arguments this allows us to temporarily set some extra args without (incorrectly) instantiating a second TestCompiler (and on the way relying on $PATH for finding qmake). Change-Id: Icce5bf7314148ddbe705606f77a26e3362b31f67 Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testcompiler.cpp | 16 ++++++++++++++-- tests/auto/tools/qmake/testcompiler.h | 8 ++++++-- tests/auto/tools/qmake/tst_qmake.cpp | 14 +++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index d2cb9f2435..8864d4d435 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -160,6 +160,18 @@ void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) qmakeCmd_ = qmakeCmd; } +void TestCompiler::resetArguments() +{ + makeArgs_.clear(); + qmakeArgs_.clear(); +} + +void TestCompiler::setArguments( QString makeArgs, QString qmakeArgs ) +{ + makeArgs_ = makeArgs; + qmakeArgs_ = qmakeArgs; +} + void TestCompiler::resetEnvironment() { environment_.clear(); @@ -222,7 +234,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const makeFile += "Makefile"; // Now start qmake and generate the makefile - return runCommand( qmakeCmd_ + " " + projectFile + " -o " + makeFile ); + return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile ); } bool TestCompiler::make( const QString &workPath, const QString &target ) @@ -230,7 +242,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target ) QDir D; D.setCurrent( workPath ); - QString cmdline = makeCmd_; + QString cmdline = makeCmd_ + " " + makeArgs_; if ( cmdline.contains("nmake", Qt::CaseInsensitive) ) cmdline.append(" /NOLOGO"); if ( !target.isEmpty() ) diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h index 116e424551..c438b52db2 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -55,6 +55,10 @@ public: virtual ~TestCompiler(); void setBaseCommands( QString makeCmd, QString qmakeCmd ); + + void resetArguments(); + void setArguments( QString makeArgs, QString qmakeArgs ); + void resetEnvironment(); void addToEnvironment( QString varAssignment ); @@ -78,8 +82,8 @@ public: private: bool runCommand( QString cmdLine ); - QString makeCmd_; - QString qmakeCmd_; + QString makeCmd_, makeArgs_; + QString qmakeCmd_, qmakeArgs_; QStringList environment_; // need to make this available somewhere diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 4da781f763..c01900c26e 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -138,6 +138,7 @@ void tst_qmake::init() void tst_qmake::cleanup() { + test_compiler.resetArguments(); test_compiler.clearCommandOutput(); } @@ -448,31 +449,30 @@ void tst_qmake::bundle_spaces() { QString workDir = base_path + "/testdata/bundle-spaces"; - // We set up alternate commands here, to make sure we're testing Mac + // We set up alternate arguments here, to make sure we're testing Mac // Bundles and since this might be the wrong output we rely on dry-running // make (-n). - TestCompiler local_tc; - local_tc.setBaseCommands("make -n", "qmake -macx -spec macx-g++"); + test_compiler.setArguments("-n", "-spec macx-g++"); - QVERIFY( local_tc.qmake(workDir, "bundle-spaces") ); + QVERIFY( test_compiler.qmake(workDir, "bundle-spaces") ); TempFile non_existing_file(workDir + "/non-existing file"); QVERIFY( !non_existing_file.exists() ); // Make fails: no rule to make "non-existing file" - QVERIFY( !local_tc.make(workDir) ); + QVERIFY( !test_compiler.make(workDir, QString()) ); QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); QVERIFY( non_existing_file.exists() ); // Aha! - QVERIFY( local_tc.make(workDir) ); + QVERIFY( test_compiler.make(workDir) ); // Cleanup QVERIFY( non_existing_file.remove() ); QVERIFY( !non_existing_file.exists() ); - QVERIFY( local_tc.removeMakefile(workDir) ); + QVERIFY( test_compiler.removeMakefile(workDir) ); } #endif // Q_OS_WIN -- cgit v1.2.3 From fd1d98b6af09d7cff73c3316097277131d82cd38 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:38:30 +0100 Subject: make qmake test suite a tad more verbose on failure automatically dump the collected output on non-expected return code Change-Id: Ifda7287869f329c5a6714e6f21aa9c3991e9ee4e Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testcompiler.cpp | 24 +++++++++++++++--------- tests/auto/tools/qmake/testcompiler.h | 6 +++--- tests/auto/tools/qmake/tst_qmake.cpp | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/testcompiler.cpp b/tests/auto/tools/qmake/testcompiler.cpp index 8864d4d435..97c640b28f 100644 --- a/tests/auto/tools/qmake/testcompiler.cpp +++ b/tests/auto/tools/qmake/testcompiler.cpp @@ -126,7 +126,13 @@ TestCompiler::~TestCompiler() { } -bool TestCompiler::runCommand( QString cmdline ) +bool TestCompiler::errorOut() +{ + qDebug(qPrintable(testOutput_.join("\n"))); + return false; +} + +bool TestCompiler::runCommand( QString cmdline, bool expectFail ) { testOutput_.append("Running command: " + cmdline); @@ -137,21 +143,21 @@ bool TestCompiler::runCommand( QString cmdline ) child.start(cmdline); if (!child.waitForStarted(-1)) { testOutput_.append( "Unable to start child process." ); - return false; + return errorOut(); } - bool failed = false; child.setReadChannel(QProcess::StandardError); child.waitForFinished(-1); + bool ok = child.exitStatus() == QProcess::NormalExit && (expectFail ^ (child.exitCode() == 0)); foreach (const QByteArray &output, child.readAllStandardError().split('\n')) { testOutput_.append(QString::fromLocal8Bit(output)); if (output.startsWith("Project MESSAGE: FAILED")) - failed = true; + ok = false; } - return !failed && child.exitStatus() == QProcess::NormalExit && child.exitCode() == 0; + return ok ? true : errorOut(); } void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) @@ -187,7 +193,7 @@ bool TestCompiler::makeClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return false; + return errorOut(); } D.setCurrent(workPath); @@ -204,7 +210,7 @@ bool TestCompiler::makeDistClean( const QString &workPath ) QDir D; if (!D.exists(workPath)) { testOutput_.append( "Directory '" + workPath + "' doesn't exist" ); - return false; + return errorOut(); } D.setCurrent(workPath); @@ -237,7 +243,7 @@ bool TestCompiler::qmake( const QString &workDir, const QString &proName, const return runCommand( qmakeCmd_ + " " + qmakeArgs_ + " " + projectFile + " -o " + makeFile ); } -bool TestCompiler::make( const QString &workPath, const QString &target ) +bool TestCompiler::make( const QString &workPath, const QString &target, bool expectFail ) { QDir D; D.setCurrent( workPath ); @@ -248,7 +254,7 @@ bool TestCompiler::make( const QString &workPath, const QString &target ) if ( !target.isEmpty() ) cmdline += " " + target; - return runCommand( cmdline ); + return runCommand( cmdline, expectFail ); } bool TestCompiler::exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ) diff --git a/tests/auto/tools/qmake/testcompiler.h b/tests/auto/tools/qmake/testcompiler.h index c438b52db2..8aed3a9987 100644 --- a/tests/auto/tools/qmake/testcompiler.h +++ b/tests/auto/tools/qmake/testcompiler.h @@ -69,7 +69,7 @@ public: // executes a qmake on proName in the specified workDir, output goes to buildDir or workDir if it's null bool qmake( const QString &workDir, const QString &proName, const QString &buildDir = QString() ); // executes a make in the specified workPath, with an optional target (eg. install) - bool make( const QString &workPath, const QString &target = QString() ); + bool make( const QString &workPath, const QString &target = QString(), bool expectFail = false ); // checks if the executable exists in destDir bool exists( const QString &destDir, const QString &exeName, BuildType buildType, const QString &version ); // removes the makefile @@ -80,13 +80,13 @@ public: void clearCommandOutput(); private: - bool runCommand( QString cmdLine ); + bool runCommand( QString cmdLine, bool expectFail = false ); + bool errorOut(); QString makeCmd_, makeArgs_; QString qmakeCmd_, qmakeArgs_; QStringList environment_; - // need to make this available somewhere QStringList testOutput_; }; diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index c01900c26e..f6d88ffce3 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -461,7 +461,7 @@ void tst_qmake::bundle_spaces() QVERIFY( !non_existing_file.exists() ); // Make fails: no rule to make "non-existing file" - QVERIFY( !test_compiler.make(workDir, QString()) ); + QVERIFY( test_compiler.make(workDir, QString(), true) ); QVERIFY( non_existing_file.open(QIODevice::WriteOnly) ); QVERIFY( non_existing_file.exists() ); -- cgit v1.2.3 From 0957085f3d5cd6555e1018e480b14982fe604fb7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:39:23 +0100 Subject: move resetEnvironment() call to cleanup() we want to call it even if the test fails Change-Id: Ie8f3f9d2df5d52990d6b9f9a632e49826278175a Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/tst_qmake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index f6d88ffce3..4db09c6c4b 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -139,6 +139,7 @@ void tst_qmake::init() void tst_qmake::cleanup() { test_compiler.resetArguments(); + test_compiler.resetEnvironment(); test_compiler.clearCommandOutput(); } @@ -306,7 +307,6 @@ void tst_qmake::export_across_file_boundaries() test_compiler.addToEnvironment("QMAKEFEATURES=."); QString workDir = base_path + "/testdata/export_across_file_boundaries"; QVERIFY( test_compiler.qmake( workDir, "foo" )); - test_compiler.resetEnvironment(); } void tst_qmake::include_dir() -- cgit v1.2.3 From 494ed1d53603e82ecdc20d766464be2b817145ae Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 23 Feb 2012 15:26:56 +0100 Subject: remove useless init() function it did the same cleanup() did, and they are always called consecutively anyway (except at start and end where it does not matter). Change-Id: I4c82024d19d6c670f1f4037d43147a15680614ae Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/tst_qmake.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index 4db09c6c4b..88ff10a764 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -57,7 +57,6 @@ public: public slots: void initTestCase(); void cleanupTestCase(); - void init(); void cleanup(); private slots: @@ -131,11 +130,6 @@ void tst_qmake::cleanupTestCase() { } -void tst_qmake::init() -{ - test_compiler.clearCommandOutput(); -} - void tst_qmake::cleanup() { test_compiler.resetArguments(); -- cgit v1.2.3 From b51296c06433d4923e4dcfd2bc104ae3ab67fb43 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 3 Feb 2012 12:28:13 +0100 Subject: Add SHA-224, SHA-256, SHA-384, and SHA-512 support to QCryptographicHash This adds Sha224, Sha256, Sha384, and Sha512 enum values to QCryptographicHash::Algorithm. The implementation comes from RFC 6234, http://tools.ietf.org/html/rfc6234, which is added to src/3rdparty/rfc6234. Only the headers and SHA-2 code is included in src/3rdparty/rfc6234 (the SHA1, HMAC, and HKDF code is not included). Change-Id: I85139fd118291f15efc22899a5ddd1cc83810cfb Reviewed-by: Lars Knoll --- .../tools/qcryptographichash/tst_qcryptographichash.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp index 81cc66f045..67c15682a2 100644 --- a/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp +++ b/tests/auto/corelib/tools/qcryptographichash/tst_qcryptographichash.cpp @@ -102,6 +102,22 @@ void tst_QCryptographicHash::intermediary_result_data() << QByteArray("abc") << QByteArray("abc") << QByteArray::fromHex("A9993E364706816ABA3E25717850C26C9CD0D89D") << QByteArray::fromHex("F8C1D87006FBF7E5CC4B026C3138BC046883DC71"); + QTest::newRow("sha224") << int(QCryptographicHash::Sha224) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7") + << QByteArray::fromHex("7C9C91FC479626AA1A525301084DEB96716131D146A2DB61B533F4C9"); + QTest::newRow("sha256") << int(QCryptographicHash::Sha256) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD") + << QByteArray::fromHex("BBB59DA3AF939F7AF5F360F2CEB80A496E3BAE1CD87DDE426DB0AE40677E1C2C"); + QTest::newRow("sha384") << int(QCryptographicHash::Sha384) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7") + << QByteArray::fromHex("CAF33A735C9535CE7F5D24FB5B3A4834F0E9316664AD15A9E8221679D4A3B4FB7E962404BA0C10C1D43AB49D03A08B8D"); + QTest::newRow("sha512") << int(QCryptographicHash::Sha512) + << QByteArray("abc") << QByteArray("abc") + << QByteArray::fromHex("DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F") + << QByteArray::fromHex("F3C41E7B63EE869596FC28BAD64120612C520F65928AB4D126C72C6998B551B8FF1CEDDFED4373E6717554DC89D1EEE6F0AB22FD3675E561ABA9AE26A3EEC53B"); } void tst_QCryptographicHash::intermediary_result() -- cgit v1.2.3 From cbc777374a26134e87054b2292a800d4b3835d82 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Mon, 27 Feb 2012 16:31:03 +1000 Subject: testlib: Improve the silent logging mode Previously the silent logging mode suppressed passes, skips and internal testlib info messages, but did not suppress debugging output, making it hard to see the fails in a noisy test. This commit changes silent mode so that it suppresses all output except test failures and fatal errors, making silent mode truly useful for seeing just the important test output. This commit also adds a selftest to verify the behaviour of silent mode. Change-Id: I75420aead03682306210746a87e2a3b608b58fc6 Reviewed-by: Rohan McGovern --- tests/auto/testlib/selftests/expected_silent.txt | 9 ++ tests/auto/testlib/selftests/selftests.pri | 1 + tests/auto/testlib/selftests/selftests.qrc | 1 + tests/auto/testlib/selftests/silent/silent.pro | 7 ++ tests/auto/testlib/selftests/silent/tst_silent.cpp | 99 ++++++++++++++++++++++ tests/auto/testlib/selftests/tst_selftests.cpp | 7 ++ 6 files changed, 124 insertions(+) create mode 100644 tests/auto/testlib/selftests/expected_silent.txt create mode 100644 tests/auto/testlib/selftests/silent/silent.pro create mode 100644 tests/auto/testlib/selftests/silent/tst_silent.cpp (limited to 'tests/auto') diff --git a/tests/auto/testlib/selftests/expected_silent.txt b/tests/auto/testlib/selftests/expected_silent.txt new file mode 100644 index 0000000000..39e0bfc601 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_silent.txt @@ -0,0 +1,9 @@ +Testing tst_Silent +FAIL! : tst_Silent::fail() 'false' returned FALSE. (This test should fail) + Loc: [/home/jasmcdon/depot/qt5-test/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp(73)] +XPASS : tst_Silent::xpass() 'true' returned TRUE unexpectedly. (This test should XPASS) + Loc: [/home/jasmcdon/depot/qt5-test/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp(85)] +QFATAL : tst_Silent::messages() This is a fatal error message that should still appear in silent test output +FAIL! : tst_Silent::messages() Received a fatal error. + Loc: [Unknown file(0)] +Totals: 3 passed, 3 failed, 1 skipped diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 0809c4d497..1fc66e6364 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -30,6 +30,7 @@ SUBPROGRAMS = \ printdatatags \ printdatatagswithglobaltags \ qexecstringlist \ + silent \ singleskip \ skip \ skipcleanup \ diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index baa539a259..d05ac2a516 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -93,6 +93,7 @@ expected_printdatatags.txt expected_printdatatagswithglobaltags.txt expected_qexecstringlist.txt + expected_silent.txt expected_singleskip.lightxml expected_singleskip.txt expected_singleskip.xml diff --git a/tests/auto/testlib/selftests/silent/silent.pro b/tests/auto/testlib/selftests/silent/silent.pro new file mode 100644 index 0000000000..3150f65a5e --- /dev/null +++ b/tests/auto/testlib/selftests/silent/silent.pro @@ -0,0 +1,7 @@ +SOURCES += tst_silent.cpp +QT = core testlib-private + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = silent diff --git a/tests/auto/testlib/selftests/silent/tst_silent.cpp b/tests/auto/testlib/selftests/silent/tst_silent.cpp new file mode 100644 index 0000000000..ec280f9f1a --- /dev/null +++ b/tests/auto/testlib/selftests/silent/tst_silent.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_Silent : public QObject +{ + Q_OBJECT + +private slots: + void pass(); + void skip(); + void fail(); + void xfail(); + void xpass(); + + // This test function must be last, as it calls qFatal(). + void messages(); +}; + +void tst_Silent::pass() +{ + QVERIFY(true); +} + +void tst_Silent::skip() +{ + QSKIP("This test should skip"); +} + +void tst_Silent::fail() +{ + QVERIFY2(false, "This test should fail"); +} + +void tst_Silent::xfail() +{ + QEXPECT_FAIL("", "This test should XFAIL", Abort); + QVERIFY(false); +} + +void tst_Silent::xpass() +{ + QEXPECT_FAIL("", "This test should XPASS", Abort); + QVERIFY2(true, "This test should XPASS"); +} + +void tst_Silent::messages() +{ + qWarning("This is a warning that should not appear in silent test output"); + QWARN("This is an internal testlib warning that should not appear in silent test output"); + qDebug("This is a debug message that should not appear in silent test output"); + qCritical("This is a critical message that should not appear in silent test output"); + QTestLog::info("This is an internal testlib info message that should not appear in silent test output", __FILE__, __LINE__); + qFatal("This is a fatal error message that should still appear in silent test output"); +} + +QTEST_MAIN(tst_Silent) +#include "tst_silent.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 7367d664b2..2b90bdb389 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -354,6 +354,7 @@ void tst_Selftests::runSubTest_data() << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" + << "silent" << "singleskip" << "skip" << "skipcleanup" @@ -409,6 +410,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "printdatatagswithglobaltags") { arguments << "-datatags"; } + else if (subtest == "silent") { + arguments << "-silent"; + } // These tests don't work right unless logging plain text to @@ -434,6 +438,9 @@ void tst_Selftests::runSubTest_data() if (subtest == "printdatatagswithglobaltags") { continue; } + if (subtest == "silent") { + continue; + } // `crashes' will not output valid XML on platforms without a crash handler if (subtest == "crashes") { continue; -- cgit v1.2.3 From 46ce1185fb8411c3dd775d19d2012c97b1d2e5fa Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Thu, 16 Feb 2012 13:25:41 +0100 Subject: restore previously non-working disabled test Change-Id: I419863a681f7be96cb855a274c68eaea25efebcb Reviewed-by: Yunqiao Yin --- .../models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index 45b9c26824..ddafeea427 100644 --- a/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/sql/models/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -1406,8 +1406,7 @@ void tst_QSqlRelationalTableModel::whiteSpaceInIdentifiers() QCOMPARE(model.data(model.index(0, 1)).toString(), QString("Washington")); QCOMPARE(model.data(model.index(0, 2)).toInt(), 7); - //TODO: For some reson setting a record using manual submit fails - //model.setEditStrategy(QSqlTableModel::OnManualSubmit); + model.setEditStrategy(QSqlTableModel::OnManualSubmit); QSqlRecord recNew; QSqlField f1New("id", QVariant::Int); -- cgit v1.2.3 From 838f828a1d76c1f9fc1fba669d336e91f622fb94 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Feb 2012 17:09:43 +0100 Subject: QComboBox: Use platform theme hint to determine popup geometry. Change-Id: I1f81be1394455715c5dfcd2d426758c4c7cd91fc Reviewed-by: Bradley T. Hughes --- .../widgets/widgets/qcombobox/tst_qcombobox.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 907a239912..0fe93995a1 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -43,6 +43,8 @@ #include "qcombobox.h" #include +#include +#include #include #include @@ -1915,19 +1917,15 @@ void tst_QComboBox::itemListPosition() QWidget topLevel; QFontComboBox combo(&topLevel); - //the code to get the avaialbe screen space is copied from QComboBox code + //the code to get the available screen space is copied from QComboBox code const int scrNumber = QApplication::desktop()->screenNumber(&combo); - QRect screen; -#ifdef Q_WS_WIN - screen = QApplication::desktop()->screenGeometry(scrNumber); -#elif defined Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) - screen = QApplication::desktop()->screenGeometry(scrNumber); - else - screen = QApplication::desktop()->availableGeometry(scrNumber); -#else - screen = QApplication::desktop()->availableGeometry(scrNumber); -#endif + + bool useFullScreenForPopupMenu = false; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool(); + const QRect screen = useFullScreenForPopupMenu ? + QApplication::desktop()->screenGeometry(scrNumber) : + QApplication::desktop()->availableGeometry(scrNumber); combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner -- cgit v1.2.3 From 0d9714f44549bf2e3a39d5c9833a4744cc3e6410 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 20:48:56 +0100 Subject: moc: Only generate IndexOfMethod for signals. moc is currently generating code to convert from a pointer to member function of a slot or signal to its index. The idea was that it could be usefull for slots to have the new syntax do the same as the old one (connecting signal index to slot index). But in practice, the new syntax do not use the IndexOfMethod for slots. Also, it does not work for all the slots (no Q_PRIVATE_SLOT, no static slots) So since it is not used, and that it would take room in the binaries to generate all the code to get the index of slots, we remove it. If ever we need it, we can still add it later. Change-Id: Ia417e3e524d7915ca86433ea86c66ac2b299c81a Reviewed-by: Kent Hansen --- tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 68ff8e4bb6..09fd0a7adb 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -326,6 +326,8 @@ public slots: signals: void sig0(); QString sig1(QString s1); + void sig10(QString s1, QString s2, QString s3, QString s4, QString s5, QString s6, QString s7, + QString s8, QString s9, QString s10); protected: QtTestObject(QVariant) {} @@ -725,6 +727,7 @@ typedef QString CustomString; class QtTestCustomObject: public QObject { Q_OBJECT + friend class tst_QMetaObject; public: QtTestCustomObject(): QObject(), sum(0) {} @@ -1129,11 +1132,9 @@ void tst_QMetaObject::indexOfMethodPMF() } INDEXOFMETHODPMF_HELPER(tst_QMetaObject, value7Changed, (const QString&)) - INDEXOFMETHODPMF_HELPER(tst_QMetaObject, stdSet, ()) - INDEXOFMETHODPMF_HELPER(QtTestObject, sl10, (QString,QString,QString,QString,QString,QString,QString,QString,QString,QString)) INDEXOFMETHODPMF_HELPER(QtTestObject, sig0, ()) - INDEXOFMETHODPMF_HELPER(QtTestObject, testLongLong, (qint64, quint64)) - INDEXOFMETHODPMF_HELPER(QtTestObject, testReference, (QString&)) + INDEXOFMETHODPMF_HELPER(QtTestObject, sig10, (QString,QString,QString,QString,QString,QString,QString,QString,QString,QString)) + INDEXOFMETHODPMF_HELPER(QtTestCustomObject, sig_custom, (const CustomString &)) } QTEST_MAIN(tst_QMetaObject) -- cgit v1.2.3 From b491d02eb3217e9b5b61a2b8f7c599080e8b8bdb Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 28 Feb 2012 12:58:02 +0200 Subject: Fix QLibrary autotest for Windows The libraries were built into wrong directory in Windows. Fixed it so that the libraries are built into debug and release directories like the test executable. Also fixed QMAKE_CLEAN statement, which was using incorrect separator. Task-number: QTBUG-24151 Change-Id: Iade656af5f83ef2b79c2b9c4177df4a16b2f6821 Reviewed-by: Friedemann Kleint --- tests/auto/corelib/plugin/qlibrary/lib/lib.pro | 8 ++++++++ tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro | 11 +++++++++-- tests/auto/corelib/plugin/qlibrary/tst/tst.pro | 2 -- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro index d8551faddc..7a2b8cd3b6 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib/lib.pro +++ b/tests/auto/corelib/plugin/qlibrary/lib/lib.pro @@ -13,3 +13,11 @@ win32-borland: DEFINES += WIN32_BORLAND # This project is testdata for tst_qlibrary target.path = $$[QT_INSTALL_TESTS]/tst_qlibrary INSTALLS += target + +win32 { + CONFIG(debug, debug|release) { + DESTDIR = ../debug/ + } else { + DESTDIR = ../release/ + } +} diff --git a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro index a15393b214..8d5af0ea79 100644 --- a/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro +++ b/tests/auto/corelib/plugin/qlibrary/lib2/lib2.pro @@ -15,13 +15,20 @@ win32-borland: DEFINES += WIN32_BORLAND # We want to test if we can load a shared library with *any* filename... win32 { + CONFIG(debug, debug|release) { + BUILD_FOLDER = debug + } else { + BUILD_FOLDER = release + } + DESTDIR = ../$$BUILD_FOLDER/ + # vcproj and Makefile generators refer to target differently contains(TEMPLATE,vc.*) { src = $(TargetPath) } else { src = $(DESTDIR_TARGET) } - files = mylib.dl2 system.qt.test.mylib.dll + files = $$BUILD_FOLDER$${QMAKE_DIR_SEP}mylib.dl2 $$BUILD_FOLDER$${QMAKE_DIR_SEP}system.qt.test.mylib.dll } else { src = $(DESTDIR)$(TARGET) files = libmylib.so2 system.qt.test.mylib.so @@ -34,7 +41,7 @@ renamed_target.path = $$target.path for(file, files) { QMAKE_POST_LINK += $$QMAKE_COPY $$src ..$$QMAKE_DIR_SEP$$file && renamed_target.extra += $$QMAKE_COPY $$src $(INSTALL_ROOT)$${target.path}$$QMAKE_DIR_SEP$$file && - CLEAN_FILES += ../$$file + CLEAN_FILES += ..$$QMAKE_DIR_SEP$$file } renamed_target.extra = $$member(renamed_target.extra, 0, -2) QMAKE_POST_LINK = $$member(QMAKE_POST_LINK, 0, -2) diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro index ae6cf97891..d59cd738bf 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro +++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro @@ -13,5 +13,3 @@ win32 { } TESTDATA += ../library_path/invalid.so - -win32:CONFIG += insignificant_test # QTBUG-24151 -- cgit v1.2.3 From f3b68e352e4ce3d9a725f57e33ab6c479c27720c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Feb 2012 12:35:48 +0100 Subject: Skip QLocale test on Windows, improve process handling. - Skip the failing windowsDefaultLocale() test. - Improve the handling of the subprocess, locate the binary in initTestCase instead of repeatedly searching it. - Make all applications console/non-app bundles. Task-number: QTBUG-24543 Change-Id: I79dfaa3320cd5698f02e74a3fe53477d4a79d4fb Reviewed-by: Miikka Heikkinen Reviewed-by: Friedemann Kleint --- .../tools/qlocale/syslocaleapp/syslocaleapp.pro | 1 + tests/auto/corelib/tools/qlocale/test/test.pro | 5 +- tests/auto/corelib/tools/qlocale/tst_qlocale.cpp | 120 +++++++++++++++------ 3 files changed, 92 insertions(+), 34 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro index d510d82207..a97350ca3f 100644 --- a/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro +++ b/tests/auto/corelib/tools/qlocale/syslocaleapp/syslocaleapp.pro @@ -1,6 +1,7 @@ SOURCES += syslocaleapp.cpp DESTDIR = ./ +CONFIG += console CONFIG -= app_bundle QT = core diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index 5a4fb674c5..eafd8c1699 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -1,5 +1,6 @@ -CONFIG += testcase -QT = core testlib network +CONFIG += console testcase +CONFIG -= app_bundle +QT = core testlib embedded: QT += gui SOURCES = ../tst_qlocale.cpp diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index db7f503f57..02acb00548 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -43,6 +43,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -83,6 +86,7 @@ public: tst_QLocale(); private slots: + void initTestCase(); void windowsDefaultLocale(); void macDefaultLocale(); @@ -131,6 +135,7 @@ private slots: private: QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; + QString m_sysapp; }; tst_QLocale::tst_QLocale() @@ -138,6 +143,22 @@ tst_QLocale::tst_QLocale() qRegisterMetaType("QLocale::FormatType"); } +void tst_QLocale::initTestCase() +{ + const QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp"); + QVERIFY2(!syslocaleapp_dir.isEmpty(), + qPrintable(QStringLiteral("Cannot find 'syslocaleapp' starting from ") + + QDir::toNativeSeparators(QDir::currentPath()))); + m_sysapp = syslocaleapp_dir + QStringLiteral("/syslocaleapp"); +#ifdef Q_OS_WIN + m_sysapp += QStringLiteral(".exe"); +#endif + const QFileInfo fi(m_sysapp); + QVERIFY2(fi.exists() && fi.isExecutable(), + qPrintable(QDir::toNativeSeparators(m_sysapp) + + QStringLiteral(" does not exist or is not executable."))); +} + void tst_QLocale::ctor() { QLocale default_locale = QLocale::system(); @@ -346,6 +367,54 @@ void tst_QLocale::ctor() #undef TEST_CTOR } +static inline bool runSysApp(const QString &binary, + const QStringList &env, + QString *output, + QString *errorMessage) +{ + output->clear(); + errorMessage->clear(); + QProcess process; + process.setEnvironment(env); + process.start(binary); + process.closeWriteChannel(); + if (!process.waitForStarted()) { + *errorMessage = QString::fromLatin1("Cannot start '%1': %2").arg(binary, process.errorString()); + return false; + } + if (!process.waitForFinished()) { + process.kill(); + *errorMessage = QStringLiteral("Timeout waiting for ") + binary; + return false; + } + *output = QString::fromLocal8Bit(process.readAllStandardOutput()); + return true; +} + +static inline bool runSysAppTest(const QString &binary, + QStringList baseEnv, + const QString &requestedLocale, + const QString &expectedOutput, + QString *errorMessage) +{ + QString output; + baseEnv.append(QStringLiteral("LANG=") + requestedLocale); + if (!runSysApp(binary, baseEnv, &output, errorMessage)) + return false; + + if (output.isEmpty()) { + *errorMessage = QString::fromLatin1("Empty output received for requested '%1' (expected '%2')"). + arg(requestedLocale, expectedOutput); + return false; + } + if (output != expectedOutput) { + *errorMessage = QString::fromLatin1("Output mismatch for requested '%1': Expected '%2', got '%3'"). + arg(requestedLocale, expectedOutput, output); + return false; + } + return true; +} + void tst_QLocale::emptyCtor() { #if defined(Q_OS_WINCE) @@ -358,15 +427,9 @@ void tst_QLocale::emptyCtor() { \ /* Test constructor without arguments. Needs separate process */ \ /* because of caching of the system locale. */ \ - QProcess process; \ - process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \ - process.start(syslocaleapp_dir + "syslocaleapp"); \ - process.waitForReadyRead(); \ - QString ret = QString(process.readAll()); \ - process.waitForFinished(); \ - QVERIFY2(!ret.isEmpty(), "Cannot launch external process"); \ - QVERIFY2(QString(exp_str) == ret, QString("Expected: " + QString(exp_str) + ", got: " \ - + ret + ". Requested: " + QString(req_lc)).toLatin1().constData()); \ + QString errorMessage; \ + QVERIFY2(runSysAppTest(m_sysapp, env, QLatin1String(req_lc), QLatin1String(exp_str), &errorMessage), \ + qPrintable(errorMessage)); \ } // Get an environment free of any locale-related variables @@ -377,15 +440,11 @@ void tst_QLocale::emptyCtor() env << entry; } - QString syslocaleapp_dir = QFINDTESTDATA("syslocaleapp/"); - // Get default locale. - QProcess p; - p.setEnvironment(env); - p.start(syslocaleapp_dir + "syslocaleapp"); - p.waitForReadyRead(); - QString defaultLoc = QString(p.readAll()); - p.waitForFinished(); + QString defaultLoc; + QString errorMessage; + QVERIFY2(runSysApp(m_sysapp, env, &defaultLoc, &errorMessage), + qPrintable(errorMessage)); TEST_CTOR("C", "C") TEST_CTOR("bla", "C") @@ -421,9 +480,9 @@ void tst_QLocale::emptyCtor() TEST_CTOR("DE", "de_DE"); TEST_CTOR("EN", "en_US"); - TEST_CTOR("en/", defaultLoc) - TEST_CTOR("asdfghj", defaultLoc); - TEST_CTOR("123456", defaultLoc); + TEST_CTOR("en/", defaultLoc.toLatin1()) + TEST_CTOR("asdfghj", defaultLoc.toLatin1()); + TEST_CTOR("123456", defaultLoc.toLatin1()); #undef TEST_CTOR #endif @@ -1147,17 +1206,15 @@ static QString getWinLocaleInfo(LCTYPE type) qWarning("QLocale: empty windows locale info (%d)", type); return QString(); } - - QByteArray buff(cnt, 0); - - cnt = GetLocaleInfo(id, type, reinterpret_cast(buff.data()), buff.size() / 2); + cnt /= sizeof(wchar_t); + QScopedArrayPointer buf(new wchar_t[cnt]); + cnt = GetLocaleInfo(id, type, buf.data(), cnt); if (cnt == 0) { qWarning("QLocale: empty windows locale info (%d)", type); return QString(); } - - return QString::fromWCharArray(reinterpret_cast(buff.data())); + return QString::fromWCharArray(buf.data()); } static void setWinLocaleInfo(LCTYPE type, const QString &value) @@ -1189,13 +1246,13 @@ public: }; -#endif +#endif // Q_OS_WIN void tst_QLocale::windowsDefaultLocale() { -#ifndef Q_OS_WIN - QSKIP("This is a Windows test"); -#else +#ifdef Q_OS_WIN + QSKIP("This test currently fails - QTBUG-24543"); + RestoreLocaleHelper systemLocale; // set weird system defaults and make sure we're using them setWinLocaleInfo(LOCALE_SDECIMAL, QLatin1String("@")); @@ -1204,7 +1261,6 @@ void tst_QLocale::windowsDefaultLocale() setWinLocaleInfo(LOCALE_SLONGDATE, QLatin1String("d@M@yyyy")); setWinLocaleInfo(LOCALE_STIMEFORMAT, QLatin1String("h^m^s")); QLocale locale = QLocale::system(); - // make sure we are seeing the system's format strings QCOMPARE(locale.decimalPoint(), QChar('@')); QCOMPARE(locale.groupSeparator(), QChar('?')); @@ -1230,7 +1286,7 @@ void tst_QLocale::windowsDefaultLocale() QCOMPARE(locale.toString(QDateTime(QDate(1974, 12, 1), QTime(1,2,3)), QLocale::LongFormat), QString("1@12@1974 1^2^3")); QCOMPARE(locale.toString(QTime(1,2,3), QLocale::LongFormat), QString("1^2^3")); -#endif +#endif // #ifdef Q_OS_WIN } void tst_QLocale::numberOptions() -- cgit v1.2.3