From a03a71e332294aa500ac8475bb777c2f33609e8b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Mar 2012 10:09:02 +0100 Subject: examples: use QVector instead of QList QPointF is in the category of types for which QList is needlessly inefficient (elements are copy-constructed onto the heap and held through pointers). Use a vector instead. This is consistent with the QPainter API. Change-Id: Id0e910c067a60d12fbc175e7ee7da824834be374 Reviewed-by: hjk Reviewed-by: Lars Knoll --- tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp | 2 +- .../benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h | 2 +- tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 220c89ec2f..daa06d0762 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -2153,7 +2153,7 @@ void tst_QGraphicsScene::mouseEventPropagation_doubleclick() class Scene : public QGraphicsScene { public: - QList mouseMovePoints; + QVector mouseMovePoints; protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h index b13f4a11e1..d2d859b402 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.h @@ -62,7 +62,7 @@ protected: private: int x, y; QColor color; - QList stuff; + QVector stuff; }; #endif diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h index ef3550e8d7..462109e599 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.h @@ -62,7 +62,7 @@ protected: private: int x, y; QColor color; - QList stuff; + QVector stuff; }; #endif -- cgit v1.2.3 From 278ddc9d5e2f4e068ec1da94a1aeae4d97310dd2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Mar 2012 10:10:16 +0100 Subject: chiptester benchmark: compile The implementation uses QScrollBar, which is no longer included by . Change-Id: I2422cfccc427179ca71e9a3195f16bd637925fb3 Reviewed-by: Lars Knoll --- .../benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp index cae21fcfac..f8d766d82a 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chiptester.cpp @@ -43,6 +43,7 @@ #include "chip.h" #include +#include #ifndef QT_NO_OPENGL #include #endif -- cgit v1.2.3 From 69c428a8101cb3a87c7fcd1f48753dc79a002641 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 5 Mar 2012 17:32:48 +0000 Subject: Add windows XFAIL to qnetworkreply autotest The test case that depends on QLocalSocket consistently fails due to bugs in QLocalSocket windows implementation Change-Id: Ibfe9eb3590be4f72b52f14cd4fbe5be61f6cf70e Reviewed-by: Joerg Bornemann --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 8685546a5f..4a90b50004 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -3874,6 +3874,10 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket() QNetworkReplyPtr reply = manager.put(QNetworkRequest(url), passive); passive->setParent(reply); +#ifdef Q_OS_WIN + if (!data.isEmpty()) + QEXPECT_FAIL("", "QTBUG-18385", Abort); +#endif QVERIFY(waitForFinish(reply) == Success); QCOMPARE(reply->error(), QNetworkReply::NoError); -- cgit v1.2.3 From fbd45a9311db8b2fcfec5ffd5c3ff4f5a684b760 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 5 Mar 2012 17:36:28 +0000 Subject: tst_qnetworkreply - remove qRegisterMetaType duplicates The metatypes are registered in the constructor, don't need to register them in test cases as well. Registering in a test case is bad practice, as it could result in tests failing when run individually due to unknown metatype. Change-Id: Ic4d65d0f5fe3cdd3ab57cf2512a4906d71205a05 Reviewed-by: Martin Petersson --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 28 ---------------------- 1 file changed, 28 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 4a90b50004..cc65ca2df5 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -2971,9 +2971,6 @@ void tst_QNetworkReply::ioGetFromHttpWithAuthSynchronous() void tst_QNetworkReply::ioGetFromHttpWithProxyAuth() { - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType(); - // This test sends three requests // The first two in parallel // The third after the first two finished @@ -3081,9 +3078,6 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy() // HTTP caching proxies are tested by the above function // test SOCKSv5 proxies too - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType(); - QFile reference(testDataDir + "/rfc3252.txt"); QVERIFY(reference.open(QIODevice::ReadOnly)); @@ -3141,9 +3135,6 @@ void tst_QNetworkReply::ioGetFromHttpWithSocksProxy() #ifndef QT_NO_SSL void tst_QNetworkReply::ioGetFromHttpsWithSslErrors() { - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType >(); - QFile reference(testDataDir + "/rfc3252.txt"); QVERIFY(reference.open(QIODevice::ReadOnly)); @@ -3175,9 +3166,6 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors() // same as above, except that we call ignoreSslErrors and don't connect // to the sslErrors() signal (which is *still* emitted) - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType >(); - QFile reference(testDataDir + "/rfc3252.txt"); QVERIFY(reference.open(QIODevice::ReadOnly)); @@ -3203,9 +3191,6 @@ void tst_QNetworkReply::ioGetFromHttpsWithIgnoreSslErrors() void tst_QNetworkReply::ioGetFromHttpsWithSslHandshakeError() { - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType >(); - QFile reference(testDataDir + "/rfc3252.txt"); QVERIFY(reference.open(QIODevice::ReadOnly)); @@ -3709,9 +3694,6 @@ void tst_QNetworkReply::ioGetWithManyProxies() { // Test proxy factories - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType(); - QFile reference(testDataDir + "/rfc3252.txt"); QVERIFY(reference.open(QIODevice::ReadOnly)); @@ -4108,10 +4090,6 @@ void tst_QNetworkReply::ioPostToHttpFromSocket_data() void tst_QNetworkReply::ioPostToHttpFromSocket() { - qRegisterMetaType(); // for QSignalSpy - qRegisterMetaType(); - qRegisterMetaType(); - QFETCH(QByteArray, data); QFETCH(QUrl, url); QFETCH(QNetworkProxy, proxy); @@ -4711,7 +4689,6 @@ void tst_QNetworkReply::rateControl() QNetworkRequest request("debugpipe://localhost:" + QString::number(sender.serverPort())); QNetworkReplyPtr reply = manager.get(request); reply->setReadBufferSize(32768); - qRegisterMetaType("QNetworkReply::NetworkError"); QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); RateControlledReader reader(sender, reply, rate, 20); @@ -5104,7 +5081,6 @@ void tst_QNetworkReply::nestedEventLoops() // seconds. (see above) qDebug("Takes 16 seconds to run, please wait"); - qRegisterMetaType(); QUrl url("http://" + QtNetworkSettings::serverName()); QNetworkRequest request(url); @@ -5325,7 +5301,6 @@ void tst_QNetworkReply::authorizationError() QCOMPARE(reply->error(), QNetworkReply::NoError); - qRegisterMetaType("QNetworkReply::NetworkError"); QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); QSignalSpy finishedSpy(reply, SIGNAL(finished())); // now run the request: @@ -6054,11 +6029,8 @@ void tst_QNetworkReply::qtbug4121unknownAuthentication() QNetworkAccessManager manager; QNetworkReplyPtr reply = manager.get(request); - qRegisterMetaType("QNetworkReply*"); - qRegisterMetaType("QAuthenticator*"); QSignalSpy authSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); QSignalSpy finishedSpy(&manager, SIGNAL(finished(QNetworkReply*))); - qRegisterMetaType("QNetworkReply::NetworkError"); QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError))); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); -- cgit v1.2.3 From 75ab89d4d6e68fd5451d0f2335c95d76d3987c10 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 6 Mar 2012 11:19:33 +0000 Subject: Mark tst_QNetworkReply::getThenDeleteObject as unstable It's unstable on all platforms, because the reply can be finished due to a race with the http thread. It isn't crashing (which the test was trying to test for), but rather the QVERIFY(!reply->isFinished()) fails, which is an inconclusive verdict. Change-Id: Ib815a7cedd220544a0c9cb83023e3334df4a0fb3 Reviewed-by: Martin Petersson --- tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index cc65ca2df5..438cf866aa 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5632,6 +5632,7 @@ void tst_QNetworkReply::getAndThenDeleteObject_data() void tst_QNetworkReply::getAndThenDeleteObject() { + QSKIP("unstable test - reply may be finished too early"); // yes, this will leak if the testcase fails. I don't care. It must not fail then :P QNetworkAccessManager *manager = new QNetworkAccessManager(); QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); -- cgit v1.2.3 From 3c529933612ff022d139975d661e37c77b1b2e99 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 27 Feb 2012 15:50:19 +0000 Subject: Rework QNetworkProxyFactory::systemProxyForQuery autotest Rather than requiring specific hardcoded proxies in the system, it now checks the proxies returned by the system have the required capabilities for the request. Note the test will pass if no proxy is configured (as QNetworkProxy::NoProxy has all required capabilities) The test prints the returned proxy lists and elapsed time diagnostic for manual comparison and debugging. Change-Id: I621ef4d1d7264a98c3e8bd485c30bc1166fcbdf0 Task-number: QTBUG-19454 Reviewed-by: Thiago Macieira --- .../tst_qnetworkproxyfactory.cpp | 97 +++++++++++++++++----- 1 file changed, 76 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index 8a1a391b51..9b7d21eff8 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -81,6 +81,7 @@ public: private slots: void systemProxyForQueryCalledFromThread(); + void systemProxyForQuery_data(); void systemProxyForQuery() const; #ifndef QT_NO_BEARERMANAGEMENT void fromConfigurations(); @@ -110,34 +111,88 @@ QString tst_QNetworkProxyFactory::formatProxyName(const QNetworkProxy & proxy) c return proxyName; } +void tst_QNetworkProxyFactory::systemProxyForQuery_data() +{ + QTest::addColumn("type"); + QTest::addColumn("url"); + QTest::addColumn("tag"); + QTest::addColumn("hostName"); + QTest::addColumn("port"); + QTest::addColumn("requiredCapabilities"); + + //URLs + QTest::newRow("http") << (int)QNetworkProxyQuery::UrlRequest << QUrl("http://qt-project.org") << QString() << QString() << 0 << 0; + //windows: "intranet" should be bypassed if "bypass proxy server for local addresses" is ticked + QTest::newRow("intranet") << (int)QNetworkProxyQuery::UrlRequest << QUrl("http://qt-test-server") << QString() << QString() << 0 << 0; + //windows: "intranet2" should be bypassed if "*.local" is in the exceptions list (advanced settings) + QTest::newRow("intranet2") << (int)QNetworkProxyQuery::UrlRequest << QUrl("http://qt-test-server.local") << QString() << QString() << 0 << 0; + QTest::newRow("https") << (int)QNetworkProxyQuery::UrlRequest << QUrl("https://qt-project.org") << QString() << QString() << 0 << (int)QNetworkProxy::TunnelingCapability; + QTest::newRow("ftp") << (int)QNetworkProxyQuery::UrlRequest << QUrl("ftp://qt-project.org") << QString() << QString() << 0 << 0; + + //TCP + QTest::newRow("imap") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString() << QString("qt-project.org") << 0 << (int)QNetworkProxy::TunnelingCapability; + QTest::newRow("autobind-server") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString() << QString() << 0 << (int)QNetworkProxy::ListeningCapability; + QTest::newRow("web-server") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString() << QString() << 80 << (int)QNetworkProxy::ListeningCapability; + + //UDP + QTest::newRow("udp") << (int)QNetworkProxyQuery::UdpSocket << QUrl() << QString() << QString() << 0 << (int)QNetworkProxy::UdpTunnelingCapability; + + //Protocol tags + QTest::newRow("http-tag") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString("http") << QString("qt-project.org") << 80 << (int)QNetworkProxy::TunnelingCapability; + QTest::newRow("ftp-tag") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString("ftp") << QString("qt-project.org") << 21 << (int)QNetworkProxy::TunnelingCapability; + QTest::newRow("https-tag") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString("https") << QString("qt-project.org") << 443 << (int)QNetworkProxy::TunnelingCapability; +#ifdef Q_OS_WIN + //in Qt 4.8, "socks" would get the socks proxy, but we dont want to enforce that for all platforms + QTest::newRow("socks-tag") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString("socks") << QString("qt-project.org") << 21 << (int)(QNetworkProxy::TunnelingCapability | QNetworkProxy::ListeningCapability); +#endif + //windows: ssh is not a tag provided by the os, but any tunneling proxy is acceptable + QTest::newRow("ssh-tag") << (int)QNetworkProxyQuery::TcpSocket << QUrl() << QString("ssh") << QString("qt-project.org") << 22 << (int)QNetworkProxy::TunnelingCapability; + + //Server protocol tags (ftp/http proxies are no good, we need socks or nothing) + QTest::newRow("http-server-tag") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString("http") << QString() << 80 << (int)QNetworkProxy::ListeningCapability; + QTest::newRow("ftp-server-tag") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString("ftp") << QString() << 21 << (int)QNetworkProxy::ListeningCapability; + QTest::newRow("imap-server-tag") << (int)QNetworkProxyQuery::TcpServer << QUrl() << QString("imap") << QString() << 143 << (int)QNetworkProxy::ListeningCapability; + + //UDP protocol tag + QTest::newRow("sip-udp-tag") << (int)QNetworkProxyQuery::UdpSocket << QUrl() << QString("sip") << QString("qt-project.org") << 5061 << (int)QNetworkProxy::UdpTunnelingCapability; +} + void tst_QNetworkProxyFactory::systemProxyForQuery() const { - QNetworkProxyQuery query(QUrl(QString("http://www.abc.com")), QNetworkProxyQuery::UrlRequest); - QList systemProxyList = QNetworkProxyFactory::systemProxyForQuery(query); - bool pass = true; - QNetworkProxy proxy; + QFETCH(int, type); + QFETCH(QUrl, url); + QFETCH(QString, tag); + QFETCH(QString, hostName); + QFETCH(int, port); + QFETCH(int, requiredCapabilities); - QList nativeProxyList; - nativeProxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QString("test.proxy.com"), 8080) << QNetworkProxy::NoProxy; + QNetworkProxyQuery query; - foreach (proxy, systemProxyList) { - if (!nativeProxyList.contains(proxy)) { - qWarning() << "System proxy not found in native proxy list: " << - formatProxyName(proxy); - pass = false; - } + switch (type) { + case QNetworkProxyQuery::UrlRequest: + query = QNetworkProxyQuery(url); + break; + case QNetworkProxyQuery::TcpSocket: + case QNetworkProxyQuery::UdpSocket: + query = QNetworkProxyQuery(hostName, port, tag, QNetworkProxyQuery::QueryType(type)); + break; + case QNetworkProxyQuery::TcpServer: + query = QNetworkProxyQuery(quint16(port), tag); + break; } - foreach (proxy, nativeProxyList) { - if (!systemProxyList.contains(proxy)) { - qWarning() << "Native proxy not found in system proxy list: " << - formatProxyName(proxy); - pass = false; - } - } + QElapsedTimer sw; + sw.start(); + QList systemProxyList = QNetworkProxyFactory::systemProxyForQuery(query); + qDebug() << sw.elapsed() << "ms"; + QVERIFY(!systemProxyList.isEmpty()); + + // for manual comparison with system + qDebug() << systemProxyList; - if (!pass) - QFAIL("One or more system proxy lookup failures occurred."); + foreach (const QNetworkProxy &proxy, systemProxyList) { + QVERIFY((requiredCapabilities == 0) || (proxy.capabilities() & requiredCapabilities)); + } } #ifndef QT_NO_BEARERMANAGEMENT -- cgit v1.2.3 From 4bdc7e6f8b5eb13a0c8012674877eacb2e92344e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 2 Mar 2012 19:10:41 +0000 Subject: Mark unstable windows network tests This is unfortunately still "most of them", because of QTBUG-24451 however some of the unit tests are still possible to test stably. Also skipped test cases which would hang forever due to QTBUG-24451. Bearer tests are not run, because they pass when test machine has no wireless LAN, but fail or hang if it does (QTBUG-24503) Change-Id: Icf99d45707102d2ef9219ed0b5ad521605716219 Reviewed-by: Sergio Ahumada Reviewed-by: Rohan McGovern --- .../auto/network/kernel/qnetworkinterface/qnetworkinterface.pro | 2 ++ tests/auto/network/network.pro | 4 ++++ tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp | 9 +++++++++ tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 6 ++++++ .../qsslsocket_onDemandCertificates_member.pro | 2 ++ .../qsslsocket_onDemandCertificates_static.pro | 2 ++ 6 files changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro b/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro index 694dec2ed7..ba401579a6 100644 --- a/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro +++ b/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro @@ -3,3 +3,5 @@ TARGET = tst_qnetworkinterface SOURCES += tst_qnetworkinterface.cpp QT = core network testlib + +win32:CONFIG+=insignificant_test # QTBUG-24451 - localAddress() diff --git a/tests/auto/network/network.pro b/tests/auto/network/network.pro index 3eafd7df70..2048d14dc8 100644 --- a/tests/auto/network/network.pro +++ b/tests/auto/network/network.pro @@ -6,3 +6,7 @@ SUBDIRS=\ ssl \ socket \ +win32 { + socket.CONFIG += no_check_target # QTBUG-24451 - all socket tests require waitForX + bearer.CONFIG += no_check_target # QTBUG-24503 - these tests fail if machine has a WLAN adaptor +} diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 5395c7c28b..3c7c3a3da0 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -1475,6 +1475,9 @@ void tst_QTcpSocket::waitForBytesWritten() //---------------------------------------------------------------------------------- void tst_QTcpSocket::waitForBytesWrittenMinusOne() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-24451 - indefinite wait may hang"); +#endif QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 80); QVERIFY(socket->waitForConnected(10000)); @@ -1500,6 +1503,9 @@ void tst_QTcpSocket::waitForReadyRead() //---------------------------------------------------------------------------------- void tst_QTcpSocket::waitForReadyReadMinusOne() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-24451 - indefinite wait may hang"); +#endif QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->write("GET / HTTP/1.0\r\n\r\n"); @@ -2102,6 +2108,9 @@ void tst_QTcpSocket::abortiveClose_abortSlot() //---------------------------------------------------------------------------------- void tst_QTcpSocket::localAddressEmptyOnBSD() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-24451 - indefinite wait may hang"); +#endif QFETCH_GLOBAL(bool, setProxy); if (setProxy) return; //proxy not useful for localhost test case diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index cdb397ccd4..2f9ed0d089 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1157,6 +1157,9 @@ void tst_QSslSocket::waitForEncrypted() void tst_QSslSocket::waitForEncryptedMinusOne() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-24451 - indefinite wait may hang"); +#endif if (!QSslSocket::supportsSsl()) return; @@ -1663,6 +1666,9 @@ protected: void tst_QSslSocket::waitForMinusOne() { +#ifdef Q_OS_WIN + QSKIP("QTBUG-24451 - indefinite wait may hang"); +#endif QFETCH_GLOBAL(bool, setProxy); if (setProxy) return; diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro index 33b55b4638..5aeb0e48ac 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_member/qsslsocket_onDemandCertificates_member.pro @@ -22,3 +22,5 @@ wince* { } requires(contains(QT_CONFIG,private_tests)) + +win32:CONFIG+=insignificant_test # QTBUG-24451 - all diff --git a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro index 8a500a3d99..3955ea106c 100644 --- a/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro +++ b/tests/auto/network/ssl/qsslsocket_onDemandCertificates_static/qsslsocket_onDemandCertificates_static.pro @@ -22,3 +22,5 @@ wince* { } requires(contains(QT_CONFIG,private_tests)) + +win32:CONFIG+=insignificant_test # QTBUG-24451 - all -- cgit v1.2.3 From d81b065bb3cea85a98f2299354d05ce440032f1f Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 29 Feb 2012 15:43:42 +1000 Subject: testlib: Improve verbose and XPASS output Previously, verbose (-v2) and XPASS test output showed all QCOMPAREs as "COMPARE()", making it impossible to see what was compared and difficult to match the output to the source of a test containing many calls to QCOMPARE. This commit changes testlib's internal compare_helper API so that string representations of the compared expressions are always passed to QTestResult::compare() when available, and can thus be shown in the verbose and XPASS output. The XPASS output has also been changed to state explicitly that the comparison succeeded unexpectedly, bringing it in line with the XPASS output resulting from a call to QVERIFY. This commit also changes all calls to compare_helper() to call the eight-argument version of the function, which simplifies much of the calling code. The now obsolete four-argument version of compare_helper() has been changed to output a warning that it is obsolete. It will be removed once other modules have had some time to catch up. The improved XPASS and verbose output is demonstrated by the expectfail and verbose2 selftests. Change-Id: I8baa46d5dd30e6c43b26f366c34dc5b64aab5f7c Reviewed-by: Rohan McGovern --- .../testlib/selftests/expected_expectfail.lightxml | 2 +- .../auto/testlib/selftests/expected_expectfail.txt | 2 +- .../auto/testlib/selftests/expected_expectfail.xml | 2 +- .../testlib/selftests/expected_expectfail.xunitxml | 2 +- .../testlib/selftests/expected_verbose2.lightxml | 12 +++++------ tests/auto/testlib/selftests/expected_verbose2.txt | 12 +++++------ tests/auto/testlib/selftests/expected_verbose2.xml | 12 +++++------ .../testlib/selftests/expected_verbose2.xunitxml | 24 +++++++++++----------- tests/auto/testlib/selftests/tst_selftests.cpp | 2 +- 9 files changed, 35 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/tests/auto/testlib/selftests/expected_expectfail.lightxml b/tests/auto/testlib/selftests/expected_expectfail.lightxml index 34f4f1e70b..55bd9578a8 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.lightxml +++ b/tests/auto/testlib/selftests/expected_expectfail.lightxml @@ -132,7 +132,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_expectfail.txt b/tests/auto/testlib/selftests/expected_expectfail.txt index bd4e2172d6..6028b5ddfe 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.txt +++ b/tests/auto/testlib/selftests/expected_expectfail.txt @@ -47,7 +47,7 @@ XPASS : tst_ExpectFail::xpass() 'true' returned TRUE unexpectedly. () XPASS : tst_ExpectFail::xpassDataDrivenWithQVerify(XPass) 'true' returned TRUE unexpectedly. () Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(250)] PASS : tst_ExpectFail::xpassDataDrivenWithQVerify(Pass) -XPASS : tst_ExpectFail::xpassDataDrivenWithQCompare(XPass) COMPARE() +XPASS : tst_ExpectFail::xpassDataDrivenWithQCompare(XPass) QCOMPARE(1, 1) returned TRUE unexpectedly. Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/expectfail/tst_expectfail.cpp(271)] PASS : tst_ExpectFail::xpassDataDrivenWithQCompare(Pass) PASS : tst_ExpectFail::cleanupTestCase() diff --git a/tests/auto/testlib/selftests/expected_expectfail.xml b/tests/auto/testlib/selftests/expected_expectfail.xml index ff870a6a68..e3200b00d6 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.xml +++ b/tests/auto/testlib/selftests/expected_expectfail.xml @@ -134,7 +134,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_expectfail.xunitxml b/tests/auto/testlib/selftests/expected_expectfail.xunitxml index 6040af41ff..45c260c77f 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.xunitxml +++ b/tests/auto/testlib/selftests/expected_expectfail.xunitxml @@ -45,7 +45,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose2.lightxml b/tests/auto/testlib/selftests/expected_verbose2.lightxml index 1310f2bb09..2937adbe01 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.lightxml +++ b/tests/auto/testlib/selftests/expected_verbose2.lightxml @@ -12,7 +12,7 @@ - + @@ -23,7 +23,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -123,7 +123,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose2.txt b/tests/auto/testlib/selftests/expected_verbose2.txt index 9012a7c569..34957f4ae7 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.txt +++ b/tests/auto/testlib/selftests/expected_verbose2.txt @@ -5,18 +5,18 @@ PASS : tst_Counting::initTestCase() INFO : tst_Counting::testPassPass() entering INFO : tst_Counting::testPassPass(row 1) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] -INFO : tst_Counting::testPassPass(row 1) COMPARE() +INFO : tst_Counting::testPassPass(row 1) QCOMPARE(2 + 1, 3) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassPass(row 1) INFO : tst_Counting::testPassPass(row 2) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] -INFO : tst_Counting::testPassPass(row 2) COMPARE() +INFO : tst_Counting::testPassPass(row 2) QCOMPARE(2 + 1, 3) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassPass(row 2) INFO : tst_Counting::testPassSkip() entering INFO : tst_Counting::testPassSkip(row 1) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] -INFO : tst_Counting::testPassSkip(row 1) COMPARE() +INFO : tst_Counting::testPassSkip(row 1) QCOMPARE(2 + 1, 3) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassSkip(row 1) SKIP : tst_Counting::testPassSkip(row 2) Skipping @@ -24,7 +24,7 @@ SKIP : tst_Counting::testPassSkip(row 2) Skipping INFO : tst_Counting::testPassFail() entering INFO : tst_Counting::testPassFail(row 1) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] -INFO : tst_Counting::testPassFail(row 1) COMPARE() +INFO : tst_Counting::testPassFail(row 1) QCOMPARE(2 + 1, 3) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testPassFail(row 1) INFO : tst_Counting::testPassFail(row 2) QVERIFY(false) @@ -36,7 +36,7 @@ SKIP : tst_Counting::testSkipPass(row 1) Skipping Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(118)] INFO : tst_Counting::testSkipPass(row 2) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] -INFO : tst_Counting::testSkipPass(row 2) COMPARE() +INFO : tst_Counting::testSkipPass(row 2) QCOMPARE(2 + 1, 3) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testSkipPass(row 2) INFO : tst_Counting::testSkipSkip() entering @@ -58,7 +58,7 @@ FAIL! : tst_Counting::testFailPass(row 1) 'false' returned FALSE. () Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(115)] INFO : tst_Counting::testFailPass(row 2) QVERIFY(true) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(111)] -INFO : tst_Counting::testFailPass(row 2) COMPARE() +INFO : tst_Counting::testFailPass(row 2) QCOMPARE(2 + 1, 3) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/counting/tst_counting.cpp(112)] PASS : tst_Counting::testFailPass(row 2) INFO : tst_Counting::testFailSkip() entering diff --git a/tests/auto/testlib/selftests/expected_verbose2.xml b/tests/auto/testlib/selftests/expected_verbose2.xml index 693ef2b187..d181c6d215 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.xml +++ b/tests/auto/testlib/selftests/expected_verbose2.xml @@ -14,7 +14,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -80,7 +80,7 @@ - + @@ -125,7 +125,7 @@ - + diff --git a/tests/auto/testlib/selftests/expected_verbose2.xunitxml b/tests/auto/testlib/selftests/expected_verbose2.xunitxml index 8b9ed5257d..a774cb9d9f 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.xunitxml +++ b/tests/auto/testlib/selftests/expected_verbose2.xunitxml @@ -7,25 +7,25 @@ - + - + - + - + - + @@ -40,7 +40,7 @@ - + @@ -70,25 +70,25 @@ - + - + - + - + - + - + diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 5d216992d7..a9ec4e31f2 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -104,7 +104,7 @@ inline bool qCompare } if (qAbs(qreal(r1.total) - qreal(r2.total)) <= qreal(r1.total)*variance) { - return compare_helper(true, "COMPARE()", file, line); + return compare_helper(true, 0, 0, 0, actual, expected, file, line); } // Whoops, didn't match. Compare the whole string for the most useful failure message. -- cgit v1.2.3 From 8854b74cf4511c758b998abfc269cc1f3a11d4a1 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 7 Mar 2012 16:17:46 +1000 Subject: selftests: Improve reporting of problems with loading expected output If the expected output file was missing (e.g. not included in selftests.qrc), tst_selftests would trigger an assert inside QList by calling QList::at() on an empty list. Make tst_selftests detect this error instead and give a meaningful error message. When loading expected output for the crashes selftest, where there are several alternative versions of the expected output, the code reused the "exp" variable when loading the alternative test output files. This caused the last file loaded to be used unintentionally if none of the alternative files had the correct number of lines. Use a different variable so that exp remains empty if none of the alternatives are valid and a failure can be reported. Change-Id: I35b2a3d905d069d3ee8dcb1447836eb68d5c8612 Reviewed-by: Rohan McGovern --- tests/auto/testlib/selftests/tst_selftests.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index a9ec4e31f2..97458abfbf 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -571,12 +571,13 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge // the actual output. if (exp.count() == 0) { QList > expArr; + QList tmp; int i = 1; do { - exp = expectedResult(subdir + QString("_%1").arg(i++), logger); - if (exp.count()) - expArr += exp; - } while (exp.count()); + tmp = expectedResult(subdir + QString("_%1").arg(i++), logger); + if (tmp.count()) + expArr += tmp; + } while (tmp.count()); for (int j = 0; j < expArr.count(); ++j) { if (res.count() == expArr.at(j).count()) { @@ -584,12 +585,24 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge break; } } + + if (expArr.count()) { + QVERIFY2(exp.count(), + qPrintable(QString::fromLatin1("None of the expected output files for " + "%1 format has matching line count.") + .arg(loggers.at(n)))); + } } else { QVERIFY2(res.count() == exp.count(), qPrintable(QString::fromLatin1("Mismatch in line count: %1 != %2 (%3).") .arg(res.count()).arg(exp.count()).arg(loggers.at(n)))); } + // By this point, we should have loaded a non-empty expected data file. + QVERIFY2(exp.count(), + qPrintable(QString::fromLatin1("Expected test data for %1 format is empty or not found.") + .arg(loggers.at(n)))); + // For xml output formats, verify that the log is valid XML. if (logFormat(logger) == "xunitxml" || logFormat(logger) == "xml" || logFormat(logger) == "lightxml") { QByteArray xml(actualOutputs[n]); -- cgit v1.2.3 From b55ed97e7967fca675fa43a8c0cd7445bbbbb493 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 Mar 2012 13:39:57 +0100 Subject: Call updateAccessibility with the right index. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Qt 4 index 0 was the widget itself. With the cleanup of child index this now changed. The default constructor uses -1 as parameter to signify that the widget is the cause, not a child. Change-Id: I329a1cc91bf2d1d1d8534739acbddfe107f40364 Reviewed-by: Jan-Arve Sæther --- .../other/qaccessibility/tst_qaccessibility.cpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4c370bebc7..3e3fce2e1c 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -415,7 +415,7 @@ void tst_QAccessibility::eventTest() button->setObjectName(QString("Olaf")); button->show(); - QVERIFY_EVENT(button, 0, QAccessible::ObjectShow); + QVERIFY_EVENT(button, -1, QAccessible::ObjectShow); button->setFocus(Qt::MouseFocusReason); QTestAccessibility::clearEvents(); QTest::mouseClick(button, Qt::LeftButton, 0); @@ -423,12 +423,12 @@ void tst_QAccessibility::eventTest() QVERIFY_EVENT(button, 0, QAccessible::StateChanged); button->setAccessibleName("Olaf the second"); - QVERIFY_EVENT(button, 0, QAccessible::NameChanged); + QVERIFY_EVENT(button, -1, QAccessible::NameChanged); button->setAccessibleDescription("This is a button labeled Olaf"); - QVERIFY_EVENT(button, 0, QAccessible::DescriptionChanged); + QVERIFY_EVENT(button, -1, QAccessible::DescriptionChanged); button->hide(); - QVERIFY_EVENT(button, 0, QAccessible::ObjectHide); + QVERIFY_EVENT(button, -1, QAccessible::ObjectHide); delete button; } @@ -732,16 +732,16 @@ void tst_QAccessibility::hideShowTest() window->show(); QVERIFY(!state(window).invisible); QVERIFY(!state(child).invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, 0, QAccessible::ObjectShow))); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, 0, QAccessible::ObjectShow))); + QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, -1, QAccessible::ObjectShow))); + QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, -1, QAccessible::ObjectShow))); QTestAccessibility::clearEvents(); // hide() and veryfy that both window and child are invisible and get ObjectHide events. window->hide(); QVERIFY(state(window).invisible); QVERIFY(state(child).invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, 0, QAccessible::ObjectHide))); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, 0, QAccessible::ObjectHide))); + QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, -1, QAccessible::ObjectHide))); + QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, -1, QAccessible::ObjectHide))); QTestAccessibility::clearEvents(); delete window; @@ -822,7 +822,7 @@ void tst_QAccessibility::mainWindowTest() QLatin1String name = QLatin1String("I am the main window"); mw->setWindowTitle(name); QTest::qWaitForWindowShown(mw); - QVERIFY_EVENT(mw, 0, QAccessible::ObjectShow); + QVERIFY_EVENT(mw, -1, QAccessible::ObjectShow); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw); QCOMPARE(interface->text(QAccessible::Name), name); @@ -1052,12 +1052,12 @@ void tst_QAccessibility::scrollBarTest() scrollBar->resize(200, 50); scrollBar->show(); QVERIFY(!scrollBarInterface->state().invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, 0, QAccessible::ObjectShow))); + QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, -1, QAccessible::ObjectShow))); QTestAccessibility::clearEvents(); scrollBar->hide(); QVERIFY(scrollBarInterface->state().invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, 0, QAccessible::ObjectHide))); + QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, -1, QAccessible::ObjectHide))); QTestAccessibility::clearEvents(); // Test that the left/right subcontrols are set to unavailable when the scrollBar is at the minimum/maximum. @@ -1498,7 +1498,7 @@ void tst_QAccessibility::spinBoxTest() QTest::keyPress(spinBox, Qt::Key_Up); QTest::qWait(200); EventList events = QTestAccessibility::events(); - QTestAccessibilityEvent expectedEvent(spinBox, 0, (int)QAccessible::ValueChanged); + QTestAccessibilityEvent expectedEvent(spinBox, -1, (int)QAccessible::ValueChanged); QVERIFY(events.contains(expectedEvent)); delete spinBox; QTestAccessibility::clearEvents(); @@ -1769,7 +1769,7 @@ void tst_QAccessibility::lineEditTest() le->setFocus(Qt::TabFocusReason); QTestAccessibility::clearEvents(); le2->setFocus(Qt::TabFocusReason); - QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, 0, QAccessible::Focus))); + QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, -1, QAccessible::Focus))); le->setText(QLatin1String("500")); le->setValidator(new QIntValidator()); @@ -1789,7 +1789,7 @@ void tst_QAccessibility::lineEditTest() le3->deselect(); le3->setCursorPosition(3); QCOMPARE(textIface->cursorPosition(), 3); - QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le3, 0, QAccessible::TextCaretMoved))); + QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le3, -1, QAccessible::TextCaretMoved))); QCOMPARE(textIface->selectionCount(), 0); QTestAccessibility::clearEvents(); -- cgit v1.2.3 From 84984af0e11029716a5a601869964470dff2d0be Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 26 Feb 2012 21:04:57 +0000 Subject: Remove usage of QtXml from rcc, add test Ported from QDom to QXmlStreamReader. This enables removal of QtXml classes from bootstrap. A new rcc test was added, copying the data from the QResourceFileEngine test. The new test runs rcc to create binary resources, dynamically loads them under various locales and checks that they do contain the expected files. Change-Id: I15d23dfda45de851a421156951ce2a60af4c1f7f Reviewed-by: Lars Knoll Reviewed-by: hjk --- tests/auto/tools/rcc/.gitignore | 1 + .../tools/rcc/data/binary/aliasdir/aliasdir.txt | 1 + .../tools/rcc/data/binary/aliasdir/compressme.txt | 322 +++++++++++++++++++++ tests/auto/tools/rcc/data/binary/aliases.expected | 4 + tests/auto/tools/rcc/data/binary/aliases.qrc | 10 + .../tools/rcc/data/binary/allfeatures.de.expected | 13 + .../rcc/data/binary/allfeatures.de_CH.expected | 13 + .../tools/rcc/data/binary/allfeatures.expected | 13 + .../tools/rcc/data/binary/allfeatures.ko.expected | 13 + .../auto/tools/rcc/data/binary/allfeatures.locale | 3 + tests/auto/tools/rcc/data/binary/allfeatures.qrc | 30 ++ tests/auto/tools/rcc/data/binary/blahblah.txt | 1 + tests/auto/tools/rcc/data/binary/currentdir.txt | 1 + tests/auto/tools/rcc/data/binary/currentdir2.txt | 1 + .../auto/tools/rcc/data/binary/locale.de.expected | 5 + .../tools/rcc/data/binary/locale.de_CH.expected | 6 + tests/auto/tools/rcc/data/binary/locale.expected | 4 + .../auto/tools/rcc/data/binary/locale.it.expected | 6 + tests/auto/tools/rcc/data/binary/locale.locale | 3 + tests/auto/tools/rcc/data/binary/locale.qrc | 30 ++ tests/auto/tools/rcc/data/binary/multiple.expected | 5 + tests/auto/tools/rcc/data/binary/multiple.qrc | 10 + .../tools/rcc/data/binary/otherdir/otherdir.txt | 1 + tests/auto/tools/rcc/data/binary/prefixes.expected | 6 + tests/auto/tools/rcc/data/binary/prefixes.qrc | 21 ++ tests/auto/tools/rcc/data/binary/search_file.txt | 1 + .../rcc/data/binary/searchpath1/search_file.txt | 1 + .../rcc/data/binary/searchpath2/search_file.txt | 1 + tests/auto/tools/rcc/data/binary/simple.expected | 3 + tests/auto/tools/rcc/data/binary/simple.qrc | 7 + tests/auto/tools/rcc/data/binary/subdir/subdir.txt | 1 + tests/auto/tools/rcc/data/binary/test/german.txt | 1 + .../auto/tools/rcc/data/binary/test/test/test1.txt | 1 + .../auto/tools/rcc/data/binary/test/test/test2.txt | 1 + tests/auto/tools/rcc/data/binary/test/testdir.txt | 1 + tests/auto/tools/rcc/data/binary/test/testdir2.txt | 1 + tests/auto/tools/rcc/data/images.bin.expected | Bin 663 -> 0 bytes tests/auto/tools/rcc/data/images.expected | 126 -------- tests/auto/tools/rcc/data/images.qrc | 7 - tests/auto/tools/rcc/data/images/circle.png | Bin 165 -> 0 bytes .../auto/tools/rcc/data/images/images.bin.expected | Bin 0 -> 663 bytes tests/auto/tools/rcc/data/images/images.expected | 126 ++++++++ tests/auto/tools/rcc/data/images/images.qrc | 7 + tests/auto/tools/rcc/data/images/images/circle.png | Bin 0 -> 165 bytes tests/auto/tools/rcc/data/images/images/square.png | Bin 0 -> 94 bytes .../rcc/data/images/images/subdir/triangle.png | Bin 0 -> 170 bytes tests/auto/tools/rcc/data/images/square.png | Bin 94 -> 0 bytes .../auto/tools/rcc/data/images/subdir/triangle.png | Bin 170 -> 0 bytes tests/auto/tools/rcc/data/parentdir.txt | 1 + tests/auto/tools/rcc/rcc.pro | 7 - tests/auto/tools/rcc/tst_rcc.cpp | 212 +++++++++++++- 51 files changed, 879 insertions(+), 149 deletions(-) create mode 100644 tests/auto/tools/rcc/data/binary/aliasdir/aliasdir.txt create mode 100644 tests/auto/tools/rcc/data/binary/aliasdir/compressme.txt create mode 100644 tests/auto/tools/rcc/data/binary/aliases.expected create mode 100644 tests/auto/tools/rcc/data/binary/aliases.qrc create mode 100644 tests/auto/tools/rcc/data/binary/allfeatures.de.expected create mode 100644 tests/auto/tools/rcc/data/binary/allfeatures.de_CH.expected create mode 100644 tests/auto/tools/rcc/data/binary/allfeatures.expected create mode 100644 tests/auto/tools/rcc/data/binary/allfeatures.ko.expected create mode 100644 tests/auto/tools/rcc/data/binary/allfeatures.locale create mode 100644 tests/auto/tools/rcc/data/binary/allfeatures.qrc create mode 100644 tests/auto/tools/rcc/data/binary/blahblah.txt create mode 100644 tests/auto/tools/rcc/data/binary/currentdir.txt create mode 100644 tests/auto/tools/rcc/data/binary/currentdir2.txt create mode 100644 tests/auto/tools/rcc/data/binary/locale.de.expected create mode 100644 tests/auto/tools/rcc/data/binary/locale.de_CH.expected create mode 100644 tests/auto/tools/rcc/data/binary/locale.expected create mode 100644 tests/auto/tools/rcc/data/binary/locale.it.expected create mode 100644 tests/auto/tools/rcc/data/binary/locale.locale create mode 100644 tests/auto/tools/rcc/data/binary/locale.qrc create mode 100644 tests/auto/tools/rcc/data/binary/multiple.expected create mode 100644 tests/auto/tools/rcc/data/binary/multiple.qrc create mode 100644 tests/auto/tools/rcc/data/binary/otherdir/otherdir.txt create mode 100644 tests/auto/tools/rcc/data/binary/prefixes.expected create mode 100644 tests/auto/tools/rcc/data/binary/prefixes.qrc create mode 100644 tests/auto/tools/rcc/data/binary/search_file.txt create mode 100644 tests/auto/tools/rcc/data/binary/searchpath1/search_file.txt create mode 100644 tests/auto/tools/rcc/data/binary/searchpath2/search_file.txt create mode 100644 tests/auto/tools/rcc/data/binary/simple.expected create mode 100644 tests/auto/tools/rcc/data/binary/simple.qrc create mode 100644 tests/auto/tools/rcc/data/binary/subdir/subdir.txt create mode 100644 tests/auto/tools/rcc/data/binary/test/german.txt create mode 100644 tests/auto/tools/rcc/data/binary/test/test/test1.txt create mode 100644 tests/auto/tools/rcc/data/binary/test/test/test2.txt create mode 100644 tests/auto/tools/rcc/data/binary/test/testdir.txt create mode 100644 tests/auto/tools/rcc/data/binary/test/testdir2.txt delete mode 100644 tests/auto/tools/rcc/data/images.bin.expected delete mode 100644 tests/auto/tools/rcc/data/images.expected delete mode 100644 tests/auto/tools/rcc/data/images.qrc delete mode 100644 tests/auto/tools/rcc/data/images/circle.png create mode 100644 tests/auto/tools/rcc/data/images/images.bin.expected create mode 100644 tests/auto/tools/rcc/data/images/images.expected create mode 100644 tests/auto/tools/rcc/data/images/images.qrc create mode 100644 tests/auto/tools/rcc/data/images/images/circle.png create mode 100644 tests/auto/tools/rcc/data/images/images/square.png create mode 100644 tests/auto/tools/rcc/data/images/images/subdir/triangle.png delete mode 100644 tests/auto/tools/rcc/data/images/square.png delete mode 100644 tests/auto/tools/rcc/data/images/subdir/triangle.png create mode 100644 tests/auto/tools/rcc/data/parentdir.txt (limited to 'tests') diff --git a/tests/auto/tools/rcc/.gitignore b/tests/auto/tools/rcc/.gitignore index 1da39dbd88..6d81961fdb 100644 --- a/tests/auto/tools/rcc/.gitignore +++ b/tests/auto/tools/rcc/.gitignore @@ -1 +1,2 @@ tst_rcc +data/binary/*.rcc diff --git a/tests/auto/tools/rcc/data/binary/aliasdir/aliasdir.txt b/tests/auto/tools/rcc/data/binary/aliasdir/aliasdir.txt new file mode 100644 index 0000000000..dcf7937f0a --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/aliasdir/aliasdir.txt @@ -0,0 +1 @@ +"This is a korean text file" diff --git a/tests/auto/tools/rcc/data/binary/aliasdir/compressme.txt b/tests/auto/tools/rcc/data/binary/aliasdir/compressme.txt new file mode 100644 index 0000000000..bd596cdacd --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/aliasdir/compressme.txt @@ -0,0 +1,322 @@ +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 diff --git a/tests/auto/tools/rcc/data/binary/aliases.expected b/tests/auto/tools/rcc/data/binary/aliases.expected new file mode 100644 index 0000000000..693b633717 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/aliases.expected @@ -0,0 +1,4 @@ +currentdir.txt currentdir.txt +alias.txt currentdir2.txt +otheralias.txt blahblah.txt +alias3 ../parentdir.txt diff --git a/tests/auto/tools/rcc/data/binary/aliases.qrc b/tests/auto/tools/rcc/data/binary/aliases.qrc new file mode 100644 index 0000000000..ac049c3e65 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/aliases.qrc @@ -0,0 +1,10 @@ + + + currentdir.txt + currentdir2.txt + blahblah.txt + + + ../parentdir.txt + + diff --git a/tests/auto/tools/rcc/data/binary/allfeatures.de.expected b/tests/auto/tools/rcc/data/binary/allfeatures.de.expected new file mode 100644 index 0000000000..fa918d0039 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/allfeatures.de.expected @@ -0,0 +1,13 @@ +/test/abc/123/+++/currentdir.txt currentdir.txt +/test/abc/123/+++/currentdir2.txt ./currentdir2.txt +/test/abc/123/+++/parentdir.txt ../parentdir.txt +/test/abc/123/+++/subdir/subdir.txt subdir/subdir.txt +/search_file.txt search_file.txt +/searchpath1/search_file.txt searchpath1/search_file.txt +/searchpath2/search_file.txt searchpath2/search_file.txt +test/testdir.txt test/testdir.txt +otherdir/otherdir.txt otherdir/otherdir.txt +aliasdir/aliasdir.txt test/german.txt +test/test/test1.txt test/test/test1.txt +test/test/test2.txt test/test/test2.txt +withoutslashes/blahblah.txt blahblah.txt diff --git a/tests/auto/tools/rcc/data/binary/allfeatures.de_CH.expected b/tests/auto/tools/rcc/data/binary/allfeatures.de_CH.expected new file mode 100644 index 0000000000..59960d4187 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/allfeatures.de_CH.expected @@ -0,0 +1,13 @@ +/test/abc/123/+++/currentdir.txt currentdir.txt +/test/abc/123/+++/currentdir2.txt ./currentdir2.txt +/test/abc/123/+++/parentdir.txt ../parentdir.txt +/test/abc/123/+++/subdir/subdir.txt subdir/subdir.txt +/search_file.txt search_file.txt +/searchpath1/search_file.txt searchpath1/search_file.txt +/searchpath2/search_file.txt searchpath2/search_file.txt +test/testdir.txt test/testdir.txt +otherdir/otherdir.txt otherdir/otherdir.txt +aliasdir/aliasdir.txt aliasdir/compressme.txt +test/test/test1.txt test/test/test1.txt +test/test/test2.txt test/test/test2.txt +withoutslashes/blahblah.txt blahblah.txt diff --git a/tests/auto/tools/rcc/data/binary/allfeatures.expected b/tests/auto/tools/rcc/data/binary/allfeatures.expected new file mode 100644 index 0000000000..831120c053 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/allfeatures.expected @@ -0,0 +1,13 @@ +/test/abc/123/+++/currentdir.txt currentdir.txt +/test/abc/123/+++/currentdir2.txt ./currentdir2.txt +/test/abc/123/+++/parentdir.txt ../parentdir.txt +/test/abc/123/+++/subdir/subdir.txt subdir/subdir.txt +/search_file.txt search_file.txt +/searchpath1/search_file.txt searchpath1/search_file.txt +/searchpath2/search_file.txt searchpath2/search_file.txt +test/testdir.txt test/testdir.txt +otherdir/otherdir.txt otherdir/otherdir.txt +aliasdir/aliasdir.txt test/testdir2.txt +test/test/test1.txt test/test/test1.txt +test/test/test2.txt test/test/test2.txt +withoutslashes/blahblah.txt blahblah.txt diff --git a/tests/auto/tools/rcc/data/binary/allfeatures.ko.expected b/tests/auto/tools/rcc/data/binary/allfeatures.ko.expected new file mode 100644 index 0000000000..80b42c378e --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/allfeatures.ko.expected @@ -0,0 +1,13 @@ +/test/abc/123/+++/currentdir.txt currentdir.txt +/test/abc/123/+++/currentdir2.txt ./currentdir2.txt +/test/abc/123/+++/parentdir.txt ../parentdir.txt +/test/abc/123/+++/subdir/subdir.txt subdir/subdir.txt +/search_file.txt search_file.txt +/searchpath1/search_file.txt searchpath1/search_file.txt +/searchpath2/search_file.txt searchpath2/search_file.txt +test/testdir.txt test/testdir.txt +otherdir/otherdir.txt otherdir/otherdir.txt +aliasdir/aliasdir.txt aliasdir/aliasdir.txt +test/test/test1.txt test/test/test1.txt +test/test/test2.txt test/test/test2.txt +withoutslashes/blahblah.txt blahblah.txt diff --git a/tests/auto/tools/rcc/data/binary/allfeatures.locale b/tests/auto/tools/rcc/data/binary/allfeatures.locale new file mode 100644 index 0000000000..a6fcbab771 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/allfeatures.locale @@ -0,0 +1,3 @@ +ko +de_CH +de diff --git a/tests/auto/tools/rcc/data/binary/allfeatures.qrc b/tests/auto/tools/rcc/data/binary/allfeatures.qrc new file mode 100644 index 0000000000..1b88b1f2cd --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/allfeatures.qrc @@ -0,0 +1,30 @@ + + + currentdir.txt + ./currentdir2.txt + ../parentdir.txt + subdir/subdir.txt + + + searchpath1/search_file.txt + searchpath2/search_file.txt + search_file.txt + + test/testdir.txt + otherdir/otherdir.txt + test/testdir2.txt + test/test + + + aliasdir/aliasdir.txt + + + aliasdir/compressme.txt + + + test/german.txt + + + blahblah.txt + + diff --git a/tests/auto/tools/rcc/data/binary/blahblah.txt b/tests/auto/tools/rcc/data/binary/blahblah.txt new file mode 100644 index 0000000000..19f0805d8d --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/blahblah.txt @@ -0,0 +1 @@ +qwerty diff --git a/tests/auto/tools/rcc/data/binary/currentdir.txt b/tests/auto/tools/rcc/data/binary/currentdir.txt new file mode 100644 index 0000000000..65f1f43def --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/currentdir.txt @@ -0,0 +1 @@ +"This is the current dir" diff --git a/tests/auto/tools/rcc/data/binary/currentdir2.txt b/tests/auto/tools/rcc/data/binary/currentdir2.txt new file mode 100644 index 0000000000..7d89108011 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/currentdir2.txt @@ -0,0 +1 @@ +"This is also the current dir" diff --git a/tests/auto/tools/rcc/data/binary/locale.de.expected b/tests/auto/tools/rcc/data/binary/locale.de.expected new file mode 100644 index 0000000000..649e56be68 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/locale.de.expected @@ -0,0 +1,5 @@ +currentdir.txt currentdir.txt +currentdir2.txt currentdir2.txt +search_file.txt search_file.txt +/root/test/testdir.txt test/testdir.txt +test/testdir2.txt test/testdir2.txt diff --git a/tests/auto/tools/rcc/data/binary/locale.de_CH.expected b/tests/auto/tools/rcc/data/binary/locale.de_CH.expected new file mode 100644 index 0000000000..55b57f44d1 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/locale.de_CH.expected @@ -0,0 +1,6 @@ +currentdir.txt blahblah.txt +currentdir2.txt currentdir2.txt +search_file.txt search_file.txt +/root/test/testdir.txt test/testdir.txt +test/testdir2.txt test/testdir2.txt +parentdir.txt ../parentdir.txt diff --git a/tests/auto/tools/rcc/data/binary/locale.expected b/tests/auto/tools/rcc/data/binary/locale.expected new file mode 100644 index 0000000000..ef693bc41d --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/locale.expected @@ -0,0 +1,4 @@ +currentdir.txt currentdir.txt +search_file.txt search_file.txt +/root/test/testdir.txt test/testdir.txt +test/testdir2.txt test/testdir2.txt diff --git a/tests/auto/tools/rcc/data/binary/locale.it.expected b/tests/auto/tools/rcc/data/binary/locale.it.expected new file mode 100644 index 0000000000..0a1066e3c4 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/locale.it.expected @@ -0,0 +1,6 @@ +currentdir.txt currentdir.txt +search_file.txt search_file.txt +/root/test/testdir.txt test/testdir.txt +test/testdir2.txt test/testdir2.txt +/root/otherdir/otherdir.txt otherdir/otherdir.txt +/root/currentdir.txt subdir/subdir.txt diff --git a/tests/auto/tools/rcc/data/binary/locale.locale b/tests/auto/tools/rcc/data/binary/locale.locale new file mode 100644 index 0000000000..828b9e437c --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/locale.locale @@ -0,0 +1,3 @@ +de +de_CH +it diff --git a/tests/auto/tools/rcc/data/binary/locale.qrc b/tests/auto/tools/rcc/data/binary/locale.qrc new file mode 100644 index 0000000000..6cef47b3a2 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/locale.qrc @@ -0,0 +1,30 @@ + + + currentdir.txt + + + currentdir2.txt + ../parentdir.txt + blahblah.txt + + + search_file.txt + + + + test/testdir.txt + + + + + test/testdir2.txt + + + + otherdir/otherdir.txt + subdir/subdir.txt + + + + + diff --git a/tests/auto/tools/rcc/data/binary/multiple.expected b/tests/auto/tools/rcc/data/binary/multiple.expected new file mode 100644 index 0000000000..6515e292f6 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/multiple.expected @@ -0,0 +1,5 @@ +blahblah.txt blahblah.txt +currentdir.txt currentdir.txt +currentdir2.txt currentdir2.txt +subdir/subdir.txt subdir/subdir.txt +otherdir/otherdir.txt otherdir/otherdir.txt diff --git a/tests/auto/tools/rcc/data/binary/multiple.qrc b/tests/auto/tools/rcc/data/binary/multiple.qrc new file mode 100644 index 0000000000..80745ac6ad --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/multiple.qrc @@ -0,0 +1,10 @@ + + + blahblah.txt + currentdir.txt + currentdir2.txt + + subdir/subdir.txt + otherdir/ + + diff --git a/tests/auto/tools/rcc/data/binary/otherdir/otherdir.txt b/tests/auto/tools/rcc/data/binary/otherdir/otherdir.txt new file mode 100644 index 0000000000..e1b430f33b --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/otherdir/otherdir.txt @@ -0,0 +1 @@ +"This is the other dir" diff --git a/tests/auto/tools/rcc/data/binary/prefixes.expected b/tests/auto/tools/rcc/data/binary/prefixes.expected new file mode 100644 index 0000000000..db07fecbbe --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/prefixes.expected @@ -0,0 +1,6 @@ +blahblah.txt blahblah.txt +/myroot/currentdir.txt currentdir.txt +/myroot/currentdir2.txt currentdir2.txt +/anotherroot/aliased.txt search_file.txt +/anotherroot/parentdir.txt ../parentdir.txt +/myroot/subdir/subdir.txt subdir/subdir.txt diff --git a/tests/auto/tools/rcc/data/binary/prefixes.qrc b/tests/auto/tools/rcc/data/binary/prefixes.qrc new file mode 100644 index 0000000000..db6b15ca0c --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/prefixes.qrc @@ -0,0 +1,21 @@ + + + blahblah.txt + + + + + currentdir.txt + + currentdir2.txt + + + + + + search_file.txt + ../parentdir.txt + + subdir/subdir.txt + + diff --git a/tests/auto/tools/rcc/data/binary/search_file.txt b/tests/auto/tools/rcc/data/binary/search_file.txt new file mode 100644 index 0000000000..d8649da39d --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/search_file.txt @@ -0,0 +1 @@ +root diff --git a/tests/auto/tools/rcc/data/binary/searchpath1/search_file.txt b/tests/auto/tools/rcc/data/binary/searchpath1/search_file.txt new file mode 100644 index 0000000000..3f31b59496 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/searchpath1/search_file.txt @@ -0,0 +1 @@ +path1 diff --git a/tests/auto/tools/rcc/data/binary/searchpath2/search_file.txt b/tests/auto/tools/rcc/data/binary/searchpath2/search_file.txt new file mode 100644 index 0000000000..8e3be1fa2e --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/searchpath2/search_file.txt @@ -0,0 +1 @@ +path2 diff --git a/tests/auto/tools/rcc/data/binary/simple.expected b/tests/auto/tools/rcc/data/binary/simple.expected new file mode 100644 index 0000000000..913a33ca46 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/simple.expected @@ -0,0 +1,3 @@ +blahblah.txt blahblah.txt +currentdir.txt currentdir.txt +currentdir2.txt currentdir2.txt diff --git a/tests/auto/tools/rcc/data/binary/simple.qrc b/tests/auto/tools/rcc/data/binary/simple.qrc new file mode 100644 index 0000000000..0d4da1909f --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/simple.qrc @@ -0,0 +1,7 @@ + + + blahblah.txt + currentdir.txt + currentdir2.txt + + diff --git a/tests/auto/tools/rcc/data/binary/subdir/subdir.txt b/tests/auto/tools/rcc/data/binary/subdir/subdir.txt new file mode 100644 index 0000000000..4506acf413 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/subdir/subdir.txt @@ -0,0 +1 @@ +"This is in the sub directory" diff --git a/tests/auto/tools/rcc/data/binary/test/german.txt b/tests/auto/tools/rcc/data/binary/test/german.txt new file mode 100644 index 0000000000..12b1cb7320 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/test/german.txt @@ -0,0 +1 @@ +Deutsch diff --git a/tests/auto/tools/rcc/data/binary/test/test/test1.txt b/tests/auto/tools/rcc/data/binary/test/test/test1.txt new file mode 100644 index 0000000000..8baef1b4ab --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/test/test/test1.txt @@ -0,0 +1 @@ +abc diff --git a/tests/auto/tools/rcc/data/binary/test/test/test2.txt b/tests/auto/tools/rcc/data/binary/test/test/test2.txt new file mode 100644 index 0000000000..24c5735c3e --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/test/test/test2.txt @@ -0,0 +1 @@ +def diff --git a/tests/auto/tools/rcc/data/binary/test/testdir.txt b/tests/auto/tools/rcc/data/binary/test/testdir.txt new file mode 100644 index 0000000000..b8cb3a8c01 --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/test/testdir.txt @@ -0,0 +1 @@ +"This is in the test directory" diff --git a/tests/auto/tools/rcc/data/binary/test/testdir2.txt b/tests/auto/tools/rcc/data/binary/test/testdir2.txt new file mode 100644 index 0000000000..dccfdc9bcf --- /dev/null +++ b/tests/auto/tools/rcc/data/binary/test/testdir2.txt @@ -0,0 +1 @@ +"This is another file in this directory" diff --git a/tests/auto/tools/rcc/data/images.bin.expected b/tests/auto/tools/rcc/data/images.bin.expected deleted file mode 100644 index cb67a25477..0000000000 Binary files a/tests/auto/tools/rcc/data/images.bin.expected and /dev/null differ diff --git a/tests/auto/tools/rcc/data/images.expected b/tests/auto/tools/rcc/data/images.expected deleted file mode 100644 index 71be819310..0000000000 --- a/tests/auto/tools/rcc/data/images.expected +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** Resource object code -** -IGNORE: ** Created: Tue Jul 15 11:17:15 2008 -IGNORE: ** by: The Resource Compiler for Qt version 4.4.2 -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include - -static const unsigned char qt_resource_data[] = { -IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/square.png - 0x0,0x0,0x0,0x5e, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x1,0x3,0x0,0x0,0x0,0x49,0xb4,0xe8,0xb7, - 0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x58,0xa8,0xff,0x8c,0x14, - 0x1f,0xab,0x0,0x0,0x0,0x13,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x0,0x81, - 0xfa,0xff,0xff,0xff,0xd,0x3e,0x2,0x4,0x0,0x8d,0x4d,0x68,0x6b,0xcf,0xb8,0x8e, - 0x86,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, -IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/circle.png - 0x0,0x0,0x0,0xa5, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4, - 0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0xd7,0x5b,0xe,0x0,0x10, - 0xc,0x44,0x51,0xcb,0xb4,0x44,0xbb,0x64,0x3,0x1e,0xd5,0x18,0x1d,0x31,0x12,0xdf, - 0xf7,0x7c,0xd1,0xa6,0xf4,0xe8,0xa9,0x93,0x8b,0x8f,0xe6,0x52,0x87,0x17,0x81,0x59, - 0x46,0xd,0x18,0x7f,0xdc,0x13,0x1e,0x40,0x62,0xe2,0x5e,0xc4,0xd1,0xf8,0x2e,0x2, - 0x12,0xb7,0x22,0xa0,0x71,0xb,0x22,0x14,0x70,0x25,0x3e,0x43,0xfc,0xd,0xb8,0x1a, - 0xef,0x21,0x4,0x10,0x40,0x0,0x3d,0x44,0x14,0x0,0x7d,0xc7,0x14,0x13,0x11,0xc5, - 0x4c,0x48,0x31,0x15,0x53,0xec,0x5,0x14,0x9b,0x11,0xc5,0x6e,0x8,0xdd,0x8e,0x1b, - 0x14,0x54,0x19,0xf3,0xa1,0x23,0xdb,0xd5,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44, - 0xae,0x42,0x60,0x82, -IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/subdir/triangle.png - 0x0,0x0,0x0,0xaa, - 0x89, - 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, - 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4, - 0x0,0x0,0x0,0x71,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0xce,0x4b,0xa,0x80,0x30, - 0x10,0x4,0xd1,0x1c,0xd3,0x23,0x7a,0xcb,0x11,0x82,0xb8,0x50,0x62,0x92,0xf9,0xd5, - 0x66,0x1a,0x7a,0x5d,0xaf,0xb5,0x5a,0xcd,0x36,0xb9,0xcf,0xc4,0x8f,0x53,0xfa,0x9, - 0xc4,0x13,0xa7,0x10,0x28,0xe0,0x13,0xcf,0x44,0xc,0xe3,0x59,0x8,0x14,0x30,0x8d, - 0x47,0x23,0x50,0xc0,0x72,0x3c,0x2,0xb1,0x1d,0xf7,0x46,0xa0,0x0,0x75,0xdc,0x3, - 0x61,0x8e,0x5b,0x11,0x28,0xc0,0x2d,0xae,0x45,0xa0,0x0,0xf7,0xf8,0xe,0x22,0x2c, - 0xbe,0x8a,0x40,0x1,0xe1,0xf1,0x3f,0x44,0x5a,0x7c,0x84,0x40,0x1,0xe9,0xf1,0x37, - 0x42,0xe0,0xd7,0xd8,0x5d,0xf,0x6f,0x97,0x11,0x88,0x38,0xa9,0x1e,0x0,0x0,0x0, - 0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, - -}; - -static const unsigned char qt_resource_name[] = { - // images - 0x0,0x6, - 0x7,0x3,0x7d,0xc3, - 0x0,0x69, - 0x0,0x6d,0x0,0x61,0x0,0x67,0x0,0x65,0x0,0x73, - // square.png - 0x0,0xa, - 0x8,0x8b,0x6,0x27, - 0x0,0x73, - 0x0,0x71,0x0,0x75,0x0,0x61,0x0,0x72,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // circle.png - 0x0,0xa, - 0xa,0x2d,0x16,0x47, - 0x0,0x63, - 0x0,0x69,0x0,0x72,0x0,0x63,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - // subdir - 0x0,0x6, - 0x7,0xab,0x8b,0x2, - 0x0,0x73, - 0x0,0x75,0x0,0x62,0x0,0x64,0x0,0x69,0x0,0x72, - // triangle.png - 0x0,0xc, - 0x5,0x59,0xa7,0xc7, - 0x0,0x74, - 0x0,0x72,0x0,0x69,0x0,0x61,0x0,0x6e,0x0,0x67,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, - -}; - -static const unsigned char qt_resource_struct[] = { - // : - 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, - // :/images - 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2, - // :/images/subdir - 0x0,0x0,0x0,0x46,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x5, - // :/images/square.png - 0x0,0x0,0x0,0x12,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, - // :/images/circle.png - 0x0,0x0,0x0,0x2c,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x62, - // :/images/subdir/triangle.png - 0x0,0x0,0x0,0x58,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0xb, - -}; - -QT_BEGIN_NAMESPACE - -extern Q_CORE_EXPORT bool qRegisterResourceData - (int, const unsigned char *, const unsigned char *, const unsigned char *); - -extern Q_CORE_EXPORT bool qUnregisterResourceData - (int, const unsigned char *, const unsigned char *, const unsigned char *); - -QT_END_NAMESPACE - - -int QT_MANGLE_NAMESPACE(qInitResources)() -{ - QT_PREPEND_NAMESPACE(qRegisterResourceData) - (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); - return 1; -} - -Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources)) - -int QT_MANGLE_NAMESPACE(qCleanupResources)() -{ - QT_PREPEND_NAMESPACE(qUnregisterResourceData) - (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); - return 1; -} - -Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources)) - diff --git a/tests/auto/tools/rcc/data/images.qrc b/tests/auto/tools/rcc/data/images.qrc deleted file mode 100644 index 773baef3e5..0000000000 --- a/tests/auto/tools/rcc/data/images.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - images/circle.png - images/square.png - images/subdir/triangle.png - - diff --git a/tests/auto/tools/rcc/data/images/circle.png b/tests/auto/tools/rcc/data/images/circle.png deleted file mode 100644 index dc392cb3f7..0000000000 Binary files a/tests/auto/tools/rcc/data/images/circle.png and /dev/null differ diff --git a/tests/auto/tools/rcc/data/images/images.bin.expected b/tests/auto/tools/rcc/data/images/images.bin.expected new file mode 100644 index 0000000000..cb67a25477 Binary files /dev/null and b/tests/auto/tools/rcc/data/images/images.bin.expected differ diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected new file mode 100644 index 0000000000..71be819310 --- /dev/null +++ b/tests/auto/tools/rcc/data/images/images.expected @@ -0,0 +1,126 @@ +/**************************************************************************** +** Resource object code +** +IGNORE: ** Created: Tue Jul 15 11:17:15 2008 +IGNORE: ** by: The Resource Compiler for Qt version 4.4.2 +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include + +static const unsigned char qt_resource_data[] = { +IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/square.png + 0x0,0x0,0x0,0x5e, + 0x89, + 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, + 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x1,0x3,0x0,0x0,0x0,0x49,0xb4,0xe8,0xb7, + 0x0,0x0,0x0,0x6,0x50,0x4c,0x54,0x45,0x0,0x0,0x0,0x58,0xa8,0xff,0x8c,0x14, + 0x1f,0xab,0x0,0x0,0x0,0x13,0x49,0x44,0x41,0x54,0x8,0xd7,0x63,0x60,0x0,0x81, + 0xfa,0xff,0xff,0xff,0xd,0x3e,0x2,0x4,0x0,0x8d,0x4d,0x68,0x6b,0xcf,0xb8,0x8e, + 0x86,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, +IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/circle.png + 0x0,0x0,0x0,0xa5, + 0x89, + 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, + 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4, + 0x0,0x0,0x0,0x6c,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0xd7,0x5b,0xe,0x0,0x10, + 0xc,0x44,0x51,0xcb,0xb4,0x44,0xbb,0x64,0x3,0x1e,0xd5,0x18,0x1d,0x31,0x12,0xdf, + 0xf7,0x7c,0xd1,0xa6,0xf4,0xe8,0xa9,0x93,0x8b,0x8f,0xe6,0x52,0x87,0x17,0x81,0x59, + 0x46,0xd,0x18,0x7f,0xdc,0x13,0x1e,0x40,0x62,0xe2,0x5e,0xc4,0xd1,0xf8,0x2e,0x2, + 0x12,0xb7,0x22,0xa0,0x71,0xb,0x22,0x14,0x70,0x25,0x3e,0x43,0xfc,0xd,0xb8,0x1a, + 0xef,0x21,0x4,0x10,0x40,0x0,0x3d,0x44,0x14,0x0,0x7d,0xc7,0x14,0x13,0x11,0xc5, + 0x4c,0x48,0x31,0x15,0x53,0xec,0x5,0x14,0x9b,0x11,0xc5,0x6e,0x8,0xdd,0x8e,0x1b, + 0x14,0x54,0x19,0xf3,0xa1,0x23,0xdb,0xd5,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44, + 0xae,0x42,0x60,0x82, +IGNORE: // /data5/dev/qt/tests/auto/rcc/data/images/subdir/triangle.png + 0x0,0x0,0x0,0xaa, + 0x89, + 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, + 0x0,0x0,0x20,0x0,0x0,0x0,0x20,0x8,0x6,0x0,0x0,0x0,0x73,0x7a,0x7a,0xf4, + 0x0,0x0,0x0,0x71,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0xce,0x4b,0xa,0x80,0x30, + 0x10,0x4,0xd1,0x1c,0xd3,0x23,0x7a,0xcb,0x11,0x82,0xb8,0x50,0x62,0x92,0xf9,0xd5, + 0x66,0x1a,0x7a,0x5d,0xaf,0xb5,0x5a,0xcd,0x36,0xb9,0xcf,0xc4,0x8f,0x53,0xfa,0x9, + 0xc4,0x13,0xa7,0x10,0x28,0xe0,0x13,0xcf,0x44,0xc,0xe3,0x59,0x8,0x14,0x30,0x8d, + 0x47,0x23,0x50,0xc0,0x72,0x3c,0x2,0xb1,0x1d,0xf7,0x46,0xa0,0x0,0x75,0xdc,0x3, + 0x61,0x8e,0x5b,0x11,0x28,0xc0,0x2d,0xae,0x45,0xa0,0x0,0xf7,0xf8,0xe,0x22,0x2c, + 0xbe,0x8a,0x40,0x1,0xe1,0xf1,0x3f,0x44,0x5a,0x7c,0x84,0x40,0x1,0xe9,0xf1,0x37, + 0x42,0xe0,0xd7,0xd8,0x5d,0xf,0x6f,0x97,0x11,0x88,0x38,0xa9,0x1e,0x0,0x0,0x0, + 0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, + +}; + +static const unsigned char qt_resource_name[] = { + // images + 0x0,0x6, + 0x7,0x3,0x7d,0xc3, + 0x0,0x69, + 0x0,0x6d,0x0,0x61,0x0,0x67,0x0,0x65,0x0,0x73, + // square.png + 0x0,0xa, + 0x8,0x8b,0x6,0x27, + 0x0,0x73, + 0x0,0x71,0x0,0x75,0x0,0x61,0x0,0x72,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, + // circle.png + 0x0,0xa, + 0xa,0x2d,0x16,0x47, + 0x0,0x63, + 0x0,0x69,0x0,0x72,0x0,0x63,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, + // subdir + 0x0,0x6, + 0x7,0xab,0x8b,0x2, + 0x0,0x73, + 0x0,0x75,0x0,0x62,0x0,0x64,0x0,0x69,0x0,0x72, + // triangle.png + 0x0,0xc, + 0x5,0x59,0xa7,0xc7, + 0x0,0x74, + 0x0,0x72,0x0,0x69,0x0,0x61,0x0,0x6e,0x0,0x67,0x0,0x6c,0x0,0x65,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, + +}; + +static const unsigned char qt_resource_struct[] = { + // : + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, + // :/images + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2, + // :/images/subdir + 0x0,0x0,0x0,0x46,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x5, + // :/images/square.png + 0x0,0x0,0x0,0x12,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, + // :/images/circle.png + 0x0,0x0,0x0,0x2c,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x62, + // :/images/subdir/triangle.png + 0x0,0x0,0x0,0x58,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0xb, + +}; + +QT_BEGIN_NAMESPACE + +extern Q_CORE_EXPORT bool qRegisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +extern Q_CORE_EXPORT bool qUnregisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +QT_END_NAMESPACE + + +int QT_MANGLE_NAMESPACE(qInitResources)() +{ + QT_PREPEND_NAMESPACE(qRegisterResourceData) + (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources)) + +int QT_MANGLE_NAMESPACE(qCleanupResources)() +{ + QT_PREPEND_NAMESPACE(qUnregisterResourceData) + (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources)) + diff --git a/tests/auto/tools/rcc/data/images/images.qrc b/tests/auto/tools/rcc/data/images/images.qrc new file mode 100644 index 0000000000..773baef3e5 --- /dev/null +++ b/tests/auto/tools/rcc/data/images/images.qrc @@ -0,0 +1,7 @@ + + + images/circle.png + images/square.png + images/subdir/triangle.png + + diff --git a/tests/auto/tools/rcc/data/images/images/circle.png b/tests/auto/tools/rcc/data/images/images/circle.png new file mode 100644 index 0000000000..dc392cb3f7 Binary files /dev/null and b/tests/auto/tools/rcc/data/images/images/circle.png differ diff --git a/tests/auto/tools/rcc/data/images/images/square.png b/tests/auto/tools/rcc/data/images/images/square.png new file mode 100644 index 0000000000..c0fd2d540a Binary files /dev/null and b/tests/auto/tools/rcc/data/images/images/square.png differ diff --git a/tests/auto/tools/rcc/data/images/images/subdir/triangle.png b/tests/auto/tools/rcc/data/images/images/subdir/triangle.png new file mode 100644 index 0000000000..2ee15f8f1f Binary files /dev/null and b/tests/auto/tools/rcc/data/images/images/subdir/triangle.png differ diff --git a/tests/auto/tools/rcc/data/images/square.png b/tests/auto/tools/rcc/data/images/square.png deleted file mode 100644 index c0fd2d540a..0000000000 Binary files a/tests/auto/tools/rcc/data/images/square.png and /dev/null differ diff --git a/tests/auto/tools/rcc/data/images/subdir/triangle.png b/tests/auto/tools/rcc/data/images/subdir/triangle.png deleted file mode 100644 index 2ee15f8f1f..0000000000 Binary files a/tests/auto/tools/rcc/data/images/subdir/triangle.png and /dev/null differ diff --git a/tests/auto/tools/rcc/data/parentdir.txt b/tests/auto/tools/rcc/data/parentdir.txt new file mode 100644 index 0000000000..da8195e17b --- /dev/null +++ b/tests/auto/tools/rcc/data/parentdir.txt @@ -0,0 +1 @@ +abcdefgihklmnopqrstuvwxyz diff --git a/tests/auto/tools/rcc/rcc.pro b/tests/auto/tools/rcc/rcc.pro index ebe36cfaff..264b8ecc66 100644 --- a/tests/auto/tools/rcc/rcc.pro +++ b/tests/auto/tools/rcc/rcc.pro @@ -3,10 +3,3 @@ QT = core testlib TARGET = tst_rcc SOURCES += tst_rcc.cpp - -wince* { - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} - diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 0124b580a8..dbf5cebd9d 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2012 Giuseppe D'Angelo ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** @@ -39,28 +40,34 @@ ** ****************************************************************************/ +#include +#include #include #include -#include #include #include #include -#include - -#include +#include +#include +#include +#include +#include +typedef QMap QStringMap; +Q_DECLARE_METATYPE(QStringMap) class tst_rcc : public QObject { Q_OBJECT -public: - tst_rcc() {} private slots: void rcc_data(); void rcc(); -}; + void binary_data(); + void binary(); + void cleanupTestCase(); +}; QString findExpectedFile(const QString &base) { @@ -95,14 +102,16 @@ static QString doCompare(const QStringList &actual, const QStringList &expected) return ba; } - void tst_rcc::rcc_data() { QTest::addColumn("directory"); QTest::addColumn("qrcfile"); QTest::addColumn("expected"); - QTest::newRow("images") << SRCDIR "data" << "images.qrc" << "images.expected"; + QString dataPath = QFINDTESTDATA("data/images/"); + if (dataPath.isEmpty()) + QFAIL("data path not found"); + QTest::newRow("images") << dataPath << "images.qrc" << "images.expected"; } void tst_rcc::rcc() @@ -157,6 +166,191 @@ void tst_rcc::rcc() +static void createRccBinaryData(const QString &baseDir, const QString &qrcFileName, const QString &rccFileName) +{ + QString currentDir = QDir::currentPath(); + QDir::setCurrent(baseDir); + + QProcess rccProcess; + rccProcess.start("rcc", QStringList() << "-binary" << "-o" << rccFileName << qrcFileName); + bool ok = rccProcess.waitForFinished(); + if (!ok) { + QString errorString = QString::fromLatin1("Could not start rcc (is it in PATH?): %1").arg(rccProcess.errorString()); + QFAIL(qPrintable(errorString)); + } + + QByteArray output = rccProcess.readAllStandardOutput(); + if (!output.isEmpty()) { + QString errorMessage = QString::fromLatin1("rcc stdout: %1").arg(QString::fromLocal8Bit(output)); + QWARN(qPrintable(errorMessage)); + } + + output = rccProcess.readAllStandardError(); + if (!output.isEmpty()) { + QString errorMessage = QString::fromLatin1("rcc stderr: %1").arg(QString::fromLocal8Bit(output)); + QWARN(qPrintable(errorMessage)); + } + + QDir::setCurrent(currentDir); +} + +static QStringList readLinesFromFile(const QString &fileName) +{ + QFile file(fileName); + + bool ok = file.open(QIODevice::ReadOnly | QIODevice::Text); + if (!ok) + QWARN(qPrintable(QString::fromLatin1("Could not open testdata file %1: %2").arg(fileName, file.errorString()))); + + QStringList lines = QString::fromUtf8(file.readAll()).split(QLatin1Char('\n'), QString::SkipEmptyParts); + return lines; +} + +static QStringMap readExpectedFiles(const QString &fileName) +{ + QStringMap expectedFiles; + + QStringList lines = readLinesFromFile(fileName); + foreach (const QString &line, lines) { + QString resourceFileName = line.section(QLatin1Char(' '), 0, 0, QString::SectionSkipEmpty); + QString actualFileName = line.section(QLatin1Char(' '), 1, 1, QString::SectionSkipEmpty); + expectedFiles[resourceFileName] = actualFileName; + } + + return expectedFiles; +} + +/* + The following test looks for all *.qrc files under data/binary/. For each + .qrc file found, these files are processed (assuming the file found is + called "base.qrc"): + + - base.qrc : processed by rcc; creates base.rcc + - base.locale : (optional) list of locales to test, one per line + - base.expected : list of pairs (file path in resource, path to real file), + one per line; the pair separated by a whitespace; the paths to real files + relative to data/binary/ (for testing the C locale) + - base.localeName.expected : for each localeName in the base.locale file, + as the above .expected file +*/ + +void tst_rcc::binary_data() +{ + QTest::addColumn("resourceFile"); + QTest::addColumn("locale"); + QTest::addColumn("baseDirectory"); + QTest::addColumn("expectedFiles"); + + QString dataPath = QFINDTESTDATA("data/binary/"); + if (dataPath.isEmpty()) + QFAIL("data path not found"); + + QDirIterator iter(dataPath, QStringList() << QLatin1String("*.qrc")); + while (iter.hasNext()) + { + iter.next(); + QFileInfo qrcFileInfo = iter.fileInfo(); + QString absoluteBaseName = QFileInfo(qrcFileInfo.absolutePath(), qrcFileInfo.baseName()).absoluteFilePath(); + QString rccFileName = absoluteBaseName + QLatin1String(".rcc"); + createRccBinaryData(dataPath, qrcFileInfo.absoluteFilePath(), rccFileName); + + QString localeFileName = absoluteBaseName + QLatin1String(".locale"); + QFile localeFile(localeFileName); + if (localeFile.exists()) { + QStringList locales = readLinesFromFile(localeFileName); + foreach (const QString &locale, locales) { + QString expectedFileName = QString::fromLatin1("%1.%2.%3").arg(absoluteBaseName, locale, QLatin1String("expected")); + QStringMap expectedFiles = readExpectedFiles(expectedFileName); + QTest::newRow(qPrintable(qrcFileInfo.baseName() + QLatin1Char('_') + locale)) << rccFileName + << QLocale(locale) + << dataPath + << expectedFiles; + } + } + + // always test for the C locale as well + QString expectedFileName = absoluteBaseName + QLatin1String(".expected"); + QStringMap expectedFiles = readExpectedFiles(expectedFileName); + QTest::newRow(qPrintable(qrcFileInfo.baseName() + QLatin1String("_C"))) << rccFileName + << QLocale::c() + << dataPath + << expectedFiles; + } +} + +void tst_rcc::binary() +{ + QFETCH(QString, baseDirectory); + QFETCH(QString, resourceFile); + QFETCH(QLocale, locale); + QFETCH(QStringMap, expectedFiles); + + const QString rootPrefix = QLatin1String("/test_root/"); + const QString resourceRootPrefix = QLatin1Char(':') + rootPrefix; + + QLocale oldDefaultLocale; + QLocale::setDefault(locale); + QVERIFY(QFile::exists(resourceFile)); + QVERIFY(QResource::registerResource(resourceFile, rootPrefix)); + + { // need to destroy the iterators on the resource, in order to be able to unregister it + + // read all the files inside the resources + QDirIterator iter(resourceRootPrefix, QDir::Files, QDirIterator::Subdirectories); + QList filesFound; + while (iter.hasNext()) + filesFound << iter.next(); + + // add the test root prefix to the expected file names + QList expectedFileNames = expectedFiles.keys(); + for (QList::iterator i = expectedFileNames.begin(); i < expectedFileNames.end(); ++i) { + // poor man's canonicalPath, which doesn't work with resources + if ((*i).startsWith(QLatin1Char('/'))) + (*i).remove(0, 1); + *i = resourceRootPrefix + *i; + } + + // check that we have all (and only) the expected files + qSort(filesFound); + qSort(expectedFileNames); + QCOMPARE(filesFound, expectedFileNames); + + // now actually check the file contents + QDir directory(baseDirectory); + for (QStringMap::const_iterator i = expectedFiles.constBegin(); i != expectedFiles.constEnd(); ++i) { + QString resourceFileName = i.key(); + QString actualFileName = i.value(); + + QFile resourceFile(resourceRootPrefix + resourceFileName); + QVERIFY(resourceFile.open(QIODevice::ReadOnly)); + QByteArray resourceData = resourceFile.readAll(); + resourceFile.close(); + + QFile actualFile(QFileInfo(directory, actualFileName).absoluteFilePath()); + QVERIFY(actualFile.open(QIODevice::ReadOnly)); + QByteArray actualData = actualFile.readAll(); + actualFile.close(); + QCOMPARE(resourceData, actualData); + } + + } + + QVERIFY(QResource::unregisterResource(resourceFile, rootPrefix)); + QLocale::setDefault(oldDefaultLocale); +} + + +void tst_rcc::cleanupTestCase() +{ + QString dataPath = QFINDTESTDATA("data/binary/"); + if (dataPath.isEmpty()) + return; + QDir dataDir(dataPath); + QFileInfoList entries = dataDir.entryInfoList(QStringList() << QLatin1String("*.rcc")); + foreach (const QFileInfo &entry, entries) + QFile::remove(entry.absoluteFilePath()); +} + QTEST_APPLESS_MAIN(tst_rcc) #include "tst_rcc.moc" -- cgit v1.2.3 From 779b3188a96ef1043ff8091ebe90e44750e1fa3b Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 7 Mar 2012 09:58:34 -0800 Subject: Windows: Make QMenuBar autotest significant again The bug has been fix by 7bc576771de0b3c96905a6d11a75a01917334dc9 . Task-number: QTBUG-24326 Change-Id: Ifd37e9fe76cb24e49132f22909c95a55a230b1ed Reviewed-by: Sergio Ahumada Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qmenubar/qmenubar.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro index 6f35d4516f..6bacaa0d37 100644 --- a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro +++ b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro @@ -5,5 +5,3 @@ SOURCES += tst_qmenubar.cpp # QTBUG-4965, QTBUG-11823 - unstable tests linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):CONFIG += insignificant_test - -win32:CONFIG += insignificant_test # QTBUG-24326 -- cgit v1.2.3 From f71487da3a93ec5f52af496301d91e5b8777494d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 6 Mar 2012 13:34:30 +0100 Subject: Fix crash in QVariant::canConvert. The function was crashing when an unsupported type id was given as an input argument. Change-Id: I2b0e3e6d43f6f248dc71532f8e6485efe68e8120 Reviewed-by: Stephen Kelly --- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index ccdab17668..d78759e923 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -612,6 +612,12 @@ void tst_QVariant::canConvert() QCOMPARE(val.canConvert(QVariant::Time), TimeCast); QCOMPARE(val.canConvert(QVariant::UInt), UIntCast); QCOMPARE(val.canConvert(QVariant::ULongLong), ULongLongCast); + + // Invalid type ids + QCOMPARE(val.canConvert(-1), false); + QCOMPARE(val.canConvert(-23), false); + QCOMPARE(val.canConvert(-23876), false); + QCOMPARE(val.canConvert(23876), false); } void tst_QVariant::toInt_data() -- cgit v1.2.3 From cf6dd5baca26c202de26c8366010a8958ea08d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 8 Mar 2012 15:36:38 +0100 Subject: Crash fix in QMetaType::typeName. The function is public, so it should validate input instead of crashing Change-Id: Ifd9f1110f8631f942929d85db6a57eee7afffb6a Reviewed-by: Stephen Kelly --- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index f8403f11a1..35439885c9 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -305,16 +305,20 @@ void tst_QMetaType::normalizedTypes() #define TYPENAME_DATA(MetaTypeName, MetaTypeId, RealType)\ QTest::newRow(#RealType) << QMetaType::MetaTypeName << #RealType; -#define TYPENAME_DATA_ALIAS(MetaTypeName, MetaTypeId, AliasType, RealTypeString)\ - QTest::newRow(RealTypeString) << QMetaType::MetaTypeName << #AliasType; - void tst_QMetaType::typeName_data() { QTest::addColumn("aType"); QTest::addColumn("aTypeName"); QT_FOR_EACH_STATIC_TYPE(TYPENAME_DATA) - QT_FOR_EACH_STATIC_ALIAS_TYPE(TYPENAME_DATA_ALIAS) + + QTest::newRow("Whity") << static_cast(::qMetaTypeId >()) << QString::fromLatin1("Whity"); + QTest::newRow("Whity") << static_cast(::qMetaTypeId >()) << QString::fromLatin1("Whity"); + QTest::newRow("Testspace::Foo") << static_cast(::qMetaTypeId()) << QString::fromLatin1("TestSpace::Foo"); + + QTest::newRow("-1") << QMetaType::Type(-1) << QString(); + QTest::newRow("-124125534") << QMetaType::Type(-124125534) << QString(); + QTest::newRow("124125534") << QMetaType::Type(124125534) << QString(); } void tst_QMetaType::typeName() -- cgit v1.2.3 From 763790bb5c4423952daf97ed0194db8db1ea1a3b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 8 Mar 2012 10:41:55 +0100 Subject: Fix a bug in the assignment operators for QJsonObject and Array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When objects or arrays where being used read only, several objects can share the same d pointer, but will have different pointers into the binary data. Correctly change the pointer into the binary data even if the d-pointer is the same. Change-Id: Ife0ea5ac5daf46586f855dccdf35b51ec696a623 Reviewed-by: João Abecasis --- tests/auto/corelib/json/tst_qtjson.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index f35831c900..079ff6e76b 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -117,6 +117,9 @@ private Q_SLOTS: void testCompactionError(); void parseUnicodeEscapes(); + + void assignObjects(); + void assignArrays(); private: QString testDataDir; }; @@ -1774,5 +1777,35 @@ void TestQtJson::parseUnicodeEscapes() QCOMPARE(array.first().toString(), result); } +void TestQtJson::assignObjects() +{ + const char *json = + "[ { \"Key\": 1 }, { \"Key\": 2 } ]"; + + QJsonDocument doc = QJsonDocument::fromJson(json); + QJsonArray array = doc.array(); + + QJsonObject object = array.at(0).toObject(); + QCOMPARE(object.value("Key").toDouble(), 1.); + + object = array.at(1).toObject(); + QCOMPARE(object.value("Key").toDouble(), 2.); +} + +void TestQtJson::assignArrays() +{ + const char *json = + "[ [ 1 ], [ 2 ] ]"; + + QJsonDocument doc = QJsonDocument::fromJson(json); + QJsonArray array = doc.array(); + + QJsonArray inner = array.at(0).toArray() ; + QCOMPARE(inner.at(0).toDouble(), 1.); + + inner= array.at(1).toArray(); + QCOMPARE(inner.at(0).toDouble(), 2.); +} + QTEST_MAIN(TestQtJson) #include "tst_qtjson.moc" -- cgit v1.2.3 From f5b2a094677abaccb1c0a76f449144ccb89e4137 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 8 Mar 2012 11:38:09 +0200 Subject: Windows: Removing insignification from QTextEdit test The commit 660af10dee503729025952ed2374b8a081f941a2 seems to have fixed the test, so removing the insignification from it. Task-number: QTBUG-24348 Change-Id: I564e90db53d10b54e22342a1cdbef6826929c63a Reviewed-by: Friedemann Kleint --- tests/auto/widgets/widgets/qtextedit/qtextedit.pro | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro index 294f1d84e7..85658c222e 100644 --- a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro +++ b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro @@ -17,5 +17,3 @@ wince* { } contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-20756 crashes on xcb - -win32:CONFIG += insignificant_test # QTBUG-24348 -- cgit v1.2.3 From 5f9d126ca8ae4678ead6a70bccb459413e4c86cc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 5 Mar 2012 12:15:50 +0100 Subject: remove strange .qmake.cache hacks they are obsolete (qmake knows the qt build configuration anyway), and messing with QTDIR is a recipe for disaster. Change-Id: Ib3594f38ec3192a5f70771f8bc5d8fd435bbbd15 Reviewed-by: Joerg Bornemann --- tests/auto/tools/qmake/testdata/one_space/one_space.pro | 5 ----- tests/auto/tools/qmake/testdata/simple_app/simple_app.pro | 5 ----- tests/auto/tools/qmake/testdata/simple_dll/simple_dll.pro | 5 ----- tests/auto/tools/qmake/testdata/subdirs/simple_app/simple_app.pro | 5 ----- tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro | 6 ------ 5 files changed, 26 deletions(-) (limited to 'tests') diff --git a/tests/auto/tools/qmake/testdata/one_space/one_space.pro b/tests/auto/tools/qmake/testdata/one_space/one_space.pro index 247bd27096..c5ffa40742 100644 --- a/tests/auto/tools/qmake/testdata/one_space/one_space.pro +++ b/tests/auto/tools/qmake/testdata/one_space/one_space.pro @@ -3,8 +3,3 @@ CONFIG += qt warn_on SOURCES = main.cpp TARGET = "one space" DESTDIR = ./ - -infile($(QTDIR)/.qmake.cache, CONFIG, debug):CONFIG += debug -infile($(QTDIR)/.qmake.cache, CONFIG, release):CONFIG += release - - diff --git a/tests/auto/tools/qmake/testdata/simple_app/simple_app.pro b/tests/auto/tools/qmake/testdata/simple_app/simple_app.pro index a8c4ad613d..94af3cd3ba 100644 --- a/tests/auto/tools/qmake/testdata/simple_app/simple_app.pro +++ b/tests/auto/tools/qmake/testdata/simple_app/simple_app.pro @@ -6,8 +6,3 @@ SOURCES = test_file.cpp \ RESOURCES = test.qrc TARGET = simple_app DESTDIR = ./ - -infile($(QTDIR)/.qmake.cache, CONFIG, debug):CONFIG += debug -infile($(QTDIR)/.qmake.cache, CONFIG, release):CONFIG += release - - diff --git a/tests/auto/tools/qmake/testdata/simple_dll/simple_dll.pro b/tests/auto/tools/qmake/testdata/simple_dll/simple_dll.pro index 9af38ecce6..09c18d1631 100644 --- a/tests/auto/tools/qmake/testdata/simple_dll/simple_dll.pro +++ b/tests/auto/tools/qmake/testdata/simple_dll/simple_dll.pro @@ -12,8 +12,3 @@ MOC_DIR = tmp OBJECTS_DIR = tmp TARGET = simple_dll DESTDIR = ./ - -infile($(QTDIR)/.qmake.cache, CONFIG, debug):CONFIG += debug -infile($(QTDIR)/.qmake.cache, CONFIG, release):CONFIG += release - - diff --git a/tests/auto/tools/qmake/testdata/subdirs/simple_app/simple_app.pro b/tests/auto/tools/qmake/testdata/subdirs/simple_app/simple_app.pro index f496d5bb8e..4191f142d8 100644 --- a/tests/auto/tools/qmake/testdata/subdirs/simple_app/simple_app.pro +++ b/tests/auto/tools/qmake/testdata/subdirs/simple_app/simple_app.pro @@ -5,8 +5,3 @@ SOURCES = test_file.cpp \ main.cpp TARGET = simple_app DESTDIR = ./ - -infile($(QTDIR)/.qmake.cache, CONFIG, debug):CONFIG += debug -infile($(QTDIR)/.qmake.cache, CONFIG, release):CONFIG += release - - diff --git a/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro b/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro index a54a07a0e7..09c18d1631 100644 --- a/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro +++ b/tests/auto/tools/qmake/testdata/subdirs/simple_dll/simple_dll.pro @@ -1,4 +1,3 @@ -include($(QTDIR)/.qmake.cache) TEMPLATE = lib CONFIG += qt warn_on dll @@ -13,8 +12,3 @@ MOC_DIR = tmp OBJECTS_DIR = tmp TARGET = simple_dll DESTDIR = ./ - -infile($(QTDIR)/.qmake.cache, CONFIG, debug):CONFIG += debug -infile($(QTDIR)/.qmake.cache, CONFIG, release):CONFIG += release - - -- cgit v1.2.3 From 59ae59977b05b0edf2ae841fc5149bdb401d8164 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 5 Mar 2012 14:20:17 +0100 Subject: use $$QT_BUILD_TREE instead of $$(QTDIR) it's a "tad" more reliable Change-Id: I7207daa6869d1682719cc357794cf6efff496225 Reviewed-by: Joerg Bornemann --- tests/benchmarks/gui/image/qimagereader/qimagereader.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro index cc2c8e0701..87c9de5461 100644 --- a/tests/benchmarks/gui/image/qimagereader/qimagereader.pro +++ b/tests/benchmarks/gui/image/qimagereader/qimagereader.pro @@ -14,11 +14,11 @@ wince*: { addFiles.path = . CONFIG(debug, debug|release):{ - imageFormatsPlugins.files = $$(QTDIR)/plugins/imageformats/*d4.dll + imageFormatsPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/*d4.dll } CONFIG(release, debug|release):{ - imageFormatsPlugins.files = $$(QTDIR)/plugins/imageformats/*[^d]4.dll + imageFormatsPlugins.files = $$QT_BUILD_TREE/plugins/imageformats/*[^d]4.dll } imageFormatsPlugins.path = imageformats DEPLOYMENT += addFiles imageFormatsPlugins -- cgit v1.2.3 From b5431419923e8f00e2d8a4a75a20f75f66241842 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 23 Feb 2012 02:53:08 +0000 Subject: QRegularExpression: improve JIT memory handling PCRE's JIT uses by default 32K on the pcre_exec caller's stack. This is fine for most situations, but in some cases (esp. patterns with lot of recursion) more memory is required. Therefore, if a match execution fails due to exhausting JIT memory, we let PCRE allocate up to 512KB to be used for the JIT's stack. The pointer to the allocated memory is put in thread local storage (so it can be reused from the same thread, if needed, and automatically goes away when the thread dies). Change-Id: Ica5fb7d517068befff88ebb198a603a26ec5d8a7 Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- .../qregularexpression/tst_qregularexpression.cpp | 27 ++++++++++++++++++++++ .../qregularexpression/tst_qregularexpression.h | 2 ++ 2 files changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 72157c0536..38b82ecf77 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -1196,3 +1196,30 @@ void tst_QRegularExpression::captureCount() if (!re.isValid()) QCOMPARE(re.captureCount(), -1); } + +void tst_QRegularExpression::pcreJitStackUsage_data() +{ + QTest::addColumn("pattern"); + QTest::addColumn("subject"); + // these patterns cause enough backtrack (or even infinite recursion) + // in the regexp engine, so that JIT requests more memory. + QTest::newRow("jitstack01") << "(?(R)a*(?1)|((?R))b)" << "aaaabcde"; + QTest::newRow("jitstack02") << "(?(R)a*(?1)|((?R))b)" << "aaaaaaabcde"; +} + +void tst_QRegularExpression::pcreJitStackUsage() +{ + QFETCH(QString, pattern); + QFETCH(QString, subject); + + QRegularExpression re(pattern); + QVERIFY(re.isValid()); + QRegularExpressionMatch match = re.match(subject); + consistencyCheck(match); + QRegularExpressionMatchIterator iterator = re.globalMatch(subject); + consistencyCheck(iterator); + while (iterator.hasNext()) { + match = iterator.next(); + consistencyCheck(match); + } +} diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h index 1a703a8f92..fd8bdfa3af 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h @@ -71,6 +71,8 @@ private slots: void operatoreq(); void captureCount_data(); void captureCount(); + void pcreJitStackUsage_data(); + void pcreJitStackUsage(); private: void provideRegularExpressions(); -- cgit v1.2.3 From 824cc9492144dff2494645319854cb68ba5570c6 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 26 Feb 2012 22:37:45 +0000 Subject: QRegularExpression: minor fix to captureIndexForName Although passing a null pointer to pcre16_get_stringnumber for the compiled pattern should simply make it error out, it's actually an undocumented behaviour, so let's stay safe and add an explicit check. Tests for this codepath are added. Change-Id: Ifd9c87874f6812ba487104ec1a5bbc83c3b16761 Reviewed-by: Thiago Macieira --- .../qregularexpression/tst_qregularexpression.cpp | 58 +++++++++++++++++++++- .../qregularexpression/tst_qregularexpression.h | 2 + 2 files changed, 59 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 38b82ecf77..a4c04d6207 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -95,8 +95,13 @@ bool operator==(const QRegularExpressionMatch &rem, const Match &m) } Q_FOREACH (const QString &name, m.namedCaptured.keys()) { - if (rem.captured(name) != m.namedCaptured.value(name)) + QString remCaptured = rem.captured(name); + QString mCaptured = m.namedCaptured.value(name); + if (remCaptured != mCaptured + || remCaptured.isNull() != mCaptured.isNull() + || remCaptured.isEmpty() != mCaptured.isEmpty()) { return false; + } } } @@ -571,6 +576,32 @@ void tst_QRegularExpression::normalMatch_data() << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) << m; + // non existing names for capturing groups + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "a string" << "a" << "string"; + m.namedCaptured["article"] = "a"; + m.namedCaptured["noun"] = "string"; + m.namedCaptured["nonexisting1"] = QString(); + m.namedCaptured["nonexisting2"] = QString(); + m.namedCaptured["nonexisting3"] = QString(); + QTest::newRow("match10") << QRegularExpression("(?
\\w+) (?\\w+)") + << "a string" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + + m.clear(); + m.isValid = true; m.hasMatch = true; + m.captured << "" << ""; + m.namedCaptured["digits"] = ""; // empty VS null + m.namedCaptured["nonexisting"] = QString(); + QTest::newRow("match11") << QRegularExpression("(?\\d*)") + << "abcde" + << 0 + << QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption) + << m; + // *** m.clear(); @@ -1223,3 +1254,28 @@ void tst_QRegularExpression::pcreJitStackUsage() consistencyCheck(match); } } + +void tst_QRegularExpression::regularExpressionMatch_data() +{ + QTest::addColumn("pattern"); + QTest::addColumn("subject"); + + QTest::newRow("validity01") << "(?\\d+)" << "1234 abcd"; + QTest::newRow("validity02") << "(?\\d+) (?\\w+)" << "1234 abcd"; +} + +void tst_QRegularExpression::regularExpressionMatch() +{ + QFETCH(QString, pattern); + QFETCH(QString, subject); + + QRegularExpression re(pattern); + QVERIFY(re.isValid()); + QRegularExpressionMatch match = re.match(subject); + consistencyCheck(match); + QCOMPARE(match.captured("non-existing").isNull(), true); + QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionMatch::captured: empty capturing group name passed"); + QCOMPARE(match.captured("").isNull(), true); + QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionMatch::captured: empty capturing group name passed"); + QCOMPARE(match.captured(QString()).isNull(), true); +} diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h index fd8bdfa3af..72a19199fd 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h @@ -73,6 +73,8 @@ private slots: void captureCount(); void pcreJitStackUsage_data(); void pcreJitStackUsage(); + void regularExpressionMatch_data(); + void regularExpressionMatch(); private: void provideRegularExpressions(); -- cgit v1.2.3 From 9f86923b5c936eefb6f435b46c1dbfc260aa431d Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 8 Mar 2012 15:48:51 -0800 Subject: tst_qimagereader: does not depend on QtWidgets Both tst_qimagereader.cpp and tst_qimagewriter.cpp do not depend on QtWidgets. Change-Id: I7e8b31c23db203c44ccb4cd4e8e747d18c5d7ed7 Reviewed-by: Friedemann Kleint --- tests/auto/gui/image/qimagereader/qimagereader.pro | 2 +- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 1 - tests/auto/gui/image/qimagewriter/qimagewriter.pro | 2 +- tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/image/qimagereader/qimagereader.pro b/tests/auto/gui/image/qimagereader/qimagereader.pro index 14d23f05ba..7686643b3a 100644 --- a/tests/auto/gui/image/qimagereader/qimagereader.pro +++ b/tests/auto/gui/image/qimagereader/qimagereader.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qimagereader SOURCES += tst_qimagereader.cpp MOC_DIR=tmp -QT += widgets widgets-private core-private gui-private network testlib +QT += core-private gui-private network testlib RESOURCES += qimagereader.qrc win32-msvc:QMAKE_CXXFLAGS -= -Zm200 diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 6f6662a80f..876d69ea1c 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/auto/gui/image/qimagewriter/qimagewriter.pro b/tests/auto/gui/image/qimagewriter/qimagewriter.pro index b6c80b8d62..f77ff0659b 100644 --- a/tests/auto/gui/image/qimagewriter/qimagewriter.pro +++ b/tests/auto/gui/image/qimagewriter/qimagewriter.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qimagewriter -QT += widgets testlib +QT += testlib SOURCES += tst_qimagewriter.cpp MOC_DIR=tmp win32-msvc:QMAKE_CXXFLAGS -= -Zm200 diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index ad9da27c7e..932d652b69 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 37c46fee300d265ea17fafdb7f9f9e75caded16a Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 8 Mar 2012 18:37:30 -0800 Subject: Clean up for some auto tests of the gui/kernel. They are not dependent on QtWidgets. Change-Id: Icbc0b0b6f0b72537fd3058cc038a1f5c4bf2aba7 Reviewed-by: Friedemann Kleint --- tests/auto/gui/kernel/qdrag/qdrag.pro | 2 +- .../qfileopeneventexternal/qfileopeneventexternal.cpp | 7 +++---- .../qfileopeneventexternal/qfileopeneventexternal.pro | 2 +- tests/auto/gui/kernel/qkeysequence/qkeysequence.pro | 2 +- tests/auto/gui/kernel/qpalette/qpalette.pro | 2 +- tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 1 - 6 files changed, 7 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qdrag/qdrag.pro b/tests/auto/gui/kernel/qdrag/qdrag.pro index 0173b57215..ac3fde8028 100644 --- a/tests/auto/gui/kernel/qdrag/qdrag.pro +++ b/tests/auto/gui/kernel/qdrag/qdrag.pro @@ -4,7 +4,7 @@ CONFIG += testcase TARGET = tst_qdrag -QT += widgets testlib +QT += testlib SOURCES += tst_qdrag.cpp diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp index 9d138f6a2e..a9f9c8db08 100644 --- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp +++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp @@ -40,13 +40,12 @@ ****************************************************************************/ #include -#include #include -struct MyApplication : public QApplication +struct MyApplication : public QGuiApplication { MyApplication(int& argc, char** argv) - : QApplication(argc, argv) + : QGuiApplication(argc, argv) {} bool event(QEvent * event) @@ -59,7 +58,7 @@ struct MyApplication : public QApplication file.write(QByteArray("+external")); return true; } else { - return QApplication::event(event); + return QGuiApplication::event(event); } } }; diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro index 7de7b2ec57..b84ff760ca 100644 --- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro +++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.pro @@ -1,4 +1,4 @@ TEMPLATE = app TARGET = qfileopeneventexternal -QT += core gui widgets +QT += core gui SOURCES += qfileopeneventexternal.cpp diff --git a/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro b/tests/auto/gui/kernel/qkeysequence/qkeysequence.pro index cf4337b156..9f79fe9ab7 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 testlib +QT += testlib QT += core-private gui-private SOURCES += tst_qkeysequence.cpp diff --git a/tests/auto/gui/kernel/qpalette/qpalette.pro b/tests/auto/gui/kernel/qpalette/qpalette.pro index 8975704f0f..9dd3f3e715 100644 --- a/tests/auto/gui/kernel/qpalette/qpalette.pro +++ b/tests/auto/gui/kernel/qpalette/qpalette.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qpalette -QT += widgets testlib +QT += testlib SOURCES += tst_qpalette.cpp diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index cc46831965..dc393fc2c3 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -43,7 +43,6 @@ #include #include "qpalette.h" -#include class tst_QPalette : public QObject { -- cgit v1.2.3 From 38224d8d009a0f35e4316a035636c2c2b929c524 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 8 Mar 2012 18:45:13 -0800 Subject: Make tst_qmouseevent.cpp independent of QtWidgets Change-Id: I6759c7be44c2d890c1a745effdd70faa3467fe5b Reviewed-by: Friedemann Kleint --- tests/auto/gui/kernel/qmouseevent/qmouseevent.pro | 2 +- .../auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qmouseevent/qmouseevent.pro b/tests/auto/gui/kernel/qmouseevent/qmouseevent.pro index b99c3016b0..5fa886334a 100644 --- a/tests/auto/gui/kernel/qmouseevent/qmouseevent.pro +++ b/tests/auto/gui/kernel/qmouseevent/qmouseevent.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qmouseevent -QT += widgets testlib +QT += testlib SOURCES += tst_qmouseevent.cpp diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp index d8f1f0640e..012502469b 100644 --- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp @@ -41,21 +41,14 @@ #include -#include -#include -#include -#include - - #include -#include +#include -class MouseEventWidget : public QWidget +class MouseEventWidget : public QWindow { public: - MouseEventWidget(QWidget *parent = 0) : QWidget(parent) + MouseEventWidget(QWindow *parent = 0) : QWindow(parent) { - setFocusPolicy(Qt::StrongFocus); } bool mousePressEventRecieved; bool mouseReleaseEventRecieved; @@ -68,7 +61,7 @@ public: protected: void mousePressEvent(QMouseEvent *e) { - QWidget::mousePressEvent(e); + QWindow::mousePressEvent(e); mousePressButton = e->button(); mousePressButtons = e->buttons(); mousePressModifiers = e->modifiers(); @@ -77,7 +70,7 @@ protected: } void mouseReleaseEvent(QMouseEvent *e) { - QWidget::mouseReleaseEvent(e); + QWindow::mouseReleaseEvent(e); mouseReleaseButton = e->button(); mouseReleaseButtons = e->buttons(); mouseReleaseModifiers = e->modifiers(); @@ -179,12 +172,14 @@ void tst_QMouseEvent::checkMousePressEvent() int modifiers = keyPressed; QTest::mousePress(testMouseWidget, Qt::MouseButton(buttonPressed), Qt::KeyboardModifiers(keyPressed)); + qApp->processEvents(); QVERIFY(testMouseWidget->mousePressEventRecieved); QCOMPARE(testMouseWidget->mousePressButton, button); QCOMPARE(testMouseWidget->mousePressButtons, buttons); QCOMPARE(testMouseWidget->mousePressModifiers, modifiers); QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonPressed), Qt::KeyboardModifiers(keyPressed)); + qApp->processEvents(); } void tst_QMouseEvent::checkMouseReleaseEvent_data() @@ -218,6 +213,7 @@ void tst_QMouseEvent::checkMouseReleaseEvent() int modifiers = keyPressed; QTest::mouseClick(testMouseWidget, Qt::MouseButton(buttonReleased), Qt::KeyboardModifiers(keyPressed)); + qApp->processEvents(); QVERIFY(testMouseWidget->mouseReleaseEventRecieved); QCOMPARE(testMouseWidget->mouseReleaseButton, button); QCOMPARE(testMouseWidget->mouseReleaseButtons, buttons); -- cgit v1.2.3 From 7c89d44d95c1c91f77aca3359cd8964a354fc41c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 9 Mar 2012 11:06:18 +0200 Subject: Windows: Fix QStyleSheetStyle autotest antialiasing issues Antialiasing of fonts was causing two tests that relied on finding at least a certain number of pixels of certain color to find one or two too few pixels of that color and thus fail. Fixed by increasing the amount of text displayed to make sure enough pixels of correct color would be present. Also removing the test insignification, as the test will now pass completely when run under Windows Classic theme, which CI uses. Task-number: QTBUG-24323 Change-Id: Ic0b614d33e4e4f5df18d53cb72a05db5d8b6b5e7 Reviewed-by: Friedemann Kleint --- .../styles/qstylesheetstyle/qstylesheetstyle.pro | 2 -- .../qstylesheetstyle/tst_qstylesheetstyle.cpp | 30 +++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro index dd17183b30..c96004bd5d 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/widgets/styles/qstylesheetstyle/qstylesheetstyle.pro @@ -6,5 +6,3 @@ 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/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 544923a1c3..3bff332252 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -728,22 +728,27 @@ void tst_QStyleSheetStyle::focusColors() // is reached if at least ten pixels of the right color can be found in // the image. // For this reason, we use unusual and extremely ugly colors! :-) + // Note that in case of anti-aliased text, ensuring that we have at least + // ten pixels of the right color requires quite a many characters, as the + // majority of the pixels will have slightly different colors due to the + // anti-aliasing effect. #if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) && !(defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL)) QSKIP("This is a fragile test which fails on many esoteric platforms because of focus problems. " "That doesn't mean that the feature doesn't work in practice."); #endif QList widgets; - widgets << new QPushButton("TESTING"); - widgets << new QLineEdit("TESTING"); - widgets << new QLabel("TESTING"); + widgets << new QPushButton("TESTING TESTING"); + widgets << new QLineEdit("TESTING TESTING"); + widgets << new QLabel("TESTING TESTING"); QSpinBox *spinbox = new QSpinBox; - spinbox->setValue(8888); + spinbox->setMaximum(1000000000); + spinbox->setValue(123456789); widgets << spinbox; QComboBox *combobox = new QComboBox; combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING"); + combobox->addItems(QStringList() << "TESTING TESTING"); widgets << combobox; - widgets << new QLabel("TESTING"); + widgets << new QLabel("TESTING TESTING"); #ifdef Q_WS_QWS // QWS has its own special focus logic which is slightly different @@ -794,17 +799,18 @@ void tst_QStyleSheetStyle::hoverColors() if (!PlatformQuirks::haveMouseCursor()) QSKIP("No mouse Cursor on this platform"); QList widgets; - widgets << new QPushButton("TESTING"); - widgets << new QLineEdit("TESTING"); - widgets << new QLabel("TESTING"); + widgets << new QPushButton("TESTING TESTING"); + widgets << new QLineEdit("TESTING TESTING"); + widgets << new QLabel("TESTING TESTING"); QSpinBox *spinbox = new QSpinBox; - spinbox->setValue(8888); + spinbox->setMaximum(1000000000); + spinbox->setValue(123456789); widgets << spinbox; QComboBox *combobox = new QComboBox; combobox->setEditable(true); - combobox->addItems(QStringList() << "TESTING"); + combobox->addItems(QStringList() << "TESTING TESTING"); widgets << combobox; - widgets << new QLabel("TESTING"); + widgets << new QLabel("TESTING TESTING"); foreach (QWidget *widget, widgets) { //without Qt::X11BypassWindowManagerHint the window manager may move the window after we moved the cursor -- cgit v1.2.3 From 53d24330f7c6c28f08cdc8b85c09c35b8f0fe296 Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Fri, 9 Mar 2012 12:56:41 +0100 Subject: Make tst_qapplication build when QT_NO_SHAREDMEMORY is defined Change-Id: I8cfd0ff2e17e6d5c04b81a042c665bcbbca36256 Reviewed-by: David Faure --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 9bbb6aa7f6..91ecbf23a2 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -2160,7 +2160,9 @@ void tst_QApplication::abortQuitOnShow() Q_GLOBAL_STATIC(QLocale, tst_qapp_locale); Q_GLOBAL_STATIC(QProcess, tst_qapp_process); Q_GLOBAL_STATIC(QFileSystemWatcher, tst_qapp_fileSystemWatcher); +#ifndef QT_NO_SHAREDMEMORY Q_GLOBAL_STATIC(QSharedMemory, tst_qapp_sharedMemory); +#endif Q_GLOBAL_STATIC(QElapsedTimer, tst_qapp_elapsedTimer); Q_GLOBAL_STATIC(QMutex, tst_qapp_mutex); Q_GLOBAL_STATIC(QWidget, tst_qapp_widget); @@ -2177,7 +2179,9 @@ void tst_QApplication::globalStaticObjectDestruction() QVERIFY(tst_qapp_locale()); QVERIFY(tst_qapp_process()); QVERIFY(tst_qapp_fileSystemWatcher()); +#ifndef QT_NO_SHAREDMEMORY QVERIFY(tst_qapp_sharedMemory()); +#endif QVERIFY(tst_qapp_elapsedTimer()); QVERIFY(tst_qapp_mutex()); QVERIFY(tst_qapp_widget()); -- cgit v1.2.3 From e9ed5853f4c5600691d2f369e26a1a7881f9750f Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 9 Mar 2012 19:04:43 -0800 Subject: Make tst_qsql.cpp independent of QtWidgets Change-Id: I032902bea6fe2c7d9eb0491886fded7602ae2bcc Reviewed-by: Mark Brand Reviewed-by: Robin Burchell --- tests/auto/sql/kernel/qsql/qsql.pro | 2 +- tests/auto/sql/kernel/qsql/tst_qsql.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsql/qsql.pro b/tests/auto/sql/kernel/qsql/qsql.pro index ac21bb392c..df6e553d8a 100644 --- a/tests/auto/sql/kernel/qsql/qsql.pro +++ b/tests/auto/sql/kernel/qsql/qsql.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_qsql SOURCES += tst_qsql.cpp -QT += sql sql-private gui widgets testlib +QT += sql sql-private gui testlib wince*: { DEPLOYMENT_PLUGIN += qsqlite diff --git a/tests/auto/sql/kernel/qsql/tst_qsql.cpp b/tests/auto/sql/kernel/qsql/tst_qsql.cpp index b02093adae..2656f4802f 100644 --- a/tests/auto/sql/kernel/qsql/tst_qsql.cpp +++ b/tests/auto/sql/kernel/qsql/tst_qsql.cpp @@ -152,7 +152,7 @@ void tst_QSql::basicDriverTest() } // make sure that the static stuff will be deleted -// when using multiple QApplication objects +// when using multiple QGuiApplication objects void tst_QSql::open() { int i; @@ -160,7 +160,7 @@ void tst_QSql::open() const char *argv[] = {"test"}; int count = -1; for ( i = 0; i < 10; ++i ) { - QApplication app(argc, const_cast(argv), false); + QGuiApplication app(argc, const_cast(argv), false); tst_Databases dbs; dbs.open(); -- cgit v1.2.3 From e3429f764b37c3d58faf06c6e1856e66fb8d64b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Thu, 8 Mar 2012 15:56:33 +0100 Subject: Crash fix in QMetaType::typeFlags. The function is public, so it should validate input instead of crashing Change-Id: Id67463b0b61ab74a76c1ede7f052bdbed37822b6 Reviewed-by: Stephen Kelly --- tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 35439885c9..3c21a5053f 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -743,6 +743,12 @@ QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; QTest::newRow("QPair") << ::qMetaTypeId >() << true << false << false; + + // invalid ids. + QTest::newRow("-1") << -1 << false << false << false; + QTest::newRow("-124125534") << -124125534 << false << false << false; + QTest::newRow("124125534") << 124125534 << false << false << false; + } void tst_QMetaType::flags() -- cgit v1.2.3 From 15c13b91e66b0bd0d179f0303bb17c7793f80a07 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Tue, 7 Feb 2012 12:25:07 +1000 Subject: Add Q_IS_ENUM(), and provide as flag in QMetaType::typeFlags() Add Q_IS_ENUM() macro to determine if a given type is an enumeration. Use information from that in QMetaType::registerType() to store whether custom registered metatypes are enums or not. This information can then be accessed by calling QMetaType::typeFlags(int type). This is used by the declarative code to determine whether a custom type in a variant can be safely cast to an integer, which is required to allow passing non-local enums as signal/slot params. Change-Id: I9733837f56af201fa3017b4a22b761437a3c0de4 Reviewed-by: Lars Knoll --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 122 +++++++++++++++++++++ .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 34 ++++++ 2 files changed, 156 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 8fedaf427a..b3d76bef8a 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -41,10 +41,12 @@ #include +#include class tst_QGlobal: public QObject { Q_OBJECT + private slots: void qIsNull(); void for_each(); @@ -53,6 +55,7 @@ private slots: void checkptr(); void qstaticassert(); void qConstructorFunction(); + void isEnum(); }; void tst_QGlobal::qIsNull() @@ -293,5 +296,124 @@ void tst_QGlobal::qConstructorFunction() QCOMPARE(qConstructorFunctionValue, 123); } +struct isEnum_A { + int n_; +}; + +enum isEnum_B_Byte { isEnum_B_Byte_x = 63 }; +enum isEnum_B_Short { isEnum_B_Short_x = 1024 }; +enum isEnum_B_Int { isEnum_B_Int_x = 1 << 20 }; + +union isEnum_C {}; + +class isEnum_D { +public: + operator int() const; +}; + +class isEnum_E { +private: + operator int() const; +}; + +class isEnum_F { +public: + enum AnEnum {}; +}; + +#if defined (Q_COMPILER_CLASS_ENUM) +enum class isEnum_G : qint64 {}; +#endif + +void tst_QGlobal::isEnum() +{ +#if defined (Q_CC_MSVC) +#define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true) +#define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false) +#else +#define IS_ENUM_TRUE(x) (Q_IS_ENUM(x) == true && QtPrivate::is_enum::value == true) +#define IS_ENUM_FALSE(x) (Q_IS_ENUM(x) == false && QtPrivate::is_enum::value == false) +#endif + + QVERIFY(IS_ENUM_TRUE(isEnum_B_Byte)); + QVERIFY(IS_ENUM_TRUE(const isEnum_B_Byte)); + QVERIFY(IS_ENUM_TRUE(volatile isEnum_B_Byte)); + QVERIFY(IS_ENUM_TRUE(const volatile isEnum_B_Byte)); + + QVERIFY(IS_ENUM_TRUE(isEnum_B_Short)); + QVERIFY(IS_ENUM_TRUE(const isEnum_B_Short)); + QVERIFY(IS_ENUM_TRUE(volatile isEnum_B_Short)); + QVERIFY(IS_ENUM_TRUE(const volatile isEnum_B_Short)); + + QVERIFY(IS_ENUM_TRUE(isEnum_B_Int)); + QVERIFY(IS_ENUM_TRUE(const isEnum_B_Int)); + QVERIFY(IS_ENUM_TRUE(volatile isEnum_B_Int)); + QVERIFY(IS_ENUM_TRUE(const volatile isEnum_B_Int)); + + QVERIFY(IS_ENUM_TRUE(isEnum_F::AnEnum)); + QVERIFY(IS_ENUM_TRUE(const isEnum_F::AnEnum)); + QVERIFY(IS_ENUM_TRUE(volatile isEnum_F::AnEnum)); + QVERIFY(IS_ENUM_TRUE(const volatile isEnum_F::AnEnum)); + + QVERIFY(IS_ENUM_FALSE(void)); + QVERIFY(IS_ENUM_FALSE(isEnum_B_Byte &)); + QVERIFY(IS_ENUM_FALSE(isEnum_B_Byte[1])); + QVERIFY(IS_ENUM_FALSE(const isEnum_B_Byte[1])); + QVERIFY(IS_ENUM_FALSE(isEnum_B_Byte[])); + QVERIFY(IS_ENUM_FALSE(int)); + QVERIFY(IS_ENUM_FALSE(float)); + QVERIFY(IS_ENUM_FALSE(isEnum_A)); + QVERIFY(IS_ENUM_FALSE(isEnum_A *)); + QVERIFY(IS_ENUM_FALSE(const isEnum_A)); + QVERIFY(IS_ENUM_FALSE(isEnum_C)); + QVERIFY(IS_ENUM_FALSE(isEnum_D)); + QVERIFY(IS_ENUM_FALSE(isEnum_E)); + QVERIFY(IS_ENUM_FALSE(void())); + QVERIFY(IS_ENUM_FALSE(void(*)())); + QVERIFY(IS_ENUM_FALSE(int isEnum_A::*)); + QVERIFY(IS_ENUM_FALSE(void (isEnum_A::*)())); + + QVERIFY(IS_ENUM_FALSE(size_t)); + QVERIFY(IS_ENUM_FALSE(bool)); + QVERIFY(IS_ENUM_FALSE(wchar_t)); + + QVERIFY(IS_ENUM_FALSE(char)); + QVERIFY(IS_ENUM_FALSE(unsigned char)); + QVERIFY(IS_ENUM_FALSE(short)); + QVERIFY(IS_ENUM_FALSE(unsigned short)); + QVERIFY(IS_ENUM_FALSE(int)); + QVERIFY(IS_ENUM_FALSE(unsigned int)); + QVERIFY(IS_ENUM_FALSE(long)); + QVERIFY(IS_ENUM_FALSE(unsigned long)); + + QVERIFY(IS_ENUM_FALSE(qint8)); + QVERIFY(IS_ENUM_FALSE(quint8)); + QVERIFY(IS_ENUM_FALSE(qint16)); + QVERIFY(IS_ENUM_FALSE(quint16)); + QVERIFY(IS_ENUM_FALSE(qint32)); + QVERIFY(IS_ENUM_FALSE(quint32)); + QVERIFY(IS_ENUM_FALSE(qint64)); + QVERIFY(IS_ENUM_FALSE(quint64)); + + QVERIFY(IS_ENUM_FALSE(void *)); + QVERIFY(IS_ENUM_FALSE(int *)); + +#if defined (Q_COMPILER_UNICODE_STRINGS) + QVERIFY(IS_ENUM_FALSE(char16_t)); + QVERIFY(IS_ENUM_FALSE(char32_t)); +#endif + +#if defined (Q_COMPILER_CLASS_ENUM) + // Strongly type class enums are not handled by the + // fallback type traits implementation. Any compiler + // supported by Qt that supports C++0x class enums + // should also support the __is_enum intrinsic. + QVERIFY(Q_IS_ENUM(isEnum_G) == true); +#endif + +#undef IS_ENUM_TRUE +#undef IS_ENUM_FALSE +} + QTEST_MAIN(tst_QGlobal) #include "tst_qglobal.moc" diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 3c21a5053f..bc5fa2716b 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -94,6 +94,7 @@ private slots: void isRegistered(); void isRegisteredStaticLess_data(); void isRegisteredStaticLess(); + void isEnum(); void registerStreamBuiltin(); void automaticTemplateRegistration(); }; @@ -1042,6 +1043,39 @@ void tst_QMetaType::isRegistered() QCOMPARE(QMetaType::isRegistered(typeId), registered); } +enum isEnumTest_Enum0 {}; +struct isEnumTest_Struct0 { enum A{}; }; + +enum isEnumTest_Enum1 {}; +struct isEnumTest_Struct1 {}; + +Q_DECLARE_METATYPE(isEnumTest_Struct1) +Q_DECLARE_METATYPE(isEnumTest_Enum1) + +void tst_QMetaType::isEnum() +{ + int type0 = qRegisterMetaType("int"); + QVERIFY((QMetaType::typeFlags(type0) & QMetaType::IsEnumeration) == 0); + + int type1 = qRegisterMetaType("isEnumTest_Enum0"); + QVERIFY((QMetaType::typeFlags(type1) & QMetaType::IsEnumeration) == QMetaType::IsEnumeration); + + int type2 = qRegisterMetaType("isEnumTest_Struct0"); + QVERIFY((QMetaType::typeFlags(type2) & QMetaType::IsEnumeration) == 0); + + int type3 = qRegisterMetaType("isEnumTest_Enum0 *"); + QVERIFY((QMetaType::typeFlags(type3) & QMetaType::IsEnumeration) == 0); + + int type4 = qRegisterMetaType("isEnumTest_Struct0::A"); + QVERIFY((QMetaType::typeFlags(type4) & QMetaType::IsEnumeration) == QMetaType::IsEnumeration); + + int type5 = ::qMetaTypeId(); + QVERIFY((QMetaType::typeFlags(type5) & QMetaType::IsEnumeration) == 0); + + int type6 = ::qMetaTypeId(); + QVERIFY((QMetaType::typeFlags(type6) & QMetaType::IsEnumeration) == QMetaType::IsEnumeration); +} + void tst_QMetaType::isRegisteredStaticLess_data() { isRegistered_data(); -- cgit v1.2.3 From a4c0109e016709dbeea1497cd122722e5ec5e26b Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 8 Mar 2012 11:30:10 +1000 Subject: testlib: Improve formatting of QCOMPARE failure messages. Make the various versions of the failure message align consistently so that it's a little easier to compare the actual and expected values. Of course, the value won't align nicely unless the "actual" and "expected" strings are the same length, but at least this commit makes that consistent across all versions of the message. Change-Id: If9ce231df3b5d279a06f6458fdb5da0aa4586068 Reviewed-by: Rohan McGovern --- .../testlib/selftests/expected_cmptest.lightxml | 36 +++++++++++----------- tests/auto/testlib/selftests/expected_cmptest.txt | 36 +++++++++++----------- tests/auto/testlib/selftests/expected_cmptest.xml | 36 +++++++++++----------- .../testlib/selftests/expected_cmptest.xunitxml | 36 +++++++++++----------- .../testlib/selftests/expected_datetime.lightxml | 6 ++-- tests/auto/testlib/selftests/expected_datetime.txt | 6 ++-- tests/auto/testlib/selftests/expected_datetime.xml | 6 ++-- .../testlib/selftests/expected_datetime.xunitxml | 6 ++-- tests/auto/testlib/selftests/expected_float.txt | 12 ++++---- .../testlib/selftests/expected_strcmp.lightxml | 10 +++--- tests/auto/testlib/selftests/expected_strcmp.txt | 10 +++--- tests/auto/testlib/selftests/expected_strcmp.xml | 10 +++--- .../testlib/selftests/expected_strcmp.xunitxml | 10 +++--- .../testlib/selftests/expected_subtest.lightxml | 4 +-- tests/auto/testlib/selftests/expected_subtest.txt | 4 +-- tests/auto/testlib/selftests/expected_subtest.xml | 4 +-- .../testlib/selftests/expected_subtest.xunitxml | 4 +-- .../auto/testlib/selftests/expected_xunit.lightxml | 2 +- tests/auto/testlib/selftests/expected_xunit.txt | 2 +- tests/auto/testlib/selftests/expected_xunit.xml | 2 +- .../auto/testlib/selftests/expected_xunit.xunitxml | 2 +- 21 files changed, 122 insertions(+), 122 deletions(-) (limited to 'tests') diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index d1cccd4bd2..83b2e6e137 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -15,7 +15,7 @@ @@ -24,19 +24,19 @@ ) + Actual (actual): QVariant(PhonyClass,) Expected (expected): QVariant(PhonyClass,)]]> @@ -50,31 +50,31 @@ + Actual (opA): 'string3' + Expected (opB): 'DIFFERS']]> + Actual (opA): 'string3' + Expected (opB): 'DIFFERS']]> @@ -85,13 +85,13 @@ @@ -100,7 +100,7 @@ @@ -115,13 +115,13 @@ @@ -130,13 +130,13 @@ diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index fce635ae5a..de666ed8b1 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -4,76 +4,76 @@ PASS : tst_Cmptest::initTestCase() PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same - Actual (actual): QVariant(int,123) + Actual (actual): QVariant(int,123) Expected (expected): QVariant(QString,hi) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(214)] PASS : tst_Cmptest::compare_tostring(both invalid) FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same - Actual (actual): QVariant(QVariantHash) + Actual (actual): QVariant(QVariantHash) Expected (expected): QVariant() Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(214)] FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same - Actual (actual): QVariant(QString,A simple string) + Actual (actual): QVariant(QString,A simple string) Expected (expected): QVariant(PhonyClass) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(214)] FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same - Actual (actual): QVariant(PhonyClass,) + Actual (actual): QVariant(PhonyClass,) Expected (expected): QVariant(PhonyClass,) Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(214)] PASS : tst_Cmptest::compareQStringLists(empty lists) PASS : tst_Cmptest::compareQStringLists(equal lists) FAIL! : tst_Cmptest::compareQStringLists(last item different) Compared QStringLists differ at index 2. - Actual (opA) : 'string3' - Expected (opB) : 'DIFFERS' + Actual (opA): 'string3' + Expected (opB): 'DIFFERS' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] FAIL! : tst_Cmptest::compareQStringLists(second-last item different) Compared QStringLists differ at index 2. - Actual (opA) : 'string3' - Expected (opB) : 'DIFFERS' + Actual (opA): 'string3' + Expected (opB): 'DIFFERS' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] FAIL! : tst_Cmptest::compareQStringLists(prefix) Compared QStringLists have different sizes. - Actual (opA) size : '2' + Actual (opA) size: '2' Expected (opB) size: '1' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] FAIL! : tst_Cmptest::compareQStringLists(short list second) Compared QStringLists have different sizes. - Actual (opA) size : '12' + Actual (opA) size: '12' Expected (opB) size: '1' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] FAIL! : tst_Cmptest::compareQStringLists(short list first) Compared QStringLists have different sizes. - Actual (opA) size : '1' + Actual (opA) size: '1' Expected (opB) size: '12' Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(308)] PASS : tst_Cmptest::compareQPixmaps(both null) FAIL! : tst_Cmptest::compareQPixmaps(one null) Compared QPixmaps differ. - Actual (opA).isNull() : 1 + Actual (opA).isNull(): 1 Expected (opB).isNull(): 0 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(333)] FAIL! : tst_Cmptest::compareQPixmaps(other null) Compared QPixmaps differ. - Actual (opA).isNull() : 0 + Actual (opA).isNull(): 0 Expected (opB).isNull(): 1 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(333)] PASS : tst_Cmptest::compareQPixmaps(equal) FAIL! : tst_Cmptest::compareQPixmaps(different size) Compared QPixmaps differ in size. - Actual (opA) : 11x20 + Actual (opA): 11x20 Expected (opB): 20x20 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(333)] FAIL! : tst_Cmptest::compareQPixmaps(different pixels) Compared values are not the same Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(333)] PASS : tst_Cmptest::compareQImages(both null) FAIL! : tst_Cmptest::compareQImages(one null) Compared QImages differ. - Actual (opA).isNull() : 1 + Actual (opA).isNull(): 1 Expected (opB).isNull(): 0 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(360)] FAIL! : tst_Cmptest::compareQImages(other null) Compared QImages differ. - Actual (opA).isNull() : 0 + Actual (opA).isNull(): 0 Expected (opB).isNull(): 1 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(360)] PASS : tst_Cmptest::compareQImages(equal) FAIL! : tst_Cmptest::compareQImages(different size) Compared QImages differ in size. - Actual (opA) : 11x20 + Actual (opA): 11x20 Expected (opB): 20x20 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(360)] FAIL! : tst_Cmptest::compareQImages(different format) Compared QImages differ in format. - Actual (opA) : 6 + Actual (opA): 6 Expected (opB): 3 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp(360)] FAIL! : tst_Cmptest::compareQImages(different pixels) Compared values are not the same diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index 90bb313518..339ef01e2d 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -17,7 +17,7 @@ @@ -26,19 +26,19 @@ ) + Actual (actual): QVariant(PhonyClass,) Expected (expected): QVariant(PhonyClass,)]]> @@ -52,31 +52,31 @@ + Actual (opA): 'string3' + Expected (opB): 'DIFFERS']]> + Actual (opA): 'string3' + Expected (opB): 'DIFFERS']]> @@ -87,13 +87,13 @@ @@ -102,7 +102,7 @@ @@ -117,13 +117,13 @@ @@ -132,13 +132,13 @@ diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index 00f5f7f480..33e78a5290 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -9,59 +9,59 @@ + Actual (opA): 'string3' + Expected (opB): 'DIFFERS'" result="fail"/> + Actual (opA): 'string3' + Expected (opB): 'DIFFERS'" result="fail"/> diff --git a/tests/auto/testlib/selftests/expected_datetime.lightxml b/tests/auto/testlib/selftests/expected_datetime.lightxml index 17fd48a196..39af3a2fcf 100644 --- a/tests/auto/testlib/selftests/expected_datetime.lightxml +++ b/tests/auto/testlib/selftests/expected_datetime.lightxml @@ -8,7 +8,7 @@ @@ -19,13 +19,13 @@ diff --git a/tests/auto/testlib/selftests/expected_datetime.txt b/tests/auto/testlib/selftests/expected_datetime.txt index 239886ca8e..6bd4103284 100644 --- a/tests/auto/testlib/selftests/expected_datetime.txt +++ b/tests/auto/testlib/selftests/expected_datetime.txt @@ -2,16 +2,16 @@ Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ PASS : tst_DateTime::initTestCase() FAIL! : tst_DateTime::dateTime() Compared values are not the same - Actual (local): 2000/05/03 04:03:04.000[local time] + Actual (local): 2000/05/03 04:03:04.000[local time] Expected (utc): 2000/05/03 04:03:04.000[UTC] Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/datetime/tst_datetime.cpp(33)] PASS : tst_DateTime::qurl(empty urls) FAIL! : tst_DateTime::qurl(empty rhs) Compared values are not the same - Actual (operandA): http://example.com + Actual (operandA): http://example.com Expected (operandB): Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/datetime/tst_datetime.cpp(41)] FAIL! : tst_DateTime::qurl(empty lhs) Compared values are not the same - Actual (operandA): + Actual (operandA): Expected (operandB): http://example.com Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/datetime/tst_datetime.cpp(41)] PASS : tst_DateTime::qurl(same urls) diff --git a/tests/auto/testlib/selftests/expected_datetime.xml b/tests/auto/testlib/selftests/expected_datetime.xml index 747ff13730..a3b7bbdee0 100644 --- a/tests/auto/testlib/selftests/expected_datetime.xml +++ b/tests/auto/testlib/selftests/expected_datetime.xml @@ -10,7 +10,7 @@ @@ -21,13 +21,13 @@ diff --git a/tests/auto/testlib/selftests/expected_datetime.xunitxml b/tests/auto/testlib/selftests/expected_datetime.xunitxml index f25e20674b..b6bb600251 100644 --- a/tests/auto/testlib/selftests/expected_datetime.xunitxml +++ b/tests/auto/testlib/selftests/expected_datetime.xunitxml @@ -7,15 +7,15 @@ diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index 6ebbeffde5..6a7804adc0 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -3,28 +3,28 @@ Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE PASS : tst_float::initTestCase() PASS : tst_float::floatComparisons(should SUCCEED 1) FAIL! : tst_float::floatComparisons(should FAIL 1) Compared floats are not the same (fuzzy compare) - Actual (operandLeft): 1 + Actual (operandLeft): 1 Expected (operandRight): 3 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(61)] FAIL! : tst_float::floatComparisons(should FAIL 2) Compared floats are not the same (fuzzy compare) - Actual (operandLeft): 1e-07 + Actual (operandLeft): 1e-07 Expected (operandRight): 3e-07 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(61)] FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the same (fuzzy compare) - Actual (operandLeft): 99998 + Actual (operandLeft): 99998 Expected (operandRight): 99999 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(61)] PASS : tst_float::floatComparisons(should SUCCEED 2) FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare) - Actual (t1): 1 + Actual (t1): 1 Expected (t3): 3 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(104)] FAIL! : tst_float::compareFloatTests(1e-7) Compared floats are not the same (fuzzy compare) - Actual (t1): 1e-07 + Actual (t1): 1e-07 Expected (t3): 3e-07 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(104)] FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fuzzy compare) - Actual (t1): 1e+07 + Actual (t1): 1e+07 Expected (t3): 3e+07 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(104)] PASS : tst_float::cleanupTestCase() diff --git a/tests/auto/testlib/selftests/expected_strcmp.lightxml b/tests/auto/testlib/selftests/expected_strcmp.lightxml index 3e71add066..d5135fd7df 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.lightxml +++ b/tests/auto/testlib/selftests/expected_strcmp.lightxml @@ -20,35 +20,35 @@ diff --git a/tests/auto/testlib/selftests/expected_strcmp.txt b/tests/auto/testlib/selftests/expected_strcmp.txt index a9e51dae5c..804d6b9265 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.txt +++ b/tests/auto/testlib/selftests/expected_strcmp.txt @@ -9,23 +9,23 @@ XFAIL : tst_StrCmp::compareByteArray() Next test should fail XFAIL : tst_StrCmp::compareByteArray() Next test should fail Loc: [./tst_strcmp.cpp(69)] FAIL! : tst_StrCmp::compareByteArray() Compared values are not the same - Actual (a): 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 ... + Actual (a): 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 ... Expected (b): 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 ... Loc: [./tst_strcmp.cpp(76)] FAIL! : tst_StrCmp::failByteArray() Compared values are not the same - Actual (QByteArray("abc")): 61 62 63 + Actual (QByteArray("abc")): 61 62 63 Expected (QByteArray("cba")): 63 62 61 Loc: [./tst_strcmp.cpp(82)] FAIL! : tst_StrCmp::failByteArrayNull() Compared values are not the same - Actual (QByteArray("foo")): 66 6F 6F + Actual (QByteArray("foo")): 66 6F 6F Expected (QByteArray()): Loc: [./tst_strcmp.cpp(88)] FAIL! : tst_StrCmp::failByteArrayEmpty() Compared values are not the same - Actual (QByteArray("")): + Actual (QByteArray("")): Expected (QByteArray("foo")): 66 6F 6F Loc: [./tst_strcmp.cpp(93)] FAIL! : tst_StrCmp::failByteArraySingleChars() Compared values are not the same - Actual (QByteArray("6")): 36 + Actual (QByteArray("6")): 36 Expected (QByteArray("7")): 37 Loc: [./tst_strcmp.cpp(100)] PASS : tst_StrCmp::cleanupTestCase() diff --git a/tests/auto/testlib/selftests/expected_strcmp.xml b/tests/auto/testlib/selftests/expected_strcmp.xml index 280eec3c9a..c35509ad7f 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.xml +++ b/tests/auto/testlib/selftests/expected_strcmp.xml @@ -22,35 +22,35 @@ diff --git a/tests/auto/testlib/selftests/expected_strcmp.xunitxml b/tests/auto/testlib/selftests/expected_strcmp.xunitxml index c2b694b8bb..a900e2f17a 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.xunitxml +++ b/tests/auto/testlib/selftests/expected_strcmp.xunitxml @@ -11,27 +11,27 @@ diff --git a/tests/auto/testlib/selftests/expected_subtest.lightxml b/tests/auto/testlib/selftests/expected_subtest.lightxml index e7d8d53efc..b156dc3991 100644 --- a/tests/auto/testlib/selftests/expected_subtest.lightxml +++ b/tests/auto/testlib/selftests/expected_subtest.lightxml @@ -122,7 +122,7 @@ @@ -140,7 +140,7 @@ diff --git a/tests/auto/testlib/selftests/expected_subtest.txt b/tests/auto/testlib/selftests/expected_subtest.txt index 7b29bfc8c3..940eb167fa 100644 --- a/tests/auto/testlib/selftests/expected_subtest.txt +++ b/tests/auto/testlib/selftests/expected_subtest.txt @@ -33,14 +33,14 @@ PASS : tst_Subtest::test3(data0) QDEBUG : tst_Subtest::test3(data1) init test3 data1 QDEBUG : tst_Subtest::test3(data1) test2 test3 data1 FAIL! : tst_Subtest::test3(data1) Compared values are not the same - Actual (str): hello1 + Actual (str): hello1 Expected (QString("hello0")): hello0 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/subtest/tst_subtest.cpp(154)] QDEBUG : tst_Subtest::test3(data1) cleanup test3 data1 QDEBUG : tst_Subtest::test3(data2) init test3 data2 QDEBUG : tst_Subtest::test3(data2) test2 test3 data2 FAIL! : tst_Subtest::test3(data2) Compared values are not the same - Actual (str): hello2 + Actual (str): hello2 Expected (QString("hello0")): hello0 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/subtest/tst_subtest.cpp(154)] QDEBUG : tst_Subtest::test3(data2) cleanup test3 data2 diff --git a/tests/auto/testlib/selftests/expected_subtest.xml b/tests/auto/testlib/selftests/expected_subtest.xml index 8a3846599c..89dd7e3006 100644 --- a/tests/auto/testlib/selftests/expected_subtest.xml +++ b/tests/auto/testlib/selftests/expected_subtest.xml @@ -124,7 +124,7 @@ @@ -142,7 +142,7 @@ diff --git a/tests/auto/testlib/selftests/expected_subtest.xunitxml b/tests/auto/testlib/selftests/expected_subtest.xunitxml index c228dc8f54..6097000e7f 100644 --- a/tests/auto/testlib/selftests/expected_subtest.xunitxml +++ b/tests/auto/testlib/selftests/expected_subtest.xunitxml @@ -38,13 +38,13 @@ diff --git a/tests/auto/testlib/selftests/expected_xunit.lightxml b/tests/auto/testlib/selftests/expected_xunit.lightxml index 71a57373d6..0615f6fd61 100644 --- a/tests/auto/testlib/selftests/expected_xunit.lightxml +++ b/tests/auto/testlib/selftests/expected_xunit.lightxml @@ -17,7 +17,7 @@ diff --git a/tests/auto/testlib/selftests/expected_xunit.txt b/tests/auto/testlib/selftests/expected_xunit.txt index 51c8f89599..88e2949580 100644 --- a/tests/auto/testlib/selftests/expected_xunit.txt +++ b/tests/auto/testlib/selftests/expected_xunit.txt @@ -6,7 +6,7 @@ WARNING: tst_Xunit::testFunc1() just a QWARN() ! PASS : tst_Xunit::testFunc1() QDEBUG : tst_Xunit::testFunc2() a qDebug() call with comment-ending stuff --> FAIL! : tst_Xunit::testFunc2() Compared values are not the same - Actual (2): 2 + Actual (2): 2 Expected (3): 3 Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/xunit/tst_xunit.cpp(74)] SKIP : tst_Xunit::testFunc3() skipping this function! diff --git a/tests/auto/testlib/selftests/expected_xunit.xml b/tests/auto/testlib/selftests/expected_xunit.xml index a1e6b20963..bfd1e9f8fa 100644 --- a/tests/auto/testlib/selftests/expected_xunit.xml +++ b/tests/auto/testlib/selftests/expected_xunit.xml @@ -19,7 +19,7 @@ diff --git a/tests/auto/testlib/selftests/expected_xunit.xunitxml b/tests/auto/testlib/selftests/expected_xunit.xunitxml index e7403443ea..7d133da7a5 100644 --- a/tests/auto/testlib/selftests/expected_xunit.xunitxml +++ b/tests/auto/testlib/selftests/expected_xunit.xunitxml @@ -11,7 +11,7 @@ -- cgit v1.2.3 From a71e12b1709557e9a7263dbf191ec28689ccd992 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 8 Mar 2012 15:48:23 +1000 Subject: Remove redundant and incorrect comment from QList autotest. Change-Id: I3187d0d8ace120181a4c49bbc68f421ddf5acbe0 Reviewed-by: Rohan McGovern --- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index fbb821c730..934130d3ee 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -43,12 +43,6 @@ #include #include -/*! - \class tst_QVector - \internal - \since 4.5 - \brief Test Qt's class QList. - */ class tst_QList : public QObject { Q_OBJECT -- cgit v1.2.3 From 16a1d5c81bfaf2103b8584d59f6bbd844fc67985 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 8 Mar 2012 16:20:31 +1000 Subject: Fix compile warnings in QCoreApplication autotest. - Use const_cast to avoid "deprecated conversion from string constant to 'char*'" warning when building argv arrays from string literals. - Use Q_UNUSED to avoid warnings on unused local variables. Change-Id: Idd2c8279adc102b6ebc6af7486ba26fe9ed4e7c1 Reviewed-by: Rohan McGovern --- .../qcoreapplication/tst_qcoreapplication.cpp | 39 ++++++++++++---------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 572c2fdfd1..84d723ca61 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -85,7 +85,7 @@ public: void tst_QCoreApplication::sendEventsOnProcessEvents() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); EventSpy spy; @@ -107,7 +107,7 @@ void tst_QCoreApplication::getSetCheck() // Test the property { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); QCOMPARE(app.property("applicationVersion").toString(), v); } @@ -119,7 +119,7 @@ void tst_QCoreApplication::getSetCheck() void tst_QCoreApplication::qAppName() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); QVERIFY(!::qAppName().isEmpty()); } @@ -131,7 +131,7 @@ void tst_QCoreApplication::argc() #endif { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); QCOMPARE(argc, 1); QCOMPARE(app.arguments().count(), 1); @@ -139,7 +139,10 @@ void tst_QCoreApplication::argc() { int argc = 4; - char *argv[] = { "tst_qcoreapplication", "arg1", "arg2", "arg3" }; + char *argv[] = { const_cast("tst_qcoreapplication"), + const_cast("arg1"), + const_cast("arg2"), + const_cast("arg3") }; QCoreApplication app(argc, argv); QCOMPARE(argc, 4); QCOMPARE(app.arguments().count(), 4); @@ -155,7 +158,8 @@ void tst_QCoreApplication::argc() { int argc = 2; - char *argv[] = { "tst_qcoreapplication", "-qmljsdebugger=port:3768,block" }; + char *argv[] = { const_cast("tst_qcoreapplication"), + const_cast("-qmljsdebugger=port:3768,block") }; QCoreApplication app(argc, argv); QCOMPARE(argc, 1); QCOMPARE(app.arguments().count(), 1); @@ -187,7 +191,7 @@ public: void tst_QCoreApplication::postEvent() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); EventSpy spy; @@ -272,7 +276,7 @@ void tst_QCoreApplication::postEvent() void tst_QCoreApplication::removePostedEvents() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); EventSpy spy; @@ -451,7 +455,7 @@ public: void tst_QCoreApplication::deliverInDefinedOrder() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); DeliverInDefinedOrderObject obj(&app); @@ -491,7 +495,7 @@ public: void tst_QCoreApplication::globalPostedEventsCount() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); QCoreApplication::sendPostedEvents(); @@ -537,7 +541,7 @@ public: void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); ProcessEventsAlwaysSendsPostedEventsObject object; @@ -555,7 +559,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() void tst_QCoreApplication::reexec() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); // exec once @@ -570,7 +574,7 @@ void tst_QCoreApplication::reexec() void tst_QCoreApplication::execAfterExit() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); app.exit(1); @@ -581,7 +585,7 @@ void tst_QCoreApplication::execAfterExit() void tst_QCoreApplication::eventLoopExecAfterExit() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); // exec once and exit @@ -633,8 +637,7 @@ void tst_QCoreApplication::customEventDispatcher() QVERIFY(!weak_ed.isNull()); { int argc = 1; - char *arg0 = "tst_qcoreapplication"; - char *argv[] = { arg0 }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); // instantiating app should not overwrite the ED QCOMPARE(QCoreApplication::eventDispatcher(), ed); @@ -728,10 +731,12 @@ private slots: QCOMPARE(privateClass->quitLockRef.load(), 2); JobObject *job3 = new JobObject(job2); + Q_UNUSED(job3); QCOMPARE(privateClass->quitLockRef.load(), 3); JobObject *job4 = new JobObject(job2); + Q_UNUSED(job4); QCOMPARE(privateClass->quitLockRef.load(), 4); @@ -747,7 +752,7 @@ private slots: void tst_QCoreApplication::testQuitLock() { int argc = 1; - char *argv[] = { "tst_qcoreapplication" }; + char *argv[] = { const_cast("tst_qcoreapplication") }; QCoreApplication app(argc, argv); QuitTester tester; -- cgit v1.2.3 From 0e905e91382ac5903c8784a28ed6b5a15adf404e Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 8 Mar 2012 15:52:03 +1000 Subject: Remove outdated assumption from QVariant autotest. The test was assuming that "data()" is a special function in autotests, but that hasn't been the case since early prototypes of testlib. Change-Id: Ic24cf5dc539b55d12eba0a6ab17173e2ed698f21 Reviewed-by: Rohan McGovern --- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index d78759e923..655c714322 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -228,7 +228,7 @@ private slots: void podUserType(); - void data_(); // data is virtual function in QtTestCase + void data(); void constData(); void saveLoadCustomTypes(); @@ -2221,7 +2221,7 @@ void tst_QVariant::basicUserType() QCOMPARE(v.toByteArray(), QByteArray("bar")); } -void tst_QVariant::data_() +void tst_QVariant::data() { QVariant v; -- cgit v1.2.3 From 2e886cfbcb0ae80a3545943d917352eb54804e98 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 8 Mar 2012 16:05:03 -0800 Subject: Move tst_qicon.cpp and tst_qpixmapfilter.cpp to QtWidgets QIcon and QPixmapFilter belong to QtWidgets instead of QtGui. Change-Id: I6d82811e04046edb0cc67c55970c161612e86d3f Reviewed-by: Sergio Ahumada Reviewed-by: Gunnar Sletta Reviewed-by: Friedemann Kleint --- tests/auto/gui/image/image.pro | 2 - tests/auto/gui/image/qicon/.gitignore | 1 - .../testtheme/16x16/actions/appointment-new.png | Bin 897 -> 0 bytes .../testtheme/22x22/actions/appointment-new.png | Bin 1411 -> 0 bytes .../testtheme/32x32/actions/appointment-new.png | Bin 2399 -> 0 bytes .../gui/image/qicon/icons/testtheme/index.theme | 492 ---------------- .../icons/testtheme/scalable/actions/svg-only.svg | 425 -------------- .../themeparent/16x16/actions/address-book-new.png | Bin 796 -> 0 bytes .../themeparent/16x16/actions/appointment-new.png | Bin 897 -> 0 bytes .../themeparent/22x22/actions/address-book-new.png | Bin 924 -> 0 bytes .../themeparent/22x22/actions/appointment-new.png | Bin 1411 -> 0 bytes .../themeparent/32x32/actions/address-book-new.png | Bin 1897 -> 0 bytes .../themeparent/32x32/actions/appointment-new.png | Bin 2399 -> 0 bytes .../gui/image/qicon/icons/themeparent/index.theme | 492 ---------------- .../scalable/actions/address-book-new.svg | 389 ------------- .../scalable/actions/appointment-new.svg | 425 -------------- tests/auto/gui/image/qicon/image.png | Bin 14743 -> 0 bytes tests/auto/gui/image/qicon/qicon.pro | 12 - tests/auto/gui/image/qicon/rect.png | Bin 175 -> 0 bytes tests/auto/gui/image/qicon/tst_qicon.cpp | 637 --------------------- tests/auto/gui/image/qicon/tst_qicon.qrc | 20 - tests/auto/gui/image/qpixmapfilter/noise.png | Bin 7517 -> 0 bytes .../auto/gui/image/qpixmapfilter/qpixmapfilter.pro | 14 - .../gui/image/qpixmapfilter/tst_qpixmapfilter.cpp | 447 --------------- tests/auto/widgets/effects/effects.pro | 1 + tests/auto/widgets/effects/qpixmapfilter/noise.png | Bin 0 -> 7517 bytes .../effects/qpixmapfilter/qpixmapfilter.pro | 14 + .../effects/qpixmapfilter/tst_qpixmapfilter.cpp | 447 +++++++++++++++ tests/auto/widgets/kernel/kernel.pro | 1 + tests/auto/widgets/kernel/qicon/.gitignore | 1 + .../testtheme/16x16/actions/appointment-new.png | Bin 0 -> 897 bytes .../testtheme/22x22/actions/appointment-new.png | Bin 0 -> 1411 bytes .../testtheme/32x32/actions/appointment-new.png | Bin 0 -> 2399 bytes .../kernel/qicon/icons/testtheme/index.theme | 492 ++++++++++++++++ .../icons/testtheme/scalable/actions/svg-only.svg | 425 ++++++++++++++ .../themeparent/16x16/actions/address-book-new.png | Bin 0 -> 796 bytes .../themeparent/16x16/actions/appointment-new.png | Bin 0 -> 897 bytes .../themeparent/22x22/actions/address-book-new.png | Bin 0 -> 924 bytes .../themeparent/22x22/actions/appointment-new.png | Bin 0 -> 1411 bytes .../themeparent/32x32/actions/address-book-new.png | Bin 0 -> 1897 bytes .../themeparent/32x32/actions/appointment-new.png | Bin 0 -> 2399 bytes .../kernel/qicon/icons/themeparent/index.theme | 492 ++++++++++++++++ .../scalable/actions/address-book-new.svg | 389 +++++++++++++ .../scalable/actions/appointment-new.svg | 425 ++++++++++++++ tests/auto/widgets/kernel/qicon/image.png | Bin 0 -> 14743 bytes tests/auto/widgets/kernel/qicon/qicon.pro | 12 + tests/auto/widgets/kernel/qicon/rect.png | Bin 0 -> 175 bytes tests/auto/widgets/kernel/qicon/tst_qicon.cpp | 637 +++++++++++++++++++++ tests/auto/widgets/kernel/qicon/tst_qicon.qrc | 20 + 49 files changed, 3356 insertions(+), 3356 deletions(-) delete mode 100644 tests/auto/gui/image/qicon/.gitignore delete mode 100644 tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/testtheme/index.theme delete mode 100644 tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/index.theme delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg delete mode 100644 tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg delete mode 100644 tests/auto/gui/image/qicon/image.png delete mode 100644 tests/auto/gui/image/qicon/qicon.pro delete mode 100644 tests/auto/gui/image/qicon/rect.png delete mode 100644 tests/auto/gui/image/qicon/tst_qicon.cpp delete mode 100644 tests/auto/gui/image/qicon/tst_qicon.qrc delete mode 100644 tests/auto/gui/image/qpixmapfilter/noise.png delete mode 100644 tests/auto/gui/image/qpixmapfilter/qpixmapfilter.pro delete mode 100644 tests/auto/gui/image/qpixmapfilter/tst_qpixmapfilter.cpp create mode 100644 tests/auto/widgets/effects/qpixmapfilter/noise.png create mode 100644 tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro create mode 100644 tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp create mode 100644 tests/auto/widgets/kernel/qicon/.gitignore create mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme create mode 100644 tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg create mode 100644 tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg create mode 100644 tests/auto/widgets/kernel/qicon/image.png create mode 100644 tests/auto/widgets/kernel/qicon/qicon.pro create mode 100644 tests/auto/widgets/kernel/qicon/rect.png create mode 100644 tests/auto/widgets/kernel/qicon/tst_qicon.cpp create mode 100644 tests/auto/widgets/kernel/qicon/tst_qicon.qrc (limited to 'tests') diff --git a/tests/auto/gui/image/image.pro b/tests/auto/gui/image/image.pro index fa8f8df29d..5a03063f47 100644 --- a/tests/auto/gui/image/image.pro +++ b/tests/auto/gui/image/image.pro @@ -5,11 +5,9 @@ SUBDIRS=\ qpixmap \ qpixmapcache \ qimage \ - qpixmapfilter \ qimageiohandler \ qimagewriter \ qmovie \ - qicon \ qpicture \ !contains(QT_CONFIG, private_tests): SUBDIRS -= \ diff --git a/tests/auto/gui/image/qicon/.gitignore b/tests/auto/gui/image/qicon/.gitignore deleted file mode 100644 index c101ef9d28..0000000000 --- a/tests/auto/gui/image/qicon/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qicon diff --git a/tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png deleted file mode 100644 index 18b7c6781e..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/testtheme/16x16/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png deleted file mode 100644 index d676ffd463..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/testtheme/22x22/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png deleted file mode 100644 index 85daef3b0b..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/testtheme/32x32/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/testtheme/index.theme b/tests/auto/gui/image/qicon/icons/testtheme/index.theme deleted file mode 100644 index e18736ab43..0000000000 --- a/tests/auto/gui/image/qicon/icons/testtheme/index.theme +++ /dev/null @@ -1,492 +0,0 @@ -[Icon Theme] -_Name=Test -_Comment=Test Theme -Inherits=crystalsvg, themeparent -Example=x-directory-normal - -# KDE Specific Stuff -DisplayDepth=32 -LinkOverlay=link_overlay -LockOverlay=lock_overlay -ZipOverlay=zip_overlay -DesktopDefault=48 -DesktopSizes=16,22,32,48,64,72,96,128 -ToolbarDefault=22 -ToolbarSizes=16,22,32,48 -MainToolbarDefault=22 -MainToolbarSizes=16,22,32,48 -SmallDefault=16 -SmallSizes=16 -PanelDefault=32 -PanelSizes=16,22,32,48,64,72,96,128 - -# Directory list -Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status - -[16x16/actions] -Size=16 -Context=Actions -Type=Fixed - -[16x16/apps] -Size=16 -Context=Applications -Type=Fixed - -[16x16/categories] -Size=16 -Context=Categories -Type=Fixed - -[16x16/devices] -Size=16 -Context=Devices -Type=Fixed - -[16x16/emblems] -Size=16 -Context=Emblems -Type=Fixed - -[16x16/emotes] -Size=16 -Context=Emotes -Type=Fixed - -[16x16/mimetypes] -Size=16 -Context=MimeTypes -Type=Fixed - -[16x16/places] -Size=16 -Context=Places -Type=Fixed - -[16x16/status] -Size=16 -Context=Status -Type=Fixed - -[22x22/actions] -Size=22 -Context=Actions -Type=Fixed - -[22x22/apps] -Size=22 -Context=Applications -Type=Fixed - -[22x22/categories] -Size=22 -Context=Categories -Type=Fixed - -[22x22/devices] -Size=22 -Context=Devices -Type=Fixed - -[22x22/emblems] -Size=22 -Context=Emblems -Type=Fixed - -[22x22/emotes] -Size=22 -Context=Emotes -Type=Fixed - -[22x22/mimetypes] -Size=22 -Context=MimeTypes -Type=Fixed - -[22x22/places] -Size=22 -Context=Places -Type=Fixed - -[22x22/status] -Size=22 -Context=Status -Type=Fixed - -[24x24/actions] -Size=24 -Context=Actions -Type=Fixed - -[24x24/apps] -Size=24 -Context=Applications -Type=Fixed - -[24x24/categories] -Size=24 -Context=Categories -Type=Fixed - -[24x24/devices] -Size=24 -Context=Devices -Type=Fixed - -[24x24/emblems] -Size=24 -Context=Emblems -Type=Fixed - -[24x24/emotes] -Size=24 -Context=Emotes -Type=Fixed - -[24x24/mimetypes] -Size=24 -Context=MimeTypes -Type=Fixed - -[24x24/places] -Size=24 -Context=Places -Type=Fixed - -[24x24/status] -Size=24 -Context=Status -Type=Fixed - -[32x32/actions] -Size=32 -Context=Actions -Type=Fixed - -[32x32/apps] -Size=32 -Context=Applications -Type=Fixed - -[32x32/categories] -Size=32 -Context=Categories -Type=Fixed - -[32x32/devices] -Size=32 -Context=Devices -Type=Fixed - -[32x32/emblems] -Size=32 -Context=Emblems -Type=Fixed - -[32x32/emotes] -Size=32 -Context=Emotes -Type=Fixed - -[32x32/mimetypes] -Size=32 -Context=MimeTypes -Type=Fixed - -[32x32/places] -Size=32 -Context=Places -Type=Fixed - -[32x32/status] -Size=32 -Context=Status -Type=Fixed - -[48x48/actions] -Size=48 -Context=Actions -Type=Fixed - -[48x48/apps] -Size=48 -Context=Applications -Type=Fixed - -[48x48/categories] -Size=48 -Context=Categories -Type=Fixed - -[48x48/devices] -Size=48 -Context=Devices -Type=Fixed - -[48x48/emblems] -Size=48 -Context=Emblems -Type=Fixed - -[48x48/emotes] -Size=48 -Context=Emotes -Type=Fixed - -[48x48/mimetypes] -Size=48 -Context=MimeTypes -Type=Fixed - -[48x48/places] -Size=48 -Context=Places -Type=Fixed - -[48x48/status] -Size=48 -Context=Status -Type=Fixed - -[64x64/actions] -Size=64 -Context=Actions -Type=Fixed - -[64x64/apps] -Size=64 -Context=Applications -Type=Fixed - -[64x64/categories] -Size=64 -Context=Categories -Type=Fixed - -[64x64/devices] -Size=64 -Context=Devices -Type=Fixed - -[64x64/emblems] -Size=64 -Context=Emblems -Type=Fixed - -[64x64/emotes] -Size=64 -Context=Emotes -Type=Fixed - -[64x64/mimetypes] -Size=64 -Context=MimeTypes -Type=Fixed - -[64x64/places] -Size=64 -Context=Places -Type=Fixed - -[64x64/status] -Size=64 -Context=Status -Type=Fixed - -[72x72/actions] -Size=72 -Context=Actions -Type=Fixed - -[72x72/apps] -Size=72 -Context=Applications -Type=Fixed - -[72x72/categories] -Size=72 -Context=Categories -Type=Fixed - -[72x72/devices] -Size=72 -Context=Devices -Type=Fixed - -[72x72/emblems] -Size=72 -Context=Emblems -Type=Fixed - -[72x72/emotes] -Size=72 -Context=Emotes -Type=Fixed - -[72x72/mimetypes] -Size=72 -Context=MimeTypes -Type=Fixed - -[72x72/places] -Size=72 -Context=Places -Type=Fixed - -[72x72/status] -Size=72 -Context=Status -Type=Fixed - -[96x96/actions] -Size=96 -Context=Actions -Type=Fixed - -[96x96/apps] -Size=96 -Context=Applications -Type=Fixed - -[96x96/categories] -Size=96 -Context=Categories -Type=Fixed - -[96x96/devices] -Size=96 -Context=Devices -Type=Fixed - -[96x96/emblems] -Size=96 -Context=Emblems -Type=Fixed - -[96x96/emotes] -Size=96 -Context=Emotes -Type=Fixed - -[96x96/mimetypes] -Size=96 -Context=MimeTypes -Type=Fixed - -[96x96/places] -Size=96 -Context=Places -Type=Fixed - -[96x96/status] -Size=96 -Context=Status -Type=Fixed - -[128x128/actions] -Size=128 -Context=Actions -Type=Fixed - -[128x128/apps] -Size=128 -Context=Applications -Type=Fixed - -[128x128/categories] -Size=128 -Context=Categories -Type=Fixed - -[128x128/devices] -Size=128 -Context=Devices -Type=Fixed - -[128x128/emblems] -Size=128 -Context=Emblems -Type=Fixed - -[128x128/emotes] -Size=128 -Context=Emotes -Type=Fixed - -[128x128/mimetypes] -Size=128 -Context=MimeTypes -Type=Fixed - -[128x128/places] -Size=128 -Context=Places -Type=Fixed - -[128x128/status] -Size=128 -Context=Status -Type=Fixed - -[scalable/actions] -Size=48 -Context=Actions -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/apps] -Size=48 -Context=Applications -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/categories] -Size=48 -Context=Categories -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/devices] -Size=48 -Context=Devices -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emblems] -Size=48 -Context=Emblems -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emotes] -Size=48 -Context=Emotes -Type=Scalable -Minsize=32 -MaxSize=256 - -[scalable/mimetypes] -Size=48 -Context=MimeTypes -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/places] -Size=48 -Context=Places -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/status] -Size=48 -Context=Status -Type=Scalable -MinSize=32 -MaxSize=256 diff --git a/tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg b/tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg deleted file mode 100644 index 4cb14f82f0..0000000000 --- a/tests/auto/gui/image/qicon/icons/testtheme/scalable/actions/svg-only.svg +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - New Appointment - - - appointment - new - meeting - rvsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png b/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png deleted file mode 100644 index 2098cfdf36..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/address-book-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png deleted file mode 100644 index 18b7c6781e..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/themeparent/16x16/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png b/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png deleted file mode 100644 index fad446cd92..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/address-book-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png deleted file mode 100644 index d676ffd463..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/themeparent/22x22/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png b/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png deleted file mode 100644 index 420139d307..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/address-book-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png b/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png deleted file mode 100644 index 85daef3b0b..0000000000 Binary files a/tests/auto/gui/image/qicon/icons/themeparent/32x32/actions/appointment-new.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/icons/themeparent/index.theme b/tests/auto/gui/image/qicon/icons/themeparent/index.theme deleted file mode 100644 index e536a0bf2f..0000000000 --- a/tests/auto/gui/image/qicon/icons/themeparent/index.theme +++ /dev/null @@ -1,492 +0,0 @@ -[Icon Theme] -_Name=Test -_Comment=Test Theme -Inherits=gnome,crystalsvg -Example=x-directory-normal - -# KDE Specific Stuff -DisplayDepth=32 -LinkOverlay=link_overlay -LockOverlay=lock_overlay -ZipOverlay=zip_overlay -DesktopDefault=48 -DesktopSizes=16,22,32,48,64,72,96,128 -ToolbarDefault=22 -ToolbarSizes=16,22,32,48 -MainToolbarDefault=22 -MainToolbarSizes=16,22,32,48 -SmallDefault=16 -SmallSizes=16 -PanelDefault=32 -PanelSizes=16,22,32,48,64,72,96,128 - -# Directory list -Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status - -[16x16/actions] -Size=16 -Context=Actions -Type=Fixed - -[16x16/apps] -Size=16 -Context=Applications -Type=Fixed - -[16x16/categories] -Size=16 -Context=Categories -Type=Fixed - -[16x16/devices] -Size=16 -Context=Devices -Type=Fixed - -[16x16/emblems] -Size=16 -Context=Emblems -Type=Fixed - -[16x16/emotes] -Size=16 -Context=Emotes -Type=Fixed - -[16x16/mimetypes] -Size=16 -Context=MimeTypes -Type=Fixed - -[16x16/places] -Size=16 -Context=Places -Type=Fixed - -[16x16/status] -Size=16 -Context=Status -Type=Fixed - -[22x22/actions] -Size=22 -Context=Actions -Type=Fixed - -[22x22/apps] -Size=22 -Context=Applications -Type=Fixed - -[22x22/categories] -Size=22 -Context=Categories -Type=Fixed - -[22x22/devices] -Size=22 -Context=Devices -Type=Fixed - -[22x22/emblems] -Size=22 -Context=Emblems -Type=Fixed - -[22x22/emotes] -Size=22 -Context=Emotes -Type=Fixed - -[22x22/mimetypes] -Size=22 -Context=MimeTypes -Type=Fixed - -[22x22/places] -Size=22 -Context=Places -Type=Fixed - -[22x22/status] -Size=22 -Context=Status -Type=Fixed - -[24x24/actions] -Size=24 -Context=Actions -Type=Fixed - -[24x24/apps] -Size=24 -Context=Applications -Type=Fixed - -[24x24/categories] -Size=24 -Context=Categories -Type=Fixed - -[24x24/devices] -Size=24 -Context=Devices -Type=Fixed - -[24x24/emblems] -Size=24 -Context=Emblems -Type=Fixed - -[24x24/emotes] -Size=24 -Context=Emotes -Type=Fixed - -[24x24/mimetypes] -Size=24 -Context=MimeTypes -Type=Fixed - -[24x24/places] -Size=24 -Context=Places -Type=Fixed - -[24x24/status] -Size=24 -Context=Status -Type=Fixed - -[32x32/actions] -Size=32 -Context=Actions -Type=Fixed - -[32x32/apps] -Size=32 -Context=Applications -Type=Fixed - -[32x32/categories] -Size=32 -Context=Categories -Type=Fixed - -[32x32/devices] -Size=32 -Context=Devices -Type=Fixed - -[32x32/emblems] -Size=32 -Context=Emblems -Type=Fixed - -[32x32/emotes] -Size=32 -Context=Emotes -Type=Fixed - -[32x32/mimetypes] -Size=32 -Context=MimeTypes -Type=Fixed - -[32x32/places] -Size=32 -Context=Places -Type=Fixed - -[32x32/status] -Size=32 -Context=Status -Type=Fixed - -[48x48/actions] -Size=48 -Context=Actions -Type=Fixed - -[48x48/apps] -Size=48 -Context=Applications -Type=Fixed - -[48x48/categories] -Size=48 -Context=Categories -Type=Fixed - -[48x48/devices] -Size=48 -Context=Devices -Type=Fixed - -[48x48/emblems] -Size=48 -Context=Emblems -Type=Fixed - -[48x48/emotes] -Size=48 -Context=Emotes -Type=Fixed - -[48x48/mimetypes] -Size=48 -Context=MimeTypes -Type=Fixed - -[48x48/places] -Size=48 -Context=Places -Type=Fixed - -[48x48/status] -Size=48 -Context=Status -Type=Fixed - -[64x64/actions] -Size=64 -Context=Actions -Type=Fixed - -[64x64/apps] -Size=64 -Context=Applications -Type=Fixed - -[64x64/categories] -Size=64 -Context=Categories -Type=Fixed - -[64x64/devices] -Size=64 -Context=Devices -Type=Fixed - -[64x64/emblems] -Size=64 -Context=Emblems -Type=Fixed - -[64x64/emotes] -Size=64 -Context=Emotes -Type=Fixed - -[64x64/mimetypes] -Size=64 -Context=MimeTypes -Type=Fixed - -[64x64/places] -Size=64 -Context=Places -Type=Fixed - -[64x64/status] -Size=64 -Context=Status -Type=Fixed - -[72x72/actions] -Size=72 -Context=Actions -Type=Fixed - -[72x72/apps] -Size=72 -Context=Applications -Type=Fixed - -[72x72/categories] -Size=72 -Context=Categories -Type=Fixed - -[72x72/devices] -Size=72 -Context=Devices -Type=Fixed - -[72x72/emblems] -Size=72 -Context=Emblems -Type=Fixed - -[72x72/emotes] -Size=72 -Context=Emotes -Type=Fixed - -[72x72/mimetypes] -Size=72 -Context=MimeTypes -Type=Fixed - -[72x72/places] -Size=72 -Context=Places -Type=Fixed - -[72x72/status] -Size=72 -Context=Status -Type=Fixed - -[96x96/actions] -Size=96 -Context=Actions -Type=Fixed - -[96x96/apps] -Size=96 -Context=Applications -Type=Fixed - -[96x96/categories] -Size=96 -Context=Categories -Type=Fixed - -[96x96/devices] -Size=96 -Context=Devices -Type=Fixed - -[96x96/emblems] -Size=96 -Context=Emblems -Type=Fixed - -[96x96/emotes] -Size=96 -Context=Emotes -Type=Fixed - -[96x96/mimetypes] -Size=96 -Context=MimeTypes -Type=Fixed - -[96x96/places] -Size=96 -Context=Places -Type=Fixed - -[96x96/status] -Size=96 -Context=Status -Type=Fixed - -[128x128/actions] -Size=128 -Context=Actions -Type=Fixed - -[128x128/apps] -Size=128 -Context=Applications -Type=Fixed - -[128x128/categories] -Size=128 -Context=Categories -Type=Fixed - -[128x128/devices] -Size=128 -Context=Devices -Type=Fixed - -[128x128/emblems] -Size=128 -Context=Emblems -Type=Fixed - -[128x128/emotes] -Size=128 -Context=Emotes -Type=Fixed - -[128x128/mimetypes] -Size=128 -Context=MimeTypes -Type=Fixed - -[128x128/places] -Size=128 -Context=Places -Type=Fixed - -[128x128/status] -Size=128 -Context=Status -Type=Fixed - -[scalable/actions] -Size=48 -Context=Actions -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/apps] -Size=48 -Context=Applications -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/categories] -Size=48 -Context=Categories -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/devices] -Size=48 -Context=Devices -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emblems] -Size=48 -Context=Emblems -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/emotes] -Size=48 -Context=Emotes -Type=Scalable -Minsize=32 -MaxSize=256 - -[scalable/mimetypes] -Size=48 -Context=MimeTypes -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/places] -Size=48 -Context=Places -Type=Scalable -MinSize=32 -MaxSize=256 - -[scalable/status] -Size=48 -Context=Status -Type=Scalable -MinSize=32 -MaxSize=256 diff --git a/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg b/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg deleted file mode 100644 index 600a82c1b0..0000000000 --- a/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/address-book-new.svg +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Addess Book - New - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - - address - contact - book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg b/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg deleted file mode 100644 index 4cb14f82f0..0000000000 --- a/tests/auto/gui/image/qicon/icons/themeparent/scalable/actions/appointment-new.svg +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - New Appointment - - - appointment - new - meeting - rvsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/auto/gui/image/qicon/image.png b/tests/auto/gui/image/qicon/image.png deleted file mode 100644 index 8d703640c1..0000000000 Binary files a/tests/auto/gui/image/qicon/image.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/qicon.pro b/tests/auto/gui/image/qicon/qicon.pro deleted file mode 100644 index c44c080ced..0000000000 --- a/tests/auto/gui/image/qicon/qicon.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qicon - -QT += widgets testlib -SOURCES += tst_qicon.cpp -RESOURCES = tst_qicon.qrc - -wince* { - QT += xml svg - DEPLOYMENT_PLUGIN += qsvg -} -TESTDATA += icons/* *.png *.svg *.svgz diff --git a/tests/auto/gui/image/qicon/rect.png b/tests/auto/gui/image/qicon/rect.png deleted file mode 100644 index b5d3ecbddf..0000000000 Binary files a/tests/auto/gui/image/qicon/rect.png and /dev/null differ diff --git a/tests/auto/gui/image/qicon/tst_qicon.cpp b/tests/auto/gui/image/qicon/tst_qicon.cpp deleted file mode 100644 index 4a9ab93921..0000000000 --- a/tests/auto/gui/image/qicon/tst_qicon.cpp +++ /dev/null @@ -1,637 +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 -#include -#include - -Q_DECLARE_METATYPE(QSize) - -class tst_QIcon : public QObject -{ - Q_OBJECT -public: - tst_QIcon(); - -private slots: - void actualSize_data(); // test with 1 pixmap - void actualSize(); - void actualSize2_data(); // test with 2 pixmaps with different aspect ratio - void actualSize2(); - void isNull(); - void swap(); - void bestMatch(); - void cacheKey(); - void detach(); - void addFile(); - void availableSizes(); - void name(); - void streamAvailableSizes_data(); - void streamAvailableSizes(); - void fromTheme(); - - void task184901_badCache(); - void task223279_inconsistentAddFile(); - -private: - bool haveImageFormat(QByteArray const&); - - const static QIcon staticIcon; -}; - -// Creating an icon statically should not cause a crash. -// But we do not officially support this. See QTBUG-8666 -const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find"); - -bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) -{ - return QImageReader::supportedImageFormats().contains(desiredFormat); -} - -tst_QIcon::tst_QIcon() -{ -} - -void tst_QIcon::actualSize_data() -{ - QTest::addColumn("source"); - QTest::addColumn("argument"); - QTest::addColumn("result"); - - // square image - QTest::newRow("resource0") << ":/image.png" << QSize(128, 128) << QSize(128, 128); - QTest::newRow("resource1") << ":/image.png" << QSize( 64, 64) << QSize( 64, 64); - QTest::newRow("resource2") << ":/image.png" << QSize( 32, 64) << QSize( 32, 32); - QTest::newRow("resource3") << ":/image.png" << QSize( 16, 64) << QSize( 16, 16); - QTest::newRow("resource4") << ":/image.png" << QSize( 16, 128) << QSize( 16, 16); - QTest::newRow("resource5") << ":/image.png" << QSize( 128, 16) << QSize( 16, 16); - QTest::newRow("resource6") << ":/image.png" << QSize( 150, 150) << QSize( 128, 128); - // rect image - QTest::newRow("resource7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); - QTest::newRow("resource8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); - QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); - QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); - - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128); - QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64); - QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32); - QTest::newRow("external3") << prefix + "image.png" << QSize( 16, 64) << QSize( 16, 16); - QTest::newRow("external4") << prefix + "image.png" << QSize( 16, 128) << QSize( 16, 16); - QTest::newRow("external5") << prefix + "image.png" << QSize( 128, 16) << QSize( 16, 16); - QTest::newRow("external6") << prefix + "image.png" << QSize( 150, 150) << QSize( 128, 128); - // rect image - QTest::newRow("external7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); - QTest::newRow("external8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); - QTest::newRow("external9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); - QTest::newRow("external10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); -} - -void tst_QIcon::actualSize() -{ - QFETCH(QString, source); - QFETCH(QSize, argument); - QFETCH(QSize, result); - - { - QPixmap pixmap(source); - QIcon icon(pixmap); - QCOMPARE(icon.actualSize(argument), result); - QCOMPARE(icon.pixmap(argument).size(), result); - } - - { - QIcon icon(source); - QCOMPARE(icon.actualSize(argument), result); - QCOMPARE(icon.pixmap(argument).size(), result); - } -} - -void tst_QIcon::actualSize2_data() -{ - QTest::addColumn("argument"); - QTest::addColumn("result"); - - // two images - 128x128 and 20x40. Let the games begin - QTest::newRow("trivial1") << QSize( 128, 128) << QSize( 128, 128); - QTest::newRow("trivial2") << QSize( 20, 40) << QSize( 20, 40); - - // QIcon chooses the one with the smallest area to choose the pixmap - QTest::newRow("best1") << QSize( 100, 100) << QSize( 100, 100); - QTest::newRow("best2") << QSize( 20, 20) << QSize( 10, 20); - QTest::newRow("best3") << QSize( 15, 30) << QSize( 15, 30); - QTest::newRow("best4") << QSize( 5, 5) << QSize( 2, 5); - QTest::newRow("best5") << QSize( 10, 15) << QSize( 7, 15); -} - -void tst_QIcon::actualSize2() -{ - QIcon icon; - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - - icon.addPixmap(QPixmap(prefix + "image.png")); - icon.addPixmap(QPixmap(prefix + "rect.png")); - - QFETCH(QSize, argument); - QFETCH(QSize, result); - - QCOMPARE(icon.actualSize(argument), result); - QCOMPARE(icon.pixmap(argument).size(), result); -} - -void tst_QIcon::isNull() { - // test default constructor - QIcon defaultConstructor; - QVERIFY(defaultConstructor.isNull()); - - // test copy constructor - QVERIFY(QIcon(defaultConstructor).isNull()); - - // test pixmap constructor - QPixmap nullPixmap; - QVERIFY(QIcon(nullPixmap).isNull()); - - // test string constructor with empty string - QIcon iconEmptyString = QIcon(QString()); - QVERIFY(iconEmptyString.isNull()); - QVERIFY(!iconEmptyString.actualSize(QSize(32, 32)).isValid());; - - // test string constructor with non-existing file - QIcon iconNoFile = QIcon("imagedoesnotexist"); - QVERIFY(!iconNoFile.isNull()); - QVERIFY(!iconNoFile.actualSize(QSize(32, 32)).isValid()); - - // test string constructor with non-existing file with suffix - QIcon iconNoFileSuffix = QIcon("imagedoesnotexist.png"); - QVERIFY(!iconNoFileSuffix.isNull()); - QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid()); - - const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; - // test string constructor with existing file but unsupported format - QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp"); - QVERIFY(!iconUnsupportedFormat.isNull()); - QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid()); - - // test string constructor with existing file and supported format - QIcon iconSupportedFormat = QIcon(prefix + "image.png"); - QVERIFY(!iconSupportedFormat.isNull()); - QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid()); -} - -void tst_QIcon::swap() -{ - QPixmap p1(1, 1), p2(2, 2); - p1.fill(Qt::black); - p2.fill(Qt::black); - - QIcon i1(p1), i2(p2); - const qint64 i1k = i1.cacheKey(); - const qint64 i2k = i2.cacheKey(); - QVERIFY(i1k != i2k); - i1.swap(i2); - QCOMPARE(i1.cacheKey(), i2k); - QCOMPARE(i2.cacheKey(), i1k); -} - -void tst_QIcon::bestMatch() -{ - QPixmap p1(1, 1); - QPixmap p2(2, 2); - QPixmap p3(3, 3); - QPixmap p4(4, 4); - QPixmap p5(5, 5); - QPixmap p6(6, 6); - QPixmap p7(7, 7); - QPixmap p8(8, 8); - - p1.fill(Qt::black); - p2.fill(Qt::black); - p3.fill(Qt::black); - p4.fill(Qt::black); - p5.fill(Qt::black); - p6.fill(Qt::black); - p7.fill(Qt::black); - p8.fill(Qt::black); - - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 2; ++j) { - QIcon::State state = (j == 0) ? QIcon::On : QIcon::Off; - QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off - : QIcon::On; - QIcon::Mode mode; - QIcon::Mode oppositeMode; - - QIcon icon; - - switch (i) { - case 0: - default: - mode = QIcon::Normal; - oppositeMode = QIcon::Active; - break; - case 1: - mode = QIcon::Active; - oppositeMode = QIcon::Normal; - break; - case 2: - mode = QIcon::Disabled; - oppositeMode = QIcon::Selected; - break; - case 3: - mode = QIcon::Selected; - oppositeMode = QIcon::Disabled; - } - - /* - The test mirrors the code in - QPixmapIconEngine::bestMatch(), to make sure that - nobody breaks QPixmapIconEngine by mistake. Before - you change this test or the code that it tests, - please talk to the maintainer if possible. - */ - if (mode == QIcon::Disabled || mode == QIcon::Selected) { - icon.addPixmap(p1, oppositeMode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); - - icon.addPixmap(p2, oppositeMode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); - - icon.addPixmap(p3, QIcon::Active, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); - - icon.addPixmap(p4, QIcon::Normal, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); - - icon.addPixmap(p5, mode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); - - icon.addPixmap(p6, QIcon::Active, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); - - icon.addPixmap(p7, QIcon::Normal, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); - - icon.addPixmap(p8, mode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); - } else { - icon.addPixmap(p1, QIcon::Selected, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); - - icon.addPixmap(p2, QIcon::Disabled, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); - - icon.addPixmap(p3, QIcon::Selected, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); - - icon.addPixmap(p4, QIcon::Disabled, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); - - icon.addPixmap(p5, oppositeMode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); - - icon.addPixmap(p6, mode, oppositeState); - QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); - - icon.addPixmap(p7, oppositeMode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); - - icon.addPixmap(p8, mode, state); - QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); - } - } - } -} - -void tst_QIcon::cacheKey() -{ - QIcon icon1("image.png"); - qint64 icon1_key = icon1.cacheKey(); - QIcon icon2 = icon1; - - QVERIFY(icon2.cacheKey() == icon1.cacheKey()); - icon2.detach(); - QVERIFY(icon2.cacheKey() != icon1.cacheKey()); - QVERIFY(icon1.cacheKey() == icon1_key); -} - -void tst_QIcon::detach() -{ - QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); - img.fill(0xffff0000); - QIcon icon1(QPixmap::fromImage(img)); - QIcon icon2 = icon1; - icon2.addFile(QFINDTESTDATA("image.png"), QSize(64, 64)); - - QImage img1 = icon1.pixmap(64, 64).toImage(); - QImage img2 = icon2.pixmap(64, 64).toImage(); - QVERIFY(img1 != img2); - - img1 = icon1.pixmap(32, 32).toImage(); - img2 = icon2.pixmap(32, 32).toImage(); - QVERIFY(img1 == img2); -} - -void tst_QIcon::addFile() -{ - QIcon icon; - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); - icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); - -#ifndef Q_OS_WINCE - QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); - QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); - QVERIFY(icon.pixmap(128, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); - QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); - QVERIFY(icon.pixmap(32, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); - QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); -#else - // WinCE only includes the 16x16 images for size reasons - QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); - QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == - QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); -#endif -} - -static bool sizeLess(const QSize &a, const QSize &b) -{ - return a.width() < b.width(); -} - -void tst_QIcon::availableSizes() -{ - { - QIcon icon; - icon.addFile("image.png", QSize(32,32)); - icon.addFile("image.png", QSize(64,64)); - icon.addFile("image.png", QSize(128,128)); - icon.addFile("image.png", QSize(256,256), QIcon::Disabled); - icon.addFile("image.png", QSize(16,16), QIcon::Normal, QIcon::On); - - QList availableSizes = icon.availableSizes(); - QCOMPARE(availableSizes.size(), 3); - qSort(availableSizes.begin(), availableSizes.end(), sizeLess); - QCOMPARE(availableSizes.at(0), QSize(32,32)); - QCOMPARE(availableSizes.at(1), QSize(64,64)); - QCOMPARE(availableSizes.at(2), QSize(128,128)); - - availableSizes = icon.availableSizes(QIcon::Disabled); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(256,256)); - - availableSizes = icon.availableSizes(QIcon::Normal, QIcon::On); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(16,16)); - } - - { - // we try to load an icon from resources - QIcon icon(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - QList availableSizes = icon.availableSizes(); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(16, 16)); - } - - { - // load an icon from binary data. - QPixmap pix; - QFile file(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - QVERIFY(file.open(QIODevice::ReadOnly)); - uchar *data = file.map(0, file.size()); - QVERIFY(data != 0); - pix.loadFromData(data, file.size()); - QIcon icon(pix); - - QList availableSizes = icon.availableSizes(); - QCOMPARE(availableSizes.size(), 1); - QCOMPARE(availableSizes.at(0), QSize(16,16)); - } - - { - // there shouldn't be available sizes for invalid images! - QVERIFY(QIcon(QLatin1String("")).availableSizes().isEmpty()); - QVERIFY(QIcon(QLatin1String("non-existing.png")).availableSizes().isEmpty()); - } -} - -void tst_QIcon::name() -{ - { - // No name if icon does not come from a theme - QIcon icon(":/image.png"); - QString name = icon.name(); - QVERIFY(name.isEmpty()); - } - - { - // Getting the name of an icon coming from a theme should work - QString searchPath = QLatin1String(":/icons"); - QIcon::setThemeSearchPaths(QStringList() << searchPath); - QString themeName("testtheme"); - QIcon::setThemeName(themeName); - - QIcon icon = QIcon::fromTheme("appointment-new"); - QString name = icon.name(); - QCOMPARE(name, QLatin1String("appointment-new")); - } -} - -void tst_QIcon::streamAvailableSizes_data() -{ - QTest::addColumn("icon"); - - QIcon icon; - icon.addFile(":/image.png", QSize(32,32)); - QTest::newRow( "32x32" ) << icon; - icon.addFile(":/image.png", QSize(64,64)); - QTest::newRow( "64x64" ) << icon; - icon.addFile(":/image.png", QSize(128,128)); - QTest::newRow( "128x128" ) << icon; - icon.addFile(":/image.png", QSize(256,256)); - QTest::newRow( "256x256" ) << icon; -} - -void tst_QIcon::streamAvailableSizes() -{ - QFETCH(QIcon, icon); - - QByteArray ba; - // write to QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << icon; - } - - // read from QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::ReadOnly); - QDataStream stream(&buffer); - QIcon i; - stream >> i; - QCOMPARE(i.isNull(), icon.isNull()); - QCOMPARE(i.availableSizes(), icon.availableSizes()); - } -} - - -static inline bool operator<(const QSize &lhs, const QSize &rhs) -{ - if (lhs.width() < rhs.width()) - return true; - else if (lhs.width() == lhs.width()) - return lhs.height() < lhs.height(); - return false; -} - -void tst_QIcon::task184901_badCache() -{ - QPixmap pm(QFINDTESTDATA("image.png")); - QIcon icon(pm); - - //the disabled icon must have an effect (grayed) - QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() != icon.pixmap(32, QIcon::Disabled).toImage()); - - icon.addPixmap(pm, QIcon::Disabled); - //the disabled icon must now be the same as the normal one. - QVERIFY( icon.pixmap(32, QIcon::Normal).toImage() == icon.pixmap(32, QIcon::Disabled).toImage() ); -} - -void tst_QIcon::fromTheme() -{ - QString searchPath = QLatin1String(":/icons"); - QIcon::setThemeSearchPaths(QStringList() << searchPath); - QVERIFY(QIcon::themeSearchPaths().size() == 1); - QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); - - QString themeName("testtheme"); - QIcon::setThemeName(themeName); - QCOMPARE(QIcon::themeName(), themeName); - - // Test normal icon - QIcon appointmentIcon = QIcon::fromTheme("appointment-new"); - QVERIFY(!appointmentIcon.isNull()); - QVERIFY(!appointmentIcon.availableSizes(QIcon::Normal, QIcon::Off).isEmpty()); - QVERIFY(appointmentIcon.availableSizes().contains(QSize(16, 16))); - QVERIFY(appointmentIcon.availableSizes().contains(QSize(32, 32))); - QVERIFY(appointmentIcon.availableSizes().contains(QSize(22, 22))); - - // Test icon from parent theme - QIcon abIcon = QIcon::fromTheme("address-book-new"); - QVERIFY(!abIcon.isNull()); - QVERIFY(QIcon::hasThemeIcon("address-book-new")); - QVERIFY(!abIcon.availableSizes().isEmpty()); - - // Test non existing icon - QIcon noIcon = QIcon::fromTheme("broken-icon"); - QVERIFY(noIcon.isNull()); - QVERIFY(!QIcon::hasThemeIcon("broken-icon")); - - // Test non existing icon with fallback - noIcon = QIcon::fromTheme("broken-icon", abIcon); - QVERIFY(noIcon.cacheKey() == abIcon.cacheKey()); - - // Test svg-only icon - noIcon = QIcon::fromTheme("svg-icon", abIcon); - QVERIFY(!noIcon.availableSizes().isEmpty()); - - QByteArray ba; - // write to QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << abIcon; - } - - // read from QByteArray - { - QBuffer buffer(&ba); - buffer.open(QIODevice::ReadOnly); - QDataStream stream(&buffer); - QIcon i; - stream >> i; - QCOMPARE(i.isNull(), abIcon.isNull()); - QCOMPARE(i.availableSizes(), abIcon.availableSizes()); - } - - // Make sure setting the theme name clears the state - QIcon::setThemeName(""); - abIcon = QIcon::fromTheme("address-book-new"); - QVERIFY(abIcon.isNull()); -} - - -void tst_QIcon::task223279_inconsistentAddFile() -{ - QIcon icon1; - icon1.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - icon1.addFile(QLatin1String("IconThatDoesntExist"), QSize(32, 32)); - QPixmap pm1 = icon1.pixmap(32, 32); - - QIcon icon2; - icon2.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); - icon2.addFile(QLatin1String("IconThatDoesntExist")); - QPixmap pm2 = icon1.pixmap(32, 32); - - QCOMPARE(pm1.isNull(), false); - QCOMPARE(pm1.size(), QSize(16,16)); - QCOMPARE(pm1.isNull(), pm2.isNull()); - QCOMPARE(pm1.size(), pm2.size()); -} - - -QTEST_MAIN(tst_QIcon) -#include "tst_qicon.moc" diff --git a/tests/auto/gui/image/qicon/tst_qicon.qrc b/tests/auto/gui/image/qicon/tst_qicon.qrc deleted file mode 100644 index 7925a33c84..0000000000 --- a/tests/auto/gui/image/qicon/tst_qicon.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - -image.png -rect.png -./icons/testtheme/16x16/actions/appointment-new.png -./icons/testtheme/22x22/actions/appointment-new.png -./icons/testtheme/32x32/actions/appointment-new.png -./icons/testtheme/index.theme -./icons/testtheme/scalable/actions/svg-only.svg -./icons/themeparent/16x16/actions/address-book-new.png -./icons/themeparent/16x16/actions/appointment-new.png -./icons/themeparent/22x22/actions/address-book-new.png -./icons/themeparent/22x22/actions/appointment-new.png -./icons/themeparent/32x32/actions/address-book-new.png -./icons/themeparent/32x32/actions/appointment-new.png -./icons/themeparent/index.theme -./icons/themeparent/scalable/actions/address-book-new.svg -./icons/themeparent/scalable/actions/appointment-new.svg - - diff --git a/tests/auto/gui/image/qpixmapfilter/noise.png b/tests/auto/gui/image/qpixmapfilter/noise.png deleted file mode 100644 index 1bebaf528e..0000000000 Binary files a/tests/auto/gui/image/qpixmapfilter/noise.png and /dev/null differ diff --git a/tests/auto/gui/image/qpixmapfilter/qpixmapfilter.pro b/tests/auto/gui/image/qpixmapfilter/qpixmapfilter.pro deleted file mode 100644 index 872686b82f..0000000000 --- a/tests/auto/gui/image/qpixmapfilter/qpixmapfilter.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qpixmapfilter - -QT += widgets widgets-private testlib -QT += gui-private - -SOURCES += tst_qpixmapfilter.cpp - -wince*: { - addFiles.files = noise.png - addFiles.path = . - DEPLOYMENT += addFiles -} - diff --git a/tests/auto/gui/image/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/gui/image/qpixmapfilter/tst_qpixmapfilter.cpp deleted file mode 100644 index c9b2e054da..0000000000 --- a/tests/auto/gui/image/qpixmapfilter/tst_qpixmapfilter.cpp +++ /dev/null @@ -1,447 +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 -#include -#include - -class tst_QPixmapFilter : public QObject -{ - Q_OBJECT - -public: - tst_QPixmapFilter(); - virtual ~tst_QPixmapFilter(); - - -public slots: - void init(); - void cleanup(); - -private slots: - void colorizeSetColor(); - void colorizeSetStrength(); - void colorizeProcess(); - void colorizeDraw(); - void colorizeDrawStrength(); - void colorizeDrawSubRect(); - void colorizeProcessSubRect(); - void convolutionBoundingRectFor(); - void convolutionDrawSubRect(); - void dropShadowBoundingRectFor(); - void blurIndexed8(); - - void testDefaultImplementations(); -}; - -class CustomFilter : public QPixmapFilter -{ -public: - enum { Type = QPixmapFilter::UserFilter + 1 }; - - CustomFilter() : QPixmapFilter((QPixmapFilter::FilterType) Type, 0) { }; - - void draw(QPainter *p, const QPointF &pt, const QPixmap &src, const QRectF &srcRect = QRectF()) const { - p->drawPixmap(QRectF(pt, srcRect.size()), src, srcRect); - } -}; - -tst_QPixmapFilter::tst_QPixmapFilter() -{ -} - -tst_QPixmapFilter::~tst_QPixmapFilter() -{ -} - -void tst_QPixmapFilter::init() -{ -} - -void tst_QPixmapFilter::cleanup() -{ -} - -void tst_QPixmapFilter::testDefaultImplementations() -{ - CustomFilter filter; - QCOMPARE(filter.type(), (QPixmapFilter::FilterType) CustomFilter::Type); - - QCOMPARE(filter.boundingRectFor(QRectF(1, 2, 4, 8)), QRectF(1, 2, 4, 8)); - - QPixmap src(10, 10); - src.fill(Qt::blue); - - QPixmap test(src.size()); - QPainter p(&test); - filter.draw(&p, QPointF(0, 0), src, src.rect()); - p.end(); - - QCOMPARE(test.toImage().pixel(0, 0), 0xff0000ff); -} - -void tst_QPixmapFilter::colorizeSetColor() -{ - QPixmapColorizeFilter filter; - filter.setColor(QColor(50, 100, 200)); - QCOMPARE(filter.color(), QColor(50, 100, 200)); -} - -void tst_QPixmapFilter::colorizeSetStrength() -{ - QPixmapColorizeFilter filter; - QCOMPARE(filter.strength(), qreal(1)); - filter.setStrength(0.5); - QCOMPARE(filter.strength(), qreal(0.5)); - filter.setStrength(0.0); - QCOMPARE(filter.strength(), qreal(0.0)); -} - -void tst_QPixmapFilter::colorizeProcess() -{ - QPixmapColorizeFilter filter; - filter.setColor(QColor(100, 100, 100)); - - QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(0, 0, 50, 50)); - QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(30, 20, 10, 40)); - QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(2.2, 6.3, 11.4, 47.5)); - - QPixmap source("noise.png"); - QImage result(source.size(), QImage::Format_ARGB32_Premultiplied); - result.fill(0); - QPainter p(&result); - filter.draw(&p, QPointF(0, 0), source); - p.end(); - QImage resultImg = result; - for(int y = 0; y < resultImg.height(); y++) - { - for(int x = 0; x < resultImg.width(); x++) - { - QRgb pixel = resultImg.pixel(x,y); - QCOMPARE(qRed(pixel), qGreen(pixel)); - QCOMPARE(qGreen(pixel), qBlue(pixel)); - } - } -} - -void tst_QPixmapFilter::colorizeDraw() -{ - QPixmapColorizeFilter filter; - filter.setColor(QColor(100, 100, 100)); - - QPixmap pixmap("noise.png"); - QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&result); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(result.rect(), QColor(128, 0, 0, 0)); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - filter.draw(&painter, QPointF(0, 0), pixmap); - painter.end(); - - QImage resultImg = result; - for(int y = 0; y < resultImg.height(); y++) - { - for(int x = 0; x < resultImg.width(); x++) - { - QRgb pixel = resultImg.pixel(x,y); - QCOMPARE(qRed(pixel), qGreen(pixel)); - QCOMPARE(qGreen(pixel), qBlue(pixel)); - } - } -} - -void tst_QPixmapFilter::colorizeDrawStrength() -{ - QPixmapColorizeFilter filter; - filter.setColor(Qt::blue); - filter.setStrength(0.3); - - QImage source(256, 128, QImage::Format_ARGB32); - source.fill(qRgb(255, 0, 0)); - QPixmap pixmap = QPixmap::fromImage(source); - - QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&result); - painter.setCompositionMode(QPainter::CompositionMode_Source); - filter.draw(&painter, QPointF(0, 0), pixmap); - painter.end(); - - QImage resultImg = result; - for(int y = 0; y < resultImg.height(); y++) - { - for(int x = 0; x < resultImg.width(); x++) - { - QRgb pixel = resultImg.pixel(x,y); - QCOMPARE(qRed(pixel), 206); - QCOMPARE(qGreen(pixel), 26); - QCOMPARE(qBlue(pixel), 75); - } - } -} - -void tst_QPixmapFilter::colorizeDrawSubRect() -{ - QPixmapColorizeFilter filter; - filter.setColor(QColor(255, 255, 255)); - - QPixmap pixmap("noise.png"); - QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&result); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(result.rect(), QColor(128, 0, 0, 255)); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - filter.draw(&painter, QPointF(16, 16), pixmap, QRectF(16, 16, 16, 16)); - painter.end(); - - QImage resultImg = result; - QImage sourceImg = pixmap.toImage(); - for(int y = 0; y < resultImg.height(); y++) - { - for(int x = 0; x < resultImg.width(); x++) - { - QRgb pixel = resultImg.pixel(x,y); - if(x>=16 && x<32 && y>=16 && y<32) { - QCOMPARE(qRed(pixel), qGreen(pixel)); - QCOMPARE(qGreen(pixel), qBlue(pixel)); - } else { - QCOMPARE(qRed(pixel), 128); - QCOMPARE(qGreen(pixel), 0); - QCOMPARE(qBlue(pixel), 0); - QCOMPARE(qAlpha(pixel), 255); - } - } - } -} - -void tst_QPixmapFilter::colorizeProcessSubRect() -{ - QPixmapColorizeFilter filter; - filter.setColor(QColor(200, 200, 200)); - - QPixmap source("noise.png"); - QImage result(QSize(16, 16), QImage::Format_ARGB32_Premultiplied); - result.fill(0); - QPainter p(&result); - filter.draw(&p, QPointF(0, 0), source, QRectF(16, 16, 16, 16)); - p.end(); - - QImage resultImg = result; - for(int y = 0; y < resultImg.height(); y++) - { - for(int x = 0; x < resultImg.width(); x++) - { - QRgb pixel = resultImg.pixel(x,y); - QCOMPARE(qRed(pixel), qGreen(pixel)); - QCOMPARE(qGreen(pixel), qBlue(pixel)); - } - } -} - -void tst_QPixmapFilter::convolutionBoundingRectFor() -{ - QPixmapConvolutionFilter filter; - QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(0, 0, 50, 50)); - QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(30, 20, 10, 40)); - QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(2.2, 6.3, 11.4, 47.5)); - qreal kernel[] = { - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0 - }; - filter.setConvolutionKernel(kernel, 2, 2); - QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(-1, -1, 51, 51)); - QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(29, 19, 11, 41)); - QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(1.2, 5.3, 12.4, 48.5)); - - filter.setConvolutionKernel(kernel, 3, 3); - QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(-1, -1, 52, 52)); - QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(29, 19, 12, 42)); - QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(1.2, 5.3, 13.4, 49.5)); - - filter.setConvolutionKernel(kernel, 4, 4); - QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(-2, -2, 53, 53)); - QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(28, 18, 13, 43)); - QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(0.2, 4.3, 14.4, 50.5)); -} - -void tst_QPixmapFilter::convolutionDrawSubRect() -{ - QPixmapConvolutionFilter filter; - qreal kernel[] = { - 0, 0, 0, - 0, 0, 0, - 0, 0, 1 - }; - filter.setConvolutionKernel(kernel, 3, 3); - - QPixmap pixmap("noise.png"); - QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); - QPainter painter(&result); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(result.rect(), QColor(128, 0, 0, 255)); - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); - filter.draw(&painter, QPointF(16, 16), pixmap, QRectF(16, 16, 16, 16)); - painter.end(); - - QImage resultImg = result; - QImage sourceImg = pixmap.toImage(); - for(int y = 0; y < resultImg.height()-1; y++) - { - for(int x = 0; x < resultImg.width()-1; x++) - { - QRgb pixel = resultImg.pixel(x,y); - QRgb srcPixel = sourceImg.pixel(x+1,y+1); - if(x>=15 && x<33 && y>=15 && y<33) { - QCOMPARE(pixel, srcPixel); - } else { - QCOMPARE(qRed(pixel), 128); - QCOMPARE(qGreen(pixel), 0); - QCOMPARE(qBlue(pixel), 0); - QCOMPARE(qAlpha(pixel), 255); - } - } - } - - - kernel[2] = 1; - kernel[8] = 0; - filter.setConvolutionKernel(kernel, 3, 3); - - QPainter painter2(&result); - painter2.setCompositionMode(QPainter::CompositionMode_Source); - painter2.fillRect(result.rect(), QColor(128, 0, 0, 255)); - painter2.setCompositionMode(QPainter::CompositionMode_SourceOver); - filter.draw(&painter2, QPointF(16, 16), pixmap, QRectF(16, 16, 16, 16)); - painter2.end(); - - resultImg = result; - sourceImg = pixmap.toImage(); - for(int y = 1; y < resultImg.height(); y++) - { - for(int x = 0; x < resultImg.width()-1; x++) - { - QRgb pixel = resultImg.pixel(x,y); - QRgb srcPixel = sourceImg.pixel(x+1,y-1); - if(x>=15 && x<33 && y>=15 && y<33) { - QCOMPARE(pixel, srcPixel); - } else { - QCOMPARE(qRed(pixel), 128); - QCOMPARE(qGreen(pixel), 0); - QCOMPARE(qBlue(pixel), 0); - QCOMPARE(qAlpha(pixel), 255); - } - } - } - -} - -void tst_QPixmapFilter::dropShadowBoundingRectFor() -{ - QPixmapDropShadowFilter filter; - filter.setBlurRadius(0); - - QCOMPARE(filter.blurRadius(), 0.); - - const QRectF rect1(0, 0, 50, 50); - const QRectF rect2(30, 20, 10, 40); - const QRectF rect3(2.2, 6.3, 11.4, 47.5); - - filter.setOffset(QPointF(0,0)); - QCOMPARE(filter.boundingRectFor(rect1), rect1); - QCOMPARE(filter.boundingRectFor(rect2), rect2); - QCOMPARE(filter.boundingRectFor(rect3), rect3); - - filter.setOffset(QPointF(1,1)); - QCOMPARE(filter.offset(), QPointF(1, 1)); - QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(0, 0, 1, 1)); - QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(0, 0, 1, 1)); - QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(0, 0, 1, 1)); - - filter.setOffset(QPointF(-1,-1)); - QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-1, -1, 0, 0)); - QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-1, -1, 0, 0)); - QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-1, -1, 0, 0)); - - filter.setBlurRadius(2); - filter.setOffset(QPointF(0,0)); - qreal delta = 2; - QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta, -delta, delta, delta)); - QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta, -delta, delta, delta)); - QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta, -delta, delta, delta)); - - filter.setOffset(QPointF(1,1)); - QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta + 1, -delta + 1, delta + 1, delta + 1)); - QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta + 1, -delta + 1, delta + 1, delta + 1)); - QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta + 1, -delta + 1, delta + 1, delta + 1)); - - filter.setOffset(QPointF(-10,-10)); - QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta - 10, -delta - 10, 0, 0)); - QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta - 10, -delta - 10, 0, 0)); - QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta - 10, -delta - 10, 0, 0)); -} - -QT_BEGIN_NAMESPACE -void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); -QT_END_NAMESPACE - -void tst_QPixmapFilter::blurIndexed8() -{ - QImage img(16, 32, QImage::Format_Indexed8); - img.setColorCount(256); - for (int i = 0; i < 256; ++i) - img.setColor(i, qRgb(i, i, i)); - - img.fill(255); - - QImage original = img; - qt_blurImage(img, 10, true, false); - QCOMPARE(original.size(), img.size()); - - original = img; - qt_blurImage(img, 10, true, true); - QCOMPARE(original.size(), QSize(img.height(), img.width())); -} - -QTEST_MAIN(tst_QPixmapFilter) -#include "tst_qpixmapfilter.moc" diff --git a/tests/auto/widgets/effects/effects.pro b/tests/auto/widgets/effects/effects.pro index fab24d6296..e598707f3e 100644 --- a/tests/auto/widgets/effects/effects.pro +++ b/tests/auto/widgets/effects/effects.pro @@ -1,4 +1,5 @@ TEMPLATE=subdirs SUBDIRS=\ qgraphicseffect \ + qpixmapfilter \ diff --git a/tests/auto/widgets/effects/qpixmapfilter/noise.png b/tests/auto/widgets/effects/qpixmapfilter/noise.png new file mode 100644 index 0000000000..1bebaf528e Binary files /dev/null and b/tests/auto/widgets/effects/qpixmapfilter/noise.png differ diff --git a/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro b/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro new file mode 100644 index 0000000000..872686b82f --- /dev/null +++ b/tests/auto/widgets/effects/qpixmapfilter/qpixmapfilter.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qpixmapfilter + +QT += widgets widgets-private testlib +QT += gui-private + +SOURCES += tst_qpixmapfilter.cpp + +wince*: { + addFiles.files = noise.png + addFiles.path = . + DEPLOYMENT += addFiles +} + diff --git a/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp new file mode 100644 index 0000000000..c9b2e054da --- /dev/null +++ b/tests/auto/widgets/effects/qpixmapfilter/tst_qpixmapfilter.cpp @@ -0,0 +1,447 @@ +/**************************************************************************** +** +** 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 +#include + +class tst_QPixmapFilter : public QObject +{ + Q_OBJECT + +public: + tst_QPixmapFilter(); + virtual ~tst_QPixmapFilter(); + + +public slots: + void init(); + void cleanup(); + +private slots: + void colorizeSetColor(); + void colorizeSetStrength(); + void colorizeProcess(); + void colorizeDraw(); + void colorizeDrawStrength(); + void colorizeDrawSubRect(); + void colorizeProcessSubRect(); + void convolutionBoundingRectFor(); + void convolutionDrawSubRect(); + void dropShadowBoundingRectFor(); + void blurIndexed8(); + + void testDefaultImplementations(); +}; + +class CustomFilter : public QPixmapFilter +{ +public: + enum { Type = QPixmapFilter::UserFilter + 1 }; + + CustomFilter() : QPixmapFilter((QPixmapFilter::FilterType) Type, 0) { }; + + void draw(QPainter *p, const QPointF &pt, const QPixmap &src, const QRectF &srcRect = QRectF()) const { + p->drawPixmap(QRectF(pt, srcRect.size()), src, srcRect); + } +}; + +tst_QPixmapFilter::tst_QPixmapFilter() +{ +} + +tst_QPixmapFilter::~tst_QPixmapFilter() +{ +} + +void tst_QPixmapFilter::init() +{ +} + +void tst_QPixmapFilter::cleanup() +{ +} + +void tst_QPixmapFilter::testDefaultImplementations() +{ + CustomFilter filter; + QCOMPARE(filter.type(), (QPixmapFilter::FilterType) CustomFilter::Type); + + QCOMPARE(filter.boundingRectFor(QRectF(1, 2, 4, 8)), QRectF(1, 2, 4, 8)); + + QPixmap src(10, 10); + src.fill(Qt::blue); + + QPixmap test(src.size()); + QPainter p(&test); + filter.draw(&p, QPointF(0, 0), src, src.rect()); + p.end(); + + QCOMPARE(test.toImage().pixel(0, 0), 0xff0000ff); +} + +void tst_QPixmapFilter::colorizeSetColor() +{ + QPixmapColorizeFilter filter; + filter.setColor(QColor(50, 100, 200)); + QCOMPARE(filter.color(), QColor(50, 100, 200)); +} + +void tst_QPixmapFilter::colorizeSetStrength() +{ + QPixmapColorizeFilter filter; + QCOMPARE(filter.strength(), qreal(1)); + filter.setStrength(0.5); + QCOMPARE(filter.strength(), qreal(0.5)); + filter.setStrength(0.0); + QCOMPARE(filter.strength(), qreal(0.0)); +} + +void tst_QPixmapFilter::colorizeProcess() +{ + QPixmapColorizeFilter filter; + filter.setColor(QColor(100, 100, 100)); + + QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(0, 0, 50, 50)); + QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(30, 20, 10, 40)); + QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(2.2, 6.3, 11.4, 47.5)); + + QPixmap source("noise.png"); + QImage result(source.size(), QImage::Format_ARGB32_Premultiplied); + result.fill(0); + QPainter p(&result); + filter.draw(&p, QPointF(0, 0), source); + p.end(); + QImage resultImg = result; + for(int y = 0; y < resultImg.height(); y++) + { + for(int x = 0; x < resultImg.width(); x++) + { + QRgb pixel = resultImg.pixel(x,y); + QCOMPARE(qRed(pixel), qGreen(pixel)); + QCOMPARE(qGreen(pixel), qBlue(pixel)); + } + } +} + +void tst_QPixmapFilter::colorizeDraw() +{ + QPixmapColorizeFilter filter; + filter.setColor(QColor(100, 100, 100)); + + QPixmap pixmap("noise.png"); + QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&result); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(result.rect(), QColor(128, 0, 0, 0)); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + filter.draw(&painter, QPointF(0, 0), pixmap); + painter.end(); + + QImage resultImg = result; + for(int y = 0; y < resultImg.height(); y++) + { + for(int x = 0; x < resultImg.width(); x++) + { + QRgb pixel = resultImg.pixel(x,y); + QCOMPARE(qRed(pixel), qGreen(pixel)); + QCOMPARE(qGreen(pixel), qBlue(pixel)); + } + } +} + +void tst_QPixmapFilter::colorizeDrawStrength() +{ + QPixmapColorizeFilter filter; + filter.setColor(Qt::blue); + filter.setStrength(0.3); + + QImage source(256, 128, QImage::Format_ARGB32); + source.fill(qRgb(255, 0, 0)); + QPixmap pixmap = QPixmap::fromImage(source); + + QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&result); + painter.setCompositionMode(QPainter::CompositionMode_Source); + filter.draw(&painter, QPointF(0, 0), pixmap); + painter.end(); + + QImage resultImg = result; + for(int y = 0; y < resultImg.height(); y++) + { + for(int x = 0; x < resultImg.width(); x++) + { + QRgb pixel = resultImg.pixel(x,y); + QCOMPARE(qRed(pixel), 206); + QCOMPARE(qGreen(pixel), 26); + QCOMPARE(qBlue(pixel), 75); + } + } +} + +void tst_QPixmapFilter::colorizeDrawSubRect() +{ + QPixmapColorizeFilter filter; + filter.setColor(QColor(255, 255, 255)); + + QPixmap pixmap("noise.png"); + QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&result); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(result.rect(), QColor(128, 0, 0, 255)); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + filter.draw(&painter, QPointF(16, 16), pixmap, QRectF(16, 16, 16, 16)); + painter.end(); + + QImage resultImg = result; + QImage sourceImg = pixmap.toImage(); + for(int y = 0; y < resultImg.height(); y++) + { + for(int x = 0; x < resultImg.width(); x++) + { + QRgb pixel = resultImg.pixel(x,y); + if(x>=16 && x<32 && y>=16 && y<32) { + QCOMPARE(qRed(pixel), qGreen(pixel)); + QCOMPARE(qGreen(pixel), qBlue(pixel)); + } else { + QCOMPARE(qRed(pixel), 128); + QCOMPARE(qGreen(pixel), 0); + QCOMPARE(qBlue(pixel), 0); + QCOMPARE(qAlpha(pixel), 255); + } + } + } +} + +void tst_QPixmapFilter::colorizeProcessSubRect() +{ + QPixmapColorizeFilter filter; + filter.setColor(QColor(200, 200, 200)); + + QPixmap source("noise.png"); + QImage result(QSize(16, 16), QImage::Format_ARGB32_Premultiplied); + result.fill(0); + QPainter p(&result); + filter.draw(&p, QPointF(0, 0), source, QRectF(16, 16, 16, 16)); + p.end(); + + QImage resultImg = result; + for(int y = 0; y < resultImg.height(); y++) + { + for(int x = 0; x < resultImg.width(); x++) + { + QRgb pixel = resultImg.pixel(x,y); + QCOMPARE(qRed(pixel), qGreen(pixel)); + QCOMPARE(qGreen(pixel), qBlue(pixel)); + } + } +} + +void tst_QPixmapFilter::convolutionBoundingRectFor() +{ + QPixmapConvolutionFilter filter; + QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(0, 0, 50, 50)); + QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(30, 20, 10, 40)); + QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(2.2, 6.3, 11.4, 47.5)); + qreal kernel[] = { + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0 + }; + filter.setConvolutionKernel(kernel, 2, 2); + QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(-1, -1, 51, 51)); + QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(29, 19, 11, 41)); + QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(1.2, 5.3, 12.4, 48.5)); + + filter.setConvolutionKernel(kernel, 3, 3); + QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(-1, -1, 52, 52)); + QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(29, 19, 12, 42)); + QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(1.2, 5.3, 13.4, 49.5)); + + filter.setConvolutionKernel(kernel, 4, 4); + QCOMPARE(filter.boundingRectFor(QRectF(0, 0, 50, 50)), QRectF(-2, -2, 53, 53)); + QCOMPARE(filter.boundingRectFor(QRectF(30, 20, 10, 40)), QRectF(28, 18, 13, 43)); + QCOMPARE(filter.boundingRectFor(QRectF(2.2, 6.3, 11.4, 47.5)), QRectF(0.2, 4.3, 14.4, 50.5)); +} + +void tst_QPixmapFilter::convolutionDrawSubRect() +{ + QPixmapConvolutionFilter filter; + qreal kernel[] = { + 0, 0, 0, + 0, 0, 0, + 0, 0, 1 + }; + filter.setConvolutionKernel(kernel, 3, 3); + + QPixmap pixmap("noise.png"); + QImage result(pixmap.size(), QImage::Format_ARGB32_Premultiplied); + QPainter painter(&result); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(result.rect(), QColor(128, 0, 0, 255)); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + filter.draw(&painter, QPointF(16, 16), pixmap, QRectF(16, 16, 16, 16)); + painter.end(); + + QImage resultImg = result; + QImage sourceImg = pixmap.toImage(); + for(int y = 0; y < resultImg.height()-1; y++) + { + for(int x = 0; x < resultImg.width()-1; x++) + { + QRgb pixel = resultImg.pixel(x,y); + QRgb srcPixel = sourceImg.pixel(x+1,y+1); + if(x>=15 && x<33 && y>=15 && y<33) { + QCOMPARE(pixel, srcPixel); + } else { + QCOMPARE(qRed(pixel), 128); + QCOMPARE(qGreen(pixel), 0); + QCOMPARE(qBlue(pixel), 0); + QCOMPARE(qAlpha(pixel), 255); + } + } + } + + + kernel[2] = 1; + kernel[8] = 0; + filter.setConvolutionKernel(kernel, 3, 3); + + QPainter painter2(&result); + painter2.setCompositionMode(QPainter::CompositionMode_Source); + painter2.fillRect(result.rect(), QColor(128, 0, 0, 255)); + painter2.setCompositionMode(QPainter::CompositionMode_SourceOver); + filter.draw(&painter2, QPointF(16, 16), pixmap, QRectF(16, 16, 16, 16)); + painter2.end(); + + resultImg = result; + sourceImg = pixmap.toImage(); + for(int y = 1; y < resultImg.height(); y++) + { + for(int x = 0; x < resultImg.width()-1; x++) + { + QRgb pixel = resultImg.pixel(x,y); + QRgb srcPixel = sourceImg.pixel(x+1,y-1); + if(x>=15 && x<33 && y>=15 && y<33) { + QCOMPARE(pixel, srcPixel); + } else { + QCOMPARE(qRed(pixel), 128); + QCOMPARE(qGreen(pixel), 0); + QCOMPARE(qBlue(pixel), 0); + QCOMPARE(qAlpha(pixel), 255); + } + } + } + +} + +void tst_QPixmapFilter::dropShadowBoundingRectFor() +{ + QPixmapDropShadowFilter filter; + filter.setBlurRadius(0); + + QCOMPARE(filter.blurRadius(), 0.); + + const QRectF rect1(0, 0, 50, 50); + const QRectF rect2(30, 20, 10, 40); + const QRectF rect3(2.2, 6.3, 11.4, 47.5); + + filter.setOffset(QPointF(0,0)); + QCOMPARE(filter.boundingRectFor(rect1), rect1); + QCOMPARE(filter.boundingRectFor(rect2), rect2); + QCOMPARE(filter.boundingRectFor(rect3), rect3); + + filter.setOffset(QPointF(1,1)); + QCOMPARE(filter.offset(), QPointF(1, 1)); + QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(0, 0, 1, 1)); + QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(0, 0, 1, 1)); + QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(0, 0, 1, 1)); + + filter.setOffset(QPointF(-1,-1)); + QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-1, -1, 0, 0)); + QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-1, -1, 0, 0)); + QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-1, -1, 0, 0)); + + filter.setBlurRadius(2); + filter.setOffset(QPointF(0,0)); + qreal delta = 2; + QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta, -delta, delta, delta)); + QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta, -delta, delta, delta)); + QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta, -delta, delta, delta)); + + filter.setOffset(QPointF(1,1)); + QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta + 1, -delta + 1, delta + 1, delta + 1)); + QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta + 1, -delta + 1, delta + 1, delta + 1)); + QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta + 1, -delta + 1, delta + 1, delta + 1)); + + filter.setOffset(QPointF(-10,-10)); + QCOMPARE(filter.boundingRectFor(rect1), rect1.adjusted(-delta - 10, -delta - 10, 0, 0)); + QCOMPARE(filter.boundingRectFor(rect2), rect2.adjusted(-delta - 10, -delta - 10, 0, 0)); + QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta - 10, -delta - 10, 0, 0)); +} + +QT_BEGIN_NAMESPACE +void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); +QT_END_NAMESPACE + +void tst_QPixmapFilter::blurIndexed8() +{ + QImage img(16, 32, QImage::Format_Indexed8); + img.setColorCount(256); + for (int i = 0; i < 256; ++i) + img.setColor(i, qRgb(i, i, i)); + + img.fill(255); + + QImage original = img; + qt_blurImage(img, 10, true, false); + QCOMPARE(original.size(), img.size()); + + original = img; + qt_blurImage(img, 10, true, true); + QCOMPARE(original.size(), QSize(img.height(), img.width())); +} + +QTEST_MAIN(tst_QPixmapFilter) +#include "tst_qpixmapfilter.moc" diff --git a/tests/auto/widgets/kernel/kernel.pro b/tests/auto/widgets/kernel/kernel.pro index 850863c112..3a00300ac3 100644 --- a/tests/auto/widgets/kernel/kernel.pro +++ b/tests/auto/widgets/kernel/kernel.pro @@ -13,6 +13,7 @@ SUBDIRS=\ qwidget \ qwidget_window \ qwidgetaction \ + qicon \ SUBDIRS -= qsound diff --git a/tests/auto/widgets/kernel/qicon/.gitignore b/tests/auto/widgets/kernel/qicon/.gitignore new file mode 100644 index 0000000000..c101ef9d28 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/.gitignore @@ -0,0 +1 @@ +tst_qicon diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png new file mode 100644 index 0000000000..18b7c6781e Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/testtheme/16x16/actions/appointment-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png new file mode 100644 index 0000000000..d676ffd463 Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/testtheme/22x22/actions/appointment-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png new file mode 100644 index 0000000000..85daef3b0b Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/testtheme/32x32/actions/appointment-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme b/tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme new file mode 100644 index 0000000000..e18736ab43 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/icons/testtheme/index.theme @@ -0,0 +1,492 @@ +[Icon Theme] +_Name=Test +_Comment=Test Theme +Inherits=crystalsvg, themeparent +Example=x-directory-normal + +# KDE Specific Stuff +DisplayDepth=32 +LinkOverlay=link_overlay +LockOverlay=lock_overlay +ZipOverlay=zip_overlay +DesktopDefault=48 +DesktopSizes=16,22,32,48,64,72,96,128 +ToolbarDefault=22 +ToolbarSizes=16,22,32,48 +MainToolbarDefault=22 +MainToolbarSizes=16,22,32,48 +SmallDefault=16 +SmallSizes=16 +PanelDefault=32 +PanelSizes=16,22,32,48,64,72,96,128 + +# Directory list +Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status + +[16x16/actions] +Size=16 +Context=Actions +Type=Fixed + +[16x16/apps] +Size=16 +Context=Applications +Type=Fixed + +[16x16/categories] +Size=16 +Context=Categories +Type=Fixed + +[16x16/devices] +Size=16 +Context=Devices +Type=Fixed + +[16x16/emblems] +Size=16 +Context=Emblems +Type=Fixed + +[16x16/emotes] +Size=16 +Context=Emotes +Type=Fixed + +[16x16/mimetypes] +Size=16 +Context=MimeTypes +Type=Fixed + +[16x16/places] +Size=16 +Context=Places +Type=Fixed + +[16x16/status] +Size=16 +Context=Status +Type=Fixed + +[22x22/actions] +Size=22 +Context=Actions +Type=Fixed + +[22x22/apps] +Size=22 +Context=Applications +Type=Fixed + +[22x22/categories] +Size=22 +Context=Categories +Type=Fixed + +[22x22/devices] +Size=22 +Context=Devices +Type=Fixed + +[22x22/emblems] +Size=22 +Context=Emblems +Type=Fixed + +[22x22/emotes] +Size=22 +Context=Emotes +Type=Fixed + +[22x22/mimetypes] +Size=22 +Context=MimeTypes +Type=Fixed + +[22x22/places] +Size=22 +Context=Places +Type=Fixed + +[22x22/status] +Size=22 +Context=Status +Type=Fixed + +[24x24/actions] +Size=24 +Context=Actions +Type=Fixed + +[24x24/apps] +Size=24 +Context=Applications +Type=Fixed + +[24x24/categories] +Size=24 +Context=Categories +Type=Fixed + +[24x24/devices] +Size=24 +Context=Devices +Type=Fixed + +[24x24/emblems] +Size=24 +Context=Emblems +Type=Fixed + +[24x24/emotes] +Size=24 +Context=Emotes +Type=Fixed + +[24x24/mimetypes] +Size=24 +Context=MimeTypes +Type=Fixed + +[24x24/places] +Size=24 +Context=Places +Type=Fixed + +[24x24/status] +Size=24 +Context=Status +Type=Fixed + +[32x32/actions] +Size=32 +Context=Actions +Type=Fixed + +[32x32/apps] +Size=32 +Context=Applications +Type=Fixed + +[32x32/categories] +Size=32 +Context=Categories +Type=Fixed + +[32x32/devices] +Size=32 +Context=Devices +Type=Fixed + +[32x32/emblems] +Size=32 +Context=Emblems +Type=Fixed + +[32x32/emotes] +Size=32 +Context=Emotes +Type=Fixed + +[32x32/mimetypes] +Size=32 +Context=MimeTypes +Type=Fixed + +[32x32/places] +Size=32 +Context=Places +Type=Fixed + +[32x32/status] +Size=32 +Context=Status +Type=Fixed + +[48x48/actions] +Size=48 +Context=Actions +Type=Fixed + +[48x48/apps] +Size=48 +Context=Applications +Type=Fixed + +[48x48/categories] +Size=48 +Context=Categories +Type=Fixed + +[48x48/devices] +Size=48 +Context=Devices +Type=Fixed + +[48x48/emblems] +Size=48 +Context=Emblems +Type=Fixed + +[48x48/emotes] +Size=48 +Context=Emotes +Type=Fixed + +[48x48/mimetypes] +Size=48 +Context=MimeTypes +Type=Fixed + +[48x48/places] +Size=48 +Context=Places +Type=Fixed + +[48x48/status] +Size=48 +Context=Status +Type=Fixed + +[64x64/actions] +Size=64 +Context=Actions +Type=Fixed + +[64x64/apps] +Size=64 +Context=Applications +Type=Fixed + +[64x64/categories] +Size=64 +Context=Categories +Type=Fixed + +[64x64/devices] +Size=64 +Context=Devices +Type=Fixed + +[64x64/emblems] +Size=64 +Context=Emblems +Type=Fixed + +[64x64/emotes] +Size=64 +Context=Emotes +Type=Fixed + +[64x64/mimetypes] +Size=64 +Context=MimeTypes +Type=Fixed + +[64x64/places] +Size=64 +Context=Places +Type=Fixed + +[64x64/status] +Size=64 +Context=Status +Type=Fixed + +[72x72/actions] +Size=72 +Context=Actions +Type=Fixed + +[72x72/apps] +Size=72 +Context=Applications +Type=Fixed + +[72x72/categories] +Size=72 +Context=Categories +Type=Fixed + +[72x72/devices] +Size=72 +Context=Devices +Type=Fixed + +[72x72/emblems] +Size=72 +Context=Emblems +Type=Fixed + +[72x72/emotes] +Size=72 +Context=Emotes +Type=Fixed + +[72x72/mimetypes] +Size=72 +Context=MimeTypes +Type=Fixed + +[72x72/places] +Size=72 +Context=Places +Type=Fixed + +[72x72/status] +Size=72 +Context=Status +Type=Fixed + +[96x96/actions] +Size=96 +Context=Actions +Type=Fixed + +[96x96/apps] +Size=96 +Context=Applications +Type=Fixed + +[96x96/categories] +Size=96 +Context=Categories +Type=Fixed + +[96x96/devices] +Size=96 +Context=Devices +Type=Fixed + +[96x96/emblems] +Size=96 +Context=Emblems +Type=Fixed + +[96x96/emotes] +Size=96 +Context=Emotes +Type=Fixed + +[96x96/mimetypes] +Size=96 +Context=MimeTypes +Type=Fixed + +[96x96/places] +Size=96 +Context=Places +Type=Fixed + +[96x96/status] +Size=96 +Context=Status +Type=Fixed + +[128x128/actions] +Size=128 +Context=Actions +Type=Fixed + +[128x128/apps] +Size=128 +Context=Applications +Type=Fixed + +[128x128/categories] +Size=128 +Context=Categories +Type=Fixed + +[128x128/devices] +Size=128 +Context=Devices +Type=Fixed + +[128x128/emblems] +Size=128 +Context=Emblems +Type=Fixed + +[128x128/emotes] +Size=128 +Context=Emotes +Type=Fixed + +[128x128/mimetypes] +Size=128 +Context=MimeTypes +Type=Fixed + +[128x128/places] +Size=128 +Context=Places +Type=Fixed + +[128x128/status] +Size=128 +Context=Status +Type=Fixed + +[scalable/actions] +Size=48 +Context=Actions +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/apps] +Size=48 +Context=Applications +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/categories] +Size=48 +Context=Categories +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/devices] +Size=48 +Context=Devices +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emblems] +Size=48 +Context=Emblems +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emotes] +Size=48 +Context=Emotes +Type=Scalable +Minsize=32 +MaxSize=256 + +[scalable/mimetypes] +Size=48 +Context=MimeTypes +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/places] +Size=48 +Context=Places +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/status] +Size=48 +Context=Status +Type=Scalable +MinSize=32 +MaxSize=256 diff --git a/tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg b/tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg new file mode 100644 index 0000000000..4cb14f82f0 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/icons/testtheme/scalable/actions/svg-only.svg @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + New Appointment + + + appointment + new + meeting + rvsp + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png new file mode 100644 index 0000000000..2098cfdf36 Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/address-book-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png new file mode 100644 index 0000000000..18b7c6781e Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/themeparent/16x16/actions/appointment-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png new file mode 100644 index 0000000000..fad446cd92 Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/address-book-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png new file mode 100644 index 0000000000..d676ffd463 Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/themeparent/22x22/actions/appointment-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png new file mode 100644 index 0000000000..420139d307 Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/address-book-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png b/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png new file mode 100644 index 0000000000..85daef3b0b Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/icons/themeparent/32x32/actions/appointment-new.png differ diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme b/tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme new file mode 100644 index 0000000000..e536a0bf2f --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/icons/themeparent/index.theme @@ -0,0 +1,492 @@ +[Icon Theme] +_Name=Test +_Comment=Test Theme +Inherits=gnome,crystalsvg +Example=x-directory-normal + +# KDE Specific Stuff +DisplayDepth=32 +LinkOverlay=link_overlay +LockOverlay=lock_overlay +ZipOverlay=zip_overlay +DesktopDefault=48 +DesktopSizes=16,22,32,48,64,72,96,128 +ToolbarDefault=22 +ToolbarSizes=16,22,32,48 +MainToolbarDefault=22 +MainToolbarSizes=16,22,32,48 +SmallDefault=16 +SmallSizes=16 +PanelDefault=32 +PanelSizes=16,22,32,48,64,72,96,128 + +# Directory list +Directories=16x16/actions,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,64x64/actions,64x64/apps,64x64/categories,64x64/devices,64x64/emblems,64x64/emotes,64x64/mimetypes,64x64/places,64x64/status,72x72/actions,72x72/apps,72x72/categories,72x72/devices,72x72/emblems,72x72/emotes,72x72/mimetypes,72x72/places,72x72/status,96x96/actions,96x96/apps,96x96/categories,96x96/devices,96x96/emblems,96x96/emotes,96x96/mimetypes,96x96/places,96x96/status,128x128/actions,128x128/apps,128x128/categories,128x128/devices,128x128/emblems,128x128/emotes,128x128/mimetypes,128x128/places,128x128/status,scalable/actions,scalable/apps,scalable/categories,scalable/devices,scalable/emblems,scalable/emotes,scalable/mimetypes,scalable/places,scalable/status + +[16x16/actions] +Size=16 +Context=Actions +Type=Fixed + +[16x16/apps] +Size=16 +Context=Applications +Type=Fixed + +[16x16/categories] +Size=16 +Context=Categories +Type=Fixed + +[16x16/devices] +Size=16 +Context=Devices +Type=Fixed + +[16x16/emblems] +Size=16 +Context=Emblems +Type=Fixed + +[16x16/emotes] +Size=16 +Context=Emotes +Type=Fixed + +[16x16/mimetypes] +Size=16 +Context=MimeTypes +Type=Fixed + +[16x16/places] +Size=16 +Context=Places +Type=Fixed + +[16x16/status] +Size=16 +Context=Status +Type=Fixed + +[22x22/actions] +Size=22 +Context=Actions +Type=Fixed + +[22x22/apps] +Size=22 +Context=Applications +Type=Fixed + +[22x22/categories] +Size=22 +Context=Categories +Type=Fixed + +[22x22/devices] +Size=22 +Context=Devices +Type=Fixed + +[22x22/emblems] +Size=22 +Context=Emblems +Type=Fixed + +[22x22/emotes] +Size=22 +Context=Emotes +Type=Fixed + +[22x22/mimetypes] +Size=22 +Context=MimeTypes +Type=Fixed + +[22x22/places] +Size=22 +Context=Places +Type=Fixed + +[22x22/status] +Size=22 +Context=Status +Type=Fixed + +[24x24/actions] +Size=24 +Context=Actions +Type=Fixed + +[24x24/apps] +Size=24 +Context=Applications +Type=Fixed + +[24x24/categories] +Size=24 +Context=Categories +Type=Fixed + +[24x24/devices] +Size=24 +Context=Devices +Type=Fixed + +[24x24/emblems] +Size=24 +Context=Emblems +Type=Fixed + +[24x24/emotes] +Size=24 +Context=Emotes +Type=Fixed + +[24x24/mimetypes] +Size=24 +Context=MimeTypes +Type=Fixed + +[24x24/places] +Size=24 +Context=Places +Type=Fixed + +[24x24/status] +Size=24 +Context=Status +Type=Fixed + +[32x32/actions] +Size=32 +Context=Actions +Type=Fixed + +[32x32/apps] +Size=32 +Context=Applications +Type=Fixed + +[32x32/categories] +Size=32 +Context=Categories +Type=Fixed + +[32x32/devices] +Size=32 +Context=Devices +Type=Fixed + +[32x32/emblems] +Size=32 +Context=Emblems +Type=Fixed + +[32x32/emotes] +Size=32 +Context=Emotes +Type=Fixed + +[32x32/mimetypes] +Size=32 +Context=MimeTypes +Type=Fixed + +[32x32/places] +Size=32 +Context=Places +Type=Fixed + +[32x32/status] +Size=32 +Context=Status +Type=Fixed + +[48x48/actions] +Size=48 +Context=Actions +Type=Fixed + +[48x48/apps] +Size=48 +Context=Applications +Type=Fixed + +[48x48/categories] +Size=48 +Context=Categories +Type=Fixed + +[48x48/devices] +Size=48 +Context=Devices +Type=Fixed + +[48x48/emblems] +Size=48 +Context=Emblems +Type=Fixed + +[48x48/emotes] +Size=48 +Context=Emotes +Type=Fixed + +[48x48/mimetypes] +Size=48 +Context=MimeTypes +Type=Fixed + +[48x48/places] +Size=48 +Context=Places +Type=Fixed + +[48x48/status] +Size=48 +Context=Status +Type=Fixed + +[64x64/actions] +Size=64 +Context=Actions +Type=Fixed + +[64x64/apps] +Size=64 +Context=Applications +Type=Fixed + +[64x64/categories] +Size=64 +Context=Categories +Type=Fixed + +[64x64/devices] +Size=64 +Context=Devices +Type=Fixed + +[64x64/emblems] +Size=64 +Context=Emblems +Type=Fixed + +[64x64/emotes] +Size=64 +Context=Emotes +Type=Fixed + +[64x64/mimetypes] +Size=64 +Context=MimeTypes +Type=Fixed + +[64x64/places] +Size=64 +Context=Places +Type=Fixed + +[64x64/status] +Size=64 +Context=Status +Type=Fixed + +[72x72/actions] +Size=72 +Context=Actions +Type=Fixed + +[72x72/apps] +Size=72 +Context=Applications +Type=Fixed + +[72x72/categories] +Size=72 +Context=Categories +Type=Fixed + +[72x72/devices] +Size=72 +Context=Devices +Type=Fixed + +[72x72/emblems] +Size=72 +Context=Emblems +Type=Fixed + +[72x72/emotes] +Size=72 +Context=Emotes +Type=Fixed + +[72x72/mimetypes] +Size=72 +Context=MimeTypes +Type=Fixed + +[72x72/places] +Size=72 +Context=Places +Type=Fixed + +[72x72/status] +Size=72 +Context=Status +Type=Fixed + +[96x96/actions] +Size=96 +Context=Actions +Type=Fixed + +[96x96/apps] +Size=96 +Context=Applications +Type=Fixed + +[96x96/categories] +Size=96 +Context=Categories +Type=Fixed + +[96x96/devices] +Size=96 +Context=Devices +Type=Fixed + +[96x96/emblems] +Size=96 +Context=Emblems +Type=Fixed + +[96x96/emotes] +Size=96 +Context=Emotes +Type=Fixed + +[96x96/mimetypes] +Size=96 +Context=MimeTypes +Type=Fixed + +[96x96/places] +Size=96 +Context=Places +Type=Fixed + +[96x96/status] +Size=96 +Context=Status +Type=Fixed + +[128x128/actions] +Size=128 +Context=Actions +Type=Fixed + +[128x128/apps] +Size=128 +Context=Applications +Type=Fixed + +[128x128/categories] +Size=128 +Context=Categories +Type=Fixed + +[128x128/devices] +Size=128 +Context=Devices +Type=Fixed + +[128x128/emblems] +Size=128 +Context=Emblems +Type=Fixed + +[128x128/emotes] +Size=128 +Context=Emotes +Type=Fixed + +[128x128/mimetypes] +Size=128 +Context=MimeTypes +Type=Fixed + +[128x128/places] +Size=128 +Context=Places +Type=Fixed + +[128x128/status] +Size=128 +Context=Status +Type=Fixed + +[scalable/actions] +Size=48 +Context=Actions +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/apps] +Size=48 +Context=Applications +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/categories] +Size=48 +Context=Categories +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/devices] +Size=48 +Context=Devices +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emblems] +Size=48 +Context=Emblems +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/emotes] +Size=48 +Context=Emotes +Type=Scalable +Minsize=32 +MaxSize=256 + +[scalable/mimetypes] +Size=48 +Context=MimeTypes +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/places] +Size=48 +Context=Places +Type=Scalable +MinSize=32 +MaxSize=256 + +[scalable/status] +Size=48 +Context=Status +Type=Scalable +MinSize=32 +MaxSize=256 diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg b/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg new file mode 100644 index 0000000000..600a82c1b0 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/address-book-new.svg @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Addess Book - New + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + + address + contact + book + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg b/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg new file mode 100644 index 0000000000..4cb14f82f0 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/icons/themeparent/scalable/actions/appointment-new.svg @@ -0,0 +1,425 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Jakub Steiner + + + http://jimmac.musichall.cz + + New Appointment + + + appointment + new + meeting + rvsp + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/auto/widgets/kernel/qicon/image.png b/tests/auto/widgets/kernel/qicon/image.png new file mode 100644 index 0000000000..8d703640c1 Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/image.png differ diff --git a/tests/auto/widgets/kernel/qicon/qicon.pro b/tests/auto/widgets/kernel/qicon/qicon.pro new file mode 100644 index 0000000000..c44c080ced --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/qicon.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_qicon + +QT += widgets testlib +SOURCES += tst_qicon.cpp +RESOURCES = tst_qicon.qrc + +wince* { + QT += xml svg + DEPLOYMENT_PLUGIN += qsvg +} +TESTDATA += icons/* *.png *.svg *.svgz diff --git a/tests/auto/widgets/kernel/qicon/rect.png b/tests/auto/widgets/kernel/qicon/rect.png new file mode 100644 index 0000000000..b5d3ecbddf Binary files /dev/null and b/tests/auto/widgets/kernel/qicon/rect.png differ diff --git a/tests/auto/widgets/kernel/qicon/tst_qicon.cpp b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp new file mode 100644 index 0000000000..4a9ab93921 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/tst_qicon.cpp @@ -0,0 +1,637 @@ +/**************************************************************************** +** +** 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 +#include + +Q_DECLARE_METATYPE(QSize) + +class tst_QIcon : public QObject +{ + Q_OBJECT +public: + tst_QIcon(); + +private slots: + void actualSize_data(); // test with 1 pixmap + void actualSize(); + void actualSize2_data(); // test with 2 pixmaps with different aspect ratio + void actualSize2(); + void isNull(); + void swap(); + void bestMatch(); + void cacheKey(); + void detach(); + void addFile(); + void availableSizes(); + void name(); + void streamAvailableSizes_data(); + void streamAvailableSizes(); + void fromTheme(); + + void task184901_badCache(); + void task223279_inconsistentAddFile(); + +private: + bool haveImageFormat(QByteArray const&); + + const static QIcon staticIcon; +}; + +// Creating an icon statically should not cause a crash. +// But we do not officially support this. See QTBUG-8666 +const QIcon tst_QIcon::staticIcon = QIcon::fromTheme("edit-find"); + +bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) +{ + return QImageReader::supportedImageFormats().contains(desiredFormat); +} + +tst_QIcon::tst_QIcon() +{ +} + +void tst_QIcon::actualSize_data() +{ + QTest::addColumn("source"); + QTest::addColumn("argument"); + QTest::addColumn("result"); + + // square image + QTest::newRow("resource0") << ":/image.png" << QSize(128, 128) << QSize(128, 128); + QTest::newRow("resource1") << ":/image.png" << QSize( 64, 64) << QSize( 64, 64); + QTest::newRow("resource2") << ":/image.png" << QSize( 32, 64) << QSize( 32, 32); + QTest::newRow("resource3") << ":/image.png" << QSize( 16, 64) << QSize( 16, 16); + QTest::newRow("resource4") << ":/image.png" << QSize( 16, 128) << QSize( 16, 16); + QTest::newRow("resource5") << ":/image.png" << QSize( 128, 16) << QSize( 16, 16); + QTest::newRow("resource6") << ":/image.png" << QSize( 150, 150) << QSize( 128, 128); + // rect image + QTest::newRow("resource7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); + QTest::newRow("resource8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); + QTest::newRow("resource9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); + QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); + + const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; + QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128); + QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64); + QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32); + QTest::newRow("external3") << prefix + "image.png" << QSize( 16, 64) << QSize( 16, 16); + QTest::newRow("external4") << prefix + "image.png" << QSize( 16, 128) << QSize( 16, 16); + QTest::newRow("external5") << prefix + "image.png" << QSize( 128, 16) << QSize( 16, 16); + QTest::newRow("external6") << prefix + "image.png" << QSize( 150, 150) << QSize( 128, 128); + // rect image + QTest::newRow("external7") << ":/rect.png" << QSize( 20, 40) << QSize( 20, 40); + QTest::newRow("external8") << ":/rect.png" << QSize( 10, 20) << QSize( 10, 20); + QTest::newRow("external9") << ":/rect.png" << QSize( 15, 50) << QSize( 15, 30); + QTest::newRow("external10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); +} + +void tst_QIcon::actualSize() +{ + QFETCH(QString, source); + QFETCH(QSize, argument); + QFETCH(QSize, result); + + { + QPixmap pixmap(source); + QIcon icon(pixmap); + QCOMPARE(icon.actualSize(argument), result); + QCOMPARE(icon.pixmap(argument).size(), result); + } + + { + QIcon icon(source); + QCOMPARE(icon.actualSize(argument), result); + QCOMPARE(icon.pixmap(argument).size(), result); + } +} + +void tst_QIcon::actualSize2_data() +{ + QTest::addColumn("argument"); + QTest::addColumn("result"); + + // two images - 128x128 and 20x40. Let the games begin + QTest::newRow("trivial1") << QSize( 128, 128) << QSize( 128, 128); + QTest::newRow("trivial2") << QSize( 20, 40) << QSize( 20, 40); + + // QIcon chooses the one with the smallest area to choose the pixmap + QTest::newRow("best1") << QSize( 100, 100) << QSize( 100, 100); + QTest::newRow("best2") << QSize( 20, 20) << QSize( 10, 20); + QTest::newRow("best3") << QSize( 15, 30) << QSize( 15, 30); + QTest::newRow("best4") << QSize( 5, 5) << QSize( 2, 5); + QTest::newRow("best5") << QSize( 10, 15) << QSize( 7, 15); +} + +void tst_QIcon::actualSize2() +{ + QIcon icon; + const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; + + icon.addPixmap(QPixmap(prefix + "image.png")); + icon.addPixmap(QPixmap(prefix + "rect.png")); + + QFETCH(QSize, argument); + QFETCH(QSize, result); + + QCOMPARE(icon.actualSize(argument), result); + QCOMPARE(icon.pixmap(argument).size(), result); +} + +void tst_QIcon::isNull() { + // test default constructor + QIcon defaultConstructor; + QVERIFY(defaultConstructor.isNull()); + + // test copy constructor + QVERIFY(QIcon(defaultConstructor).isNull()); + + // test pixmap constructor + QPixmap nullPixmap; + QVERIFY(QIcon(nullPixmap).isNull()); + + // test string constructor with empty string + QIcon iconEmptyString = QIcon(QString()); + QVERIFY(iconEmptyString.isNull()); + QVERIFY(!iconEmptyString.actualSize(QSize(32, 32)).isValid());; + + // test string constructor with non-existing file + QIcon iconNoFile = QIcon("imagedoesnotexist"); + QVERIFY(!iconNoFile.isNull()); + QVERIFY(!iconNoFile.actualSize(QSize(32, 32)).isValid()); + + // test string constructor with non-existing file with suffix + QIcon iconNoFileSuffix = QIcon("imagedoesnotexist.png"); + QVERIFY(!iconNoFileSuffix.isNull()); + QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid()); + + const QString prefix = QFileInfo(QFINDTESTDATA("icons")).absolutePath() + "/"; + // test string constructor with existing file but unsupported format + QIcon iconUnsupportedFormat = QIcon(prefix + "tst_qicon.cpp"); + QVERIFY(!iconUnsupportedFormat.isNull()); + QVERIFY(!iconUnsupportedFormat.actualSize(QSize(32, 32)).isValid()); + + // test string constructor with existing file and supported format + QIcon iconSupportedFormat = QIcon(prefix + "image.png"); + QVERIFY(!iconSupportedFormat.isNull()); + QVERIFY(iconSupportedFormat.actualSize(QSize(32, 32)).isValid()); +} + +void tst_QIcon::swap() +{ + QPixmap p1(1, 1), p2(2, 2); + p1.fill(Qt::black); + p2.fill(Qt::black); + + QIcon i1(p1), i2(p2); + const qint64 i1k = i1.cacheKey(); + const qint64 i2k = i2.cacheKey(); + QVERIFY(i1k != i2k); + i1.swap(i2); + QCOMPARE(i1.cacheKey(), i2k); + QCOMPARE(i2.cacheKey(), i1k); +} + +void tst_QIcon::bestMatch() +{ + QPixmap p1(1, 1); + QPixmap p2(2, 2); + QPixmap p3(3, 3); + QPixmap p4(4, 4); + QPixmap p5(5, 5); + QPixmap p6(6, 6); + QPixmap p7(7, 7); + QPixmap p8(8, 8); + + p1.fill(Qt::black); + p2.fill(Qt::black); + p3.fill(Qt::black); + p4.fill(Qt::black); + p5.fill(Qt::black); + p6.fill(Qt::black); + p7.fill(Qt::black); + p8.fill(Qt::black); + + for (int i = 0; i < 4; ++i) { + for (int j = 0; j < 2; ++j) { + QIcon::State state = (j == 0) ? QIcon::On : QIcon::Off; + QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off + : QIcon::On; + QIcon::Mode mode; + QIcon::Mode oppositeMode; + + QIcon icon; + + switch (i) { + case 0: + default: + mode = QIcon::Normal; + oppositeMode = QIcon::Active; + break; + case 1: + mode = QIcon::Active; + oppositeMode = QIcon::Normal; + break; + case 2: + mode = QIcon::Disabled; + oppositeMode = QIcon::Selected; + break; + case 3: + mode = QIcon::Selected; + oppositeMode = QIcon::Disabled; + } + + /* + The test mirrors the code in + QPixmapIconEngine::bestMatch(), to make sure that + nobody breaks QPixmapIconEngine by mistake. Before + you change this test or the code that it tests, + please talk to the maintainer if possible. + */ + if (mode == QIcon::Disabled || mode == QIcon::Selected) { + icon.addPixmap(p1, oppositeMode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); + + icon.addPixmap(p2, oppositeMode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); + + icon.addPixmap(p3, QIcon::Active, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); + + icon.addPixmap(p4, QIcon::Normal, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); + + icon.addPixmap(p5, mode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); + + icon.addPixmap(p6, QIcon::Active, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); + + icon.addPixmap(p7, QIcon::Normal, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); + + icon.addPixmap(p8, mode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); + } else { + icon.addPixmap(p1, QIcon::Selected, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p1.size()); + + icon.addPixmap(p2, QIcon::Disabled, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p2.size()); + + icon.addPixmap(p3, QIcon::Selected, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p3.size()); + + icon.addPixmap(p4, QIcon::Disabled, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p4.size()); + + icon.addPixmap(p5, oppositeMode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p5.size()); + + icon.addPixmap(p6, mode, oppositeState); + QVERIFY(icon.pixmap(100, mode, state).size() == p6.size()); + + icon.addPixmap(p7, oppositeMode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p7.size()); + + icon.addPixmap(p8, mode, state); + QVERIFY(icon.pixmap(100, mode, state).size() == p8.size()); + } + } + } +} + +void tst_QIcon::cacheKey() +{ + QIcon icon1("image.png"); + qint64 icon1_key = icon1.cacheKey(); + QIcon icon2 = icon1; + + QVERIFY(icon2.cacheKey() == icon1.cacheKey()); + icon2.detach(); + QVERIFY(icon2.cacheKey() != icon1.cacheKey()); + QVERIFY(icon1.cacheKey() == icon1_key); +} + +void tst_QIcon::detach() +{ + QImage img(32, 32, QImage::Format_ARGB32_Premultiplied); + img.fill(0xffff0000); + QIcon icon1(QPixmap::fromImage(img)); + QIcon icon2 = icon1; + icon2.addFile(QFINDTESTDATA("image.png"), QSize(64, 64)); + + QImage img1 = icon1.pixmap(64, 64).toImage(); + QImage img2 = icon2.pixmap(64, 64).toImage(); + QVERIFY(img1 != img2); + + img1 = icon1.pixmap(32, 32).toImage(); + img2 = icon2.pixmap(32, 32).toImage(); + QVERIFY(img1 == img2); +} + +void tst_QIcon::addFile() +{ + QIcon icon; + icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")); + icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")); + icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"), QSize(), QIcon::Selected); + icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"), QSize(), QIcon::Selected); + +#ifndef Q_OS_WINCE + QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png")).toImage()); + QVERIFY(icon.pixmap(128, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png")).toImage()); + QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); + QVERIFY(icon.pixmap(32, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png")).toImage()); + QVERIFY(icon.pixmap(128, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png")).toImage()); +#else + // WinCE only includes the 16x16 images for size reasons + QVERIFY(icon.pixmap(16, QIcon::Normal).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")).toImage()); + QVERIFY(icon.pixmap(16, QIcon::Selected).toImage() == + QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png")).toImage()); +#endif +} + +static bool sizeLess(const QSize &a, const QSize &b) +{ + return a.width() < b.width(); +} + +void tst_QIcon::availableSizes() +{ + { + QIcon icon; + icon.addFile("image.png", QSize(32,32)); + icon.addFile("image.png", QSize(64,64)); + icon.addFile("image.png", QSize(128,128)); + icon.addFile("image.png", QSize(256,256), QIcon::Disabled); + icon.addFile("image.png", QSize(16,16), QIcon::Normal, QIcon::On); + + QList availableSizes = icon.availableSizes(); + QCOMPARE(availableSizes.size(), 3); + qSort(availableSizes.begin(), availableSizes.end(), sizeLess); + QCOMPARE(availableSizes.at(0), QSize(32,32)); + QCOMPARE(availableSizes.at(1), QSize(64,64)); + QCOMPARE(availableSizes.at(2), QSize(128,128)); + + availableSizes = icon.availableSizes(QIcon::Disabled); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(256,256)); + + availableSizes = icon.availableSizes(QIcon::Normal, QIcon::On); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(16,16)); + } + + { + // we try to load an icon from resources + QIcon icon(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + QList availableSizes = icon.availableSizes(); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(16, 16)); + } + + { + // load an icon from binary data. + QPixmap pix; + QFile file(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + QVERIFY(file.open(QIODevice::ReadOnly)); + uchar *data = file.map(0, file.size()); + QVERIFY(data != 0); + pix.loadFromData(data, file.size()); + QIcon icon(pix); + + QList availableSizes = icon.availableSizes(); + QCOMPARE(availableSizes.size(), 1); + QCOMPARE(availableSizes.at(0), QSize(16,16)); + } + + { + // there shouldn't be available sizes for invalid images! + QVERIFY(QIcon(QLatin1String("")).availableSizes().isEmpty()); + QVERIFY(QIcon(QLatin1String("non-existing.png")).availableSizes().isEmpty()); + } +} + +void tst_QIcon::name() +{ + { + // No name if icon does not come from a theme + QIcon icon(":/image.png"); + QString name = icon.name(); + QVERIFY(name.isEmpty()); + } + + { + // Getting the name of an icon coming from a theme should work + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + + QIcon icon = QIcon::fromTheme("appointment-new"); + QString name = icon.name(); + QCOMPARE(name, QLatin1String("appointment-new")); + } +} + +void tst_QIcon::streamAvailableSizes_data() +{ + QTest::addColumn("icon"); + + QIcon icon; + icon.addFile(":/image.png", QSize(32,32)); + QTest::newRow( "32x32" ) << icon; + icon.addFile(":/image.png", QSize(64,64)); + QTest::newRow( "64x64" ) << icon; + icon.addFile(":/image.png", QSize(128,128)); + QTest::newRow( "128x128" ) << icon; + icon.addFile(":/image.png", QSize(256,256)); + QTest::newRow( "256x256" ) << icon; +} + +void tst_QIcon::streamAvailableSizes() +{ + QFETCH(QIcon, icon); + + QByteArray ba; + // write to QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + QDataStream stream(&buffer); + stream << icon; + } + + // read from QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::ReadOnly); + QDataStream stream(&buffer); + QIcon i; + stream >> i; + QCOMPARE(i.isNull(), icon.isNull()); + QCOMPARE(i.availableSizes(), icon.availableSizes()); + } +} + + +static inline bool operator<(const QSize &lhs, const QSize &rhs) +{ + if (lhs.width() < rhs.width()) + return true; + else if (lhs.width() == lhs.width()) + return lhs.height() < lhs.height(); + return false; +} + +void tst_QIcon::task184901_badCache() +{ + QPixmap pm(QFINDTESTDATA("image.png")); + QIcon icon(pm); + + //the disabled icon must have an effect (grayed) + QVERIFY(icon.pixmap(32, QIcon::Normal).toImage() != icon.pixmap(32, QIcon::Disabled).toImage()); + + icon.addPixmap(pm, QIcon::Disabled); + //the disabled icon must now be the same as the normal one. + QVERIFY( icon.pixmap(32, QIcon::Normal).toImage() == icon.pixmap(32, QIcon::Disabled).toImage() ); +} + +void tst_QIcon::fromTheme() +{ + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QVERIFY(QIcon::themeSearchPaths().size() == 1); + QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); + + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + QCOMPARE(QIcon::themeName(), themeName); + + // Test normal icon + QIcon appointmentIcon = QIcon::fromTheme("appointment-new"); + QVERIFY(!appointmentIcon.isNull()); + QVERIFY(!appointmentIcon.availableSizes(QIcon::Normal, QIcon::Off).isEmpty()); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(16, 16))); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(32, 32))); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(22, 22))); + + // Test icon from parent theme + QIcon abIcon = QIcon::fromTheme("address-book-new"); + QVERIFY(!abIcon.isNull()); + QVERIFY(QIcon::hasThemeIcon("address-book-new")); + QVERIFY(!abIcon.availableSizes().isEmpty()); + + // Test non existing icon + QIcon noIcon = QIcon::fromTheme("broken-icon"); + QVERIFY(noIcon.isNull()); + QVERIFY(!QIcon::hasThemeIcon("broken-icon")); + + // Test non existing icon with fallback + noIcon = QIcon::fromTheme("broken-icon", abIcon); + QVERIFY(noIcon.cacheKey() == abIcon.cacheKey()); + + // Test svg-only icon + noIcon = QIcon::fromTheme("svg-icon", abIcon); + QVERIFY(!noIcon.availableSizes().isEmpty()); + + QByteArray ba; + // write to QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + QDataStream stream(&buffer); + stream << abIcon; + } + + // read from QByteArray + { + QBuffer buffer(&ba); + buffer.open(QIODevice::ReadOnly); + QDataStream stream(&buffer); + QIcon i; + stream >> i; + QCOMPARE(i.isNull(), abIcon.isNull()); + QCOMPARE(i.availableSizes(), abIcon.availableSizes()); + } + + // Make sure setting the theme name clears the state + QIcon::setThemeName(""); + abIcon = QIcon::fromTheme("address-book-new"); + QVERIFY(abIcon.isNull()); +} + + +void tst_QIcon::task223279_inconsistentAddFile() +{ + QIcon icon1; + icon1.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon1.addFile(QLatin1String("IconThatDoesntExist"), QSize(32, 32)); + QPixmap pm1 = icon1.pixmap(32, 32); + + QIcon icon2; + icon2.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png")); + icon2.addFile(QLatin1String("IconThatDoesntExist")); + QPixmap pm2 = icon1.pixmap(32, 32); + + QCOMPARE(pm1.isNull(), false); + QCOMPARE(pm1.size(), QSize(16,16)); + QCOMPARE(pm1.isNull(), pm2.isNull()); + QCOMPARE(pm1.size(), pm2.size()); +} + + +QTEST_MAIN(tst_QIcon) +#include "tst_qicon.moc" diff --git a/tests/auto/widgets/kernel/qicon/tst_qicon.qrc b/tests/auto/widgets/kernel/qicon/tst_qicon.qrc new file mode 100644 index 0000000000..7925a33c84 --- /dev/null +++ b/tests/auto/widgets/kernel/qicon/tst_qicon.qrc @@ -0,0 +1,20 @@ + + +image.png +rect.png +./icons/testtheme/16x16/actions/appointment-new.png +./icons/testtheme/22x22/actions/appointment-new.png +./icons/testtheme/32x32/actions/appointment-new.png +./icons/testtheme/index.theme +./icons/testtheme/scalable/actions/svg-only.svg +./icons/themeparent/16x16/actions/address-book-new.png +./icons/themeparent/16x16/actions/appointment-new.png +./icons/themeparent/22x22/actions/address-book-new.png +./icons/themeparent/22x22/actions/appointment-new.png +./icons/themeparent/32x32/actions/address-book-new.png +./icons/themeparent/32x32/actions/appointment-new.png +./icons/themeparent/index.theme +./icons/themeparent/scalable/actions/address-book-new.svg +./icons/themeparent/scalable/actions/appointment-new.svg + + -- cgit v1.2.3 From eb57da5b3ff9915d2254fdbf57992fa0320d9041 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 Mar 2012 13:51:31 +0100 Subject: Update accessibility StateChange by custom event. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subclass QAccessibleEvent to give details what changed in the state change. Change-Id: I9005d311e85a3c8bfa6e062833fa6a8a7dc6a4a4 Reviewed-by: Jan-Arve Sæther --- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 3e3fce2e1c..b8649a6443 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -419,8 +419,6 @@ void tst_QAccessibility::eventTest() button->setFocus(Qt::MouseFocusReason); QTestAccessibility::clearEvents(); QTest::mouseClick(button, Qt::LeftButton, 0); - QVERIFY_EVENT(button, 0, QAccessible::StateChanged); - QVERIFY_EVENT(button, 0, QAccessible::StateChanged); button->setAccessibleName("Olaf the second"); QVERIFY_EVENT(button, -1, QAccessible::NameChanged); -- cgit v1.2.3 From 57cf7c8a1bb1905294038ba5c98f1e8235fc08af Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 9 Mar 2012 18:09:17 -0800 Subject: Clean up some auto tests of gui These unit tests do not depent on QtWidget. Change-Id: I95526125c563885c0531da7ebfee06bca9a87b1c Reviewed-by: Gunnar Sletta Reviewed-by: Friedemann Kleint --- tests/auto/gui/painting/qbrush/qbrush.pro | 2 +- tests/auto/gui/painting/qpolygon/qpolygon.pro | 2 +- tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp | 1 - .../qabstracttextdocumentlayout.pro | 2 +- tests/auto/gui/text/qstatictext/qstatictext.pro | 2 +- tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 11 +++++------ tests/auto/gui/text/qtextblock/qtextblock.pro | 2 +- tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro | 2 +- tests/auto/gui/util/qdesktopservices/qdesktopservices.pro | 2 +- tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp | 1 - 10 files changed, 12 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/painting/qbrush/qbrush.pro b/tests/auto/gui/painting/qbrush/qbrush.pro index 2a470c4db1..3ef9b36ef5 100644 --- a/tests/auto/gui/painting/qbrush/qbrush.pro +++ b/tests/auto/gui/painting/qbrush/qbrush.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qbrush -QT += widgets testlib +QT += testlib SOURCES += tst_qbrush.cpp diff --git a/tests/auto/gui/painting/qpolygon/qpolygon.pro b/tests/auto/gui/painting/qpolygon/qpolygon.pro index 869fbd30c5..804fc0dfd2 100644 --- a/tests/auto/gui/painting/qpolygon/qpolygon.pro +++ b/tests/auto/gui/painting/qpolygon/qpolygon.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qpolygon -QT += widgets testlib +QT += testlib SOURCES += tst_qpolygon.cpp unix:!mac:LIBS+=-lm diff --git a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp index 5e5f661a09..f9dbbbf219 100644 --- a/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp +++ b/tests/auto/gui/painting/qpolygon/tst_qpolygon.cpp @@ -47,7 +47,6 @@ #include #include -#include class tst_QPolygon : public QObject { diff --git a/tests/auto/gui/text/qabstracttextdocumentlayout/qabstracttextdocumentlayout.pro b/tests/auto/gui/text/qabstracttextdocumentlayout/qabstracttextdocumentlayout.pro index 025b3f8a26..3848a287dc 100644 --- a/tests/auto/gui/text/qabstracttextdocumentlayout/qabstracttextdocumentlayout.pro +++ b/tests/auto/gui/text/qabstracttextdocumentlayout/qabstracttextdocumentlayout.pro @@ -4,7 +4,7 @@ CONFIG += testcase TARGET = tst_qabstracttextdocumentlayout -QT += widgets testlib +QT += testlib SOURCES += tst_qabstracttextdocumentlayout.cpp diff --git a/tests/auto/gui/text/qstatictext/qstatictext.pro b/tests/auto/gui/text/qstatictext/qstatictext.pro index a0955af710..67f2e047a4 100644 --- a/tests/auto/gui/text/qstatictext/qstatictext.pro +++ b/tests/auto/gui/text/qstatictext/qstatictext.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qstatictext -QT += widgets widgets-private testlib +QT += testlib QT += core core-private gui gui-private SOURCES += tst_qstatictext.cpp diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 66145f2dcf..fbb9549425 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include +#include #include #include @@ -48,7 +48,6 @@ #include #include -#include // #define DEBUG_SAVE_IMAGE @@ -296,7 +295,7 @@ void tst_QStaticText::prepareToWrongData() void tst_QStaticText::setFont() { - QFont font = QApplication::font(); + QFont font = QGuiApplication::font(); font.setBold(true); font.setPointSize(28); @@ -618,7 +617,7 @@ void tst_QStaticText::plainTextVsRichText() void tst_QStaticText::setPenPlainText() { - QFont font = QApplication::font(); + QFont font = QGuiApplication::font(); font.setStyleStrategy(QFont::NoAntialias); QFontMetricsF fm(font); @@ -646,7 +645,7 @@ void tst_QStaticText::setPenPlainText() void tst_QStaticText::setPenRichText() { - QFont font = QApplication::font(); + QFont font = QGuiApplication::font(); font.setStyleStrategy(QFont::NoAntialias); QFontMetricsF fm(font); @@ -675,7 +674,7 @@ void tst_QStaticText::setPenRichText() void tst_QStaticText::richTextOverridesPen() { - QFont font = QApplication::font(); + QFont font = QGuiApplication::font(); font.setStyleStrategy(QFont::NoAntialias); QFontMetricsF fm(font); diff --git a/tests/auto/gui/text/qtextblock/qtextblock.pro b/tests/auto/gui/text/qtextblock/qtextblock.pro index cad009a35a..cf3456bbf6 100644 --- a/tests/auto/gui/text/qtextblock/qtextblock.pro +++ b/tests/auto/gui/text/qtextblock/qtextblock.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qtextblock -QT += widgets widgets-private testlib +QT += testlib QT += core-private gui-private SOURCES += tst_qtextblock.cpp diff --git a/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro b/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro index 930d18f5fe..1419e32012 100644 --- a/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro +++ b/tests/auto/gui/text/qtextpiecetable/qtextpiecetable.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qtextpiecetable -QT += widgets widgets-private testlib +QT += testlib QT += core-private gui-private SOURCES += tst_qtextpiecetable.cpp HEADERS += ../qtextdocument/common.h diff --git a/tests/auto/gui/util/qdesktopservices/qdesktopservices.pro b/tests/auto/gui/util/qdesktopservices/qdesktopservices.pro index 98bc5c3d0d..cf14e6b47a 100644 --- a/tests/auto/gui/util/qdesktopservices/qdesktopservices.pro +++ b/tests/auto/gui/util/qdesktopservices/qdesktopservices.pro @@ -1,5 +1,5 @@ CONFIG += testcase -QT += widgets testlib +QT += testlib SOURCES += tst_qdesktopservices.cpp TARGET = tst_qdesktopservices diff --git a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp index ad45d00520..0ad37c21e8 100644 --- a/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/gui/util/qdesktopservices/tst_qdesktopservices.cpp @@ -41,7 +41,6 @@ #include -#include #include #include -- cgit v1.2.3 From 4eeb07d886940087de85ba1c4a12e634f35d8d9d Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 9 Mar 2012 18:43:21 -0800 Subject: Move tst_qprinter.cpp to QtPrintSupport QPrinter and QPrinterInfo belong to QtPrintSupport. Change-Id: I0c146e0c717be365e752c1eaf7dbe6765fb72da2 Reviewed-by: Gunnar Sletta Reviewed-by: Friedemann Kleint --- tests/auto/auto.pro | 1 + tests/auto/gui/painting/painting.pro | 2 - tests/auto/gui/painting/qprinter/.gitignore | 4 - tests/auto/gui/painting/qprinter/qprinter.pro | 7 - tests/auto/gui/painting/qprinter/tst_qprinter.cpp | 1023 -------------------- tests/auto/gui/painting/qprinterinfo/.gitignore | 1 - .../gui/painting/qprinterinfo/qprinterinfo.pro | 10 - .../gui/painting/qprinterinfo/tst_qprinterinfo.cpp | 393 -------- tests/auto/printsupport/kernel/kernel.pro | 4 + tests/auto/printsupport/kernel/qprinter/.gitignore | 4 + .../auto/printsupport/kernel/qprinter/qprinter.pro | 7 + .../printsupport/kernel/qprinter/tst_qprinter.cpp | 1023 ++++++++++++++++++++ .../printsupport/kernel/qprinterinfo/.gitignore | 1 + .../kernel/qprinterinfo/qprinterinfo.pro | 10 + .../kernel/qprinterinfo/tst_qprinterinfo.cpp | 393 ++++++++ tests/auto/printsupport/printsupport.pro | 3 + 16 files changed, 1446 insertions(+), 1440 deletions(-) delete mode 100644 tests/auto/gui/painting/qprinter/.gitignore delete mode 100644 tests/auto/gui/painting/qprinter/qprinter.pro delete mode 100644 tests/auto/gui/painting/qprinter/tst_qprinter.cpp delete mode 100644 tests/auto/gui/painting/qprinterinfo/.gitignore delete mode 100644 tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro delete mode 100644 tests/auto/gui/painting/qprinterinfo/tst_qprinterinfo.cpp create mode 100644 tests/auto/printsupport/kernel/kernel.pro create mode 100644 tests/auto/printsupport/kernel/qprinter/.gitignore create mode 100644 tests/auto/printsupport/kernel/qprinter/qprinter.pro create mode 100644 tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp create mode 100644 tests/auto/printsupport/kernel/qprinterinfo/.gitignore create mode 100644 tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro create mode 100644 tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp create mode 100644 tests/auto/printsupport/printsupport.pro (limited to 'tests') diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 63c4ca6a48..124af19799 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -13,6 +13,7 @@ SUBDIRS += \ concurrent \ other \ widgets \ + printsupport \ cross_compile: SUBDIRS -= tools !contains(QT_CONFIG, opengl): SUBDIRS -= opengl diff --git a/tests/auto/gui/painting/painting.pro b/tests/auto/gui/painting/painting.pro index 62230eeac7..8f018fd921 100644 --- a/tests/auto/gui/painting/painting.pro +++ b/tests/auto/gui/painting/painting.pro @@ -7,12 +7,10 @@ SUBDIRS=\ qregion \ qpainter \ qpathclipper \ - qprinterinfo \ qpen \ qpaintengine \ qtransform \ qwmatrix \ - qprinter \ qpolygon \ !contains(QT_CONFIG, private_tests): SUBDIRS -= \ diff --git a/tests/auto/gui/painting/qprinter/.gitignore b/tests/auto/gui/painting/qprinter/.gitignore deleted file mode 100644 index 85de0e9675..0000000000 --- a/tests/auto/gui/painting/qprinter/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -tqpluginloader/st_qprinter -silly -test.pdf - diff --git a/tests/auto/gui/painting/qprinter/qprinter.pro b/tests/auto/gui/painting/qprinter/qprinter.pro deleted file mode 100644 index 7543e91f8c..0000000000 --- a/tests/auto/gui/painting/qprinter/qprinter.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_qprinter -QT += printsupport widgets testlib -SOURCES += tst_qprinter.cpp - -mac*:CONFIG+=insignificant_test -win32:CONFIG += insignificant_test # QTBUG-24191 diff --git a/tests/auto/gui/painting/qprinter/tst_qprinter.cpp b/tests/auto/gui/painting/qprinter/tst_qprinter.cpp deleted file mode 100644 index 3460ad702b..0000000000 --- a/tests/auto/gui/painting/qprinter/tst_qprinter.cpp +++ /dev/null @@ -1,1023 +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 -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef Q_OS_WIN -#include -#endif - -Q_DECLARE_METATYPE(QRect) - -QT_FORWARD_DECLARE_CLASS(QPrinter) - -// Helper class to make sure temp files are cleaned up after test complete -class TempFileCleanup -{ -public: - TempFileCleanup(const QString &file) - : m_file(file) - { - } - - ~TempFileCleanup() - { - QFile::remove(m_file); - } -private: - QString m_file; -}; - -class tst_QPrinter : public QObject -{ - Q_OBJECT - -#ifdef QT_NO_PRINTER -public slots: - void initTestCase(); -#else -private slots: - void getSetCheck(); -// Add your testfunctions and testdata create functions here - void testPageSize(); - void testPageRectAndPaperRect(); - void testPageRectAndPaperRect_data(); - void testSetOptions(); - void testMargins_data(); - void testMargins(); - void testNonExistentPrinter(); - void testPageSetupDialog(); - void testMulitpleSets_data(); - void testMulitpleSets(); - void testPageMargins_data(); - void testPageMargins(); - void changingOutputFormat(); - void outputFormatFromSuffix(); - void setGetPaperSize(); - void valuePreservation(); - void errorReporting(); - void testCustomPageSizes(); -#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) - void printDialogCompleter(); -#endif - - void testCopyCount(); - void testCurrentPage(); - - void taskQTBUG4497_reusePrinterOnDifferentFiles(); - void testPdfTitle(); -#endif -}; - -#ifdef QT_NO_PRINTER -void tst_QPrinter::initTestCase() -{ - QSKIP("This test requires printing support"); -} - -#else - -// Testing get/set functions -void tst_QPrinter::getSetCheck() -{ - QPrinter obj1; - // OutputFormat QPrinter::outputFormat() - // void QPrinter::setOutputFormat(OutputFormat) - obj1.setOutputFormat(QPrinter::OutputFormat(QPrinter::PdfFormat)); - QCOMPARE(QPrinter::OutputFormat(QPrinter::PdfFormat), obj1.outputFormat()); - - // bool QPrinter::collateCopies() - // void QPrinter::setCollateCopies(bool) - obj1.setCollateCopies(false); - QCOMPARE(false, obj1.collateCopies()); - obj1.setCollateCopies(true); - QCOMPARE(true, obj1.collateCopies()); - - obj1.setColorMode(QPrinter::GrayScale); - QCOMPARE(obj1.colorMode(), QPrinter::GrayScale); - obj1.setColorMode(QPrinter::Color); - QCOMPARE(obj1.colorMode(), QPrinter::Color); - - obj1.setCreator(QString::fromLatin1("RandomQtUser")); - QCOMPARE(obj1.creator(), QString::fromLatin1("RandomQtUser")); - - obj1.setDocName(QString::fromLatin1("RandomQtDocument")); - QCOMPARE(obj1.docName(), QString::fromLatin1("RandomQtDocument")); - - obj1.setDoubleSidedPrinting(true); - QCOMPARE(obj1.doubleSidedPrinting(), true); - obj1.setDoubleSidedPrinting(false); - QCOMPARE(obj1.doubleSidedPrinting(), false); - - obj1.setFromTo(1, 4); - QCOMPARE(obj1.fromPage(), 1); - QCOMPARE(obj1.toPage(), 4); - - obj1.setFullPage(true); - QCOMPARE(obj1.fullPage(), true); - obj1.setFullPage(false); - QCOMPARE(obj1.fullPage(), false); - - obj1.setOrientation(QPrinter::Landscape); - QCOMPARE(obj1.orientation(), QPrinter::Landscape); - obj1.setOrientation(QPrinter::Portrait); - QCOMPARE(obj1.orientation(), QPrinter::Portrait); - - obj1.setOutputFileName(QString::fromLatin1("RandomQtName")); - QCOMPARE(obj1.outputFileName(), QString::fromLatin1("RandomQtName")); - - obj1.setPageOrder(QPrinter::FirstPageFirst); - QCOMPARE(obj1.pageOrder(), QPrinter::FirstPageFirst); - obj1.setPageOrder(QPrinter::LastPageFirst); - QCOMPARE(obj1.pageOrder(), QPrinter::LastPageFirst); - - obj1.setPaperSource(QPrinter::Cassette); - QCOMPARE(obj1.paperSource(), QPrinter::Cassette); - obj1.setPaperSource(QPrinter::Middle); - QCOMPARE(obj1.paperSource(), QPrinter::Middle); - -#ifdef Q_OS_UNIX - obj1.setPrintProgram(QString::fromLatin1("/bin/true")); - QCOMPARE(obj1.printProgram(), QString::fromLatin1("/bin/true")); - - obj1.setPrinterSelectionOption(QString::fromLatin1("--option")); - QCOMPARE(obj1.printerSelectionOption(), QString::fromLatin1("--option")); -#endif - - obj1.setPrinterName(QString::fromLatin1("myPrinter")); - QCOMPARE(obj1.printerName(), QString::fromLatin1("myPrinter")); - - // bool QPrinter::fontEmbeddingEnabled() - // void QPrinter::setFontEmbeddingEnabled(bool) - obj1.setFontEmbeddingEnabled(false); - QCOMPARE(false, obj1.fontEmbeddingEnabled()); - obj1.setFontEmbeddingEnabled(true); - QCOMPARE(true, obj1.fontEmbeddingEnabled()); - - // PageSize QPrinter::pageSize() - // void QPrinter::setPageSize(PageSize) - obj1.setPageSize(QPrinter::PageSize(QPrinter::A4)); - QCOMPARE(QPrinter::PageSize(QPrinter::A4), obj1.pageSize()); - obj1.setPageSize(QPrinter::PageSize(QPrinter::Letter)); - QCOMPARE(QPrinter::PageSize(QPrinter::Letter), obj1.pageSize()); - obj1.setPageSize(QPrinter::PageSize(QPrinter::Legal)); - QCOMPARE(QPrinter::PageSize(QPrinter::Legal), obj1.pageSize()); - - // PrintRange QPrinter::printRange() - // void QPrinter::setPrintRange(PrintRange) - obj1.setPrintRange(QPrinter::PrintRange(QPrinter::AllPages)); - QCOMPARE(QPrinter::PrintRange(QPrinter::AllPages), obj1.printRange()); - obj1.setPrintRange(QPrinter::PrintRange(QPrinter::Selection)); - QCOMPARE(QPrinter::PrintRange(QPrinter::Selection), obj1.printRange()); - obj1.setPrintRange(QPrinter::PrintRange(QPrinter::PageRange)); - QCOMPARE(QPrinter::PrintRange(QPrinter::PageRange), obj1.printRange()); -} - -#define MYCOMPARE(a, b) QCOMPARE(QVariant((int)a), QVariant((int)b)) - -void tst_QPrinter::testPageSetupDialog() -{ - // Make sure this doesn't crash at least - { - QPrinter printer; - QPageSetupDialog dialog(&printer); - } -} - -void tst_QPrinter::testPageSize() -{ -#if 1 - QSKIP("QPrinter::winPageSize(): Windows only and currently not implemented / QTBUG-22927"); -#else - QPrinter prn; - - prn.setPageSize(QPrinter::Letter); - MYCOMPARE(prn.pageSize(), QPrinter::Letter); - MYCOMPARE(prn.winPageSize(), DMPAPER_LETTER); - - prn.setPageSize(QPrinter::A4); - MYCOMPARE(prn.pageSize(), QPrinter::A4); - MYCOMPARE(prn.winPageSize(), DMPAPER_A4); - - prn.setWinPageSize(DMPAPER_LETTER); - MYCOMPARE(prn.winPageSize(), DMPAPER_LETTER); - MYCOMPARE(prn.pageSize(), QPrinter::Letter); - - prn.setWinPageSize(DMPAPER_A4); - MYCOMPARE(prn.winPageSize(), DMPAPER_A4); - MYCOMPARE(prn.pageSize(), QPrinter::A4); -#endif -} - -void tst_QPrinter::testPageRectAndPaperRect_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("withPainter"); - QTest::addColumn("resolution"); - QTest::addColumn("doPaperRect"); - - // paperrect - QTest::newRow("paperRect0") << int(QPrinter::Portrait) << true << 300 << true; - QTest::newRow("paperRect1") << int(QPrinter::Portrait) << false << 300 << true; - QTest::newRow("paperRect2") << int(QPrinter::Landscape) << true << 300 << true; - QTest::newRow("paperRect3") << int(QPrinter::Landscape) << false << 300 << true; - QTest::newRow("paperRect4") << int(QPrinter::Portrait) << true << 600 << true; - QTest::newRow("paperRect5") << int(QPrinter::Portrait) << false << 600 << true; - QTest::newRow("paperRect6") << int(QPrinter::Landscape) << true << 600 << true; - QTest::newRow("paperRect7") << int(QPrinter::Landscape) << false << 600 << true; - QTest::newRow("paperRect8") << int(QPrinter::Portrait) << true << 1200 << true; - QTest::newRow("paperRect9") << int(QPrinter::Portrait) << false << 1200 << true; - QTest::newRow("paperRect10") << int(QPrinter::Landscape) << true << 1200 << true; - QTest::newRow("paperRect11") << int(QPrinter::Landscape) << false << 1200 << true; - - // page rect - QTest::newRow("pageRect0") << int(QPrinter::Portrait) << true << 300 << false; - QTest::newRow("pageRect1") << int(QPrinter::Portrait) << false << 300 << false; - QTest::newRow("pageRect2") << int(QPrinter::Landscape) << true << 300 << false; - QTest::newRow("pageRect3") << int(QPrinter::Landscape) << false << 300 << false; - QTest::newRow("pageRect4") << int(QPrinter::Portrait) << true << 600 << false; - QTest::newRow("pageRect5") << int(QPrinter::Portrait) << false << 600 << false; - QTest::newRow("pageRect6") << int(QPrinter::Landscape) << true << 600 << false; - QTest::newRow("pageRect7") << int(QPrinter::Landscape) << false << 600 << false; - QTest::newRow("pageRect8") << int(QPrinter::Portrait) << true << 1200 << false; - QTest::newRow("pageRect9") << int(QPrinter::Portrait) << false << 1200 << false; - QTest::newRow("pageRect10") << int(QPrinter::Landscape) << true << 1200 << false; - QTest::newRow("pageRect11") << int(QPrinter::Landscape) << false << 1200 << false; -} - -void tst_QPrinter::testPageRectAndPaperRect() -{ - QFETCH(bool, withPainter); - QFETCH(int, orientation); - QFETCH(int, resolution); - QFETCH(bool, doPaperRect); - - QPainter *painter = 0; - QPrinter printer(QPrinter::HighResolution); - printer.setOrientation(QPrinter::Orientation(orientation)); - printer.setOutputFileName("silly"); - TempFileCleanup tmpFile("silly"); - - QRect pageRect = doPaperRect ? printer.paperRect() : printer.pageRect(); - float inchesX = float(pageRect.width()) / float(printer.resolution()); - float inchesY = float(pageRect.height()) / float(printer.resolution()); - printer.setResolution(resolution); - if (withPainter) - painter = new QPainter(&printer); - - QRect otherRect = doPaperRect ? printer.paperRect() : printer.pageRect(); - float otherInchesX = float(otherRect.width()) / float(printer.resolution()); - float otherInchesY = float(otherRect.height()) / float(printer.resolution()); - if (painter != 0) - delete painter; - - QVERIFY(qAbs(otherInchesX - inchesX) < 0.01); - QVERIFY(qAbs(otherInchesY - inchesY) < 0.01); - - QVERIFY(printer.orientation() == QPrinter::Portrait || pageRect.width() > pageRect.height()); - QVERIFY(printer.orientation() != QPrinter::Portrait || pageRect.width() < pageRect.height()); -} - -void tst_QPrinter::testSetOptions() -{ - QPrinter prn; - QPrintDialog dlg(&prn); - - // Verify default values - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), true); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), false); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), true); - - dlg.setEnabledOptions(QAbstractPrintDialog::PrintPageRange); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), false); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), false); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), true); - - dlg.setEnabledOptions((QAbstractPrintDialog::PrintDialogOptions(QAbstractPrintDialog::PrintSelection - | QAbstractPrintDialog::PrintPageRange))); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), false); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), true); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), true); - - dlg.setEnabledOptions(QAbstractPrintDialog::PrintSelection); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), false); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), true); - MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), false); -} - -void tst_QPrinter::testMargins_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("fullpage"); - QTest::addColumn("pagesize"); - QTest::addColumn("width"); - QTest::addColumn("height"); - QTest::addColumn("withPainter"); - - QTest::newRow("data0") << int(QPrinter::Portrait) << true << int(QPrinter::A4) << 210 << 297 << false; - QTest::newRow("data1") << int(QPrinter::Landscape) << true << int(QPrinter::A4) << 297 << 210 << false; - QTest::newRow("data2") << int(QPrinter::Landscape) << false << int(QPrinter::A4) << 297 << 210 << false; - QTest::newRow("data3") << int(QPrinter::Portrait) << false << int(QPrinter::A4) << 210 << 297 << false; - QTest::newRow("data4") << int(QPrinter::Portrait) << true << int(QPrinter::A4) << 210 << 297 << true; - QTest::newRow("data5") << int(QPrinter::Landscape) << true << int(QPrinter::A4) << 297 << 210 << true; - QTest::newRow("data6") << int(QPrinter::Landscape) << false << int(QPrinter::A4) << 297 << 210 << true; - QTest::newRow("data7") << int(QPrinter::Portrait) << false << int(QPrinter::A4) << 210 << 297 << true; -} - -void tst_QPrinter::testMargins() -{ - QFETCH(bool, withPainter); - QFETCH(int, orientation); - QFETCH(int, pagesize); - QFETCH(int, width); - QFETCH(int, height); - QFETCH(bool, fullpage); - Q_UNUSED(width); - Q_UNUSED(height); - QPrinter printer; - QPainter *painter = 0; - printer.setOutputFileName("silly"); - printer.setOrientation((QPrinter::Orientation)orientation); - printer.setFullPage(fullpage); - printer.setPageSize((QPrinter::PageSize)pagesize); - if (withPainter) - painter = new QPainter(&printer); - - if (painter) - delete painter; - QFile::remove("silly"); -} - -void tst_QPrinter::testNonExistentPrinter() -{ -#ifndef Q_OS_WIN - QSKIP("QPrinter::testNonExistentPrinter() is not relevant for this platform"); -#else - QPrinter printer; - QPainter painter; - - // Make sure it doesn't crash on setting or getting properties - printer.setPrinterName("some non existing printer"); - printer.setPageSize(QPrinter::A4); - printer.setOrientation(QPrinter::Portrait); - printer.setFullPage(true); - printer.pageSize(); - printer.orientation(); - printer.fullPage(); - printer.setCopyCount(1); - printer.printerName(); - - // nor metrics - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmWidth), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmHeight), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmWidthMM), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmHeightMM), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmNumColors), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDepth), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDpiX), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDpiY), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiX), 0); - QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiY), 0); - - QVERIFY(!painter.begin(&printer)); -#endif -} - -void tst_QPrinter::testMulitpleSets_data() -{ - QTest::addColumn("resolution"); - QTest::addColumn("pageSize"); - QTest::addColumn("widthMMAfter"); - QTest::addColumn("heightMMAfter"); - - - QTest::newRow("lowRes") << int(QPrinter::ScreenResolution) << int(QPrinter::A4) << 210 << 297; - QTest::newRow("lowResLetter") << int(QPrinter::ScreenResolution) << int(QPrinter::Letter) << 216 << 279; - QTest::newRow("lowResA5") << int(QPrinter::ScreenResolution) << int(QPrinter::A5) << 148 << 210; - QTest::newRow("midRes") << int(QPrinter::PrinterResolution) << int(QPrinter::A4) << 210 << 297; - QTest::newRow("midResLetter") << int(QPrinter::PrinterResolution) << int(QPrinter::Letter) << 216 << 279; - QTest::newRow("midResA5") << int(QPrinter::PrinterResolution) << int(QPrinter::A5) << 148 << 210; - QTest::newRow("highRes") << int(QPrinter::HighResolution) << int(QPrinter::A4) << 210 << 297; - QTest::newRow("highResLetter") << int(QPrinter::HighResolution) << int(QPrinter::Letter) << 216 << 279; - QTest::newRow("highResA5") << int(QPrinter::HighResolution) << int(QPrinter::A5) << 148 << 210; -} - -static void computePageValue(const QPrinter &printer, int &retWidth, int &retHeight) -{ - const double Inch2MM = 25.4; - - double width = double(printer.paperRect().width()) / printer.logicalDpiX() * Inch2MM; - double height = double(printer.paperRect().height()) / printer.logicalDpiY() * Inch2MM; - retWidth = qRound(width); - retHeight = qRound(height); -} - -void tst_QPrinter::testMulitpleSets() -{ - // A very simple test, but Mac needs to have its format "validated" if the format is changed - // This takes care of that. - QFETCH(int, resolution); - QFETCH(int, pageSize); - QFETCH(int, widthMMAfter); - QFETCH(int, heightMMAfter); - - - QPrinter::PrinterMode mode = QPrinter::PrinterMode(resolution); - QPrinter::PageSize printerPageSize = QPrinter::PageSize(pageSize); - QPrinter printer(mode); - printer.setFullPage(true); - - int paperWidth, paperHeight; - //const int Tolerance = 2; - - computePageValue(printer, paperWidth, paperHeight); - printer.setPageSize(printerPageSize); - - if (printer.pageSize() != printerPageSize) { - QSKIP("Current page size is not supported on this printer"); - return; - } - - QCOMPARE(printer.widthMM(), widthMMAfter); - QCOMPARE(printer.heightMM(), heightMMAfter); - - computePageValue(printer, paperWidth, paperHeight); - - QVERIFY(qAbs(paperWidth - widthMMAfter) <= 2); - QVERIFY(qAbs(paperHeight - heightMMAfter) <= 2); - - // Set it again and see if it still works. - printer.setPageSize(printerPageSize); - QCOMPARE(printer.widthMM(), widthMMAfter); - QCOMPARE(printer.heightMM(), heightMMAfter); - - printer.setOrientation(QPrinter::Landscape); - computePageValue(printer, paperWidth, paperHeight); - QVERIFY(qAbs(paperWidth - heightMMAfter) <= 2); - QVERIFY(qAbs(paperHeight - widthMMAfter) <= 2); -} - -void tst_QPrinter::changingOutputFormat() -{ -#if QT_VERSION < 0x050000 - QPrinter p; - p.setOutputFormat(QPrinter::PostScriptFormat); - p.setPageSize(QPrinter::A8); - p.setOutputFormat(QPrinter::PdfFormat); - QCOMPARE(p.pageSize(), QPrinter::A8); -#endif -} - -void tst_QPrinter::outputFormatFromSuffix() -{ - if (QPrinterInfo::availablePrinters().size() == 0) - QSKIP("No printers available."); - QPrinter p; - QVERIFY(p.outputFormat() == QPrinter::NativeFormat); - p.setOutputFileName("test.pdf"); - TempFileCleanup tmpFile("test.pdf"); - QVERIFY(p.outputFormat() == QPrinter::PdfFormat); - p.setOutputFileName(QString()); - QVERIFY(p.outputFormat() == QPrinter::NativeFormat); -} - -void tst_QPrinter::setGetPaperSize() -{ - QPrinter p; - p.setOutputFormat(QPrinter::PdfFormat); - QSizeF size(500, 10); - p.setPaperSize(size, QPrinter::Millimeter); - QCOMPARE(p.paperSize(QPrinter::Millimeter), size); - QSizeF ptSize = p.paperSize(QPrinter::Point); - //qDebug() << ptSize; - QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4); - QVERIFY(qAbs(ptSize.height() - size.height() * (72/25.4)) < 1E-4); -} - -void tst_QPrinter::testPageMargins_data() -{ - QTest::addColumn("left"); - QTest::addColumn("top"); - QTest::addColumn("right"); - QTest::addColumn("bottom"); - QTest::addColumn("unit"); - - QTest::newRow("data0") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Millimeter); - QTest::newRow("data1") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Point); - QTest::newRow("data2") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Inch); - QTest::newRow("data3") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Pica); - QTest::newRow("data4") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Didot); - QTest::newRow("data5") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Cicero); -} - -void tst_QPrinter::testPageMargins() -{ - QPrinter obj1; - - qreal toMillimeters[6]; - toMillimeters[QPrinter::Millimeter] = 1; - toMillimeters[QPrinter::Point] = 0.352777778; - toMillimeters[QPrinter::Inch] = 25.4; - toMillimeters[QPrinter::Pica] = 4.23333333; - toMillimeters[QPrinter::Didot] = 0.376; - toMillimeters[QPrinter::Cicero] = 4.51166667; - - QFETCH(qreal, left); - QFETCH(qreal, top); - QFETCH(qreal, right); - QFETCH(qreal, bottom); - QFETCH(int, unit); - - qreal nLeft, nTop, nRight, nBottom; - - obj1.setPageMargins(left, top, right, bottom, static_cast(unit)); - - qreal tolerance = 0.05; - - obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Millimeter); - QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Millimeter]) < tolerance); - QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Millimeter]) < tolerance); - QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Millimeter]) < tolerance); - QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Millimeter]) < tolerance); - - obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Point); - QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Point]) < tolerance); - QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Point]) < tolerance); - QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Point]) < tolerance); - QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Point]) < tolerance); - - obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Inch); - QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Inch]) < tolerance); - QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Inch]) < tolerance); - QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Inch]) < tolerance); - QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Inch]) < tolerance); - - obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Pica); - QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Pica]) < tolerance); - QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Pica]) < tolerance); - QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Pica]) < tolerance); - QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Pica]) < tolerance); - - obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Didot); - QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Didot]) < tolerance); - QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Didot]) < tolerance); - QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Didot]) < tolerance); - QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Didot]) < tolerance); - - obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Cicero); - QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Cicero]) < tolerance); - QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Cicero]) < tolerance); - QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Cicero]) < tolerance); - QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Cicero]) < tolerance); -} - -void tst_QPrinter::valuePreservation() -{ - QPrinter::OutputFormat oldFormat = QPrinter::PdfFormat; - QPrinter::OutputFormat newFormat = QPrinter::NativeFormat; // TODO: Correct? - - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - bool status = printer.collateCopies(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.collateCopies(), status); - - printer.setCollateCopies(!status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.collateCopies(), !status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.collateCopies(), !status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QPrinter::ColorMode status = printer.colorMode(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.colorMode(), status); - - printer.setColorMode(QPrinter::ColorMode(!status)); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.colorMode(), QPrinter::ColorMode(!status)); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.colorMode(), QPrinter::ColorMode(!status)); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QString status = printer.creator(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.creator(), status); - - status = QString::fromLatin1("Mr. Test"); - printer.setCreator(status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.creator(), status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.creator(), status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QString status = printer.docName(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.docName(), status); - - status = QString::fromLatin1("Test document"); - printer.setDocName(status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.docName(), status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.docName(), status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - bool status = printer.doubleSidedPrinting(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.doubleSidedPrinting(), status); - - printer.setDoubleSidedPrinting(!status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.doubleSidedPrinting(), !status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.doubleSidedPrinting(), !status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - bool status = printer.fontEmbeddingEnabled(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.fontEmbeddingEnabled(), status); - - printer.setFontEmbeddingEnabled(!status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.fontEmbeddingEnabled(), !status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.fontEmbeddingEnabled(), !status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - bool status = printer.fullPage(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.fullPage(), status); - - printer.setFullPage(!status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.fullPage(), !status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.fullPage(), !status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QPrinter::Orientation status = printer.orientation(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.orientation(), status); - - printer.setOrientation(QPrinter::Orientation(!status)); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.orientation(), QPrinter::Orientation(!status)); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.orientation(), QPrinter::Orientation(!status)); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QString status = printer.outputFileName(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.outputFileName(), status); - - status = QString::fromLatin1("Test file"); - printer.setOutputFileName(status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.outputFileName(), status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.outputFileName(), status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QPrinter::PageOrder status = printer.pageOrder(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.pageOrder(), status); - - printer.setPageOrder(QPrinter::PageOrder(!status)); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.pageOrder(), QPrinter::PageOrder(!status)); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.pageOrder(), QPrinter::PageOrder(!status)); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QPrinter::PageSize status = printer.pageSize(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.pageSize(), status); - - printer.setPageSize(QPrinter::B5); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.pageSize(), QPrinter::B5); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.pageSize(), QPrinter::B5); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QPrinter::PaperSource status = printer.paperSource(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.paperSource(), status); - - printer.setPaperSource(QPrinter::Manual); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.paperSource(), QPrinter::Manual); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.paperSource(), QPrinter::Manual); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QString status = printer.printProgram(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printProgram(), status); - - status = QString::fromLatin1("/usr/local/bin/lpr"); - printer.setPrintProgram(status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.printProgram(), status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printProgram(), status); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QPrinter::PrintRange status = printer.printRange(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printRange(), status); - - printer.setPrintRange(QPrinter::PrintRange(!status)); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.printRange(), QPrinter::PrintRange(!status)); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printRange(), QPrinter::PrintRange(!status)); - } - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QString status = printer.printerName(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printerName(), status); - - status = QString::fromLatin1("SuperDuperPrinter"); - printer.setPrinterName(status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.printerName(), status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printerName(), status); - } -#ifndef Q_OS_WIN - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - QString status = printer.printerSelectionOption(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printerSelectionOption(), status); - - status = QString::fromLatin1("Optional option"); - printer.setPrinterSelectionOption(status); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.printerSelectionOption(), status); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.printerSelectionOption(), status); - } -#endif - { - QPrinter printer; - printer.setOutputFormat(oldFormat); - int status = printer.resolution(); - printer.setOutputFormat(newFormat); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.resolution(), status); - - printer.setResolution(status-150); - printer.setOutputFormat(newFormat); - QCOMPARE(printer.resolution(), status-150); - printer.setOutputFormat(oldFormat); - QCOMPARE(printer.resolution(), status-150); - } -} - -void tst_QPrinter::errorReporting() -{ - QPrinter p; - p.setOutputFormat(QPrinter::PdfFormat); - QCOMPARE(p.isValid(), true); - QPainter painter; -#ifndef Q_WS_WIN - // not sure how to choose a never-writable file on windows. But its QFile behavior anyway, so lets rely on it failing elsewhere - p.setOutputFileName("/foobar/nonwritable.pdf"); - QCOMPARE(painter.begin(&p), false); // it should check the output file is writable -#endif - p.setOutputFileName("test.pdf"); - TempFileCleanup tmpFile("test.pdf"); - QCOMPARE(painter.begin(&p), true); // it should check the output - QCOMPARE(p.isValid(), true); - painter.end(); -} - -void tst_QPrinter::testCustomPageSizes() -{ - QPrinter p; - - QSizeF customSize(8.5, 11.0); - p.setPaperSize(customSize, QPrinter::Inch); - - QSizeF paperSize = p.paperSize(QPrinter::Inch); - QCOMPARE(paperSize, customSize); - - QPrinter p2(QPrinter::HighResolution); - p2.setPaperSize(customSize, QPrinter::Inch); - paperSize = p.paperSize(QPrinter::Inch); - QCOMPARE(paperSize, customSize); -} - -#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) -void tst_QPrinter::printDialogCompleter() -{ - QPrintDialog dialog; - dialog.printer()->setOutputFileName("file.pdf"); - TempFileCleanup tmpFile("file.pdf"); - dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile); - dialog.show(); - - QTest::qWait(100); - - QTest::keyClick(&dialog, Qt::Key_Tab); - QTest::keyClick(&dialog, 'P'); - // The test passes if it doesn't crash. -} -#endif - -void tst_QPrinter::testCopyCount() -{ - QPrinter p; - p.setCopyCount(15); - QCOMPARE(p.copyCount(), 15); -} - -static void printPage(QPainter *painter) -{ - painter->setPen(QPen(Qt::black, 4)); - painter->drawRect(50, 60, 70, 80); -} - -void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles() -{ - TempFileCleanup tmpFile1("out1.ps"); - TempFileCleanup tmpFile2("out2.ps"); - - QPrinter printer; - { - - printer.setOutputFileName("out1.ps"); - QPainter painter(&printer); - printPage(&painter); - - } - { - - printer.setOutputFileName("out2.ps"); - QPainter painter(&printer); - printPage(&painter); - - } - QFile file1("out1.ps"); - QVERIFY(file1.open(QIODevice::ReadOnly)); - - QFile file2("out2.ps"); - QVERIFY(file2.open(QIODevice::ReadOnly)); - - QEXPECT_FAIL("", "QTBUG-22562, QTBUG-22296", Abort); - QCOMPARE(file1.readAll(), file2.readAll()); -} - -void tst_QPrinter::testCurrentPage() -{ - QPrinter printer; - printer.setFromTo(1, 10); - - // Test set print range - printer.setPrintRange(QPrinter::CurrentPage); - QCOMPARE(printer.printRange(), QPrinter::CurrentPage); - QCOMPARE(printer.fromPage(), 1); - QCOMPARE(printer.toPage(), 10); - - QPrintDialog dialog(&printer); - - // Test default Current Page option to off - QCOMPARE(dialog.isOptionEnabled(QPrintDialog::PrintCurrentPage), false); - - // Test enable Current Page option - dialog.setOption(QPrintDialog::PrintCurrentPage); - QCOMPARE(dialog.isOptionEnabled(QPrintDialog::PrintCurrentPage), true); - -} - -void tst_QPrinter::testPdfTitle() -{ - // Check the document name is represented correctly in produced pdf - { - QPainter painter; - QPrinter printer; - // This string is just the UTF-8 encoding of the string: \()f ø hiragana o - const unsigned char titleBuf[]={0x5c, 0x28, 0x29, 0x66, 0xc3, 0xb8, 0xe3, 0x81, 0x8a, 0x00}; - const char *title = reinterpret_cast(titleBuf); - printer.setOutputFileName("file.pdf"); - printer.setDocName(QString::fromUtf8(title)); - painter.begin(&printer); - painter.end(); - } - TempFileCleanup tmpFile("file.pdf"); - QFile file("file.pdf"); - QVERIFY(file.open(QIODevice::ReadOnly)); - // The we expect the title to appear in the PDF as: - // ASCII('\title (') UTF16(\\\(\)f ø hiragana o) ASCII(')'). - // which has the following binary representation - const unsigned char expectedBuf[] = { - 0x2f, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x20, 0x28, 0xfe, - 0xff, 0x00, 0x5c, 0x5c, 0x00, 0x5c, 0x28, 0x00, 0x5c, - 0x29, 0x00, 0x66, 0x00, 0xf8, 0x30, 0x4a, 0x29}; - const char *expected = reinterpret_cast(expectedBuf); - QVERIFY(file.readAll().contains(QByteArray(expected, 26))); -} - -#endif - -QTEST_MAIN(tst_QPrinter) -#include "tst_qprinter.moc" diff --git a/tests/auto/gui/painting/qprinterinfo/.gitignore b/tests/auto/gui/painting/qprinterinfo/.gitignore deleted file mode 100644 index fcef7c1997..0000000000 --- a/tests/auto/gui/painting/qprinterinfo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qprinterinfo diff --git a/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro b/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro deleted file mode 100644 index 88cb07f338..0000000000 --- a/tests/auto/gui/painting/qprinterinfo/qprinterinfo.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qprinterinfo -SOURCES += tst_qprinterinfo.cpp - -QT += printsupport network testlib - -DEFINES += QT_USE_USING_NAMESPACE - -mac: CONFIG += insignificant_test # QTBUG-23060 -win32:CONFIG += insignificant_test # QTBUG-24190 diff --git a/tests/auto/gui/painting/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/gui/painting/qprinterinfo/tst_qprinterinfo.cpp deleted file mode 100644 index 2323dc8df3..0000000000 --- a/tests/auto/gui/painting/qprinterinfo/tst_qprinterinfo.cpp +++ /dev/null @@ -1,393 +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 -#include -#include -#include - -#ifdef Q_OS_UNIX -# include -# include -# include -#endif - -Q_DECLARE_METATYPE(QRect) - -class tst_QPrinterInfo : public QObject -{ - Q_OBJECT - -#ifdef QT_NO_PRINTER -public slots: - void initTestCase(); -#else -private slots: - void testForDefaultPrinter(); - void testForPrinters(); - void testForPaperSizes(); - void testConstructors(); - void testAssignment(); - -private: - void macFixNameFormat(QString *printerName); - QString getDefaultPrinterFromSystem(); - QStringList getPrintersFromSystem(); - - QString getOutputFromCommand(const QStringList& command); -#endif -}; - -#ifdef QT_NO_PRINTER -void tst_QPrinterInfo::initTestCase() -{ - QSKIP("This test requires printing support"); -} - -#else - -void tst_QPrinterInfo::macFixNameFormat(QString *printerName) -{ -// Modify the format of the printer name to match Qt, lpstat returns -// foo___domain_no, Qt returns foo @ domain.no -#ifdef Q_OS_MAC - printerName->replace(QLatin1String("___"), QLatin1String(" @ ")); - printerName->replace(QLatin1String("_"), QLatin1String(".")); -#else - Q_UNUSED(printerName); -#endif -} - -QString tst_QPrinterInfo::getDefaultPrinterFromSystem() -{ - QStringList command; - command << "lpstat" << "-d"; - QString output = getOutputFromCommand(command); - - QRegExp noDefaultReg("[^:]*no .*default"); - int pos = noDefaultReg.indexIn(output); - if (pos >= 0) { - return QString(); - } - - QRegExp defaultReg("default.*: *([a-zA-Z0-9_-]+)"); - defaultReg.indexIn(output); - QString printer = defaultReg.cap(1); - macFixNameFormat(&printer); - return printer; -} - -QStringList tst_QPrinterInfo::getPrintersFromSystem() -{ - QStringList ans; - - QStringList command; - command << "lpstat" << "-p"; - QString output = getOutputFromCommand(command); - QStringList list = output.split(QChar::fromLatin1('\n')); - - QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)"); - for (int c = 0; c < list.size(); ++c) { - if (reg.indexIn(list[c]) >= 0) { - QString printer = reg.cap(1); - macFixNameFormat(&printer); - ans << printer; - } - } - - return ans; -} - -// This function does roughly the same as the `command substitution` in -// the shell. -QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command) -{ -// The command execution does nothing on non-unix systems. -#ifdef Q_OS_UNIX - int pid; - int status = 0; - int pipePtr[2]; - - // Create a pipe that is shared between parent and child process. - if (pipe(pipePtr) < 0) { - return QString(); - } - pid = fork(); - if (pid < 0) { - close(pipePtr[0]); - close(pipePtr[1]); - return QString(); - } else if (pid == 0) { - // In child. - // Close the reading end. - close(pipePtr[0]); - // Redirect stdout to the pipe. - if (dup2(pipePtr[1], 1) < 0) { - exit(1); - } - - char** argv = new char*[command.size()+1]; - for (int c = 0; c < command.size(); ++c) { - argv[c] = new char[command[c].size()+1]; - strcpy(argv[c], command[c].toLatin1().data()); - } - argv[command.size()] = NULL; - execvp(argv[0], argv); - // Shouldn't get here, but it's possible if command is not found. - close(pipePtr[1]); - close(1); - for (int c = 0; c < command.size(); ++c) { - delete [] argv[c]; - } - delete [] argv; - exit(1); - } else { - // In parent. - // Close the writing end. - close(pipePtr[1]); - - QFile pipeRead; - if (!pipeRead.open(pipePtr[0], QIODevice::ReadOnly)) { - close(pipePtr[0]); - return QString(); - } - QByteArray array; - array = pipeRead.readAll(); - pipeRead.close(); - close(pipePtr[0]); - wait(&status); - return QString(array); - } -#else - return QString(); -#endif -} - -void tst_QPrinterInfo::testForDefaultPrinter() -{ -#if defined(Q_OS_UNIX) || defined(Q_OS_WIN32) -# ifdef Q_OS_WIN32 - if (QHostInfo::localHostName() == "fantomet" || QHostInfo::localHostName() == "bobo") { - QWARN("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows and may fail"); - } else { - QSKIP("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows"); - } - QString defSysPrinter; - if (QHostInfo::localHostName() == "fantomet") { - defSysPrinter = "Yacc (Lexmark Optra T610 PS3)"; - } else if (QHostInfo::localHostName() == "bobo") { - defSysPrinter = "press"; - } -# else - QString defSysPrinter = getDefaultPrinterFromSystem(); -# endif - if (defSysPrinter == "") - QSKIP("No default printer available"); - - QList list = QPrinterInfo::availablePrinters(); - bool found = false; - for (int c = 0; c < list.size(); ++c) { - if (list[c].isDefault()) { - QVERIFY(list.at(c).printerName() == defSysPrinter); - QVERIFY(!list.at(c).isNull()); - found = true; - } else { - QVERIFY(list.at(c).printerName() != defSysPrinter); - QVERIFY(!list.at(c).isNull()); - } - } - - if (!found && defSysPrinter != "") QFAIL("No default printer reported by Qt, although there is one"); -#else - QSKIP("Test doesn't work on non-Unix"); -#endif -} - -void tst_QPrinterInfo::testForPrinters() -{ -#if defined(Q_OS_UNIX) || defined(Q_OS_WIN32) -# ifdef Q_OS_WIN32 - if (QHostInfo::localHostName() == "fantomet" || QHostInfo::localHostName() == "bobo") { - QWARN("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows and may fail"); - } else { - QSKIP("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows"); - } - QStringList sysPrinters; - if (QHostInfo::localHostName() == "fantomet") { - sysPrinters - << "Press" - << "Canon PS-IPU Color Laser Copier v52.3" - << "EPSON EPL-N4000 PS3" - << "Kroksleiven" - << "Lexmark Optra Color 1200 PS" - << "Yacc (Lexmark Optra T610 PCL)" - << "Yacc (Lexmark Optra T610 PS3)" - ; - } else if (QHostInfo::localHostName() == "bobo") { - sysPrinters - << "press" - << "finnmarka" - << "nordmarka" - ; - } -# else - QStringList sysPrinters = getPrintersFromSystem(); -# endif - QList printers = QPrinterInfo::availablePrinters(); - - QCOMPARE(printers.size(), sysPrinters.size()); - - QHash qtPrinters; - - for (int j = 0; j < printers.size(); ++j) { - qtPrinters.insert(printers.at(j).printerName(), !printers.at(j).isNull()); - } - - for (int i = 0; i < sysPrinters.size(); ++i) { - if (!qtPrinters.value(sysPrinters.at(i))) { - qDebug() << "Available printers: " << qtPrinters; - QFAIL(qPrintable(QString("Printer '%1' reported by system, but not reported by Qt").arg(sysPrinters.at(i)))); - } - } -#else - QSKIP("Test doesn't work on non-Unix"); -#endif -} - -void tst_QPrinterInfo::testForPaperSizes() -{ -QSKIP("PaperSize feature doesn't work on Windows, fails on Mac, and is unstable on Linux"); - // This test is based on common printers found at the Oslo - // office. It is likely to be skipped or fail for other locations. - QStringList hardPrinters; - hardPrinters << "Finnmarka" << "Huldra"; - - QList > hardSizes; - hardSizes - << QList() - << QList() - ; - hardSizes[0] // Finnmarka - << QPrinter::Letter - << QPrinter::A4 - << QPrinter::A3 - << QPrinter::A5 - << QPrinter::B4 - << QPrinter::B5 - << QPrinter::Custom // COM10 - << QPrinter::Custom // C5 - << QPrinter::Custom // DL - << QPrinter::Custom // Monarch - << QPrinter::Executive - << QPrinter::Custom // Foolscap - << QPrinter::Custom // ISO B5 - << QPrinter::Ledger - << QPrinter::Legal - << QPrinter::Custom // Japanese Post Card - << QPrinter::Custom // Invoice - ; - hardSizes[1] // Huldra - << QPrinter::Custom // Not listed at http://localhost:631/, name "Custom" - << QPrinter::Letter - << QPrinter::A4 - << QPrinter::A5 - << QPrinter::A6 - << QPrinter::B5 - << QPrinter::Custom // #5 1/2 Envelope - << QPrinter::Custom // 6x9 Envelope - << QPrinter::Custom // #10 Envelope - << QPrinter::Custom // A7 Envelope - << QPrinter::Custom // C5 Envelope - << QPrinter::Custom // DL Envelope - << QPrinter::Custom // Monarch Envelope - << QPrinter::Custom // #6 3/4 Envelope - << QPrinter::Executive - << QPrinter::Custom // US Folio - << QPrinter::Custom // Index Card - << QPrinter::Custom // ISO B5 - << QPrinter::Legal - << QPrinter::Custom // Statement - ; - - QList printers = QPrinterInfo::availablePrinters(); - for (int i = 0; i < printers.size(); ++i) { - for (int j = 0; j < hardPrinters.size(); ++j) { - if (printers[i].printerName() == hardPrinters[j]) { - QList sizes = printers[i].supportedPaperSizes(); - qSort(sizes); - qSort(hardSizes[j]); - QCOMPARE(sizes, hardSizes[j]); - } - } - } -} - -void tst_QPrinterInfo::testConstructors() -{ - QList prns(QPrinterInfo::availablePrinters()); - - for (int c = 0; c < prns.size(); ++c) { - QList list1, list2; - list1 = prns[c].supportedPaperSizes(); - QPrinter pr(prns[c]); - list2 = QPrinterInfo(pr).supportedPaperSizes(); - QCOMPARE(list2, list1); - } -} - -void tst_QPrinterInfo::testAssignment() -{ - QList prns(QPrinterInfo::availablePrinters()); - - for (int c = 0; c < prns.size(); ++c) { - QPrinterInfo pi = QPrinterInfo::defaultPrinter(); - pi = prns[c]; - QCOMPARE(pi.printerName(), prns[c].printerName()); - QCOMPARE(pi.supportedPaperSizes(), prns[c].supportedPaperSizes()); - } -} - -#endif - -QTEST_MAIN(tst_QPrinterInfo) -#include "tst_qprinterinfo.moc" diff --git a/tests/auto/printsupport/kernel/kernel.pro b/tests/auto/printsupport/kernel/kernel.pro new file mode 100644 index 0000000000..6f5802bf3e --- /dev/null +++ b/tests/auto/printsupport/kernel/kernel.pro @@ -0,0 +1,4 @@ +TEMPLATE=subdirs +SUBDIRS=\ + qprinter \ + qprinterinfo \ diff --git a/tests/auto/printsupport/kernel/qprinter/.gitignore b/tests/auto/printsupport/kernel/qprinter/.gitignore new file mode 100644 index 0000000000..85de0e9675 --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinter/.gitignore @@ -0,0 +1,4 @@ +tqpluginloader/st_qprinter +silly +test.pdf + diff --git a/tests/auto/printsupport/kernel/qprinter/qprinter.pro b/tests/auto/printsupport/kernel/qprinter/qprinter.pro new file mode 100644 index 0000000000..7543e91f8c --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinter/qprinter.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qprinter +QT += printsupport widgets testlib +SOURCES += tst_qprinter.cpp + +mac*:CONFIG+=insignificant_test +win32:CONFIG += insignificant_test # QTBUG-24191 diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp new file mode 100644 index 0000000000..3460ad702b --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -0,0 +1,1023 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include +#include +#include + +#include + +#ifdef Q_OS_WIN +#include +#endif + +Q_DECLARE_METATYPE(QRect) + +QT_FORWARD_DECLARE_CLASS(QPrinter) + +// Helper class to make sure temp files are cleaned up after test complete +class TempFileCleanup +{ +public: + TempFileCleanup(const QString &file) + : m_file(file) + { + } + + ~TempFileCleanup() + { + QFile::remove(m_file); + } +private: + QString m_file; +}; + +class tst_QPrinter : public QObject +{ + Q_OBJECT + +#ifdef QT_NO_PRINTER +public slots: + void initTestCase(); +#else +private slots: + void getSetCheck(); +// Add your testfunctions and testdata create functions here + void testPageSize(); + void testPageRectAndPaperRect(); + void testPageRectAndPaperRect_data(); + void testSetOptions(); + void testMargins_data(); + void testMargins(); + void testNonExistentPrinter(); + void testPageSetupDialog(); + void testMulitpleSets_data(); + void testMulitpleSets(); + void testPageMargins_data(); + void testPageMargins(); + void changingOutputFormat(); + void outputFormatFromSuffix(); + void setGetPaperSize(); + void valuePreservation(); + void errorReporting(); + void testCustomPageSizes(); +#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) + void printDialogCompleter(); +#endif + + void testCopyCount(); + void testCurrentPage(); + + void taskQTBUG4497_reusePrinterOnDifferentFiles(); + void testPdfTitle(); +#endif +}; + +#ifdef QT_NO_PRINTER +void tst_QPrinter::initTestCase() +{ + QSKIP("This test requires printing support"); +} + +#else + +// Testing get/set functions +void tst_QPrinter::getSetCheck() +{ + QPrinter obj1; + // OutputFormat QPrinter::outputFormat() + // void QPrinter::setOutputFormat(OutputFormat) + obj1.setOutputFormat(QPrinter::OutputFormat(QPrinter::PdfFormat)); + QCOMPARE(QPrinter::OutputFormat(QPrinter::PdfFormat), obj1.outputFormat()); + + // bool QPrinter::collateCopies() + // void QPrinter::setCollateCopies(bool) + obj1.setCollateCopies(false); + QCOMPARE(false, obj1.collateCopies()); + obj1.setCollateCopies(true); + QCOMPARE(true, obj1.collateCopies()); + + obj1.setColorMode(QPrinter::GrayScale); + QCOMPARE(obj1.colorMode(), QPrinter::GrayScale); + obj1.setColorMode(QPrinter::Color); + QCOMPARE(obj1.colorMode(), QPrinter::Color); + + obj1.setCreator(QString::fromLatin1("RandomQtUser")); + QCOMPARE(obj1.creator(), QString::fromLatin1("RandomQtUser")); + + obj1.setDocName(QString::fromLatin1("RandomQtDocument")); + QCOMPARE(obj1.docName(), QString::fromLatin1("RandomQtDocument")); + + obj1.setDoubleSidedPrinting(true); + QCOMPARE(obj1.doubleSidedPrinting(), true); + obj1.setDoubleSidedPrinting(false); + QCOMPARE(obj1.doubleSidedPrinting(), false); + + obj1.setFromTo(1, 4); + QCOMPARE(obj1.fromPage(), 1); + QCOMPARE(obj1.toPage(), 4); + + obj1.setFullPage(true); + QCOMPARE(obj1.fullPage(), true); + obj1.setFullPage(false); + QCOMPARE(obj1.fullPage(), false); + + obj1.setOrientation(QPrinter::Landscape); + QCOMPARE(obj1.orientation(), QPrinter::Landscape); + obj1.setOrientation(QPrinter::Portrait); + QCOMPARE(obj1.orientation(), QPrinter::Portrait); + + obj1.setOutputFileName(QString::fromLatin1("RandomQtName")); + QCOMPARE(obj1.outputFileName(), QString::fromLatin1("RandomQtName")); + + obj1.setPageOrder(QPrinter::FirstPageFirst); + QCOMPARE(obj1.pageOrder(), QPrinter::FirstPageFirst); + obj1.setPageOrder(QPrinter::LastPageFirst); + QCOMPARE(obj1.pageOrder(), QPrinter::LastPageFirst); + + obj1.setPaperSource(QPrinter::Cassette); + QCOMPARE(obj1.paperSource(), QPrinter::Cassette); + obj1.setPaperSource(QPrinter::Middle); + QCOMPARE(obj1.paperSource(), QPrinter::Middle); + +#ifdef Q_OS_UNIX + obj1.setPrintProgram(QString::fromLatin1("/bin/true")); + QCOMPARE(obj1.printProgram(), QString::fromLatin1("/bin/true")); + + obj1.setPrinterSelectionOption(QString::fromLatin1("--option")); + QCOMPARE(obj1.printerSelectionOption(), QString::fromLatin1("--option")); +#endif + + obj1.setPrinterName(QString::fromLatin1("myPrinter")); + QCOMPARE(obj1.printerName(), QString::fromLatin1("myPrinter")); + + // bool QPrinter::fontEmbeddingEnabled() + // void QPrinter::setFontEmbeddingEnabled(bool) + obj1.setFontEmbeddingEnabled(false); + QCOMPARE(false, obj1.fontEmbeddingEnabled()); + obj1.setFontEmbeddingEnabled(true); + QCOMPARE(true, obj1.fontEmbeddingEnabled()); + + // PageSize QPrinter::pageSize() + // void QPrinter::setPageSize(PageSize) + obj1.setPageSize(QPrinter::PageSize(QPrinter::A4)); + QCOMPARE(QPrinter::PageSize(QPrinter::A4), obj1.pageSize()); + obj1.setPageSize(QPrinter::PageSize(QPrinter::Letter)); + QCOMPARE(QPrinter::PageSize(QPrinter::Letter), obj1.pageSize()); + obj1.setPageSize(QPrinter::PageSize(QPrinter::Legal)); + QCOMPARE(QPrinter::PageSize(QPrinter::Legal), obj1.pageSize()); + + // PrintRange QPrinter::printRange() + // void QPrinter::setPrintRange(PrintRange) + obj1.setPrintRange(QPrinter::PrintRange(QPrinter::AllPages)); + QCOMPARE(QPrinter::PrintRange(QPrinter::AllPages), obj1.printRange()); + obj1.setPrintRange(QPrinter::PrintRange(QPrinter::Selection)); + QCOMPARE(QPrinter::PrintRange(QPrinter::Selection), obj1.printRange()); + obj1.setPrintRange(QPrinter::PrintRange(QPrinter::PageRange)); + QCOMPARE(QPrinter::PrintRange(QPrinter::PageRange), obj1.printRange()); +} + +#define MYCOMPARE(a, b) QCOMPARE(QVariant((int)a), QVariant((int)b)) + +void tst_QPrinter::testPageSetupDialog() +{ + // Make sure this doesn't crash at least + { + QPrinter printer; + QPageSetupDialog dialog(&printer); + } +} + +void tst_QPrinter::testPageSize() +{ +#if 1 + QSKIP("QPrinter::winPageSize(): Windows only and currently not implemented / QTBUG-22927"); +#else + QPrinter prn; + + prn.setPageSize(QPrinter::Letter); + MYCOMPARE(prn.pageSize(), QPrinter::Letter); + MYCOMPARE(prn.winPageSize(), DMPAPER_LETTER); + + prn.setPageSize(QPrinter::A4); + MYCOMPARE(prn.pageSize(), QPrinter::A4); + MYCOMPARE(prn.winPageSize(), DMPAPER_A4); + + prn.setWinPageSize(DMPAPER_LETTER); + MYCOMPARE(prn.winPageSize(), DMPAPER_LETTER); + MYCOMPARE(prn.pageSize(), QPrinter::Letter); + + prn.setWinPageSize(DMPAPER_A4); + MYCOMPARE(prn.winPageSize(), DMPAPER_A4); + MYCOMPARE(prn.pageSize(), QPrinter::A4); +#endif +} + +void tst_QPrinter::testPageRectAndPaperRect_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("withPainter"); + QTest::addColumn("resolution"); + QTest::addColumn("doPaperRect"); + + // paperrect + QTest::newRow("paperRect0") << int(QPrinter::Portrait) << true << 300 << true; + QTest::newRow("paperRect1") << int(QPrinter::Portrait) << false << 300 << true; + QTest::newRow("paperRect2") << int(QPrinter::Landscape) << true << 300 << true; + QTest::newRow("paperRect3") << int(QPrinter::Landscape) << false << 300 << true; + QTest::newRow("paperRect4") << int(QPrinter::Portrait) << true << 600 << true; + QTest::newRow("paperRect5") << int(QPrinter::Portrait) << false << 600 << true; + QTest::newRow("paperRect6") << int(QPrinter::Landscape) << true << 600 << true; + QTest::newRow("paperRect7") << int(QPrinter::Landscape) << false << 600 << true; + QTest::newRow("paperRect8") << int(QPrinter::Portrait) << true << 1200 << true; + QTest::newRow("paperRect9") << int(QPrinter::Portrait) << false << 1200 << true; + QTest::newRow("paperRect10") << int(QPrinter::Landscape) << true << 1200 << true; + QTest::newRow("paperRect11") << int(QPrinter::Landscape) << false << 1200 << true; + + // page rect + QTest::newRow("pageRect0") << int(QPrinter::Portrait) << true << 300 << false; + QTest::newRow("pageRect1") << int(QPrinter::Portrait) << false << 300 << false; + QTest::newRow("pageRect2") << int(QPrinter::Landscape) << true << 300 << false; + QTest::newRow("pageRect3") << int(QPrinter::Landscape) << false << 300 << false; + QTest::newRow("pageRect4") << int(QPrinter::Portrait) << true << 600 << false; + QTest::newRow("pageRect5") << int(QPrinter::Portrait) << false << 600 << false; + QTest::newRow("pageRect6") << int(QPrinter::Landscape) << true << 600 << false; + QTest::newRow("pageRect7") << int(QPrinter::Landscape) << false << 600 << false; + QTest::newRow("pageRect8") << int(QPrinter::Portrait) << true << 1200 << false; + QTest::newRow("pageRect9") << int(QPrinter::Portrait) << false << 1200 << false; + QTest::newRow("pageRect10") << int(QPrinter::Landscape) << true << 1200 << false; + QTest::newRow("pageRect11") << int(QPrinter::Landscape) << false << 1200 << false; +} + +void tst_QPrinter::testPageRectAndPaperRect() +{ + QFETCH(bool, withPainter); + QFETCH(int, orientation); + QFETCH(int, resolution); + QFETCH(bool, doPaperRect); + + QPainter *painter = 0; + QPrinter printer(QPrinter::HighResolution); + printer.setOrientation(QPrinter::Orientation(orientation)); + printer.setOutputFileName("silly"); + TempFileCleanup tmpFile("silly"); + + QRect pageRect = doPaperRect ? printer.paperRect() : printer.pageRect(); + float inchesX = float(pageRect.width()) / float(printer.resolution()); + float inchesY = float(pageRect.height()) / float(printer.resolution()); + printer.setResolution(resolution); + if (withPainter) + painter = new QPainter(&printer); + + QRect otherRect = doPaperRect ? printer.paperRect() : printer.pageRect(); + float otherInchesX = float(otherRect.width()) / float(printer.resolution()); + float otherInchesY = float(otherRect.height()) / float(printer.resolution()); + if (painter != 0) + delete painter; + + QVERIFY(qAbs(otherInchesX - inchesX) < 0.01); + QVERIFY(qAbs(otherInchesY - inchesY) < 0.01); + + QVERIFY(printer.orientation() == QPrinter::Portrait || pageRect.width() > pageRect.height()); + QVERIFY(printer.orientation() != QPrinter::Portrait || pageRect.width() < pageRect.height()); +} + +void tst_QPrinter::testSetOptions() +{ + QPrinter prn; + QPrintDialog dlg(&prn); + + // Verify default values + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), true); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), false); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), true); + + dlg.setEnabledOptions(QAbstractPrintDialog::PrintPageRange); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), false); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), false); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), true); + + dlg.setEnabledOptions((QAbstractPrintDialog::PrintDialogOptions(QAbstractPrintDialog::PrintSelection + | QAbstractPrintDialog::PrintPageRange))); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), false); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), true); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), true); + + dlg.setEnabledOptions(QAbstractPrintDialog::PrintSelection); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintToFile), false); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintSelection), true); + MYCOMPARE(dlg.isOptionEnabled(QAbstractPrintDialog::PrintPageRange), false); +} + +void tst_QPrinter::testMargins_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("fullpage"); + QTest::addColumn("pagesize"); + QTest::addColumn("width"); + QTest::addColumn("height"); + QTest::addColumn("withPainter"); + + QTest::newRow("data0") << int(QPrinter::Portrait) << true << int(QPrinter::A4) << 210 << 297 << false; + QTest::newRow("data1") << int(QPrinter::Landscape) << true << int(QPrinter::A4) << 297 << 210 << false; + QTest::newRow("data2") << int(QPrinter::Landscape) << false << int(QPrinter::A4) << 297 << 210 << false; + QTest::newRow("data3") << int(QPrinter::Portrait) << false << int(QPrinter::A4) << 210 << 297 << false; + QTest::newRow("data4") << int(QPrinter::Portrait) << true << int(QPrinter::A4) << 210 << 297 << true; + QTest::newRow("data5") << int(QPrinter::Landscape) << true << int(QPrinter::A4) << 297 << 210 << true; + QTest::newRow("data6") << int(QPrinter::Landscape) << false << int(QPrinter::A4) << 297 << 210 << true; + QTest::newRow("data7") << int(QPrinter::Portrait) << false << int(QPrinter::A4) << 210 << 297 << true; +} + +void tst_QPrinter::testMargins() +{ + QFETCH(bool, withPainter); + QFETCH(int, orientation); + QFETCH(int, pagesize); + QFETCH(int, width); + QFETCH(int, height); + QFETCH(bool, fullpage); + Q_UNUSED(width); + Q_UNUSED(height); + QPrinter printer; + QPainter *painter = 0; + printer.setOutputFileName("silly"); + printer.setOrientation((QPrinter::Orientation)orientation); + printer.setFullPage(fullpage); + printer.setPageSize((QPrinter::PageSize)pagesize); + if (withPainter) + painter = new QPainter(&printer); + + if (painter) + delete painter; + QFile::remove("silly"); +} + +void tst_QPrinter::testNonExistentPrinter() +{ +#ifndef Q_OS_WIN + QSKIP("QPrinter::testNonExistentPrinter() is not relevant for this platform"); +#else + QPrinter printer; + QPainter painter; + + // Make sure it doesn't crash on setting or getting properties + printer.setPrinterName("some non existing printer"); + printer.setPageSize(QPrinter::A4); + printer.setOrientation(QPrinter::Portrait); + printer.setFullPage(true); + printer.pageSize(); + printer.orientation(); + printer.fullPage(); + printer.setCopyCount(1); + printer.printerName(); + + // nor metrics + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmWidth), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmHeight), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmWidthMM), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmHeightMM), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmNumColors), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDepth), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDpiX), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmDpiY), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiX), 0); + QCOMPARE(printer.printEngine()->metric(QPaintDevice::PdmPhysicalDpiY), 0); + + QVERIFY(!painter.begin(&printer)); +#endif +} + +void tst_QPrinter::testMulitpleSets_data() +{ + QTest::addColumn("resolution"); + QTest::addColumn("pageSize"); + QTest::addColumn("widthMMAfter"); + QTest::addColumn("heightMMAfter"); + + + QTest::newRow("lowRes") << int(QPrinter::ScreenResolution) << int(QPrinter::A4) << 210 << 297; + QTest::newRow("lowResLetter") << int(QPrinter::ScreenResolution) << int(QPrinter::Letter) << 216 << 279; + QTest::newRow("lowResA5") << int(QPrinter::ScreenResolution) << int(QPrinter::A5) << 148 << 210; + QTest::newRow("midRes") << int(QPrinter::PrinterResolution) << int(QPrinter::A4) << 210 << 297; + QTest::newRow("midResLetter") << int(QPrinter::PrinterResolution) << int(QPrinter::Letter) << 216 << 279; + QTest::newRow("midResA5") << int(QPrinter::PrinterResolution) << int(QPrinter::A5) << 148 << 210; + QTest::newRow("highRes") << int(QPrinter::HighResolution) << int(QPrinter::A4) << 210 << 297; + QTest::newRow("highResLetter") << int(QPrinter::HighResolution) << int(QPrinter::Letter) << 216 << 279; + QTest::newRow("highResA5") << int(QPrinter::HighResolution) << int(QPrinter::A5) << 148 << 210; +} + +static void computePageValue(const QPrinter &printer, int &retWidth, int &retHeight) +{ + const double Inch2MM = 25.4; + + double width = double(printer.paperRect().width()) / printer.logicalDpiX() * Inch2MM; + double height = double(printer.paperRect().height()) / printer.logicalDpiY() * Inch2MM; + retWidth = qRound(width); + retHeight = qRound(height); +} + +void tst_QPrinter::testMulitpleSets() +{ + // A very simple test, but Mac needs to have its format "validated" if the format is changed + // This takes care of that. + QFETCH(int, resolution); + QFETCH(int, pageSize); + QFETCH(int, widthMMAfter); + QFETCH(int, heightMMAfter); + + + QPrinter::PrinterMode mode = QPrinter::PrinterMode(resolution); + QPrinter::PageSize printerPageSize = QPrinter::PageSize(pageSize); + QPrinter printer(mode); + printer.setFullPage(true); + + int paperWidth, paperHeight; + //const int Tolerance = 2; + + computePageValue(printer, paperWidth, paperHeight); + printer.setPageSize(printerPageSize); + + if (printer.pageSize() != printerPageSize) { + QSKIP("Current page size is not supported on this printer"); + return; + } + + QCOMPARE(printer.widthMM(), widthMMAfter); + QCOMPARE(printer.heightMM(), heightMMAfter); + + computePageValue(printer, paperWidth, paperHeight); + + QVERIFY(qAbs(paperWidth - widthMMAfter) <= 2); + QVERIFY(qAbs(paperHeight - heightMMAfter) <= 2); + + // Set it again and see if it still works. + printer.setPageSize(printerPageSize); + QCOMPARE(printer.widthMM(), widthMMAfter); + QCOMPARE(printer.heightMM(), heightMMAfter); + + printer.setOrientation(QPrinter::Landscape); + computePageValue(printer, paperWidth, paperHeight); + QVERIFY(qAbs(paperWidth - heightMMAfter) <= 2); + QVERIFY(qAbs(paperHeight - widthMMAfter) <= 2); +} + +void tst_QPrinter::changingOutputFormat() +{ +#if QT_VERSION < 0x050000 + QPrinter p; + p.setOutputFormat(QPrinter::PostScriptFormat); + p.setPageSize(QPrinter::A8); + p.setOutputFormat(QPrinter::PdfFormat); + QCOMPARE(p.pageSize(), QPrinter::A8); +#endif +} + +void tst_QPrinter::outputFormatFromSuffix() +{ + if (QPrinterInfo::availablePrinters().size() == 0) + QSKIP("No printers available."); + QPrinter p; + QVERIFY(p.outputFormat() == QPrinter::NativeFormat); + p.setOutputFileName("test.pdf"); + TempFileCleanup tmpFile("test.pdf"); + QVERIFY(p.outputFormat() == QPrinter::PdfFormat); + p.setOutputFileName(QString()); + QVERIFY(p.outputFormat() == QPrinter::NativeFormat); +} + +void tst_QPrinter::setGetPaperSize() +{ + QPrinter p; + p.setOutputFormat(QPrinter::PdfFormat); + QSizeF size(500, 10); + p.setPaperSize(size, QPrinter::Millimeter); + QCOMPARE(p.paperSize(QPrinter::Millimeter), size); + QSizeF ptSize = p.paperSize(QPrinter::Point); + //qDebug() << ptSize; + QVERIFY(qAbs(ptSize.width() - size.width() * (72/25.4)) < 1E-4); + QVERIFY(qAbs(ptSize.height() - size.height() * (72/25.4)) < 1E-4); +} + +void tst_QPrinter::testPageMargins_data() +{ + QTest::addColumn("left"); + QTest::addColumn("top"); + QTest::addColumn("right"); + QTest::addColumn("bottom"); + QTest::addColumn("unit"); + + QTest::newRow("data0") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Millimeter); + QTest::newRow("data1") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Point); + QTest::newRow("data2") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Inch); + QTest::newRow("data3") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Pica); + QTest::newRow("data4") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Didot); + QTest::newRow("data5") << qreal(5.5) << qreal(6.5) << qreal(7.5) << qreal(8.5) << static_cast(QPrinter::Cicero); +} + +void tst_QPrinter::testPageMargins() +{ + QPrinter obj1; + + qreal toMillimeters[6]; + toMillimeters[QPrinter::Millimeter] = 1; + toMillimeters[QPrinter::Point] = 0.352777778; + toMillimeters[QPrinter::Inch] = 25.4; + toMillimeters[QPrinter::Pica] = 4.23333333; + toMillimeters[QPrinter::Didot] = 0.376; + toMillimeters[QPrinter::Cicero] = 4.51166667; + + QFETCH(qreal, left); + QFETCH(qreal, top); + QFETCH(qreal, right); + QFETCH(qreal, bottom); + QFETCH(int, unit); + + qreal nLeft, nTop, nRight, nBottom; + + obj1.setPageMargins(left, top, right, bottom, static_cast(unit)); + + qreal tolerance = 0.05; + + obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Millimeter); + QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Millimeter]) < tolerance); + QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Millimeter]) < tolerance); + QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Millimeter]) < tolerance); + QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Millimeter]) < tolerance); + + obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Point); + QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Point]) < tolerance); + QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Point]) < tolerance); + QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Point]) < tolerance); + QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Point]) < tolerance); + + obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Inch); + QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Inch]) < tolerance); + QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Inch]) < tolerance); + QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Inch]) < tolerance); + QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Inch]) < tolerance); + + obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Pica); + QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Pica]) < tolerance); + QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Pica]) < tolerance); + QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Pica]) < tolerance); + QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Pica]) < tolerance); + + obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Didot); + QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Didot]) < tolerance); + QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Didot]) < tolerance); + QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Didot]) < tolerance); + QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Didot]) < tolerance); + + obj1.getPageMargins(&nLeft, &nTop, &nRight, &nBottom, QPrinter::Cicero); + QVERIFY(fabs(left*toMillimeters[unit] - nLeft*toMillimeters[QPrinter::Cicero]) < tolerance); + QVERIFY(fabs(top*toMillimeters[unit] - nTop*toMillimeters[QPrinter::Cicero]) < tolerance); + QVERIFY(fabs(right*toMillimeters[unit] - nRight*toMillimeters[QPrinter::Cicero]) < tolerance); + QVERIFY(fabs(bottom*toMillimeters[unit] - nBottom*toMillimeters[QPrinter::Cicero]) < tolerance); +} + +void tst_QPrinter::valuePreservation() +{ + QPrinter::OutputFormat oldFormat = QPrinter::PdfFormat; + QPrinter::OutputFormat newFormat = QPrinter::NativeFormat; // TODO: Correct? + + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + bool status = printer.collateCopies(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.collateCopies(), status); + + printer.setCollateCopies(!status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.collateCopies(), !status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.collateCopies(), !status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QPrinter::ColorMode status = printer.colorMode(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.colorMode(), status); + + printer.setColorMode(QPrinter::ColorMode(!status)); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.colorMode(), QPrinter::ColorMode(!status)); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.colorMode(), QPrinter::ColorMode(!status)); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QString status = printer.creator(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.creator(), status); + + status = QString::fromLatin1("Mr. Test"); + printer.setCreator(status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.creator(), status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.creator(), status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QString status = printer.docName(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.docName(), status); + + status = QString::fromLatin1("Test document"); + printer.setDocName(status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.docName(), status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.docName(), status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + bool status = printer.doubleSidedPrinting(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.doubleSidedPrinting(), status); + + printer.setDoubleSidedPrinting(!status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.doubleSidedPrinting(), !status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.doubleSidedPrinting(), !status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + bool status = printer.fontEmbeddingEnabled(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.fontEmbeddingEnabled(), status); + + printer.setFontEmbeddingEnabled(!status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.fontEmbeddingEnabled(), !status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.fontEmbeddingEnabled(), !status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + bool status = printer.fullPage(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.fullPage(), status); + + printer.setFullPage(!status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.fullPage(), !status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.fullPage(), !status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QPrinter::Orientation status = printer.orientation(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.orientation(), status); + + printer.setOrientation(QPrinter::Orientation(!status)); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.orientation(), QPrinter::Orientation(!status)); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.orientation(), QPrinter::Orientation(!status)); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QString status = printer.outputFileName(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.outputFileName(), status); + + status = QString::fromLatin1("Test file"); + printer.setOutputFileName(status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.outputFileName(), status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.outputFileName(), status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QPrinter::PageOrder status = printer.pageOrder(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.pageOrder(), status); + + printer.setPageOrder(QPrinter::PageOrder(!status)); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.pageOrder(), QPrinter::PageOrder(!status)); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.pageOrder(), QPrinter::PageOrder(!status)); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QPrinter::PageSize status = printer.pageSize(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.pageSize(), status); + + printer.setPageSize(QPrinter::B5); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.pageSize(), QPrinter::B5); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.pageSize(), QPrinter::B5); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QPrinter::PaperSource status = printer.paperSource(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.paperSource(), status); + + printer.setPaperSource(QPrinter::Manual); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.paperSource(), QPrinter::Manual); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.paperSource(), QPrinter::Manual); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QString status = printer.printProgram(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printProgram(), status); + + status = QString::fromLatin1("/usr/local/bin/lpr"); + printer.setPrintProgram(status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.printProgram(), status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printProgram(), status); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QPrinter::PrintRange status = printer.printRange(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printRange(), status); + + printer.setPrintRange(QPrinter::PrintRange(!status)); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.printRange(), QPrinter::PrintRange(!status)); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printRange(), QPrinter::PrintRange(!status)); + } + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QString status = printer.printerName(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printerName(), status); + + status = QString::fromLatin1("SuperDuperPrinter"); + printer.setPrinterName(status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.printerName(), status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printerName(), status); + } +#ifndef Q_OS_WIN + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + QString status = printer.printerSelectionOption(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printerSelectionOption(), status); + + status = QString::fromLatin1("Optional option"); + printer.setPrinterSelectionOption(status); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.printerSelectionOption(), status); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.printerSelectionOption(), status); + } +#endif + { + QPrinter printer; + printer.setOutputFormat(oldFormat); + int status = printer.resolution(); + printer.setOutputFormat(newFormat); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.resolution(), status); + + printer.setResolution(status-150); + printer.setOutputFormat(newFormat); + QCOMPARE(printer.resolution(), status-150); + printer.setOutputFormat(oldFormat); + QCOMPARE(printer.resolution(), status-150); + } +} + +void tst_QPrinter::errorReporting() +{ + QPrinter p; + p.setOutputFormat(QPrinter::PdfFormat); + QCOMPARE(p.isValid(), true); + QPainter painter; +#ifndef Q_WS_WIN + // not sure how to choose a never-writable file on windows. But its QFile behavior anyway, so lets rely on it failing elsewhere + p.setOutputFileName("/foobar/nonwritable.pdf"); + QCOMPARE(painter.begin(&p), false); // it should check the output file is writable +#endif + p.setOutputFileName("test.pdf"); + TempFileCleanup tmpFile("test.pdf"); + QCOMPARE(painter.begin(&p), true); // it should check the output + QCOMPARE(p.isValid(), true); + painter.end(); +} + +void tst_QPrinter::testCustomPageSizes() +{ + QPrinter p; + + QSizeF customSize(8.5, 11.0); + p.setPaperSize(customSize, QPrinter::Inch); + + QSizeF paperSize = p.paperSize(QPrinter::Inch); + QCOMPARE(paperSize, customSize); + + QPrinter p2(QPrinter::HighResolution); + p2.setPaperSize(customSize, QPrinter::Inch); + paperSize = p.paperSize(QPrinter::Inch); + QCOMPARE(paperSize, customSize); +} + +#if !defined(QT_NO_COMPLETER) && !defined(QT_NO_FILEDIALOG) +void tst_QPrinter::printDialogCompleter() +{ + QPrintDialog dialog; + dialog.printer()->setOutputFileName("file.pdf"); + TempFileCleanup tmpFile("file.pdf"); + dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile); + dialog.show(); + + QTest::qWait(100); + + QTest::keyClick(&dialog, Qt::Key_Tab); + QTest::keyClick(&dialog, 'P'); + // The test passes if it doesn't crash. +} +#endif + +void tst_QPrinter::testCopyCount() +{ + QPrinter p; + p.setCopyCount(15); + QCOMPARE(p.copyCount(), 15); +} + +static void printPage(QPainter *painter) +{ + painter->setPen(QPen(Qt::black, 4)); + painter->drawRect(50, 60, 70, 80); +} + +void tst_QPrinter::taskQTBUG4497_reusePrinterOnDifferentFiles() +{ + TempFileCleanup tmpFile1("out1.ps"); + TempFileCleanup tmpFile2("out2.ps"); + + QPrinter printer; + { + + printer.setOutputFileName("out1.ps"); + QPainter painter(&printer); + printPage(&painter); + + } + { + + printer.setOutputFileName("out2.ps"); + QPainter painter(&printer); + printPage(&painter); + + } + QFile file1("out1.ps"); + QVERIFY(file1.open(QIODevice::ReadOnly)); + + QFile file2("out2.ps"); + QVERIFY(file2.open(QIODevice::ReadOnly)); + + QEXPECT_FAIL("", "QTBUG-22562, QTBUG-22296", Abort); + QCOMPARE(file1.readAll(), file2.readAll()); +} + +void tst_QPrinter::testCurrentPage() +{ + QPrinter printer; + printer.setFromTo(1, 10); + + // Test set print range + printer.setPrintRange(QPrinter::CurrentPage); + QCOMPARE(printer.printRange(), QPrinter::CurrentPage); + QCOMPARE(printer.fromPage(), 1); + QCOMPARE(printer.toPage(), 10); + + QPrintDialog dialog(&printer); + + // Test default Current Page option to off + QCOMPARE(dialog.isOptionEnabled(QPrintDialog::PrintCurrentPage), false); + + // Test enable Current Page option + dialog.setOption(QPrintDialog::PrintCurrentPage); + QCOMPARE(dialog.isOptionEnabled(QPrintDialog::PrintCurrentPage), true); + +} + +void tst_QPrinter::testPdfTitle() +{ + // Check the document name is represented correctly in produced pdf + { + QPainter painter; + QPrinter printer; + // This string is just the UTF-8 encoding of the string: \()f ø hiragana o + const unsigned char titleBuf[]={0x5c, 0x28, 0x29, 0x66, 0xc3, 0xb8, 0xe3, 0x81, 0x8a, 0x00}; + const char *title = reinterpret_cast(titleBuf); + printer.setOutputFileName("file.pdf"); + printer.setDocName(QString::fromUtf8(title)); + painter.begin(&printer); + painter.end(); + } + TempFileCleanup tmpFile("file.pdf"); + QFile file("file.pdf"); + QVERIFY(file.open(QIODevice::ReadOnly)); + // The we expect the title to appear in the PDF as: + // ASCII('\title (') UTF16(\\\(\)f ø hiragana o) ASCII(')'). + // which has the following binary representation + const unsigned char expectedBuf[] = { + 0x2f, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x20, 0x28, 0xfe, + 0xff, 0x00, 0x5c, 0x5c, 0x00, 0x5c, 0x28, 0x00, 0x5c, + 0x29, 0x00, 0x66, 0x00, 0xf8, 0x30, 0x4a, 0x29}; + const char *expected = reinterpret_cast(expectedBuf); + QVERIFY(file.readAll().contains(QByteArray(expected, 26))); +} + +#endif + +QTEST_MAIN(tst_QPrinter) +#include "tst_qprinter.moc" diff --git a/tests/auto/printsupport/kernel/qprinterinfo/.gitignore b/tests/auto/printsupport/kernel/qprinterinfo/.gitignore new file mode 100644 index 0000000000..fcef7c1997 --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinterinfo/.gitignore @@ -0,0 +1 @@ +tst_qprinterinfo diff --git a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro new file mode 100644 index 0000000000..88cb07f338 --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_qprinterinfo +SOURCES += tst_qprinterinfo.cpp + +QT += printsupport network testlib + +DEFINES += QT_USE_USING_NAMESPACE + +mac: CONFIG += insignificant_test # QTBUG-23060 +win32:CONFIG += insignificant_test # QTBUG-24190 diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp new file mode 100644 index 0000000000..2323dc8df3 --- /dev/null +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -0,0 +1,393 @@ +/**************************************************************************** +** +** 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 +#include +#include + +#ifdef Q_OS_UNIX +# include +# include +# include +#endif + +Q_DECLARE_METATYPE(QRect) + +class tst_QPrinterInfo : public QObject +{ + Q_OBJECT + +#ifdef QT_NO_PRINTER +public slots: + void initTestCase(); +#else +private slots: + void testForDefaultPrinter(); + void testForPrinters(); + void testForPaperSizes(); + void testConstructors(); + void testAssignment(); + +private: + void macFixNameFormat(QString *printerName); + QString getDefaultPrinterFromSystem(); + QStringList getPrintersFromSystem(); + + QString getOutputFromCommand(const QStringList& command); +#endif +}; + +#ifdef QT_NO_PRINTER +void tst_QPrinterInfo::initTestCase() +{ + QSKIP("This test requires printing support"); +} + +#else + +void tst_QPrinterInfo::macFixNameFormat(QString *printerName) +{ +// Modify the format of the printer name to match Qt, lpstat returns +// foo___domain_no, Qt returns foo @ domain.no +#ifdef Q_OS_MAC + printerName->replace(QLatin1String("___"), QLatin1String(" @ ")); + printerName->replace(QLatin1String("_"), QLatin1String(".")); +#else + Q_UNUSED(printerName); +#endif +} + +QString tst_QPrinterInfo::getDefaultPrinterFromSystem() +{ + QStringList command; + command << "lpstat" << "-d"; + QString output = getOutputFromCommand(command); + + QRegExp noDefaultReg("[^:]*no .*default"); + int pos = noDefaultReg.indexIn(output); + if (pos >= 0) { + return QString(); + } + + QRegExp defaultReg("default.*: *([a-zA-Z0-9_-]+)"); + defaultReg.indexIn(output); + QString printer = defaultReg.cap(1); + macFixNameFormat(&printer); + return printer; +} + +QStringList tst_QPrinterInfo::getPrintersFromSystem() +{ + QStringList ans; + + QStringList command; + command << "lpstat" << "-p"; + QString output = getOutputFromCommand(command); + QStringList list = output.split(QChar::fromLatin1('\n')); + + QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)"); + for (int c = 0; c < list.size(); ++c) { + if (reg.indexIn(list[c]) >= 0) { + QString printer = reg.cap(1); + macFixNameFormat(&printer); + ans << printer; + } + } + + return ans; +} + +// This function does roughly the same as the `command substitution` in +// the shell. +QString tst_QPrinterInfo::getOutputFromCommand(const QStringList& command) +{ +// The command execution does nothing on non-unix systems. +#ifdef Q_OS_UNIX + int pid; + int status = 0; + int pipePtr[2]; + + // Create a pipe that is shared between parent and child process. + if (pipe(pipePtr) < 0) { + return QString(); + } + pid = fork(); + if (pid < 0) { + close(pipePtr[0]); + close(pipePtr[1]); + return QString(); + } else if (pid == 0) { + // In child. + // Close the reading end. + close(pipePtr[0]); + // Redirect stdout to the pipe. + if (dup2(pipePtr[1], 1) < 0) { + exit(1); + } + + char** argv = new char*[command.size()+1]; + for (int c = 0; c < command.size(); ++c) { + argv[c] = new char[command[c].size()+1]; + strcpy(argv[c], command[c].toLatin1().data()); + } + argv[command.size()] = NULL; + execvp(argv[0], argv); + // Shouldn't get here, but it's possible if command is not found. + close(pipePtr[1]); + close(1); + for (int c = 0; c < command.size(); ++c) { + delete [] argv[c]; + } + delete [] argv; + exit(1); + } else { + // In parent. + // Close the writing end. + close(pipePtr[1]); + + QFile pipeRead; + if (!pipeRead.open(pipePtr[0], QIODevice::ReadOnly)) { + close(pipePtr[0]); + return QString(); + } + QByteArray array; + array = pipeRead.readAll(); + pipeRead.close(); + close(pipePtr[0]); + wait(&status); + return QString(array); + } +#else + return QString(); +#endif +} + +void tst_QPrinterInfo::testForDefaultPrinter() +{ +#if defined(Q_OS_UNIX) || defined(Q_OS_WIN32) +# ifdef Q_OS_WIN32 + if (QHostInfo::localHostName() == "fantomet" || QHostInfo::localHostName() == "bobo") { + QWARN("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows and may fail"); + } else { + QSKIP("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows"); + } + QString defSysPrinter; + if (QHostInfo::localHostName() == "fantomet") { + defSysPrinter = "Yacc (Lexmark Optra T610 PS3)"; + } else if (QHostInfo::localHostName() == "bobo") { + defSysPrinter = "press"; + } +# else + QString defSysPrinter = getDefaultPrinterFromSystem(); +# endif + if (defSysPrinter == "") + QSKIP("No default printer available"); + + QList list = QPrinterInfo::availablePrinters(); + bool found = false; + for (int c = 0; c < list.size(); ++c) { + if (list[c].isDefault()) { + QVERIFY(list.at(c).printerName() == defSysPrinter); + QVERIFY(!list.at(c).isNull()); + found = true; + } else { + QVERIFY(list.at(c).printerName() != defSysPrinter); + QVERIFY(!list.at(c).isNull()); + } + } + + if (!found && defSysPrinter != "") QFAIL("No default printer reported by Qt, although there is one"); +#else + QSKIP("Test doesn't work on non-Unix"); +#endif +} + +void tst_QPrinterInfo::testForPrinters() +{ +#if defined(Q_OS_UNIX) || defined(Q_OS_WIN32) +# ifdef Q_OS_WIN32 + if (QHostInfo::localHostName() == "fantomet" || QHostInfo::localHostName() == "bobo") { + QWARN("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows and may fail"); + } else { + QSKIP("Test is hardcoded to \"fantomet\" and \"bobo\" on Windows"); + } + QStringList sysPrinters; + if (QHostInfo::localHostName() == "fantomet") { + sysPrinters + << "Press" + << "Canon PS-IPU Color Laser Copier v52.3" + << "EPSON EPL-N4000 PS3" + << "Kroksleiven" + << "Lexmark Optra Color 1200 PS" + << "Yacc (Lexmark Optra T610 PCL)" + << "Yacc (Lexmark Optra T610 PS3)" + ; + } else if (QHostInfo::localHostName() == "bobo") { + sysPrinters + << "press" + << "finnmarka" + << "nordmarka" + ; + } +# else + QStringList sysPrinters = getPrintersFromSystem(); +# endif + QList printers = QPrinterInfo::availablePrinters(); + + QCOMPARE(printers.size(), sysPrinters.size()); + + QHash qtPrinters; + + for (int j = 0; j < printers.size(); ++j) { + qtPrinters.insert(printers.at(j).printerName(), !printers.at(j).isNull()); + } + + for (int i = 0; i < sysPrinters.size(); ++i) { + if (!qtPrinters.value(sysPrinters.at(i))) { + qDebug() << "Available printers: " << qtPrinters; + QFAIL(qPrintable(QString("Printer '%1' reported by system, but not reported by Qt").arg(sysPrinters.at(i)))); + } + } +#else + QSKIP("Test doesn't work on non-Unix"); +#endif +} + +void tst_QPrinterInfo::testForPaperSizes() +{ +QSKIP("PaperSize feature doesn't work on Windows, fails on Mac, and is unstable on Linux"); + // This test is based on common printers found at the Oslo + // office. It is likely to be skipped or fail for other locations. + QStringList hardPrinters; + hardPrinters << "Finnmarka" << "Huldra"; + + QList > hardSizes; + hardSizes + << QList() + << QList() + ; + hardSizes[0] // Finnmarka + << QPrinter::Letter + << QPrinter::A4 + << QPrinter::A3 + << QPrinter::A5 + << QPrinter::B4 + << QPrinter::B5 + << QPrinter::Custom // COM10 + << QPrinter::Custom // C5 + << QPrinter::Custom // DL + << QPrinter::Custom // Monarch + << QPrinter::Executive + << QPrinter::Custom // Foolscap + << QPrinter::Custom // ISO B5 + << QPrinter::Ledger + << QPrinter::Legal + << QPrinter::Custom // Japanese Post Card + << QPrinter::Custom // Invoice + ; + hardSizes[1] // Huldra + << QPrinter::Custom // Not listed at http://localhost:631/, name "Custom" + << QPrinter::Letter + << QPrinter::A4 + << QPrinter::A5 + << QPrinter::A6 + << QPrinter::B5 + << QPrinter::Custom // #5 1/2 Envelope + << QPrinter::Custom // 6x9 Envelope + << QPrinter::Custom // #10 Envelope + << QPrinter::Custom // A7 Envelope + << QPrinter::Custom // C5 Envelope + << QPrinter::Custom // DL Envelope + << QPrinter::Custom // Monarch Envelope + << QPrinter::Custom // #6 3/4 Envelope + << QPrinter::Executive + << QPrinter::Custom // US Folio + << QPrinter::Custom // Index Card + << QPrinter::Custom // ISO B5 + << QPrinter::Legal + << QPrinter::Custom // Statement + ; + + QList printers = QPrinterInfo::availablePrinters(); + for (int i = 0; i < printers.size(); ++i) { + for (int j = 0; j < hardPrinters.size(); ++j) { + if (printers[i].printerName() == hardPrinters[j]) { + QList sizes = printers[i].supportedPaperSizes(); + qSort(sizes); + qSort(hardSizes[j]); + QCOMPARE(sizes, hardSizes[j]); + } + } + } +} + +void tst_QPrinterInfo::testConstructors() +{ + QList prns(QPrinterInfo::availablePrinters()); + + for (int c = 0; c < prns.size(); ++c) { + QList list1, list2; + list1 = prns[c].supportedPaperSizes(); + QPrinter pr(prns[c]); + list2 = QPrinterInfo(pr).supportedPaperSizes(); + QCOMPARE(list2, list1); + } +} + +void tst_QPrinterInfo::testAssignment() +{ + QList prns(QPrinterInfo::availablePrinters()); + + for (int c = 0; c < prns.size(); ++c) { + QPrinterInfo pi = QPrinterInfo::defaultPrinter(); + pi = prns[c]; + QCOMPARE(pi.printerName(), prns[c].printerName()); + QCOMPARE(pi.supportedPaperSizes(), prns[c].supportedPaperSizes()); + } +} + +#endif + +QTEST_MAIN(tst_QPrinterInfo) +#include "tst_qprinterinfo.moc" diff --git a/tests/auto/printsupport/printsupport.pro b/tests/auto/printsupport/printsupport.pro new file mode 100644 index 0000000000..69ba296738 --- /dev/null +++ b/tests/auto/printsupport/printsupport.pro @@ -0,0 +1,3 @@ +TEMPLATE=subdirs +SUBDIRS=\ + kernel \ -- cgit v1.2.3 From 074508c2caf0417bf2cde7d1a55aadbbc88aa742 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 9 Mar 2012 13:50:19 +1000 Subject: Remove gcc 3.x-specific code from QtConcurrent and its tests. Change-Id: I4dd0ce50b70a47a0a00f4c7ec18077a1bcbe5705 Reviewed-by: Rohan McGovern --- .../qtconcurrentfilter/tst_qtconcurrentfilter.cpp | 14 -------------- .../concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp | 14 -------------- 2 files changed, 28 deletions(-) (limited to 'tests') diff --git a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp index 971a6992ff..eb1faab94f 100644 --- a/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ b/tests/auto/concurrent/qtconcurrentfilter/tst_qtconcurrentfilter.cpp @@ -51,9 +51,6 @@ class tst_QtConcurrentFilter : public QObject Q_OBJECT private slots: -#ifdef QT_NO_CONCURRENT_FILTER - void initTestCase(); -#else void filter(); void filtered(); void filteredReduced(); @@ -63,17 +60,8 @@ private slots: #ifndef QT_NO_STL void stlContainers(); #endif -#endif }; -#ifdef QT_NO_CONCURRENT_FILTER -void tst_QtConcurrentFilter::initTestCase() -{ - QSKIP("This test is skipped for gcc 3.x"); -} - -#else - void tst_QtConcurrentFilter::filter() { // functor @@ -1537,7 +1525,5 @@ void tst_QtConcurrentFilter::stlContainers() } #endif -#endif - QTEST_MAIN(tst_QtConcurrentFilter) #include "tst_qtconcurrentfilter.moc" diff --git a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp index 960511d87b..35ee0be326 100644 --- a/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp +++ b/tests/auto/concurrent/qtconcurrentmap/tst_qtconcurrentmap.cpp @@ -59,9 +59,6 @@ class tst_QtConcurrentMap: public QObject { Q_OBJECT private slots: -#ifdef QT_NO_CONCURRENT_MAP - void initTestCase() -#else void map(); void blocking_map(); void mapped(); @@ -82,17 +79,8 @@ private slots: void stressTest(); public slots: void throttling(); -#endif }; -#ifdef QT_NO_CONCURRENT_FILTER -void tst_QtConcurrentFilter::initTestCase() -{ - QSKIP("This test is skipped for gcc 3.x"); -} - -#else - using namespace QtConcurrent; void multiplyBy2Immutable(int x) @@ -2420,7 +2408,5 @@ void tst_QtConcurrentMap::stressTest() } } -#endif - QTEST_MAIN(tst_QtConcurrentMap) #include "tst_qtconcurrentmap.moc" -- cgit v1.2.3 From c4342ddea083baf0ba7a22df6ce672f0fbcc04c2 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 9 Mar 2012 14:11:26 +1000 Subject: Fix indentation of QWaitCondition autotest. No functional changes - cosmetic change only. Change-Id: I7332eaab31720776c70a7ef813d55db44bab83f7 Reviewed-by: Rohan McGovern --- .../thread/qwaitcondition/tst_qwaitcondition.cpp | 703 ++++++++++----------- 1 file changed, 351 insertions(+), 352 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp index 0e1fa47a3e..a9fbde8037 100644 --- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp @@ -73,10 +73,10 @@ public: void run() { - mutex.lock(); - cond.wakeOne(); - cond.wait(&mutex); - mutex.unlock(); + mutex.lock(); + cond.wakeOne(); + cond.wait(&mutex); + mutex.unlock(); } }; @@ -94,10 +94,10 @@ public: void run() { - mutex->lock(); - started.wakeOne(); - cond->wait(mutex); - mutex->unlock(); + mutex->lock(); + started.wakeOne(); + cond->wait(mutex); + mutex->unlock(); } }; @@ -112,10 +112,10 @@ public: void run() { - readWriteLock.lockForWrite(); - cond.wakeOne(); - cond.wait(&readWriteLock); - readWriteLock.unlock(); + readWriteLock.lockForWrite(); + cond.wakeOne(); + cond.wait(&readWriteLock); + readWriteLock.unlock(); } }; @@ -133,10 +133,10 @@ public: void run() { - readWriteLock->lockForRead(); - started.wakeOne(); - cond->wait(readWriteLock); - readWriteLock->unlock(); + readWriteLock->lockForRead(); + started.wakeOne(); + cond->wait(readWriteLock); + readWriteLock->unlock(); } }; @@ -144,80 +144,80 @@ void tst_QWaitCondition::wait_QMutex() { int x; for (int i = 0; i < iterations; ++i) { - { - QMutex mutex; - QWaitCondition cond; - - mutex.lock(); + { + QMutex mutex; + QWaitCondition cond; - cond.wakeOne(); - QVERIFY(!cond.wait(&mutex, 1)); - - cond.wakeAll(); - QVERIFY(!cond.wait(&mutex, 1)); + mutex.lock(); - mutex.unlock(); - } + cond.wakeOne(); + QVERIFY(!cond.wait(&mutex, 1)); - { - // test multiple threads waiting on separate wait conditions - wait_QMutex_Thread_1 thread[ThreadCount]; + cond.wakeAll(); + QVERIFY(!cond.wait(&mutex, 1)); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex.lock(); - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].cond.wait(&thread[x].mutex, 1000)); - thread[x].mutex.unlock(); + mutex.unlock(); } - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } + { + // test multiple threads waiting on separate wait conditions + wait_QMutex_Thread_1 thread[ThreadCount]; - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex.lock(); - thread[x].cond.wakeOne(); - thread[x].mutex.unlock(); - } + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex.lock(); + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].cond.wait(&thread[x].mutex, 1000)); + thread[x].mutex.unlock(); + } - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); - } - } + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } - { - // test multiple threads waiting on a wait condition - QMutex mutex; - QWaitCondition cond1, cond2; - wait_QMutex_Thread_2 thread[ThreadCount]; + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex.lock(); + thread[x].cond.wakeOne(); + thread[x].mutex.unlock(); + } - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } } - mutex.unlock(); - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } + { + // test multiple threads waiting on a wait condition + QMutex mutex; + QWaitCondition cond1, cond2; + wait_QMutex_Thread_2 thread[ThreadCount]; + + mutex.lock(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + } + mutex.unlock(); - mutex.lock(); - cond1.wakeAll(); - cond2.wakeAll(); - mutex.unlock(); + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); + mutex.lock(); + cond1.wakeAll(); + cond2.wakeAll(); + mutex.unlock(); + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } } } - } } void tst_QWaitCondition::wait_QReadWriteLock() @@ -263,96 +263,95 @@ void tst_QWaitCondition::wait_QReadWriteLock() int x; for (int i = 0; i < iterations; ++i) { - { - QReadWriteLock readWriteLock; - QWaitCondition waitCondition; + { + QReadWriteLock readWriteLock; + QWaitCondition waitCondition; - readWriteLock.lockForRead(); + readWriteLock.lockForRead(); - waitCondition.wakeOne(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - - waitCondition.wakeAll(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + waitCondition.wakeOne(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - readWriteLock.unlock(); - } - - { - QReadWriteLock readWriteLock; - QWaitCondition waitCondition; + waitCondition.wakeAll(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - readWriteLock.lockForWrite(); + readWriteLock.unlock(); + } - waitCondition.wakeOne(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + { + QReadWriteLock readWriteLock; + QWaitCondition waitCondition; - waitCondition.wakeAll(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + readWriteLock.lockForWrite(); - readWriteLock.unlock(); - } + waitCondition.wakeOne(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - { - // test multiple threads waiting on separate wait conditions - wait_QReadWriteLock_Thread_1 thread[ThreadCount]; + waitCondition.wakeAll(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - for (x = 0; x < ThreadCount; ++x) { - thread[x].readWriteLock.lockForRead(); - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 1000)); - thread[x].readWriteLock.unlock(); + readWriteLock.unlock(); } - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } + { + // test multiple threads waiting on separate wait conditions + wait_QReadWriteLock_Thread_1 thread[ThreadCount]; - for (x = 0; x < ThreadCount; ++x) { - thread[x].readWriteLock.lockForRead(); - thread[x].cond.wakeOne(); - thread[x].readWriteLock.unlock(); - } + for (x = 0; x < ThreadCount; ++x) { + thread[x].readWriteLock.lockForRead(); + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 1000)); + thread[x].readWriteLock.unlock(); + } - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); - } - } + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } - { - // test multiple threads waiting on a wait condition - QReadWriteLock readWriteLock; - QWaitCondition cond1, cond2; - wait_QReadWriteLock_Thread_2 thread[ThreadCount]; + for (x = 0; x < ThreadCount; ++x) { + thread[x].readWriteLock.lockForRead(); + thread[x].cond.wakeOne(); + thread[x].readWriteLock.unlock(); + } - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].readWriteLock = &readWriteLock; - thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&readWriteLock, 1000)); + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } } - readWriteLock.unlock(); - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } + { + // test multiple threads waiting on a wait condition + QReadWriteLock readWriteLock; + QWaitCondition cond1, cond2; + wait_QReadWriteLock_Thread_2 thread[ThreadCount]; + + readWriteLock.lockForWrite(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].readWriteLock = &readWriteLock; + thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&readWriteLock, 1000)); + } + readWriteLock.unlock(); - readWriteLock.lockForWrite(); - cond1.wakeAll(); - cond2.wakeAll(); - readWriteLock.unlock(); + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); + readWriteLock.lockForWrite(); + cond1.wakeAll(); + cond2.wakeAll(); + readWriteLock.unlock(); + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } } } - } - } class wake_Thread : public QThread @@ -375,14 +374,14 @@ public: void run() { - mutex->lock(); - ++count; + mutex->lock(); + ++count; dummy.wakeOne(); // this wakeup should be lost - started.wakeOne(); + started.wakeOne(); dummy.wakeAll(); // this one too - cond->wait(mutex); + cond->wait(mutex); --count; - mutex->unlock(); + mutex->unlock(); } }; @@ -408,14 +407,14 @@ public: void run() { - readWriteLock->lockForWrite(); - ++count; + readWriteLock->lockForWrite(); + ++count; dummy.wakeOne(); // this wakeup should be lost started.wakeOne(); dummy.wakeAll(); // this one too - cond->wait(readWriteLock); + cond->wait(readWriteLock); --count; - readWriteLock->unlock(); + readWriteLock->unlock(); } }; @@ -426,264 +425,264 @@ void tst_QWaitCondition::wakeOne() int x; // wake up threads, one at a time for (int i = 0; i < iterations; ++i) { - QMutex mutex; - QWaitCondition cond; - - // QMutex - wake_Thread thread[ThreadCount]; - bool thread_exited[ThreadCount]; - - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = &cond; - thread_exited[x] = false; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - } - mutex.unlock(); + QMutex mutex; + QWaitCondition cond; - QCOMPARE(wake_Thread::count, ThreadCount); + // QMutex + wake_Thread thread[ThreadCount]; + bool thread_exited[ThreadCount]; - // wake up threads one at a time - for (x = 0; x < ThreadCount; ++x) { mutex.lock(); - cond.wakeOne(); - QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = &cond; + thread_exited[x] = false; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + } mutex.unlock(); - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (thread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = true; - ++exited; - } - } + QCOMPARE(wake_Thread::count, ThreadCount); - QCOMPARE(exited, 1); - QCOMPARE(wake_Thread::count, ThreadCount - (x + 1)); - } + // wake up threads one at a time + for (x = 0; x < ThreadCount; ++x) { + mutex.lock(); + cond.wakeOne(); + QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + mutex.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (thread[y].wait(exited > 0 ? 10 : 1000)) { + thread_exited[y] = true; + ++exited; + } + } - QCOMPARE(wake_Thread::count, 0); + QCOMPARE(exited, 1); + QCOMPARE(wake_Thread::count, ThreadCount - (x + 1)); + } - // QReadWriteLock - QReadWriteLock readWriteLock; - wake_Thread_2 rwthread[ThreadCount]; - - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - rwthread[x].readWriteLock = &readWriteLock; - rwthread[x].cond = &cond; - thread_exited[x] = false; - rwthread[x].start(); - // wait for thread to start - QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - } - readWriteLock.unlock(); + QCOMPARE(wake_Thread::count, 0); - QCOMPARE(wake_Thread_2::count, ThreadCount); + // QReadWriteLock + QReadWriteLock readWriteLock; + wake_Thread_2 rwthread[ThreadCount]; - // wake up threads one at a time - for (x = 0; x < ThreadCount; ++x) { readWriteLock.lockForWrite(); - cond.wakeOne(); - QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + for (x = 0; x < ThreadCount; ++x) { + rwthread[x].readWriteLock = &readWriteLock; + rwthread[x].cond = &cond; + thread_exited[x] = false; + rwthread[x].start(); + // wait for thread to start + QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + } readWriteLock.unlock(); - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = true; - ++exited; + QCOMPARE(wake_Thread_2::count, ThreadCount); + + // wake up threads one at a time + for (x = 0; x < ThreadCount; ++x) { + readWriteLock.lockForWrite(); + cond.wakeOne(); + QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + readWriteLock.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { + thread_exited[y] = true; + ++exited; + } } - } - QCOMPARE(exited, 1); - QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 1)); - } + QCOMPARE(exited, 1); + QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 1)); + } - QCOMPARE(wake_Thread_2::count, 0); + QCOMPARE(wake_Thread_2::count, 0); } // wake up threads, two at a time for (int i = 0; i < iterations; ++i) { - QMutex mutex; - QWaitCondition cond; + QMutex mutex; + QWaitCondition cond; // QMutex - wake_Thread thread[ThreadCount]; - bool thread_exited[ThreadCount]; - - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = &cond; - thread_exited[x] = false; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - } - mutex.unlock(); - - QCOMPARE(wake_Thread::count, ThreadCount); + wake_Thread thread[ThreadCount]; + bool thread_exited[ThreadCount]; - // wake up threads one at a time - for (x = 0; x < ThreadCount; x += 2) { mutex.lock(); - cond.wakeOne(); - cond.wakeOne(); - QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - QVERIFY(!thread[x + 1].dummy.wait(&mutex, 1)); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = &cond; + thread_exited[x] = false; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + } mutex.unlock(); - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (thread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = true; - ++exited; + QCOMPARE(wake_Thread::count, ThreadCount); + + // wake up threads one at a time + for (x = 0; x < ThreadCount; x += 2) { + mutex.lock(); + cond.wakeOne(); + cond.wakeOne(); + QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + QVERIFY(!thread[x + 1].dummy.wait(&mutex, 1)); + mutex.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (thread[y].wait(exited > 0 ? 10 : 1000)) { + thread_exited[y] = true; + ++exited; + } } - } - QCOMPARE(exited, 2); - QCOMPARE(wake_Thread::count, ThreadCount - (x + 2)); - } + QCOMPARE(exited, 2); + QCOMPARE(wake_Thread::count, ThreadCount - (x + 2)); + } - QCOMPARE(wake_Thread::count, 0); + QCOMPARE(wake_Thread::count, 0); // QReadWriteLock QReadWriteLock readWriteLock; wake_Thread_2 rwthread[ThreadCount]; - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - rwthread[x].readWriteLock = &readWriteLock; - rwthread[x].cond = &cond; - thread_exited[x] = false; - rwthread[x].start(); - // wait for thread to start - QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - } - readWriteLock.unlock(); - - QCOMPARE(wake_Thread_2::count, ThreadCount); - - // wake up threads one at a time - for (x = 0; x < ThreadCount; x += 2) { readWriteLock.lockForWrite(); - cond.wakeOne(); - cond.wakeOne(); - QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - QVERIFY(!rwthread[x + 1].dummy.wait(&readWriteLock, 1)); + for (x = 0; x < ThreadCount; ++x) { + rwthread[x].readWriteLock = &readWriteLock; + rwthread[x].cond = &cond; + thread_exited[x] = false; + rwthread[x].start(); + // wait for thread to start + QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + } readWriteLock.unlock(); - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { - thread_exited[y] = true; - ++exited; + QCOMPARE(wake_Thread_2::count, ThreadCount); + + // wake up threads one at a time + for (x = 0; x < ThreadCount; x += 2) { + readWriteLock.lockForWrite(); + cond.wakeOne(); + cond.wakeOne(); + QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + QVERIFY(!rwthread[x + 1].dummy.wait(&readWriteLock, 1)); + readWriteLock.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { + thread_exited[y] = true; + ++exited; + } } + + QCOMPARE(exited, 2); + QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 2)); } - QCOMPARE(exited, 2); - QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 2)); + QCOMPARE(wake_Thread_2::count, 0); } - - QCOMPARE(wake_Thread_2::count, 0); -} } void tst_QWaitCondition::wakeAll() { int x; for (int i = 0; i < iterations; ++i) { - QMutex mutex; - QWaitCondition cond; + QMutex mutex; + QWaitCondition cond; - // QMutex - wake_Thread thread[ThreadCount]; + // QMutex + wake_Thread thread[ThreadCount]; - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = &cond; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - } - mutex.unlock(); + mutex.lock(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = &cond; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + } + mutex.unlock(); - QCOMPARE(wake_Thread::count, ThreadCount); + QCOMPARE(wake_Thread::count, ThreadCount); - // wake up all threads at once - mutex.lock(); - cond.wakeAll(); - QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); - mutex.unlock(); + // wake up all threads at once + mutex.lock(); + cond.wakeAll(); + QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); + mutex.unlock(); - int exited = 0; - for (x = 0; x < ThreadCount; ++x) { - if (thread[x].wait(1000)) - ++exited; - } + int exited = 0; + for (x = 0; x < ThreadCount; ++x) { + if (thread[x].wait(1000)) + ++exited; + } - QCOMPARE(exited, ThreadCount); - QCOMPARE(wake_Thread::count, 0); + QCOMPARE(exited, ThreadCount); + QCOMPARE(wake_Thread::count, 0); - // QReadWriteLock - QReadWriteLock readWriteLock; - wake_Thread_2 rwthread[ThreadCount]; - - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - rwthread[x].readWriteLock = &readWriteLock; - rwthread[x].cond = &cond; - rwthread[x].start(); - // wait for thread to start - QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); - } - readWriteLock.unlock(); + // QReadWriteLock + QReadWriteLock readWriteLock; + wake_Thread_2 rwthread[ThreadCount]; - QCOMPARE(wake_Thread_2::count, ThreadCount); + readWriteLock.lockForWrite(); + for (x = 0; x < ThreadCount; ++x) { + rwthread[x].readWriteLock = &readWriteLock; + rwthread[x].cond = &cond; + rwthread[x].start(); + // wait for thread to start + QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); + } + readWriteLock.unlock(); - // wake up all threads at once - readWriteLock.lockForWrite(); - cond.wakeAll(); - QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); - readWriteLock.unlock(); + QCOMPARE(wake_Thread_2::count, ThreadCount); - exited = 0; - for (x = 0; x < ThreadCount; ++x) { - if (rwthread[x].wait(1000)) - ++exited; - } + // wake up all threads at once + readWriteLock.lockForWrite(); + cond.wakeAll(); + QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); + readWriteLock.unlock(); + + exited = 0; + for (x = 0; x < ThreadCount; ++x) { + if (rwthread[x].wait(1000)) + ++exited; + } - QCOMPARE(exited, ThreadCount); - QCOMPARE(wake_Thread_2::count, 0); + QCOMPARE(exited, ThreadCount); + QCOMPARE(wake_Thread_2::count, 0); } } -- cgit v1.2.3 From ca737f566b1016712a0d90e8b5e55e49ce8748d2 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 Mar 2012 16:21:38 +0100 Subject: Use QAccessibleEvent in test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4f9c0f503543caa5704a29c8ccd7c4134b455625 Reviewed-by: Jan-Arve Sæther --- .../other/qaccessibility/tst_qaccessibility.cpp | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index b8649a6443..0edda96f2a 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -403,8 +403,8 @@ void tst_QAccessibility::cleanup() qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(), QString(QTest::currentTestFunction()).toAscii().constData()); for (int i = 0; i < list.count(); ++i) - qWarning(" %d: Object: %p Event: '%s' (%d) Child: %d", i + 1, list.at(i).object, - eventName(list.at(i).event).toAscii().constData(), list.at(i).event, list.at(i).child); + qWarning(" %d: Object: %p Event: '%s' Child: %d", i + 1, list.at(i).object(), + eventName(list.at(i).type()).toAscii().constData(), list.at(i).child()); } QTestAccessibility::clearEvents(); } @@ -415,18 +415,18 @@ void tst_QAccessibility::eventTest() button->setObjectName(QString("Olaf")); button->show(); - QVERIFY_EVENT(button, -1, QAccessible::ObjectShow); + QVERIFY_EVENT(QAccessibleEvent(QAccessible::ObjectShow, button, -1)); button->setFocus(Qt::MouseFocusReason); QTestAccessibility::clearEvents(); QTest::mouseClick(button, Qt::LeftButton, 0); button->setAccessibleName("Olaf the second"); - QVERIFY_EVENT(button, -1, QAccessible::NameChanged); + QVERIFY_EVENT(QAccessibleEvent(QAccessible::NameChanged, button)); button->setAccessibleDescription("This is a button labeled Olaf"); - QVERIFY_EVENT(button, -1, QAccessible::DescriptionChanged); + QVERIFY_EVENT(QAccessibleEvent(QAccessible::DescriptionChanged, button)); button->hide(); - QVERIFY_EVENT(button, -1, QAccessible::ObjectHide); + QVERIFY_EVENT(QAccessibleEvent(QAccessible::ObjectHide, button)); delete button; } @@ -730,16 +730,16 @@ void tst_QAccessibility::hideShowTest() window->show(); QVERIFY(!state(window).invisible); QVERIFY(!state(child).invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, -1, QAccessible::ObjectShow))); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, -1, QAccessible::ObjectShow))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::ObjectShow, window))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::ObjectShow, child))); QTestAccessibility::clearEvents(); // hide() and veryfy that both window and child are invisible and get ObjectHide events. window->hide(); QVERIFY(state(window).invisible); QVERIFY(state(child).invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(window, -1, QAccessible::ObjectHide))); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(child, -1, QAccessible::ObjectHide))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::ObjectHide, window))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::ObjectHide, child))); QTestAccessibility::clearEvents(); delete window; @@ -820,7 +820,7 @@ void tst_QAccessibility::mainWindowTest() QLatin1String name = QLatin1String("I am the main window"); mw->setWindowTitle(name); QTest::qWaitForWindowShown(mw); - QVERIFY_EVENT(mw, -1, QAccessible::ObjectShow); + QVERIFY_EVENT(QAccessibleEvent(QAccessible::ObjectShow, mw)); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw); QCOMPARE(interface->text(QAccessible::Name), name); @@ -1050,12 +1050,12 @@ void tst_QAccessibility::scrollBarTest() scrollBar->resize(200, 50); scrollBar->show(); QVERIFY(!scrollBarInterface->state().invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, -1, QAccessible::ObjectShow))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::ObjectShow, scrollBar))); QTestAccessibility::clearEvents(); scrollBar->hide(); QVERIFY(scrollBarInterface->state().invisible); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(scrollBar, -1, QAccessible::ObjectHide))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::ObjectHide, scrollBar))); QTestAccessibility::clearEvents(); // Test that the left/right subcontrols are set to unavailable when the scrollBar is at the minimum/maximum. @@ -1496,7 +1496,7 @@ void tst_QAccessibility::spinBoxTest() QTest::keyPress(spinBox, Qt::Key_Up); QTest::qWait(200); EventList events = QTestAccessibility::events(); - QTestAccessibilityEvent expectedEvent(spinBox, -1, (int)QAccessible::ValueChanged); + QAccessibleEvent expectedEvent(QAccessible::ValueChanged, spinBox); QVERIFY(events.contains(expectedEvent)); delete spinBox; QTestAccessibility::clearEvents(); @@ -1767,7 +1767,7 @@ void tst_QAccessibility::lineEditTest() le->setFocus(Qt::TabFocusReason); QTestAccessibility::clearEvents(); le2->setFocus(Qt::TabFocusReason); - QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, -1, QAccessible::Focus))); + QTRY_VERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::Focus, le2))); le->setText(QLatin1String("500")); le->setValidator(new QIntValidator()); @@ -1787,7 +1787,7 @@ void tst_QAccessibility::lineEditTest() le3->deselect(); le3->setCursorPosition(3); QCOMPARE(textIface->cursorPosition(), 3); - QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le3, -1, QAccessible::TextCaretMoved))); + QTRY_VERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::TextCaretMoved, le3))); QCOMPARE(textIface->selectionCount(), 0); QTestAccessibility::clearEvents(); @@ -2158,11 +2158,11 @@ void tst_QAccessibility::listTest() // Check for events QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(1)).center()); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 2, QAccessible::Selection))); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 2, QAccessible::Focus))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::Selection, listView, 2))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::Focus, listView, 2))); QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(2)).center()); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 3, QAccessible::Selection))); - QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 3, QAccessible::Focus))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::Selection, listView, 3))); + QVERIFY(QTestAccessibility::events().contains(QAccessibleEvent(QAccessible::Focus, listView, 3))); listView->addItem("Munich"); QCOMPARE(iface->childCount(), 4); -- cgit v1.2.3 From edea0e19173d92526b6f5378a6182f53d29f45e6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 6 Mar 2012 12:14:51 +0100 Subject: tst_exceptionsafety_objects: add virtual ~AbstractTester GCC complained about undefined behaviour when deleting subclasses of AbstractTester through pointers to AbstractTester, and it's doing so correctly... Change-Id: Ie641281d8aafe32c5c9784e8aa39672ff0b699c7 Reviewed-by: Lars Knoll --- tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index a426a90976..14628b2c8b 100644 --- a/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/other/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -94,6 +94,7 @@ void tst_ExceptionSafety_Objects::initTestCase() // helper structs to create an arbitrary widget struct AbstractTester { + virtual ~AbstractTester() {} virtual void operator()(QObject *parent) = 0; }; Q_DECLARE_METATYPE(AbstractTester *) -- cgit v1.2.3 From db390d46c3a983f0270fb40be7f59297e9a77d64 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Thu, 8 Mar 2012 16:48:17 -0800 Subject: Move the auto test of QPixmap::grabWidget() from QPixmap to QWidget Change-Id: Id565fa1eb8fe13c62a93a5afa39a5701ce7b20ea QPixmap::grabWidget is deprecated, which calls QWidget::grab() at present. Reviewed-by: Gunnar Sletta Reviewed-by: Friedemann Kleint --- tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 43 ------------- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 75 +++++++++++++++++++++++ 2 files changed, 75 insertions(+), 43 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index 563baef486..c7652e445f 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include @@ -111,7 +110,6 @@ private slots: void setGetMask(); void cacheKey(); void drawBitmap(); - void grabWidget(); void grabWindow(); void isNull(); void task_246446(); @@ -718,47 +716,6 @@ void tst_QPixmap::drawBitmap() QVERIFY(lenientCompare(pixmap, expected)); } -void tst_QPixmap::grabWidget() -{ - for (int opaque = 0; opaque < 2; ++opaque) { - QWidget widget; - QImage image(128, 128, opaque ? QImage::Format_RGB32 : QImage::Format_ARGB32_Premultiplied); - for (int row = 0; row < image.height(); ++row) { - QRgb *line = reinterpret_cast(image.scanLine(row)); - for (int col = 0; col < image.width(); ++col) - line[col] = qRgba(rand() & 255, row, col, opaque ? 255 : 127); - } - - QPalette pal = widget.palette(); - pal.setBrush(QPalette::Window, QBrush(image)); - widget.setPalette(pal); - widget.resize(128, 128); - - QPixmap expected(64, 64); - if (!opaque) - expected.fill(Qt::transparent); - - QPainter p(&expected); - p.translate(-64, -64); - p.drawTiledPixmap(0, 0, 128, 128, pal.brush(QPalette::Window).texture(), 0, 0); - p.end(); - - QPixmap actual = QPixmap::grabWidget(&widget, QRect(64, 64, 64, 64)); - QVERIFY(lenientCompare(actual, expected)); - - actual = QPixmap::grabWidget(&widget, 64, 64); - QVERIFY(lenientCompare(actual, expected)); - - // Make sure a widget that is not yet shown is grabbed correctly. - QTreeWidget widget2; - actual = QPixmap::grabWidget(&widget2); - widget2.show(); - expected = QPixmap::grabWidget(&widget2); - - QVERIFY(lenientCompare(actual, expected)); - } -} - void tst_QPixmap::grabWindow() { // ### fixme: Check platforms diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index dab9dd7690..49c93f8f03 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -412,6 +413,7 @@ private slots: void taskQTBUG_17333_ResizeInfiniteRecursion(); void nativeChildFocus(); + void grab(); private: bool ensureScreenSize(int width, int height); @@ -9288,5 +9290,78 @@ void tst_QWidget::nativeChildFocus() QTest::qWait(1000); } +static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) +{ + QImage expectedImage = expected.toImage().convertToFormat(QImage::Format_RGB32); + QImage actualImage = actual.toImage().convertToFormat(QImage::Format_RGB32); + + if (expectedImage.size() != actualImage.size()) { + qWarning("Image size comparison failed: expected: %dx%d, got %dx%d", + expectedImage.size().width(), expectedImage.size().height(), + actualImage.size().width(), actualImage.size().height()); + return false; + } + + const int size = actual.width() * actual.height(); + const int threshold = QPixmap::defaultDepth() == 16 ? 10 : 2; + + QRgb *a = (QRgb *)actualImage.bits(); + QRgb *e = (QRgb *)expectedImage.bits(); + for (int i = 0; i < size; ++i) { + const QColor ca(a[i]); + const QColor ce(e[i]); + if (qAbs(ca.red() - ce.red()) > threshold + || qAbs(ca.green() - ce.green()) > threshold + || qAbs(ca.blue() - ce.blue()) > threshold) { + qWarning("Color mismatch at pixel #%d: Expected: %d,%d,%d, got %d,%d,%d", + i, ce.red(), ce.green(), ce.blue(), ca.red(), ca.green(), ca.blue()); + return false; + } + } + + return true; +} + +void tst_QWidget::grab() +{ + for (int opaque = 0; opaque < 2; ++opaque) { + QWidget widget; + QImage image(128, 128, opaque ? QImage::Format_RGB32 : QImage::Format_ARGB32_Premultiplied); + for (int row = 0; row < image.height(); ++row) { + QRgb *line = reinterpret_cast(image.scanLine(row)); + for (int col = 0; col < image.width(); ++col) + line[col] = qRgba(rand() & 255, row, col, opaque ? 255 : 127); + } + + QPalette pal = widget.palette(); + pal.setBrush(QPalette::Window, QBrush(image)); + widget.setPalette(pal); + widget.resize(128, 128); + + QPixmap expected(64, 64); + if (!opaque) + expected.fill(Qt::transparent); + + QPainter p(&expected); + p.translate(-64, -64); + p.drawTiledPixmap(0, 0, 128, 128, pal.brush(QPalette::Window).texture(), 0, 0); + p.end(); + + QPixmap actual = widget.grab(QRect(64, 64, 64, 64)); + QVERIFY(lenientCompare(actual, expected)); + + actual = widget.grab(QRect(64, 64, -1, -1)); + QVERIFY(lenientCompare(actual, expected)); + + // Make sure a widget that is not yet shown is grabbed correctly. + QTreeWidget widget2; + actual = widget2.grab(QRect()); + widget2.show(); + expected = widget2.grab(QRect()); + + QVERIFY(lenientCompare(actual, expected)); + } +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v1.2.3 From 6e278b868824db8e24b68d48fa0f6e154de1b2f6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 9 Mar 2012 09:53:10 +0100 Subject: Implement QSystemTrayIcon for Windows. No longer base the implementation on a QWidget which is not necessary when all that is required is a message window listening to task-tray messages. Export a service function creating a message window from the Windows native interface and use that. Task-number: QTBUG-20978 Change-Id: I01d0faeac777df4eee802c51d2bc722fce814080 Reviewed-by: Friedemann Kleint --- .../widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp index cfafa9ea47..1f717727b0 100644 --- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp +++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp @@ -120,14 +120,14 @@ void tst_QSystemTrayIcon::getSetCheck() void tst_QSystemTrayIcon::supportsMessages() { // ### fixme: Check platforms. - QEXPECT_FAIL("", "QTBUG-20978 QSystemTrayIcon is unimplemented for qpa", Abort); - -#if !defined(Q_WS_QWS) - QCOMPARE(QSystemTrayIcon::supportsMessages(), true ); +#if defined(Q_WS_QWS) + QCOMPARE(QSystemTrayIcon::supportsMessages(), false); +#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + QCOMPARE(QSystemTrayIcon::supportsMessages(), true); #else - QCOMPARE(QSystemTrayIcon::supportsMessages(), false ); + QEXPECT_FAIL("", "QTBUG-20978 QSystemTrayIcon is unimplemented for qpa", Abort); + QCOMPARE(QSystemTrayIcon::supportsMessages(), true); #endif - } void tst_QSystemTrayIcon::lastWindowClosed() -- cgit v1.2.3