diff options
Diffstat (limited to 'tests/auto')
48 files changed, 965 insertions, 387 deletions
diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro index 95a16f67d9..7a655d6208 100644 --- a/tests/auto/corelib.pro +++ b/tests/auto/corelib.pro @@ -30,6 +30,7 @@ SUBDIRS=\ qfileinfo \ qfilesystemwatcher \ qflags \ + qfreelist \ qfuture \ qfuturewatcher \ qgetputenv \ diff --git a/tests/auto/moc/moc.pro b/tests/auto/moc/moc.pro index 59106aa11d..056c6b0958 100644 --- a/tests/auto/moc/moc.pro +++ b/tests/auto/moc/moc.pro @@ -26,5 +26,3 @@ contains(QT_CONFIG, dbus){ QT += dbus } -CONFIG+=insignificant_test - diff --git a/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro index 6f5044f6bb..4dea3c9c8c 100644 --- a/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro @@ -10,3 +10,5 @@ wince*|symbian: { } symbian: TARGET.CAPABILITY = NetworkServices + +CONFIG += insignificant_test # QTBUG-20686; note, assumed unstable on all platforms diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp index 0b581af77b..99f0941ac2 100644 --- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp @@ -361,26 +361,25 @@ class DeliverInDefinedOrderObject : public QObject QPointer<QThread> thread; int count; + int startCount; + int loopLevel; public: DeliverInDefinedOrderObject(QObject *parent) - : QObject(parent), thread(0), count(0) + : QObject(parent), thread(0), count(0), startCount(0), loopLevel(0) { } - ~DeliverInDefinedOrderObject() - { - if (!thread.isNull()) - thread->wait(); - } + +signals: + void done(); public slots: - void start() + void startThread() { QVERIFY(!thread); thread = new DeliverInDefinedOrderThread(); connect(thread, SIGNAL(progress(int)), this, SLOT(threadProgress(int))); connect(thread, SIGNAL(finished()), this, SLOT(threadFinished())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - connect(thread, SIGNAL(destroyed()), this, SLOT(start())); + connect(thread, SIGNAL(destroyed()), this, SLOT(threadDestroyed())); thread->start(); QCoreApplication::postEvent(this, new QEvent(QEvent::MaxUser), -1); @@ -398,21 +397,34 @@ public slots: { QVERIFY(count == 7); count = 0; + thread->deleteLater(); QCoreApplication::postEvent(this, new QEvent(QEvent::MaxUser), -1); } + void threadDestroyed() + { + if (++startCount < 20) + startThread(); + else + emit done(); + } + public: bool event(QEvent *event) { switch (event->type()) { case QEvent::User: - { - (void) QEventLoop().exec(); - break; + { + ++loopLevel; + if (loopLevel == 2) { + // Ready. Starts a thread that emits (queued) signals, which should be handled in order + startThread(); } - case QEvent::User + 1: + QCoreApplication::postEvent(this, new QEvent(QEvent::MaxUser), -1); + (void) QEventLoop().exec(); break; + } default: break; } @@ -430,11 +442,8 @@ void tst_QCoreApplication::deliverInDefinedOrder() // causes sendPostedEvents() to recurse twice QCoreApplication::postEvent(&obj, new QEvent(QEvent::User)); QCoreApplication::postEvent(&obj, new QEvent(QEvent::User)); - // starts a thread that emits (queued) signals, which should be handled in order - obj.start(); - // run for 15 seconds - QTimer::singleShot(15000, &app, SLOT(quit())); + QObject::connect(&obj, SIGNAL(done()), &app, SLOT(quit())); app.exec(); } #endif // QT_NO_QTHREAD @@ -524,7 +533,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() QCoreApplication::processEvents(); QCOMPARE(object.counter, i); ++i; - } while (t.elapsed() < 3000); + } while (t.elapsed() < 1000); } void tst_QCoreApplication::reexec() diff --git a/tests/auto/qdialog/qdialog.pro b/tests/auto/qdialog/qdialog.pro index 0d59590117..7c4defacd9 100644 --- a/tests/auto/qdialog/qdialog.pro +++ b/tests/auto/qdialog/qdialog.pro @@ -1,6 +1,3 @@ load(qttest_p4) QT += widgets SOURCES += tst_qdialog.cpp - - -CONFIG+=insignificant_test diff --git a/tests/auto/qdialog/tst_qdialog.cpp b/tests/auto/qdialog/tst_qdialog.cpp index 6d9f7988cd..86dde21ba0 100644 --- a/tests/auto/qdialog/tst_qdialog.cpp +++ b/tests/auto/qdialog/tst_qdialog.cpp @@ -467,6 +467,22 @@ void tst_QDialog::throwInExec() #if defined(Q_WS_MAC) || (defined(Q_WS_WINCE) && defined(_ARM_)) QSKIP("Throwing exceptions in exec() is not supported on this platform.", SkipAll); #endif + +#if defined(Q_OS_LINUX) + // C++ exceptions can't be passed through glib callbacks. Skip the test if + // we're using the glib event loop. + QByteArray dispatcher = QAbstractEventDispatcher::instance()->metaObject()->className(); + if (dispatcher.contains("Glib")) { + QSKIP( + qPrintable(QString( + "Throwing exceptions in exec() won't work if %1 event dispatcher is used.\n" + "Try running with QT_NO_GLIB=1 in environment." + ).arg(QString::fromLatin1(dispatcher))), + SkipAll + ); + } +#endif + int caughtExceptions = 0; try { ExceptionDialog dialog; diff --git a/tests/auto/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/qdoublevalidator/tst_qdoublevalidator.cpp index 76d4494a39..6014ce5165 100644 --- a/tests/auto/qdoublevalidator/tst_qdoublevalidator.cpp +++ b/tests/auto/qdoublevalidator/tst_qdoublevalidator.cpp @@ -55,6 +55,7 @@ private slots: void validateThouSep(); void validateIntEquiv_data(); void validateIntEquiv(); + void notifySignals(); }; Q_DECLARE_METATYPE(QValidator::State); @@ -244,6 +245,62 @@ void tst_QDoubleValidator::validate() dv.setNotation(QDoubleValidator::StandardNotation); QCOMPARE((int)dv.validate(value, dummy), (int)standard_state); } +void tst_QDoubleValidator::notifySignals() +{ + QDoubleValidator dv(0.1, 0.9, 10, 0); + QSignalSpy topSpy(&dv, SIGNAL(topChanged(double))); + QSignalSpy bottomSpy(&dv, SIGNAL(bottomChanged(double))); + QSignalSpy decSpy(&dv, SIGNAL(decimalsChanged(int))); + + qRegisterMetaType<QDoubleValidator::Notation>("QDoubleValidator::Notation"); + QSignalSpy notSpy(&dv, SIGNAL(notationChanged(QDoubleValidator::Notation))); + + dv.setTop(0.8); + QCOMPARE(topSpy.count(), 1); + QVERIFY(dv.top() == 0.8); + dv.setBottom(0.2); + QCOMPARE(bottomSpy.count(), 1); + QVERIFY(dv.bottom() == 0.2); + + dv.setRange(0.2, 0.7); + QCOMPARE(topSpy.count(), 2); + QCOMPARE(bottomSpy.count(), 1); + QCOMPARE(decSpy.count(), 1); + QVERIFY(dv.bottom() == 0.2); + QVERIFY(dv.top() == 0.7); + QVERIFY(dv.decimals() == 0.); + + dv.setRange(0.3, 0.7); + QCOMPARE(topSpy.count(), 2); + QCOMPARE(bottomSpy.count(), 2); + QVERIFY(dv.bottom() == 0.3); + QVERIFY(dv.top() == 0.7); + QVERIFY(dv.decimals() == 0.); + + dv.setRange(0.4, 0.6); + QCOMPARE(topSpy.count(), 3); + QCOMPARE(bottomSpy.count(), 3); + QVERIFY(dv.bottom() == 0.4); + QVERIFY(dv.top() == 0.6); + QVERIFY(dv.decimals() == 0.); + + dv.setDecimals(10); + QCOMPARE(decSpy.count(), 2); + QVERIFY(dv.decimals() == 10.); + + + dv.setRange(0.4, 0.6, 100); + QCOMPARE(topSpy.count(), 3); + QCOMPARE(bottomSpy.count(), 3); + QCOMPARE(decSpy.count(), 3); + QVERIFY(dv.bottom() == 0.4); + QVERIFY(dv.top() == 0.6); + QVERIFY(dv.decimals() == 100.); + + dv.setNotation(QDoubleValidator::StandardNotation); + QCOMPARE(notSpy.count(), 1); + QVERIFY(dv.notation() == QDoubleValidator::StandardNotation); +} void tst_QDoubleValidator::validateIntEquiv_data() { diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 0f211b9de5..f4ec12f874 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -41,4 +41,4 @@ symbian { LIBS+=-lefsrv } -CONFIG+=insignificant_test +mac*:CONFIG+=insignificant_test diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 4a78876843..aafe79484e 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -2438,7 +2438,7 @@ void tst_QFile::rename_data() QTest::newRow("a -> b") << QString("a") << QString("b") << false; QTest::newRow("a -> .") << QString("a") << QString(".") << false; QTest::newRow("renamefile -> renamefile") << QString("renamefile") << QString("renamefile") << false; - QTest::newRow("renamefile -> Makefile") << QString("renamefile") << QString("Makefile") << false; + QTest::newRow("renamefile -> noreadfile") << QString("renamefile") << QString("noreadfile") << false; #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QTest::newRow("renamefile -> /etc/renamefile") << QString("renamefile") << QString("/etc/renamefile") << false; #endif diff --git a/tests/auto/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/qfilesystemmodel/qfilesystemmodel.pro index 5c97761b99..b0b6d7a18d 100644 --- a/tests/auto/qfilesystemmodel/qfilesystemmodel.pro +++ b/tests/auto/qfilesystemmodel/qfilesystemmodel.pro @@ -15,5 +15,3 @@ symbian: { DEPLOYMENT += dummyDeploy LIBS += -lefsrv } - -CONFIG+=insignificant_test diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index c2b3e7c521..a9a4fc7fc3 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -909,12 +909,16 @@ void tst_QFileSystemModel::sort() expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + "." << dirPath + QChar('/') + ".."; //File dialog Mode means sub trees are not sorted, only the current root if (fileDialogMode) { + // FIXME: we were only able to disableRecursiveSort in developer builds, so we can only + // stably perform this test for developer builds +#ifdef QT_BUILD_INTERNAL QList<QString> actualRows; for(int i = 0; i < myModel->rowCount(parent); ++i) { actualRows << dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString(); } QVERIFY(actualRows != expectedOrder); +#endif } else { for(int i = 0; i < myModel->rowCount(parent); ++i) { diff --git a/tests/auto/qfreelist/qfreelist.pro b/tests/auto/qfreelist/qfreelist.pro new file mode 100644 index 0000000000..b7f2b3d38f --- /dev/null +++ b/tests/auto/qfreelist/qfreelist.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +SOURCES += tst_qfreelist.cpp +QT += core-private +QT -= gui + +!private_tests:SOURCES += $$QT_SOURCE_TREE/src/corelib/tools/qfreelist.cpp diff --git a/tests/auto/qfreelist/tst_qfreelist.cpp b/tests/auto/qfreelist/tst_qfreelist.cpp new file mode 100644 index 0000000000..139d76e64a --- /dev/null +++ b/tests/auto/qfreelist/tst_qfreelist.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 <QtCore/QCoreApplication> +#include <QtCore/QElapsedTimer> +#include <QtCore/QList> +#include <QtCore/QThread> +#include <private/qfreelist_p.h> +#include <QtTest/QtTest> + +//TESTED_CLASS=QFreeList +//TESTED_FILES=corelib/tools/qfreelist_p.h + +class tst_QFreeList : public QObject +{ + Q_OBJECT + +private slots: + void basicTest(); + void customized(); + void threadedTest(); +}; + +void tst_QFreeList::basicTest() +{ + { + QFreeList<void> voidFreeList; + int zero = voidFreeList.next(); + int one = voidFreeList.next(); + int two = voidFreeList.next(); + QCOMPARE(zero, 0); + QCOMPARE(one, 1); + QCOMPARE(two, 2); + voidFreeList[zero]; + voidFreeList[one]; + voidFreeList[two]; + voidFreeList.at(zero); + voidFreeList.at(one); + voidFreeList.at(two); + voidFreeList.release(one); + int next = voidFreeList.next(); + QCOMPARE(next, 1); + voidFreeList[next]; + voidFreeList.at(next); + } + + { + QFreeList<int> intFreeList; + int zero = intFreeList.next(); + int one = intFreeList.next(); + int two = intFreeList.next(); + QCOMPARE(zero, 0); + QCOMPARE(one, 1); + QCOMPARE(two, 2); + intFreeList[zero] = zero; + intFreeList[one] = one; + intFreeList[two] = two; + QCOMPARE(intFreeList.at(zero), zero); + QCOMPARE(intFreeList.at(one), one); + QCOMPARE(intFreeList.at(two), two); + intFreeList.release(one); + int next = intFreeList.next(); + QCOMPARE(next, 1); + QCOMPARE(intFreeList.at(next), one); + intFreeList[next] = -one; + QCOMPARE(intFreeList.at(next), -one); + } +} + +struct CustomFreeListConstants : public QFreeListDefaultConstants +{ + enum { + InitialNextValue = 50, + BlockCount = 10 + }; + + static const int Sizes[10]; +}; + +const int CustomFreeListConstants::Sizes[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 16777216 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 }; + +void tst_QFreeList::customized() +{ + QFreeList<void, CustomFreeListConstants> customFreeList; + int next = customFreeList.next(); + QCOMPARE(next, int(CustomFreeListConstants::InitialNextValue)); + customFreeList[next]; + customFreeList.at(next); + customFreeList.release(next); +} + +enum { TimeLimit = 3000 }; + +class FreeListThread : public QThread +{ + static QFreeList<void> freelist; + +public: + inline FreeListThread() : QThread() { } + inline void run() + { + QElapsedTimer t; + t.start(); + QList<int> needToRelease; + do { + int i = freelist.next(); + int j = freelist.next(); + int k = freelist.next(); + int l = freelist.next(); + freelist.release(k); + int n = freelist.next(); + int m = freelist.next(); + freelist.release(l); + freelist.release(m); + freelist.release(n); + freelist.release(j); + // freelist.release(i); + needToRelease << i; + } while (t.elapsed() < TimeLimit); + + foreach (int x, needToRelease) + freelist.release(x); + } +}; + +QFreeList<void> FreeListThread::freelist; + +void tst_QFreeList::threadedTest() +{ + const int ThreadCount = QThread::idealThreadCount(); + FreeListThread *threads = new FreeListThread[ThreadCount]; + for (int i = 0; i < ThreadCount; ++i) + threads[i].start(); + for (int i = 0; i < ThreadCount; ++i) + threads[i].wait(); + delete [] threads; +} + +QTEST_MAIN(tst_QFreeList) +#include "tst_qfreelist.moc" diff --git a/tests/auto/qftp/qftp.pro b/tests/auto/qftp/qftp.pro index 42c700e72e..69f89572ba 100644 --- a/tests/auto/qftp/qftp.pro +++ b/tests/auto/qftp/qftp.pro @@ -18,5 +18,3 @@ wince*: { } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } - -CONFIG+=insignificant_test diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 62b454099b..e31b5acda3 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -378,6 +378,8 @@ void tst_QFtp::connectToUnresponsiveHost() a lot of other stuff in QFtp, so we just expect this test to fail on Windows. */ QEXPECT_FAIL("", "timeout not working due to strange Windows socket behaviour (see source file of this test for explanation)", Abort); +#else + QEXPECT_FAIL("", "QTBUG-20687", Abort); #endif QVERIFY2(! QTestEventLoop::instance().timeout(), "Network timeout longer than expected (should have been 60 seconds)"); diff --git a/tests/auto/qglobal/tst_qglobal.cpp b/tests/auto/qglobal/tst_qglobal.cpp index 841151efc4..19a13f6ad0 100644 --- a/tests/auto/qglobal/tst_qglobal.cpp +++ b/tests/auto/qglobal/tst_qglobal.cpp @@ -130,10 +130,12 @@ void tst_QGlobal::qInternalCallbacks() QInternal::unregisterCallback(QInternal::DisconnectCallback, disconnect_callback); connect_info.reset(); + QTest::ignoreMessage(QtWarningMsg, "Object::connect: No such signal QObject::mysignal(x)"); ok = QObject::connect(&a, signal.toLatin1(), &b, slot.toLatin1(), Qt::AutoConnection); QVERIFY(!ok); QCOMPARE(connect_info.sender, (QObject *) 0); + QTest::ignoreMessage(QtWarningMsg, "Object::disconnect: No such signal QObject::mysignal(x)"); ok = QObject::disconnect(&a, signal.toLatin1(), &b, slot.toLatin1()); QVERIFY(!ok); QCOMPARE(connect_info.sender, (QObject *) 0); diff --git a/tests/auto/qgraphicstransform/qgraphicstransform.pro b/tests/auto/qgraphicstransform/qgraphicstransform.pro index 57cbb0e5bd..4f9d001717 100644 --- a/tests/auto/qgraphicstransform/qgraphicstransform.pro +++ b/tests/auto/qgraphicstransform/qgraphicstransform.pro @@ -2,5 +2,3 @@ load(qttest_p4) QT += widgets SOURCES += tst_qgraphicstransform.cpp CONFIG += parallel_test - -CONFIG+=insignificant_test diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index f229ee7d5f..7b928909ff 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -61,6 +61,9 @@ private slots: void rotation3d(); void rotation3dArbitraryAxis_data(); void rotation3dArbitraryAxis(); + +private: + QString toString(QTransform const&); }; @@ -305,6 +308,15 @@ void tst_QGraphicsTransform::rotation3d() QVERIFY(transform2D(rotation).isIdentity()); } +QByteArray labelForTest(QVector3D const& axis, int angle) { + return QString("rotation of %1 on (%2, %3, %4)") + .arg(angle) + .arg(axis.x()) + .arg(axis.y()) + .arg(axis.z()) + .toLatin1(); +} + void tst_QGraphicsTransform::rotation3dArbitraryAxis_data() { QTest::addColumn<QVector3D>("axis"); @@ -317,11 +329,11 @@ void tst_QGraphicsTransform::rotation3dArbitraryAxis_data() QVector3D axis5 = QVector3D(0.01f, 0.01f, 0.01f); for (int angle = 0; angle <= 360; angle++) { - QTest::newRow("test rotation on (1, 1, 1)") << axis1 << qreal(angle); - QTest::newRow("test rotation on (2, -3, .5)") << axis2 << qreal(angle); - QTest::newRow("test rotation on (-2, 0, -.5)") << axis3 << qreal(angle); - QTest::newRow("test rotation on (.0001, .0001, .0001)") << axis4 << qreal(angle); - QTest::newRow("test rotation on (.01, .01, .01)") << axis5 << qreal(angle); + QTest::newRow(labelForTest(axis1, angle).constData()) << axis1 << qreal(angle); + QTest::newRow(labelForTest(axis2, angle).constData()) << axis2 << qreal(angle); + QTest::newRow(labelForTest(axis3, angle).constData()) << axis3 << qreal(angle); + QTest::newRow(labelForTest(axis4, angle).constData()) << axis4 << qreal(angle); + QTest::newRow(labelForTest(axis5, angle).constData()) << axis5 << qreal(angle); } } @@ -347,7 +359,26 @@ void tst_QGraphicsTransform::rotation3dArbitraryAxis() exp.rotate(angle, axis); QTransform expected = exp.toTransform(1024.0f); - QVERIFY(fuzzyCompare(transform2D(rotation), expected)); +#ifdef Q_OS_LINUX + // These failures possibly relate to the float vs qreal issue mentioned + // in the comment above fuzzyCompare(). + if (sizeof(qreal) == sizeof(double)) { + QEXPECT_FAIL("rotation of 120 on (1, 1, 1)", "QTBUG-20661", Abort); + QEXPECT_FAIL("rotation of 240 on (1, 1, 1)", "QTBUG-20661", Abort); + QEXPECT_FAIL("rotation of 120 on (0.01, 0.01, 0.01)", "QTBUG-20661", Abort); + QEXPECT_FAIL("rotation of 240 on (0.01, 0.01, 0.01)", "QTBUG-20661", Abort); + QEXPECT_FAIL("rotation of 120 on (0.0001, 0.0001, 0.0001)", "QTBUG-20661", Abort); + QEXPECT_FAIL("rotation of 240 on (0.0001, 0.0001, 0.0001)", "QTBUG-20661", Abort); + } +#endif + + QTransform actual = transform2D(rotation); + QVERIFY2(fuzzyCompare(actual, expected), qPrintable( + QString("\nactual: %1\n" + "expected: %2") + .arg(toString(actual)) + .arg(toString(expected)) + )); // Check that "rotation" produces the 4x4 form of the 3x3 matrix. // i.e. third row and column are 0 0 1 0. @@ -357,6 +388,21 @@ void tst_QGraphicsTransform::rotation3dArbitraryAxis() QVERIFY(qFuzzyCompare(t, r)); } +QString tst_QGraphicsTransform::toString(QTransform const& t) +{ + return QString("[ [ %1 %2 %3 ]; [ %4 %5 %6 ]; [ %7 %8 %9 ] ]") + .arg(t.m11()) + .arg(t.m12()) + .arg(t.m13()) + .arg(t.m21()) + .arg(t.m22()) + .arg(t.m23()) + .arg(t.m31()) + .arg(t.m32()) + .arg(t.m33()) + ; +} + QTEST_MAIN(tst_QGraphicsTransform) #include "tst_qgraphicstransform.moc" diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 196519096c..d6bc8ff3e8 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -104,6 +104,7 @@ static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton QTest::mouseMove(widget, point); QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0); QApplication::sendEvent(widget, &event); + QApplication::processEvents(); } static void sendMouseRelease(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton) diff --git a/tests/auto/qicon/qicon.pro b/tests/auto/qicon/qicon.pro index aea7b9db64..cc87fae539 100644 --- a/tests/auto/qicon/qicon.pro +++ b/tests/auto/qicon/qicon.pro @@ -28,5 +28,3 @@ wince* { } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } - -CONFIG+=insignificant_test diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index cd3f84f4b0..4c430f9435 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -41,7 +41,7 @@ #include <QtTest/QtTest> - +#include <QImageReader> #include <qicon.h> #if defined(Q_OS_SYMBIAN) @@ -87,6 +87,8 @@ private slots: void task239461_custom_iconengine_crash(); private: + bool haveImageFormat(QByteArray const&); + QString oldCurrentDir; const static QIcon staticIcon; @@ -112,6 +114,11 @@ void tst_QIcon::cleanup() } } +bool tst_QIcon::haveImageFormat(QByteArray const& desiredFormat) +{ + return QImageReader::supportedImageFormats().contains(desiredFormat); +} + tst_QIcon::tst_QIcon() { } @@ -205,6 +212,10 @@ void tst_QIcon::actualSize2() void tst_QIcon::svgActualSize() { + if (!haveImageFormat("svg")) { + QSKIP("SVG support is not available", SkipAll); + } + const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); QIcon icon(prefix + "rect.svg"); QCOMPARE(icon.actualSize(QSize(16, 16)), QSize(16, 2)); @@ -415,6 +426,9 @@ void tst_QIcon::detach() void tst_QIcon::svg() { + if (!haveImageFormat("svg")) { + QSKIP("SVG support is not available", SkipAll); + } QIcon icon1("heart.svg"); QVERIFY(!icon1.pixmap(32).isNull()); @@ -521,14 +535,14 @@ void tst_QIcon::availableSizes() QCOMPARE(availableSizes.at(0), QSize(16,16)); } - { + if (haveImageFormat("svg")) { // checks that there are no availableSizes for scalable images. QIcon icon("heart.svg"); QList<QSize> availableSizes = icon.availableSizes(); QVERIFY(availableSizes.isEmpty()); } - { + if (haveImageFormat("svg")) { // even if an a scalable image contain added pixmaps, // availableSizes still should be empty. QIcon icon("heart.svg"); diff --git a/tests/auto/qimagereader/images/test32bfv4.bmp b/tests/auto/qimagereader/images/test32bfv4.bmp Binary files differnew file mode 100644 index 0000000000..37060373ed --- /dev/null +++ b/tests/auto/qimagereader/images/test32bfv4.bmp diff --git a/tests/auto/qimagereader/images/test32v5.bmp b/tests/auto/qimagereader/images/test32v5.bmp Binary files differnew file mode 100644 index 0000000000..8ad3cfa60d --- /dev/null +++ b/tests/auto/qimagereader/images/test32v5.bmp diff --git a/tests/auto/qimagereader/qimagereader.pro b/tests/auto/qimagereader/qimagereader.pro index 34ec607570..43d587ea48 100644 --- a/tests/auto/qimagereader/qimagereader.pro +++ b/tests/auto/qimagereader/qimagereader.pro @@ -5,12 +5,6 @@ QT += widgets widgets-private core-private gui-private network RESOURCES += qimagereader.qrc !symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" -!contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF -!contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG -!contains(QT_CONFIG, no-mng):DEFINES += QTEST_HAVE_MNG -!contains(QT_CONFIG, no-tiff):DEFINES += QTEST_HAVE_TIFF -!contains(QT_CONFIG, no-svg):DEFINES += QTEST_HAVE_SVG - win32-msvc:QMAKE_CXXFLAGS -= -Zm200 win32-msvc:QMAKE_CXXFLAGS += -Zm800 win32-msvc.net:QMAKE_CXXFLAGS -= -Zm300 @@ -40,5 +34,3 @@ symbian: { DEPLOYMENT += imagePlugins } } - -CONFIG+=insignificant_test diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index 632b73abb0..2c70652389 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -42,6 +42,8 @@ <file>images/teapot.ppm</file> <file>images/test.ppm</file> <file>images/test.xpm</file> + <file>images/test32bfv4.bmp</file> + <file>images/test32v5.bmp</file> <file>images/tst7.bmp</file> <file>images/tst7.png</file> <file>images/transparent.xpm</file> diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 5c65cb3044..6359468597 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -143,12 +143,10 @@ private slots: void imageFormatBeforeRead_data(); void imageFormatBeforeRead(); -#if defined QTEST_HAVE_GIF void gifHandlerBugs(); void animatedGif(); void gifImageCount(); void gifLoopCount(); -#endif void readCorruptImage_data(); void readCorruptImage(); @@ -157,7 +155,6 @@ private slots: void supportsOption_data(); void supportsOption(); -#if defined QTEST_HAVE_TIFF void tiffCompression_data(); void tiffCompression(); void tiffEndianness(); @@ -166,7 +163,6 @@ private slots: void tiffOrientation(); void tiffGrayscale(); -#endif void autoDetectImageFormat(); void fileNameProbing(); @@ -192,6 +188,12 @@ private slots: static const QLatin1String prefix(SRCDIR "/images/"); +// helper to skip an autotest when the given image format is not supported +#define SKIP_IF_UNSUPPORTED(format) do { \ + if (!QByteArray(format).isEmpty() && !QImageReader::supportedImageFormats().contains(format)) \ + QSKIP("\"" + QByteArray(format) + "\" images are not supported", SkipSingle); \ +} while (0) + // Testing get/set functions void tst_QImageReader::getSetCheck() { @@ -234,6 +236,8 @@ void tst_QImageReader::readImage_data() QTest::newRow("empty") << QString() << false << QByteArray(); QTest::newRow("BMP: colorful") << QString("colorful.bmp") << true << QByteArray("bmp"); + QTest::newRow("BMP: test32bfv4") << QString("test32bfv4.bmp") << true << QByteArray("bmp"); + QTest::newRow("BMP: test32v5") << QString("test32v5.bmp") << true << QByteArray("bmp"); QTest::newRow("BMP: font") << QString("font.bmp") << true << QByteArray("bmp"); QTest::newRow("BMP: signed char") << QString("crash-signed-char.bmp") << true << QByteArray("bmp"); QTest::newRow("BMP: 4bpp RLE") << QString("4bpp-rle.bmp") << true << QByteArray("bmp"); @@ -247,22 +251,17 @@ void tst_QImageReader::readImage_data() QTest::newRow("PPM: test") << QString("test.ppm") << true << QByteArray("ppm"); QTest::newRow("XBM: gnus") << QString("gnus.xbm") << true << QByteArray("xbm"); -#if defined QTEST_HAVE_JPEG QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg"); QTest::newRow("JPEG: qtbug13653") << QString("qtbug13653-no_eoi.jpg") << true << QByteArray("jpeg"); -#endif -#if defined QTEST_HAVE_GIF + QTest::newRow("GIF: earth") << QString("earth.gif") << true << QByteArray("gif"); QTest::newRow("GIF: trolltech") << QString("trolltech.gif") << true << QByteArray("gif"); -#endif -#if defined QTEST_HAVE_MNG + QTest::newRow("MNG: ball") << QString("ball.mng") << true << QByteArray("mng"); QTest::newRow("MNG: fire") << QString("fire.mng") << true << QByteArray("mng"); -#endif -#if defined QTEST_HAVE_SVG + QTest::newRow("SVG: rect") << QString("rect.svg") << true << QByteArray("svg"); QTest::newRow("SVGZ: rect") << QString("rect.svgz") << true << QByteArray("svgz"); -#endif } void tst_QImageReader::readImage() @@ -271,6 +270,8 @@ void tst_QImageReader::readImage() QFETCH(bool, success); QFETCH(QByteArray, format); + SKIP_IF_UNSUPPORTED(format); + for (int i = 0; i < 2; ++i) { QImageReader io(prefix + fileName, i ? QByteArray() : format); if (success) { @@ -361,7 +362,7 @@ void tst_QImageReader::setScaledSize_data() QTest::newRow("PPM: runners") << "runners.ppm" << QSize(400, 400) << QByteArray("ppm"); QTest::newRow("PPM: test") << "test.ppm" << QSize(10, 10) << QByteArray("ppm"); QTest::newRow("XBM: gnus") << "gnus" << QSize(200, 200) << QByteArray("xbm"); -#ifdef QTEST_HAVE_JPEG + QTest::newRow("JPEG: beavis A") << "beavis" << QSize(200, 200) << QByteArray("jpeg"); QTest::newRow("JPEG: beavis B") << "beavis" << QSize(175, 175) << QByteArray("jpeg"); QTest::newRow("JPEG: beavis C") << "beavis" << QSize(100, 100) << QByteArray("jpeg"); @@ -371,19 +372,15 @@ void tst_QImageReader::setScaledSize_data() QTest::newRow("JPEG: beavis G") << "beavis" << QSize(50, 45) << QByteArray("jpeg"); QTest::newRow("JPEG: beavis H") << "beavis" << QSize(43, 43) << QByteArray("jpeg"); QTest::newRow("JPEG: beavis I") << "beavis" << QSize(25, 25) << QByteArray("jpeg"); -#endif // QTEST_HAVE_JPEG -#ifdef QTEST_HAVE_GIF + QTest::newRow("GIF: earth") << "earth" << QSize(200, 200) << QByteArray("gif"); QTest::newRow("GIF: trolltech") << "trolltech" << QSize(200, 200) << QByteArray("gif"); -#endif // QTEST_HAVE_GIF -#ifdef QTEST_HAVE_MNG + QTest::newRow("MNG: ball") << "ball" << QSize(200, 200) << QByteArray("mng"); QTest::newRow("MNG: fire") << "fire" << QSize(200, 200) << QByteArray("mng"); -#endif // QTEST_HAVE_MNG -#if defined QTEST_HAVE_SVG + QTest::newRow("SVG: rect") << "rect" << QSize(200, 200) << QByteArray("svg"); QTest::newRow("SVGZ: rect") << "rect" << QSize(200, 200) << QByteArray("svgz"); -#endif } void tst_QImageReader::setScaledSize() @@ -392,8 +389,7 @@ void tst_QImageReader::setScaledSize() QFETCH(QSize, newSize); QFETCH(QByteArray, format); - if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format)) - QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle); + SKIP_IF_UNSUPPORTED(format); QImageReader reader(prefix + fileName); reader.setScaledSize(newSize); @@ -413,8 +409,7 @@ void tst_QImageReader::task255627_setNullScaledSize() QFETCH(QString, fileName); QFETCH(QByteArray, format); - if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format)) - QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle); + SKIP_IF_UNSUPPORTED(format); QImageReader reader(prefix + fileName); @@ -432,6 +427,8 @@ void tst_QImageReader::setClipRect_data() QTest::addColumn<QRect>("newRect"); QTest::addColumn<QByteArray>("format"); QTest::newRow("BMP: colorful") << "colorful" << QRect(0, 0, 50, 50) << QByteArray("bmp"); + QTest::newRow("BMP: test32bfv4") << "test32bfv4" << QRect(0, 0, 50, 50) << QByteArray("bmp"); + QTest::newRow("BMP: test32v5") << "test32v5" << QRect(0, 0, 50, 50) << QByteArray("bmp"); QTest::newRow("BMP: font") << "font" << QRect(0, 0, 50, 50) << QByteArray("bmp"); QTest::newRow("BMP: 4bpp uncompressed") << "tst7.bmp" << QRect(0, 0, 31, 31) << QByteArray("bmp"); QTest::newRow("XPM: marble") << "marble" << QRect(0, 0, 50, 50) << QByteArray("xpm"); @@ -440,21 +437,17 @@ void tst_QImageReader::setClipRect_data() QTest::newRow("PPM: runners") << "runners.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm"); QTest::newRow("PPM: test") << "test.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm"); QTest::newRow("XBM: gnus") << "gnus" << QRect(0, 0, 50, 50) << QByteArray("xbm"); -#ifdef QTEST_HAVE_JPEG + QTest::newRow("JPEG: beavis") << "beavis" << QRect(0, 0, 50, 50) << QByteArray("jpeg"); -#endif // QTEST_HAVE_JPEG -#ifdef QTEST_HAVE_GIF + QTest::newRow("GIF: earth") << "earth" << QRect(0, 0, 50, 50) << QByteArray("gif"); QTest::newRow("GIF: trolltech") << "trolltech" << QRect(0, 0, 50, 50) << QByteArray("gif"); -#endif // QTEST_HAVE_GIF -#ifdef QTEST_HAVE_MNG + QTest::newRow("MNG: ball") << "ball" << QRect(0, 0, 50, 50) << QByteArray("mng"); QTest::newRow("MNG: fire") << "fire" << QRect(0, 0, 50, 50) << QByteArray("mng"); -#endif // QTEST_HAVE_MNG -#if defined QTEST_HAVE_SVG + QTest::newRow("SVG: rect") << "rect" << QRect(0, 0, 50, 50) << QByteArray("svg"); QTest::newRow("SVGZ: rect") << "rect" << QRect(0, 0, 50, 50) << QByteArray("svgz"); -#endif } void tst_QImageReader::setClipRect() @@ -463,8 +456,7 @@ void tst_QImageReader::setClipRect() QFETCH(QRect, newRect); QFETCH(QByteArray, format); - if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format)) - QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle); + SKIP_IF_UNSUPPORTED(format); QImageReader reader(prefix + fileName); reader.setClipRect(newRect); @@ -484,6 +476,8 @@ void tst_QImageReader::setScaledClipRect_data() QTest::addColumn<QByteArray>("format"); QTest::newRow("BMP: colorful") << "colorful" << QRect(0, 0, 50, 50) << QByteArray("bmp"); + QTest::newRow("BMP: test32bfv4") << "test32bfv4" << QRect(0, 0, 50, 50) << QByteArray("bmp"); + QTest::newRow("BMP: test32v5") << "test32v5" << QRect(0, 0, 50, 50) << QByteArray("bmp"); QTest::newRow("BMP: font") << "font" << QRect(0, 0, 50, 50) << QByteArray("bmp"); QTest::newRow("XPM: marble") << "marble" << QRect(0, 0, 50, 50) << QByteArray("xpm"); QTest::newRow("PNG: kollada") << "kollada" << QRect(0, 0, 50, 50) << QByteArray("png"); @@ -491,21 +485,17 @@ void tst_QImageReader::setScaledClipRect_data() QTest::newRow("PPM: runners") << "runners.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm"); QTest::newRow("PPM: test") << "test.ppm" << QRect(0, 0, 50, 50) << QByteArray("ppm"); QTest::newRow("XBM: gnus") << "gnus" << QRect(0, 0, 50, 50) << QByteArray("xbm"); -#ifdef QTEST_HAVE_JPEG + QTest::newRow("JPEG: beavis") << "beavis" << QRect(0, 0, 50, 50) << QByteArray("jpeg"); -#endif // QTEST_HAVE_JPEG -#ifdef QTEST_HAVE_GIF + QTest::newRow("GIF: earth") << "earth" << QRect(0, 0, 50, 50) << QByteArray("gif"); QTest::newRow("GIF: trolltech") << "trolltech" << QRect(0, 0, 50, 50) << QByteArray("gif"); -#endif // QTEST_HAVE_GIF -#ifdef QTEST_HAVE_MNG + QTest::newRow("MNG: ball") << "ball" << QRect(0, 0, 50, 50) << QByteArray("mng"); QTest::newRow("MNG: fire") << "fire" << QRect(0, 0, 50, 50) << QByteArray("mng"); -#endif // QTEST_HAVE_MNG -#if defined QTEST_HAVE_SVG + QTest::newRow("SVG: rect") << "rect" << QRect(0, 0, 50, 50) << QByteArray("svg"); QTest::newRow("SVGZ: rect") << "rect" << QRect(0, 0, 50, 50) << QByteArray("svgz"); -#endif } void tst_QImageReader::setScaledClipRect() @@ -514,8 +504,7 @@ void tst_QImageReader::setScaledClipRect() QFETCH(QRect, newRect); QFETCH(QByteArray, format); - if (!format.isEmpty() && !QImageReader::supportedImageFormats().contains(format)) - QSKIP("Qt does not support reading the \"" + format + "\" format", SkipSingle); + SKIP_IF_UNSUPPORTED(format); QImageReader reader(prefix + fileName); reader.setScaledSize(QSize(300, 300)); @@ -542,19 +531,20 @@ void tst_QImageReader::imageFormat_data() QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm") << QImage::Format_RGB32; QTest::newRow("ppm-3") << QString("runners.ppm") << QByteArray("ppm") << QImage::Format_RGB32; QTest::newRow("ppm-4") << QString("test.ppm") << QByteArray("ppm") << QImage::Format_RGB32; -#ifdef QTEST_HAVE_JPEG + QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg") << QImage::Format_Indexed8; QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg") << QImage::Format_RGB32; QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg") << QImage::Format_RGB32; -#endif -#if defined QTEST_HAVE_GIF + QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif") << QImage::Format_Invalid; QTest::newRow("gif-2") << QString("trolltech.gif") << QByteArray("gif") << QImage::Format_Invalid; -#endif + QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm") << QImage::Format_MonoLSB; QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm") << QImage::Format_Indexed8; QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp") << QImage::Format_Indexed8; QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp") << QImage::Format_Indexed8; + QTest::newRow("bmp-3") << QString("test32bfv4.bmp") << QByteArray("bmp") << QImage::Format_RGB32; + QTest::newRow("bmp-4") << QString("test32v5.bmp") << QByteArray("bmp") << QImage::Format_RGB32; QTest::newRow("png") << QString("kollada.png") << QByteArray("png") << QImage::Format_ARGB32; QTest::newRow("png-2") << QString("YCbCr_cmyk.png") << QByteArray("png") << QImage::Format_RGB32; QTest::newRow("mng-1") << QString("ball.mng") << QByteArray("mng") << QImage::Format_Invalid; @@ -569,27 +559,9 @@ void tst_QImageReader::imageFormat() QFETCH(QByteArray, format); QFETCH(QImage::Format, imageFormat); - if (QImageReader::imageFormat(prefix + fileName).isEmpty()) { - if (QByteArray("jpeg") == format) -#ifndef QTEST_HAVE_JPEG - return; -#endif // !QTEST_HAVE_JPEG - if (QByteArray("gif") == format) -#ifndef QTEST_HAVE_GIF - return; -#endif // !QTEST_HAVE_GIF - if (QByteArray("mng") == format) -#ifndef QTEST_HAVE_MNG - return; -#endif // !QTEST_HAVE_MNG - if (QByteArray("svg") == format || QByteArray("svgz") == format) -#ifndef QTEST_HAVE_SVG - return; -#endif // !QTEST_HAVE_SVG - QSKIP(("Qt does not support the " + format + " format.").constData(), SkipSingle); - } else { - QCOMPARE(QImageReader::imageFormat(prefix + fileName), format); - } + SKIP_IF_UNSUPPORTED(format); + + QCOMPARE(QImageReader::imageFormat(prefix + fileName), format); QImageReader reader(prefix + fileName); QCOMPARE(reader.imageFormat(), imageFormat); } @@ -649,21 +621,17 @@ void tst_QImageReader::setBackgroundColor_data() QTest::newRow("PPM: runners") << QString("runners.ppm") << QColor(Qt::red); QTest::newRow("PPM: test") << QString("test.ppm") << QColor(Qt::white); QTest::newRow("XBM: gnus") << QString("gnus.xbm") << QColor(Qt::blue); -#if defined QTEST_HAVE_JPEG + QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << QColor(Qt::darkBlue); -#endif -#if defined QTEST_HAVE_GIF + QTest::newRow("GIF: earth") << QString("earth.gif") << QColor(Qt::cyan); QTest::newRow("GIF: trolltech") << QString("trolltech.gif") << QColor(Qt::magenta); -#endif -#if defined QTEST_HAVE_MNG + QTest::newRow("MNG: ball") << QString("ball.mng") << QColor(Qt::yellow); QTest::newRow("MNG: fire") << QString("fire.mng") << QColor(Qt::gray); -#endif -#if defined QTEST_HAVE_SVG + QTest::newRow("SVG: rect") << QString("rect.svg") << QColor(Qt::darkGreen); QTest::newRow("SVGZ: rect") << QString("rect.svgz") << QColor(Qt::darkGreen); -#endif } void tst_QImageReader::setBackgroundColor() @@ -684,27 +652,25 @@ void tst_QImageReader::supportsAnimation_data() QTest::newRow("BMP: colorful") << QString("colorful.bmp") << false; QTest::newRow("BMP: font") << QString("font.bmp") << false; QTest::newRow("BMP: signed char") << QString("crash-signed-char.bmp") << false; + QTest::newRow("BMP: test32bfv4") << QString("test32bfv4.bmp") << false;; + QTest::newRow("BMP: test32v5") << QString("test32v5.bmp") << false; QTest::newRow("XPM: marble") << QString("marble.xpm") << false; QTest::newRow("PNG: kollada") << QString("kollada.png") << false; QTest::newRow("PPM: teapot") << QString("teapot.ppm") << false; QTest::newRow("PPM: teapot") << QString("teapot.ppm") << false; QTest::newRow("PPM: runners") << QString("runners.ppm") << false; QTest::newRow("XBM: gnus") << QString("gnus.xbm") << false; -#if defined QTEST_HAVE_JPEG + QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << false; -#endif -#if defined QTEST_HAVE_GIF + QTest::newRow("GIF: earth") << QString("earth.gif") << true; QTest::newRow("GIF: trolltech") << QString("trolltech.gif") << true; -#endif -#if defined QTEST_HAVE_MNG + QTest::newRow("MNG: ball") << QString("ball.mng") << true; QTest::newRow("MNG: fire") << QString("fire.mng") << true; -#endif -#if defined QTEST_HAVE_SVG + QTest::newRow("SVG: rect") << QString("rect.svg") << false; QTest::newRow("SVGZ: rect") << QString("rect.svgz") << false; -#endif } void tst_QImageReader::supportsAnimation() @@ -724,6 +690,9 @@ void tst_QImageReader::sizeBeforeRead() { QFETCH(QString, fileName); QFETCH(QByteArray, format); + + SKIP_IF_UNSUPPORTED(format); + QImageReader reader(prefix + fileName); QVERIFY(reader.canRead()); if (format == "mng") { @@ -771,7 +740,11 @@ void tst_QImageReader::imageFormatBeforeRead_data() void tst_QImageReader::imageFormatBeforeRead() { QFETCH(QString, fileName); + QFETCH(QByteArray, format); QFETCH(QImage::Format, imageFormat); + + SKIP_IF_UNSUPPORTED(format); + QImageReader reader(fileName); if (reader.supportsOption(QImageIOHandler::ImageFormat)) { QImage::Format fileFormat = reader.imageFormat(); @@ -783,9 +756,10 @@ void tst_QImageReader::imageFormatBeforeRead() } } -#if defined QTEST_HAVE_GIF void tst_QImageReader::gifHandlerBugs() { + SKIP_IF_UNSUPPORTED("gif"); + { QImageReader io(prefix + "trolltech.gif"); QVERIFY(io.loopCount() != 1); @@ -827,6 +801,8 @@ void tst_QImageReader::gifHandlerBugs() void tst_QImageReader::animatedGif() { + SKIP_IF_UNSUPPORTED("gif"); + QImageReader io(":images/qt.gif"); QImage image = io.read(); QVERIFY(!image.isNull()); @@ -842,6 +818,8 @@ void tst_QImageReader::animatedGif() // Check the count of images in various call orders... void tst_QImageReader::gifImageCount() { + SKIP_IF_UNSUPPORTED("gif"); + // just read every frame... and see how much we got.. { QImageReader io(":images/four-frames.gif"); @@ -977,6 +955,8 @@ void tst_QImageReader::gifImageCount() void tst_QImageReader::gifLoopCount() { + SKIP_IF_UNSUPPORTED("gif"); + { QImageReader io(":images/qt-gif-anim.gif"); QCOMPARE(io.loopCount(), -1); // infinite loop @@ -987,8 +967,6 @@ void tst_QImageReader::gifLoopCount() } } -#endif - class Server : public QObject { Q_OBJECT @@ -1050,29 +1028,28 @@ void tst_QImageReader::readFromDevice_data() QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm"); QTest::newRow("ppm-3") << QString("teapot.ppm") << QByteArray("ppm"); QTest::newRow("ppm-4") << QString("runners.ppm") << QByteArray("ppm"); -#ifdef QTEST_HAVE_JPEG + QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-4") << QString("qtbug13653-no_eoi.jpg") << QByteArray("jpeg"); -#endif // QTEST_HAVE_JPEG -#ifdef QTEST_HAVE_GIF + QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif"); QTest::newRow("gif-2") << QString("trolltech.gif") << QByteArray("gif"); -#endif // QTEST_HAVE_GIF + QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm"); QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm"); QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp"); QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-3") << QString("test32bfv4.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-4") << QString("test32v5.bmp") << QByteArray("bmp"); QTest::newRow("png") << QString("kollada.png") << QByteArray("png"); -#ifdef QTEST_HAVE_MNG + QTest::newRow("mng-1") << QString("ball.mng") << QByteArray("mng"); QTest::newRow("mng-2") << QString("fire.mng") << QByteArray("mng"); -#endif // QTEST_HAVE_MNG -#if defined QTEST_HAVE_SVG + QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg"); QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz"); -#endif } void tst_QImageReader::readFromDevice() @@ -1080,6 +1057,8 @@ void tst_QImageReader::readFromDevice() QFETCH(QString, fileName); QFETCH(QByteArray, format); + SKIP_IF_UNSUPPORTED(format); + QImage expectedImage(prefix + fileName, format); QFile file(prefix + fileName); @@ -1142,26 +1121,20 @@ void tst_QImageReader::readFromFileAfterJunk_data() QTest::newRow("ppm-2") << QString("teapot.ppm") << QByteArray("ppm"); QTest::newRow("ppm-3") << QString("teapot.ppm") << QByteArray("ppm"); QTest::newRow("ppm-4") << QString("runners.ppm") << QByteArray("ppm"); -#ifdef QTEST_HAVE_JPEG + QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg"); -#endif -#if defined QTEST_HAVE_GIF -// QTest::newRow("gif-1") << QString("images/earth.gif") << QByteArray("gif"); -// QTest::newRow("gif-2") << QString("images/trolltech.gif") << QByteArray("gif"); -#endif + QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm"); QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm"); QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp"); QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-3") << QString("test32bfv4.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-4") << QString("test32v5.bmp") << QByteArray("bmp"); QTest::newRow("png") << QString("kollada.png") << QByteArray("png"); -// QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng"); -// QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng"); -#if defined QTEST_HAVE_SVG QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg"); QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz"); -#endif } void tst_QImageReader::readFromFileAfterJunk() @@ -1169,10 +1142,7 @@ void tst_QImageReader::readFromFileAfterJunk() QFETCH(QString, fileName); QFETCH(QByteArray, format); - if (!QImageReader::supportedImageFormats().contains(format)) { - QString cause = QString("Skipping %1; no %2 support").arg(fileName).arg(QString(format)); - QSKIP(qPrintable(cause), SkipSingle); - } + SKIP_IF_UNSUPPORTED(format); QFile::remove("junk"); QFile junkFile("junk"); @@ -1221,25 +1191,22 @@ void tst_QImageReader::devicePosition_data() QTest::newRow("pbm") << QString("image.pbm") << QByteArray("pbm"); QTest::newRow("pgm") << QString("image.pgm") << QByteArray("pgm"); QTest::newRow("ppm-1") << QString("image.ppm") << QByteArray("ppm"); -#ifdef QTEST_HAVE_JPEG + QTest::newRow("jpeg-1") << QString("beavis.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-2") << QString("YCbCr_cmyk.jpg") << QByteArray("jpeg"); QTest::newRow("jpeg-3") << QString("YCbCr_rgb.jpg") << QByteArray("jpeg"); -#endif -#if defined QTEST_HAVE_GIF + QTest::newRow("gif-1") << QString("earth.gif") << QByteArray("gif"); -#endif + QTest::newRow("xbm") << QString("gnus.xbm") << QByteArray("xbm"); QTest::newRow("xpm") << QString("marble.xpm") << QByteArray("xpm"); QTest::newRow("bmp-1") << QString("colorful.bmp") << QByteArray("bmp"); QTest::newRow("bmp-2") << QString("font.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-3") << QString("test32bfv4.bmp") << QByteArray("bmp"); + QTest::newRow("bmp-4") << QString("test32v5.bmp") << QByteArray("bmp"); QTest::newRow("png") << QString("kollada.png") << QByteArray("png"); -// QTest::newRow("mng-1") << QString("images/ball.mng") << QByteArray("mng"); -// QTest::newRow("mng-2") << QString("images/fire.mng") << QByteArray("mng"); -#if defined QTEST_HAVE_SVG QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg"); QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz"); -#endif } void tst_QImageReader::devicePosition() @@ -1247,6 +1214,8 @@ void tst_QImageReader::devicePosition() QFETCH(QString, fileName); QFETCH(QByteArray, format); + SKIP_IF_UNSUPPORTED(format); + QImage expected(prefix + fileName); QVERIFY(!expected.isNull()); @@ -1305,7 +1274,12 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("4bpp-rle.bmp") << QString("4bpp-rle.bmp") << QByteArray("bmp") << QSize(640, 480) << QString(""); -#ifdef QTEST_HAVE_GIF + QTest::newRow("test32bfv4.bmp") << QString("test32bfv4.bmp") + << QByteArray("bmp") << QSize(373, 156) + << QString(""); + QTest::newRow("test32v5.bmp") << QString("test32v5.bmp") + << QByteArray("bmp") << QSize(373, 156) + << QString(""); QTest::newRow("corrupt.gif") << QString("corrupt.gif") << QByteArray("gif") << QSize(0, 0) << QString(""); @@ -1324,8 +1298,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("bat2.gif") << QString("bat2.gif") << QByteArray("gif") << QSize(32, 32) << QString(""); -#endif -#ifdef QTEST_HAVE_JPEG QTest::newRow("corrupt.jpg") << QString("corrupt.jpg") << QByteArray("jpg") << QSize(0, 0) << QString("JPEG datastream contains no image"); @@ -1341,8 +1313,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("qtbug13653-no_eoi.jpg") << QString("qtbug13653-no_eoi.jpg") << QByteArray("jpg") << QSize(240, 180) << QString(""); -#endif -#ifdef QTEST_HAVE_MNG QTest::newRow("corrupt.mng") << QString("corrupt.mng") << QByteArray("mng") << QSize(0, 0) << QString("MNG error 901: Application signalled I/O error; chunk IHDR; subcode 0:0"); @@ -1352,8 +1322,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("ball.mng") << QString("ball.mng") << QByteArray("mng") << QSize(32, 32) << QString(""); -#endif -#ifdef QTEST_HAVE_SVG QTest::newRow("rect.svg") << QString("rect.svg") << QByteArray("svg") << QSize(105, 137) << QString(""); @@ -1366,7 +1334,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("corrupt.svgz") << QString("corrupt.svgz") << QByteArray("svgz") << QSize(0, 0) << QString(""); -#endif QTest::newRow("image.pbm") << QString("image.pbm") << QByteArray("pbm") << QSize(16, 6) << QString(""); @@ -1403,7 +1370,6 @@ void tst_QImageReader::readFromResources_data() QTest::newRow("test.ppm") << QString("test.ppm") << QByteArray("ppm") << QSize(10, 10) << QString(""); -// QTest::newRow("corrupt.xbm") << QString("corrupt.xbm") << QByteArray("xbm") << QSize(0, 0); QTest::newRow("gnus.xbm") << QString("gnus.xbm") << QByteArray("xbm") << QSize(271, 273) << QString(""); @@ -1442,6 +1408,9 @@ void tst_QImageReader::readFromResources() QFETCH(QByteArray, format); QFETCH(QSize, size); QFETCH(QString, message); + + SKIP_IF_UNSUPPORTED(format); + for (int i = 0; i < 2; ++i) { QString file = i ? (":/images/" + fileName) : (prefix + fileName); { @@ -1515,31 +1484,26 @@ void tst_QImageReader::readCorruptImage_data() QTest::addColumn<QString>("fileName"); QTest::addColumn<bool>("shouldFail"); QTest::addColumn<QString>("message"); -#if defined QTEST_HAVE_JPEG + QTest::addColumn<QByteArray>("format"); QTest::newRow("corrupt jpeg") << QString("corrupt.jpg") << true - << QString("JPEG datastream contains no image"); -#endif -#if defined QTEST_HAVE_GIF - QTest::newRow("corrupt gif") << QString("corrupt.gif") << true << QString(""); -#endif -#ifdef QTEST_HAVE_MNG + << QString("JPEG datastream contains no image") + << QByteArray("jpeg"); + QTest::newRow("corrupt gif") << QString("corrupt.gif") << true << QString("") << QByteArray("gif"); QTest::newRow("corrupt mng") << QString("corrupt.mng") << true - << QString("MNG error 901: Application signalled I/O error; chunk IHDR; subcode 0:0"); -#endif - QTest::newRow("corrupt png") << QString("corrupt.png") << true << QString(""); - QTest::newRow("corrupt bmp") << QString("corrupt.bmp") << true << QString(""); + << QString("MNG error 901: Application signalled I/O error; chunk IHDR; subcode 0:0") + << QByteArray("mng"); + QTest::newRow("corrupt png") << QString("corrupt.png") << true << QString("") << QByteArray("png"); + QTest::newRow("corrupt bmp") << QString("corrupt.bmp") << true << QString("") << QByteArray("bmp"); QTest::newRow("corrupt xpm (colors)") << QString("corrupt-colors.xpm") << true - << QString("QImage: XPM color specification is missing: bla9an.n#x"); + << QString("QImage: XPM color specification is missing: bla9an.n#x") + << QByteArray("xpm"); QTest::newRow("corrupt xpm (pixels)") << QString("corrupt-pixels.xpm") << true - << QString("QImage: XPM pixels missing on image line 3"); - QTest::newRow("corrupt xbm") << QString("corrupt.xbm") << false << QString(""); -#if defined QTEST_HAVE_TIFF - QTest::newRow("corrupt tiff") << QString("corrupt-data.tif") << true << QString(""); -#endif -#if defined QTEST_HAVE_SVG - QTest::newRow("corrupt svg") << QString("corrupt.svg") << true << QString(""); - QTest::newRow("corrupt svgz") << QString("corrupt.svgz") << true << QString(""); -#endif + << QString("QImage: XPM pixels missing on image line 3") + << QByteArray("xpm"); + QTest::newRow("corrupt xbm") << QString("corrupt.xbm") << false << QString("") << QByteArray("xbm"); + QTest::newRow("corrupt tiff") << QString("corrupt-data.tif") << true << QString("") << QByteArray("tiff"); + QTest::newRow("corrupt svg") << QString("corrupt.svg") << true << QString("") << QByteArray("svg"); + QTest::newRow("corrupt svgz") << QString("corrupt.svgz") << true << QString("") << QByteArray("svgz"); } void tst_QImageReader::readCorruptImage() @@ -1547,6 +1511,9 @@ void tst_QImageReader::readCorruptImage() QFETCH(QString, fileName); QFETCH(bool, shouldFail); QFETCH(QString, message); + QFETCH(QByteArray, format); + + SKIP_IF_UNSUPPORTED(format); if (!message.isEmpty()) QTest::ignoreMessage(QtWarningMsg, message.toLatin1()); @@ -1603,7 +1570,6 @@ void tst_QImageReader::supportsOption() QVERIFY(!reader.supportsOption(option)); } -#if defined QTEST_HAVE_TIFF void tst_QImageReader::tiffCompression_data() { QTest::addColumn<QString>("uncompressedFile"); @@ -1624,6 +1590,8 @@ void tst_QImageReader::tiffCompression() QFETCH(QString, uncompressedFile); QFETCH(QString, compressedFile); + SKIP_IF_UNSUPPORTED("tiff"); + QImage uncompressedImage(prefix + uncompressedFile); QImage compressedImage(prefix + compressedFile); @@ -1632,6 +1600,8 @@ void tst_QImageReader::tiffCompression() void tst_QImageReader::tiffEndianness() { + SKIP_IF_UNSUPPORTED("tiff"); + QImage littleEndian(prefix + "rgba_nocompression_littleendian.tif"); QImage bigEndian(prefix + "rgba_nocompression_bigendian.tif"); @@ -1675,6 +1645,8 @@ void tst_QImageReader::tiffOrientation() QFETCH(QString, expected); QFETCH(QString, oriented); + SKIP_IF_UNSUPPORTED("tiff"); + QImage expectedImage(prefix + expected); QImage orientedImage(prefix + oriented); QCOMPARE(expectedImage, orientedImage); @@ -1682,22 +1654,22 @@ void tst_QImageReader::tiffOrientation() void tst_QImageReader::tiffGrayscale() { + SKIP_IF_UNSUPPORTED("tiff"); + QImage actualImage(prefix + "grayscale.tif"); QImage expectedImage(prefix + "grayscale-ref.tif"); QCOMPARE(expectedImage, actualImage.convertToFormat(expectedImage.format())); } -#endif void tst_QImageReader::dotsPerMeter_data() { QTest::addColumn<QString>("fileName"); QTest::addColumn<int>("expectedDotsPerMeterX"); QTest::addColumn<int>("expectedDotsPerMeterY"); -#if defined QTEST_HAVE_TIFF - QTest::newRow("TIFF: 72 dpi") << ("rgba_nocompression_littleendian.tif") << qRound(72 * (100 / 2.54)) << qRound(72 * (100 / 2.54)); - QTest::newRow("TIFF: 100 dpi") << ("image_100dpi.tif") << qRound(100 * (100 / 2.54)) << qRound(100 * (100 / 2.54)); -#endif + QTest::addColumn<QByteArray>("format"); + QTest::newRow("TIFF: 72 dpi") << ("rgba_nocompression_littleendian.tif") << qRound(72 * (100 / 2.54)) << qRound(72 * (100 / 2.54)) << QByteArray("tiff"); + QTest::newRow("TIFF: 100 dpi") << ("image_100dpi.tif") << qRound(100 * (100 / 2.54)) << qRound(100 * (100 / 2.54)) << QByteArray("tiff"); } void tst_QImageReader::dotsPerMeter() @@ -1705,6 +1677,9 @@ void tst_QImageReader::dotsPerMeter() QFETCH(QString, fileName); QFETCH(int, expectedDotsPerMeterX); QFETCH(int, expectedDotsPerMeterY); + QFETCH(QByteArray, format); + + SKIP_IF_UNSUPPORTED(format); QImage image(prefix + fileName); @@ -1717,10 +1692,9 @@ void tst_QImageReader::physicalDpi_data() QTest::addColumn<QString>("fileName"); QTest::addColumn<int>("expectedPhysicalDpiX"); QTest::addColumn<int>("expectedPhysicalDpiY"); -#if defined QTEST_HAVE_TIFF - QTest::newRow("TIFF: 72 dpi") << "rgba_nocompression_littleendian.tif" << 72 << 72; - QTest::newRow("TIFF: 100 dpi") << "image_100dpi.tif" << 100 << 100; -#endif + QTest::addColumn<QByteArray>("format"); + QTest::newRow("TIFF: 72 dpi") << "rgba_nocompression_littleendian.tif" << 72 << 72 << QByteArray("tiff"); + QTest::newRow("TIFF: 100 dpi") << "image_100dpi.tif" << 100 << 100 << QByteArray("tiff"); } void tst_QImageReader::physicalDpi() @@ -1728,6 +1702,9 @@ void tst_QImageReader::physicalDpi() QFETCH(QString, fileName); QFETCH(int, expectedPhysicalDpiX); QFETCH(int, expectedPhysicalDpiY); + QFETCH(QByteArray, format); + + SKIP_IF_UNSUPPORTED(format); QImage image(prefix + fileName); @@ -1769,21 +1746,19 @@ void tst_QImageReader::autoDetectImageFormat() QVERIFY(!reader.read().isNull()); } -#ifdef QTEST_HAVE_JPEG - { + if (QImageReader::supportedImageFormats().contains("jpeg")) { QImageReader io(prefix + "YCbCr_rgb.jpg"); io.setAutoDetectImageFormat(false); // This should fail since no format string is given QImage image; QVERIFY(!io.read(&image)); } - { + if (QImageReader::supportedImageFormats().contains("jpeg")) { QImageReader io(prefix + "YCbCr_rgb.jpg", "jpg"); io.setAutoDetectImageFormat(false); QImage image; QVERIFY(io.read(&image)); } -#endif { QImageReader io(prefix + "tst7.png"); io.setAutoDetectImageFormat(false); @@ -1873,26 +1848,16 @@ void tst_QImageReader::testIgnoresFormatAndExtension_data() QTest::newRow("image.pbm") << "image" << "pbm" << "pbm"; QTest::newRow("image.pgm") << "image" << "pgm" << "pgm"; -#if defined QTEST_HAVE_GIF QTest::newRow("bat1.gif") << "bat1" << "gif" << "gif"; -#endif -#if defined QTEST_HAVE_JPEG QTest::newRow("beavis.jpg") << "beavis" << "jpg" << "jpeg"; -#endif -#if defined QTEST_HAVE_MNG QTest::newRow("fire.mng") << "fire" << "mng" << "mng"; -#endif -#if defined QTEST_HAVE_TIFF QTest::newRow("image_100dpi.tif") << "image_100dpi" << "tif" << "tiff"; -#endif -#if defined QTEST_HAVE_SVG QTest::newRow("rect.svg") << "rect" << "svg" << "svg"; QTest::newRow("rect.svgz") << "rect" << "svgz" << "svgz"; -#endif } @@ -1902,6 +1867,8 @@ void tst_QImageReader::testIgnoresFormatAndExtension() QFETCH(QString, extension); QFETCH(QString, expected); + SKIP_IF_UNSUPPORTED(expected.toLatin1()); + QList<QByteArray> formats = QImageReader::supportedImageFormats(); QString fileNameBase = prefix + name + "."; diff --git a/tests/auto/qintvalidator/tst_qintvalidator.cpp b/tests/auto/qintvalidator/tst_qintvalidator.cpp index d53763566d..369e3254e8 100644 --- a/tests/auto/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/qintvalidator/tst_qintvalidator.cpp @@ -51,6 +51,7 @@ private slots: void validate(); void validateArabic(); void validateFrench(); + void notifySignals(); }; Q_DECLARE_METATYPE(QValidator::State); @@ -189,7 +190,6 @@ void tst_QIntValidator::validateFrench() QIntValidator validator(-2000, 2000, 0); validator.setLocale(QLocale::French); int i; - QString s = QLatin1String("1 "); QCOMPARE(validator.validate(s, i), QValidator::Acceptable); validator.fixup(s); @@ -220,5 +220,36 @@ void tst_QIntValidator::validate() QCOMPARE((int)iv.validate(value, dummy), (int)state); } +void tst_QIntValidator::notifySignals() +{ + QIntValidator iv(0, 10, 0); + QSignalSpy topSpy(&iv, SIGNAL(topChanged(int))); + QSignalSpy bottomSpy(&iv, SIGNAL(bottomChanged(int))); + iv.setTop(9); + QCOMPARE(topSpy.count(), 1); + QVERIFY(iv.top() == 9); + iv.setBottom(1); + QCOMPARE(bottomSpy.count(), 1); + QVERIFY(iv.bottom() == 1); + + iv.setRange(1, 8); + QCOMPARE(topSpy.count(), 2); + QCOMPARE(bottomSpy.count(), 1); + QVERIFY(iv.top() == 8); + QVERIFY(iv.bottom() == 1); + + iv.setRange(2, 8); + QCOMPARE(topSpy.count(), 2); + QCOMPARE(bottomSpy.count(), 2); + QVERIFY(iv.top() == 8); + QVERIFY(iv.bottom() == 2); + + iv.setRange(3, 7); + QCOMPARE(topSpy.count(), 3); + QCOMPARE(bottomSpy.count(), 3); + QVERIFY(iv.top() == 7); + QVERIFY(iv.bottom() == 3); +} + QTEST_MAIN(tst_QIntValidator) #include "tst_qintvalidator.moc" diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 70debfa1f3..a0f57f9d8d 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -129,11 +129,11 @@ void tst_QIODevice::constructing_QTcpSocket() QVERIFY(!device->isOpen()); socket.connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket.waitForConnected(5000)); + QVERIFY(socket.waitForConnected(30000)); QVERIFY(device->isOpen()); while (!device->canReadLine()) - QVERIFY(device->waitForReadyRead(5000)); + QVERIFY(device->waitForReadyRead(30000)); char buf[1024]; memset(buf, 0, sizeof(buf)); @@ -143,11 +143,11 @@ void tst_QIODevice::constructing_QTcpSocket() socket.close(); socket.connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket.waitForConnected(5000)); + QVERIFY(socket.waitForConnected(30000)); QVERIFY(device->isOpen()); while (!device->canReadLine()) - QVERIFY(device->waitForReadyRead(5000)); + QVERIFY(device->waitForReadyRead(30000)); char buf2[1024]; memset(buf2, 0, sizeof(buf2)); diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index 0c31fddfdb..675d0e6ab6 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -297,7 +297,7 @@ void tst_QLibrary::unload_after_implicit_load() #endif QLibrary library( "./mylib" ); - void *p = library.resolve("mylibversion"); + QFunctionPointer p = library.resolve("mylibversion"); QVERIFY(p); // Check if it was loaded QVERIFY(library.isLoaded()); QVERIFY(library.unload()); diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 92574ea01b..68e88a87ed 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -72,6 +72,8 @@ #include "qcommonstyle.h" #include "qstyleoption.h" +#include "qplatformdefs.h" + QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE @@ -180,6 +182,10 @@ private slots: void echoMode(); void passwordEchoOnEdit(); +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + void passwordEchoDelay(); +#endif + void maxLength_mask_data(); void maxLength_mask(); @@ -283,6 +289,9 @@ private slots: void bidiLogicalMovement_data(); void bidiLogicalMovement(); + void selectAndCursorPosition(); + void inputMethodSelection(); + protected slots: void editingFinished(); @@ -1679,6 +1688,51 @@ void tst_QLineEdit::passwordEchoOnEdit() testWidget->setEchoMode(QLineEdit::Normal); } +#ifdef QT_GUI_PASSWORD_ECHO_DELAY +void tst_QLineEdit::passwordEchoDelay() +{ + QStyleOptionFrameV2 opt; + QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget); + + testWidget->setEchoMode(QLineEdit::Password); + testWidget->setFocus(); + testWidget->raise(); + QTRY_VERIFY(testWidget->hasFocus()); + + QTest::keyPress(testWidget, '0'); + QTest::keyPress(testWidget, '1'); + QTest::keyPress(testWidget, '2'); + QCOMPARE(testWidget->displayText(), QString(2, fillChar) + QLatin1Char('2')); + QTest::keyPress(testWidget, '3'); + QTest::keyPress(testWidget, '4'); + QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4')); + QTest::keyPress(testWidget, Qt::Key_Backspace); + QCOMPARE(testWidget->displayText(), QString(4, fillChar)); + QTest::keyPress(testWidget, '4'); + QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4')); + QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); + QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar)); + QTest::keyPress(testWidget, '5'); + QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5')); + testWidget->clearFocus(); + QVERIFY(!testWidget->hasFocus()); + QCOMPARE(testWidget->displayText(), QString(6, fillChar)); + testWidget->setFocus(); + QTRY_VERIFY(testWidget->hasFocus()); + QCOMPARE(testWidget->displayText(), QString(6, fillChar)); + QTest::keyPress(testWidget, '6'); + QCOMPARE(testWidget->displayText(), QString(6, fillChar) + QLatin1Char('6')); + + QInputMethodEvent ev; + ev.setCommitString(QLatin1String("7")); + QApplication::sendEvent(testWidget, &ev); + QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7')); + + // restore clean state + testWidget->setEchoMode(QLineEdit::Normal); +} +#endif + void tst_QLineEdit::maxLength_mask_data() { QTest::addColumn<QString>("mask"); @@ -3820,5 +3874,38 @@ void tst_QLineEdit::bidiLogicalMovement() } while (moved && i >= 0); } +void tst_QLineEdit::selectAndCursorPosition() +{ + testWidget->setText("This is a long piece of text"); + + testWidget->setSelection(0, 5); + QCOMPARE(testWidget->cursorPosition(), 5); + testWidget->setSelection(5, -5); + QCOMPARE(testWidget->cursorPosition(), 0); +} + +void tst_QLineEdit::inputMethodSelection() +{ + testWidget->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + testWidget->setSelection(0,0); + QSignalSpy selectionSpy(testWidget, SIGNAL(selectionChanged())); + + QCOMPARE(selectionSpy.count(), 0); + QCOMPARE(testWidget->selectionStart(), -1); + + testWidget->setSelection(0,5); + + QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(testWidget->selectionStart(), 0); + + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(testWidget, &event); + + QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(testWidget->selectionStart(), 12); +} + QTEST_MAIN(tst_QLineEdit) #include "tst_qlineedit.moc" diff --git a/tests/auto/qmessagebox/qmessagebox.pro b/tests/auto/qmessagebox/qmessagebox.pro index fe0e08aede..e3f6ddb1f6 100644 --- a/tests/auto/qmessagebox/qmessagebox.pro +++ b/tests/auto/qmessagebox/qmessagebox.pro @@ -7,5 +7,3 @@ INCLUDEPATH += . # Input SOURCES += tst_qmessagebox.cpp - -CONFIG+=insignificant_test diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp index 0913454263..6b737681b1 100644 --- a/tests/auto/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp @@ -127,9 +127,7 @@ private slots: void shortcut(); void staticSourceCompat(); - void staticBinaryCompat(); void instanceSourceCompat(); - void instanceBinaryCompat(); void testSymbols(); void incorrectDefaultButton(); @@ -407,19 +405,6 @@ void tst_QMessageBox::about() #endif } -// Old message box enums -const int Old_Ok = 1; -const int Old_Cancel = 2; -const int Old_Yes = 3; -const int Old_No = 4; -const int Old_Abort = 5; -const int Old_Retry = 6; -const int Old_Ignore = 7; -const int Old_YesAll = 8; -const int Old_NoAll = 9; -const int Old_Default = 0x100; -const int Old_Escape = 0x200; - void tst_QMessageBox::staticSourceCompat() { int ret; @@ -508,74 +493,6 @@ void tst_QMessageBox::instanceSourceCompat() QCOMPARE(exec(&mb, Qt::ALT + Qt::Key_Z), 1); } -void tst_QMessageBox::staticBinaryCompat() -{ - int ret; - - // binary compat tests for < 4.2 - keyToSend = Qt::Key_Enter; - sendKeySoon(); - ret = QMessageBox::information(0, "title", "text", Old_Yes, Old_No, 0); - int expectedButton = int(Old_Yes); -#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) - if (qobject_cast<QMacStyle *>(qApp->style())) - expectedButton = int(Old_No); -#elif !defined(QT_NO_STYLE_CLEANLOOKS) - if (qobject_cast<QCleanlooksStyle *>(qApp->style())) - expectedButton = int(Old_No); -#endif - QCOMPARE(ret, expectedButton); - QCOMPARE(keyToSend, -1); - - keyToSend = Qt::Key_Escape; - sendKeySoon(); - ret = QMessageBox::information(0, "title", "text", Old_Yes | Old_Escape, Old_No, 0); - QCOMPARE(ret, int(Old_Yes)); - QCOMPARE(keyToSend, -1); - - keyToSend = Qt::Key_Enter; - sendKeySoon(); - ret = QMessageBox::information(0, "title", "text", Old_Yes | Old_Default, Old_No, 0); - QCOMPARE(ret, int(Old_Yes)); - QCOMPARE(keyToSend, -1); - -#if 0 - keyToSend = Qt::Key_Escape; - sendKeySoon(); - ret = QMessageBox::information(0, "title", "text", Old_Yes, Old_No | Old_Default, 0); - QCOMPARE(ret, -1); - QCOMPARE(keyToSend, -1); -#endif - - keyToSend = Qt::Key_Escape; - sendKeySoon(); - ret = QMessageBox::information(0, "title", "text", Old_Yes | Old_Escape, Old_No | Old_Default, 0); - QCOMPARE(ret, Old_Yes); - QCOMPARE(keyToSend, -1); - - keyToSend = Qt::Key_Escape; - sendKeySoon(); - ret = QMessageBox::information(0, "title", "text", Old_Yes | Old_Default, Old_No | Old_Escape, 0); - QCOMPARE(ret, Old_No); - QCOMPARE(keyToSend, -1); - -} - -void tst_QMessageBox::instanceBinaryCompat() -{ - QMessageBox mb("Application name here", - "Saving the file will overwrite the original file on the disk.\n" - "Do you really want to save?", - QMessageBox::Information, - Old_Yes | Old_Default, - Old_No, - Old_Cancel | Old_Escape); - mb.setButtonText(Old_Yes, "Save"); - mb.setButtonText(Old_No, "Discard"); - QCOMPARE(exec(&mb, Qt::Key_Enter), int(Old_Yes)); - QCOMPARE(exec(&mb, Qt::Key_Escape), int(Old_Cancel)); -} - void tst_QMessageBox::testSymbols() { return; diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index 5fed6bb44e..7ad6a98a4d 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -65,6 +65,7 @@ private slots: void stressTest(); void tryLockRace(); void qtbug16115_trylock(); + void moreStress(); }; static const int iterations = 100; @@ -83,6 +84,8 @@ QMutex normalMutex, recursiveMutex(QMutex::Recursive); QSemaphore testsTurn; QSemaphore threadsTurn; +enum { waitTime = 100 }; + void tst_QMutex::tryLock() { // test non-recursive mutex @@ -109,18 +112,18 @@ void tst_QMutex::tryLock() threadsTurn.acquire(); QTime timer; timer.start(); - QVERIFY(!normalMutex.tryLock(1000)); - QVERIFY(timer.elapsed() >= 1000); + QVERIFY(!normalMutex.tryLock(waitTime)); + QVERIFY(timer.elapsed() >= waitTime); testsTurn.release(); threadsTurn.acquire(); timer.start(); - QVERIFY(normalMutex.tryLock(1000)); - QVERIFY(timer.elapsed() <= 1000); + QVERIFY(normalMutex.tryLock(waitTime)); + QVERIFY(timer.elapsed() <= waitTime); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); timer.start(); - QVERIFY(!normalMutex.tryLock(1000)); - QVERIFY(timer.elapsed() >= 1000); + QVERIFY(!normalMutex.tryLock(waitTime)); + QVERIFY(timer.elapsed() >= waitTime); QVERIFY(lockCount.testAndSetRelaxed(1, 0)); normalMutex.unlock(); testsTurn.release(); @@ -132,7 +135,7 @@ void tst_QMutex::tryLock() threadsTurn.acquire(); timer.start(); QVERIFY(normalMutex.tryLock(0)); - QVERIFY(timer.elapsed() < 1000); + QVERIFY(timer.elapsed() < waitTime); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); QVERIFY(!normalMutex.tryLock(0)); QVERIFY(lockCount.testAndSetRelaxed(1, 0)); @@ -158,13 +161,13 @@ void tst_QMutex::tryLock() normalMutex.unlock(); threadsTurn.release(); - // thread can't acquire lock, timeout = 1000 + // thread can't acquire lock, timeout = waitTime testsTurn.acquire(); normalMutex.lock(); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); threadsTurn.release(); - // thread can acquire lock, timeout = 1000 + // thread can acquire lock, timeout = waitTime testsTurn.acquire(); QVERIFY(lockCount.testAndSetRelaxed(1, 0)); normalMutex.unlock(); @@ -215,17 +218,17 @@ void tst_QMutex::tryLock() threadsTurn.acquire(); QTime timer; timer.start(); - QVERIFY(!recursiveMutex.tryLock(1000)); - QVERIFY(timer.elapsed() >= 1000); + QVERIFY(!recursiveMutex.tryLock(waitTime)); + QVERIFY(timer.elapsed() >= waitTime); QVERIFY(!recursiveMutex.tryLock(0)); testsTurn.release(); threadsTurn.acquire(); timer.start(); - QVERIFY(recursiveMutex.tryLock(1000)); - QVERIFY(timer.elapsed() <= 1000); + QVERIFY(recursiveMutex.tryLock(waitTime)); + QVERIFY(timer.elapsed() <= waitTime); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); - QVERIFY(recursiveMutex.tryLock(1000)); + QVERIFY(recursiveMutex.tryLock(waitTime)); QVERIFY(lockCount.testAndSetRelaxed(1, 2)); QVERIFY(lockCount.testAndSetRelaxed(2, 1)); recursiveMutex.unlock(); @@ -241,7 +244,7 @@ void tst_QMutex::tryLock() threadsTurn.acquire(); timer.start(); QVERIFY(recursiveMutex.tryLock(0)); - QVERIFY(timer.elapsed() < 1000); + QVERIFY(timer.elapsed() < waitTime); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); QVERIFY(recursiveMutex.tryLock(0)); QVERIFY(lockCount.testAndSetRelaxed(1, 2)); @@ -274,7 +277,7 @@ void tst_QMutex::tryLock() recursiveMutex.unlock(); threadsTurn.release(); - // thread can't acquire lock, timeout = 1000 + // thread can't acquire lock, timeout = waitTime testsTurn.acquire(); recursiveMutex.lock(); QVERIFY(lockCount.testAndSetRelaxed(0, 1)); @@ -282,7 +285,7 @@ void tst_QMutex::tryLock() QVERIFY(lockCount.testAndSetRelaxed(1, 2)); threadsTurn.release(); - // thread can acquire lock, timeout = 1000 + // thread can acquire lock, timeout = waitTime testsTurn.acquire(); QVERIFY(lockCount.testAndSetRelaxed(2, 1)); recursiveMutex.unlock(); @@ -436,7 +439,8 @@ void tst_QMutex::lock_unlock_locked_tryLock() } } -enum { one_minute = 60 * 1000, threadCount = 10 }; +enum { one_minute = 6 * 1000, //not really one minute, but else it is too long. + threadCount = 10 }; class StressTestThread : public QThread { @@ -497,7 +501,7 @@ public: do { if (mutex.tryLock()) mutex.unlock(); - } while (t.elapsed() < 20000); + } while (t.elapsed() < one_minute/2); } }; QMutex TryLockRaceThread::mutex; @@ -534,7 +538,7 @@ void tst_QMutex::qtbug16115_trylock() TrylockThread(QMutex &mut) : mut(mut) {} QMutex &mut; void run() { - for (int i = 0; i < 1000000; ++i) { + for (int i = 0; i < 100000; ++i) { if (mut.tryLock(0)) { if ((++qtbug16115_trylock_counter) != 1) ++qtbug16115_failure_count; @@ -553,7 +557,7 @@ void tst_QMutex::qtbug16115_trylock() t2.start(); t3.start(); - for (int i = 0; i < 1000000; ++i) { + for (int i = 0; i < 100000; ++i) { mut.lock(); if ((++qtbug16115_trylock_counter) != 1) ++qtbug16115_failure_count; @@ -567,5 +571,70 @@ void tst_QMutex::qtbug16115_trylock() QCOMPARE(qtbug16115_failure_count, 0); } + +class MoreStressTestThread : public QThread +{ + QTime t; +public: + static QAtomicInt lockCount; + static QAtomicInt sentinel[threadCount]; + static QMutex mutex[threadCount]; + static QAtomicInt errorCount; + void start() + { + t.start(); + QThread::start(); + } + void run() + { + quint64 i = 0; + while (t.elapsed() < one_minute) { + i++; + uint nb = (i * 9 + lockCount * 13) % threadCount; + QMutexLocker locker(&mutex[nb]); + if (sentinel[nb]) errorCount.ref(); + if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref(); + if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref(); + if (sentinel[nb]) errorCount.ref(); + lockCount.ref(); + nb = (nb * 17 + i * 5 + lockCount * 3) % threadCount; + if (mutex[nb].tryLock()) { + if (sentinel[nb]) errorCount.ref(); + if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref(); + if (!sentinel[nb].testAndSetRelaxed(16, 0)) errorCount.ref(); + if (sentinel[nb]) errorCount.ref(); + lockCount.ref(); + mutex[nb].unlock(); + } + nb = (nb * 15 + i * 47 + lockCount * 31) % threadCount; + if (mutex[nb].tryLock(2)) { + if (sentinel[nb]) errorCount.ref(); + if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref(); + if (!sentinel[nb].testAndSetRelaxed(53, 0)) errorCount.ref(); + if (sentinel[nb]) errorCount.ref(); + lockCount.ref(); + mutex[nb].unlock(); + } + } + } +}; +QMutex MoreStressTestThread::mutex[threadCount]; +QAtomicInt MoreStressTestThread::lockCount; +QAtomicInt MoreStressTestThread::sentinel[threadCount]; +QAtomicInt MoreStressTestThread::errorCount = 0; + +void tst_QMutex::moreStress() +{ + MoreStressTestThread threads[threadCount]; + for (int i = 0; i < threadCount; ++i) + threads[i].start(); + QVERIFY(threads[0].wait(one_minute + 10000)); + for (int i = 1; i < threadCount; ++i) + QVERIFY(threads[i].wait(10000)); + qDebug("locked %d times", int(MoreStressTestThread::lockCount)); + QCOMPARE(int(MoreStressTestThread::errorCount), 0); +} + + QTEST_MAIN(tst_QMutex) #include "tst_qmutex.moc" diff --git a/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro b/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro index 7b968723cd..885dbf796c 100644 --- a/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro +++ b/tests/auto/qnetworkaddressentry/qnetworkaddressentry.pro @@ -4,5 +4,3 @@ SOURCES += tst_qnetworkaddressentry.cpp QT = core network symbian: TARGET.CAPABILITY = NetworkServices - -CONFIG+=insignificant_test diff --git a/tests/auto/qnetworkaddressentry/tst_qnetworkaddressentry.cpp b/tests/auto/qnetworkaddressentry/tst_qnetworkaddressentry.cpp index cf14aabb41..42b9af8dd3 100644 --- a/tests/auto/qnetworkaddressentry/tst_qnetworkaddressentry.cpp +++ b/tests/auto/qnetworkaddressentry/tst_qnetworkaddressentry.cpp @@ -97,7 +97,7 @@ void tst_QNetworkAddressEntry::prefixAndNetmask_data() // IPv4 set: QHostAddress ipv4(QHostAddress::LocalHost); - QTest::newRow("v4/0") << ipv4 << QHostAddress(QHostAddress::Any) << 0; + QTest::newRow("v4/0") << ipv4 << QHostAddress(QHostAddress::AnyIPv4) << 0; QTest::newRow("v4/32") << ipv4 << QHostAddress("255.255.255.255") << 32; QTest::newRow("v4/24") << ipv4 << QHostAddress("255.255.255.0") << 24; QTest::newRow("v4/23") << ipv4 << QHostAddress("255.255.254.0") << 23; diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index f54dfa3f68..9873c3e357 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -335,7 +335,7 @@ void tst_QProcess::crashTest() QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError))); QSignalSpy spy2(process, SIGNAL(finished(int, QProcess::ExitStatus))); - QVERIFY(process->waitForFinished(5000)); + QVERIFY(process->waitForFinished(30000)); QCOMPARE(spy.count(), 1); QCOMPARE(*static_cast<const QProcess::ProcessError *>(spy.at(0).at(0).constData()), QProcess::Crashed); @@ -372,7 +372,7 @@ void tst_QProcess::crashTest2() QObject::connect(process, SIGNAL(finished(int)), this, SLOT(exitLoopSlot())); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Failed to detect crash : operation timed out"); @@ -673,7 +673,7 @@ void tst_QProcess::exitStatus() for (int i = 0; i < processList.count(); ++i) { process->start(processList.at(i)); QVERIFY(process->waitForStarted(5000)); - QVERIFY(process->waitForFinished(5000)); + QVERIFY(process->waitForFinished(30000)); QCOMPARE(process->exitStatus(), exitStatus.at(i)); } diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp index e0680c4257..eb78057b5e 100644 --- a/tests/auto/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/qrawfont/tst_qrawfont.cpp @@ -47,7 +47,6 @@ class tst_QRawFont: public QObject { Q_OBJECT - #if !defined(QT_NO_RAWFONT) private slots: void invalidRawFont(); @@ -94,6 +93,11 @@ private slots: void rawFontSetPixelSize_data(); void rawFontSetPixelSize(); + +#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) + void multipleRawFontsFromData(); +#endif + #endif // QT_NO_RAWFONT }; @@ -843,6 +847,25 @@ void tst_QRawFont::rawFontSetPixelSize() QCOMPARE(rawFont.pixelSize(), 24.0); } +#if defined(Q_WS_X11) || defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) +void tst_QRawFont::multipleRawFontsFromData() +{ + QFile file(QString::fromLatin1(SRCDIR "testfont.ttf")); + QRawFont testFont; + if (file.open(QIODevice::ReadOnly)) { + testFont.loadFromData(file.readAll(), 11, QFont::PreferDefaultHinting); + file.close(); + } + file.setFileName(QLatin1String(SRCDIR "testfont_bold_italic.ttf")); + QRawFont testFontBoldItalic; + if (file.open(QIODevice::ReadOnly)) + testFontBoldItalic.loadFromData(file.readAll(), 11, QFont::PreferDefaultHinting); + + QVERIFY(testFont.familyName() != (testFontBoldItalic.familyName()) + || testFont.styleName() != (testFontBoldItalic.styleName())); +} +#endif + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QRawFont) diff --git a/tests/auto/qregexpvalidator/tst_qregexpvalidator.cpp b/tests/auto/qregexpvalidator/tst_qregexpvalidator.cpp index d8ef92a439..23cd5b1ef1 100644 --- a/tests/auto/qregexpvalidator/tst_qregexpvalidator.cpp +++ b/tests/auto/qregexpvalidator/tst_qregexpvalidator.cpp @@ -115,9 +115,12 @@ void tst_QRegExpValidator::validate() QFETCH( int, state ); QRegExpValidator rv( 0 ); + QSignalSpy spy(&rv, SIGNAL(regExpChanged(const QRegExp&))); + rv.setRegExp( QRegExp( rx ) ); int dummy; QCOMPARE( (int)rv.validate( value, dummy ), state ); + QCOMPARE(spy.count(), 1); } QTEST_MAIN(tst_QRegExpValidator) diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp index cc4ab67d53..5f1a6211aa 100644 --- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp +++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp @@ -92,6 +92,7 @@ private slots: void escapedTableName(); void whiteSpaceInIdentifiers(); void psqlSchemaTest(); + void selectAfterUpdate(); private: void dropTestTables( QSqlDatabase db ); @@ -1467,5 +1468,27 @@ void tst_QSqlRelationalTableModel::psqlSchemaTest() QVERIFY_SQL(model, select()); } +void tst_QSqlRelationalTableModel::selectAfterUpdate() +{ + QFETCH_GLOBAL(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + + QSqlRelationalTableModel model(0, db); + model.setTable(reltest1); + model.setRelation(2, QSqlRelation(reltest2, "tid", "title")); + QVERIFY_SQL(model, select()); + QVERIFY(model.relationModel(2)->rowCount() == 2); + { + QSqlQuery q(db); + QVERIFY_SQL(q, exec("insert into " + reltest2 + " values(3, 'mrs')")); + model.relationModel(2)->select(); + } + QVERIFY(model.relationModel(2)->rowCount() == 3); + QVERIFY(model.setData(model.index(0,2), 3)); + QVERIFY(model.submitAll()); + QCOMPARE(model.data(model.index(0,2)), QVariant("mrs")); +} + QTEST_MAIN(tst_QSqlRelationalTableModel) #include "tst_qsqlrelationaltablemodel.moc" diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 451465df0c..e0bc029c71 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -118,6 +118,9 @@ private slots: void subjectAndIssuerAttributes(); void verify(); + // helper for verbose test failure messages + QString toString(const QList<QSslError>&); + // ### add tests for certificate bundles (multiple certificates concatenated into a single // structure); both PEM and DER formatted #endif @@ -907,10 +910,16 @@ void tst_QSslCertificate::verify() QList<QSslError> errors; QList<QSslCertificate> toVerify; + // Like QVERIFY, but be verbose about the content of `errors' when failing +#define VERIFY_VERBOSE(A) \ + QVERIFY2((A), \ + qPrintable(QString("errors: %1").arg(toString(errors))) \ + ) + // Empty chain is unspecified error errors = QSslCertificate::verify(toVerify); - QVERIFY(errors.count() == 1); - QVERIFY(errors[0] == QSslError(QSslError::UnspecifiedError)); + VERIFY_VERBOSE(errors.count() == 1); + VERIFY_VERBOSE(errors[0] == QSslError(QSslError::UnspecifiedError)); errors.clear(); // Verify a valid cert signed by a CA @@ -920,7 +929,8 @@ void tst_QSslCertificate::verify() toVerify = QSslCertificate::fromPath(SRCDIR "verify-certs/test-ocsp-good-cert.pem"); errors = QSslCertificate::verify(toVerify); - QVERIFY(errors.count() == 0); + QEXPECT_FAIL("", "QTBUG-20582 fails since ~5am, 27th July 2011", Continue); + VERIFY_VERBOSE(errors.count() == 0); errors.clear(); // Test a blacklisted certificate @@ -939,8 +949,8 @@ void tst_QSslCertificate::verify() // This one is expired and untrusted toVerify = QSslCertificate::fromPath(SRCDIR "more-certificates/cert-large-serial-number.pem"); errors = QSslCertificate::verify(toVerify); - QVERIFY(errors.contains(QSslError(QSslError::SelfSignedCertificate, toVerify[0]))); - QVERIFY(errors.contains(QSslError(QSslError::CertificateExpired, toVerify[0]))); + VERIFY_VERBOSE(errors.contains(QSslError(QSslError::SelfSignedCertificate, toVerify[0]))); + VERIFY_VERBOSE(errors.contains(QSslError(QSslError::CertificateExpired, toVerify[0]))); errors.clear(); toVerify.clear(); @@ -948,23 +958,38 @@ void tst_QSslCertificate::verify() toVerify << QSslCertificate::fromPath(SRCDIR "verify-certs/test-intermediate-not-ca-cert.pem").first(); toVerify << QSslCertificate::fromPath(SRCDIR "verify-certs/test-ocsp-good-cert.pem").first(); errors = QSslCertificate::verify(toVerify); - QVERIFY(errors.contains(QSslError(QSslError::InvalidCaCertificate, toVerify[1]))); + VERIFY_VERBOSE(errors.contains(QSslError(QSslError::InvalidCaCertificate, toVerify[1]))); toVerify.clear(); // This one is signed by a valid cert, and the signer is a valid CA toVerify << QSslCertificate::fromPath(SRCDIR "verify-certs/test-intermediate-is-ca-cert.pem").first(); toVerify << QSslCertificate::fromPath(SRCDIR "verify-certs/test-intermediate-ca-cert.pem").first(); errors = QSslCertificate::verify(toVerify); - QVERIFY(errors.length() == 0); + QEXPECT_FAIL("", "QTBUG-20582 fails since ~5am, 27th July 2011", Continue); + VERIFY_VERBOSE(errors.count() == 0); // Recheck the above with hostname validation errors = QSslCertificate::verify(toVerify, QLatin1String("example.com")); - QVERIFY(errors.length() == 0); + QEXPECT_FAIL("", "QTBUG-20582 fails since ~5am, 27th July 2011", Continue); + VERIFY_VERBOSE(errors.count() == 0); // Recheck the above with a bad hostname errors = QSslCertificate::verify(toVerify, QLatin1String("fail.example.com")); - QVERIFY(errors.contains(QSslError(QSslError::HostNameMismatch, toVerify[0]))); + VERIFY_VERBOSE(errors.contains(QSslError(QSslError::HostNameMismatch, toVerify[0]))); toVerify.clear(); + +#undef VERIFY_VERBOSE +} + +QString tst_QSslCertificate::toString(const QList<QSslError>& errors) +{ + QStringList errorStrings; + + foreach (const QSslError& error, errors) { + errorStrings.append(QLatin1String("\"") + error.errorString() + QLatin1String("\"")); + } + + return QLatin1String("[ ") + errorStrings.join(QLatin1String(", ")) + QLatin1String(" ]"); } #endif // QT_NO_OPENSSL diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index 8c725fa109..f7a725c164 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -5110,7 +5110,7 @@ void tst_QString::toUpperLower_icu() void tst_QString::literals() { -#if defined(QT_QSTRING_UNICODE_MARKER) && (defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU)) +#if defined(QT_UNICODE_LITERAL) && (defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU)) QString str(QStringLiteral("abcd")); QVERIFY(str.length() == 4); diff --git a/tests/auto/qstringbuilder1/stringbuilder.cpp b/tests/auto/qstringbuilder1/stringbuilder.cpp index de7ad656e4..4d453b0585 100644 --- a/tests/auto/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/qstringbuilder1/stringbuilder.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include <QtTest/QtTest> + #define LITERAL "some literal" #define LITERAL_LEN (sizeof(LITERAL)-1) #define LITERAL_EXTRA "some literal" "EXTRA" @@ -48,6 +50,12 @@ #define UTF8_LITERAL_LEN (sizeof(UTF8_LITERAL)-1) #define UTF8_LITERAL_EXTRA "s\xc3\xb6m\xc3\xab l\xc3\xaft\xc3\xabr\xc3\xa4l" "EXTRA" +#ifdef Q_COMPILER_UNICODE_STRINGS +// "some literal", but replacing all vocals by their umlauted UTF-8 string :) +#define UNICODE_LITERAL u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" +#define UNICODE_LITERAL_LEN ((sizeof(UNICODE_LITERAL) - 1) / 2) +#define UNICODE_LITERAL_EXTRA u"s\u00f6m\u00eb l\u00eft\u00ebr\u00e4l" "EXTRA" +#endif //fix for gcc4.0: if the operator+ does not exist without QT_USE_FAST_OPERATOR_PLUS #ifndef QT_USE_FAST_CONCATENATION @@ -68,6 +76,7 @@ void runScenario() QStringRef stringref(&string, 2, 10); QLatin1Char achar('c'); QString r2(QLatin1String(LITERAL LITERAL)); + QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); QString r; r = l1literal Q l1literal; @@ -80,10 +89,23 @@ void runScenario() QCOMPARE(r, r2); r = string P l1string; QCOMPARE(r, r2); + r = string Q QStringLiteral(LITERAL); + QCOMPARE(r, r2); + r = QStringLiteral(LITERAL) Q string; + QCOMPARE(r, r2); + r = l1string Q QStringLiteral(LITERAL); + QCOMPARE(r, r2); r = string + achar; QCOMPARE(r, QString(string P achar)); r = achar + string; QCOMPARE(r, QString(achar P string)); + +#ifdef Q_COMPILER_UNICODE_STRINGS + r = QStringLiteral(UNICODE_LITERAL); + r = r Q QStringLiteral(UNICODE_LITERAL); + QCOMPARE(r, r3); +#endif + #ifndef QT_NO_CAST_FROM_ASCII r = string P LITERAL; QCOMPARE(r, r2); @@ -96,6 +118,11 @@ void runScenario() r = string P ba; QCOMPARE(r, r2); + r = string P QByteArrayLiteral(LITERAL); + QCOMPARE(r, r2); + r = QByteArrayLiteral(LITERAL) P string; + QCOMPARE(r, r2); + static const char badata[] = LITERAL_EXTRA; ba = QByteArray::fromRawData(badata, LITERAL_LEN); r = ba P string; @@ -109,24 +136,23 @@ void runScenario() QCOMPARE(QTextCodec::codecForCStrings()->name(), QByteArray("UTF-8")); string = QString::fromUtf8(UTF8_LITERAL); - r2 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); ba = UTF8_LITERAL; r = string P UTF8_LITERAL; - QCOMPARE(r.size(), r2.size()); - QCOMPARE(r, r2); + QCOMPARE(r.size(), r3.size()); + QCOMPARE(r, r3); r = UTF8_LITERAL P string; - QCOMPARE(r, r2); + QCOMPARE(r, r3); r = ba P string; - QCOMPARE(r, r2); + QCOMPARE(r, r3); r = string P ba; - QCOMPARE(r, r2); + QCOMPARE(r, r3); ba = QByteArray::fromRawData(UTF8_LITERAL_EXTRA, UTF8_LITERAL_LEN); r = ba P string; - QCOMPARE(r, r2); + QCOMPARE(r, r3); r = string P ba; - QCOMPARE(r, r2); + QCOMPARE(r, r3); ba = QByteArray(); // empty r = ba P string; @@ -152,6 +178,11 @@ void runScenario() QByteArray superba = ba P ba P LITERAL; QCOMPARE(superba, QByteArray(LITERAL LITERAL LITERAL)); + ba = QByteArrayLiteral(LITERAL); + QCOMPARE(ba, QByteArray(LITERAL)); + superba = ba P QByteArrayLiteral(LITERAL) P LITERAL; + QCOMPARE(superba, QByteArray(LITERAL LITERAL LITERAL)); + QByteArray testWith0 = ba P "test\0with\0zero" P ba; QCOMPARE(testWith0, QByteArray(LITERAL "test" LITERAL)); diff --git a/tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro b/tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro index ee2b77d63c..62d4908e69 100644 --- a/tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro +++ b/tests/auto/qtconcurrentfilter/qtconcurrentfilter.pro @@ -3,4 +3,4 @@ DEFINES += QT_STRICT_ITERATORS SOURCES += tst_qtconcurrentfilter.cpp QT = core CONFIG += parallel_test -CONFIG += parallel_test +linux*:CONFIG += insignificant_test diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index b566e5cebd..b72e61f374 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -575,7 +575,7 @@ void tst_QTcpServer::addressReusable() socket.connectToHost(QHostAddress::LocalHost, 49199); QVERIFY(socket.waitForConnected(5000)); - QVERIFY(process.waitForFinished(5000)); + QVERIFY(process.waitForFinished(30000)); // Give the system some time. QTest::qSleep(10); diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 67c610b21a..f10879d284 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -207,6 +207,8 @@ private slots: void bidiLogicalMovement_data(); void bidiLogicalMovement(); + void inputMethodSelection(); + private: void createSelection(); int blockCount() const; @@ -2365,5 +2367,30 @@ void tst_QTextEdit::bidiLogicalMovement() } while (moved && i >= 0); } +void tst_QTextEdit::inputMethodSelection() +{ + ed->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + + QSignalSpy selectionSpy(ed, SIGNAL(selectionChanged())); + QTextCursor cursor = ed->textCursor(); + cursor.setPosition(0); + cursor.setPosition(5, QTextCursor::KeepAnchor); + ed->setTextCursor(cursor); + + QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(ed->textCursor().selectionStart(), 0); + QCOMPARE(ed->textCursor().selectionEnd(), 5); + + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(ed, &event); + + QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(ed->textCursor().selectionStart(), 12); + QCOMPARE(ed->textCursor().selectionEnd(), 17); +} + + QTEST_MAIN(tst_QTextEdit) #include "tst_qtextedit.moc" diff --git a/tests/auto/qtextscriptengine/qtextscriptengine.pro b/tests/auto/qtextscriptengine/qtextscriptengine.pro index 1bd80d35b6..0f5076e2ed 100644 --- a/tests/auto/qtextscriptengine/qtextscriptengine.pro +++ b/tests/auto/qtextscriptengine/qtextscriptengine.pro @@ -5,5 +5,3 @@ QT += core-private gui-private HEADERS += SOURCES += tst_qtextscriptengine.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src - -CONFIG+=insignificant_test diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp index 6cbff362bc..cbed675cb7 100644 --- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp @@ -76,9 +76,6 @@ //TESTED_CLASS= //TESTED_FILES= gui/text/qscriptengine.cpp -// This test depends on the fonts in the following package being installed: -// http://people.freedesktop.org/~hausmann/harfbuzz-test-fonts-0.1.tar.bz2 - class tst_QTextScriptEngine : public QObject { Q_OBJECT @@ -89,6 +86,7 @@ public: public slots: + void initTestCase(); void init(); void cleanup(); private slots: @@ -111,9 +109,13 @@ private slots: void mirroredChars_data(); void mirroredChars(); + +private: + bool haveTestFonts; }; tst_QTextScriptEngine::tst_QTextScriptEngine() + : haveTestFonts(qgetenv("QT_HAVE_TEST_FONTS") == QByteArray("1")) { } @@ -121,6 +123,21 @@ tst_QTextScriptEngine::~tst_QTextScriptEngine() { } +void tst_QTextScriptEngine::initTestCase() +{ +#if defined(Q_WS_X11) + if (!haveTestFonts) { + qWarning( + "Some of these tests depend on the internals of some test fonts which are not freely " + "distributable.\n" + "These tests will be skipped.\n" + "If you have the fonts available, set QT_HAVE_TEST_FONTS=1 in your environment and " + "run the test again." + ); + } +#endif +} + void tst_QTextScriptEngine::init() { } @@ -184,6 +201,10 @@ static bool shaping( const QFont &f, const ShapeTable *s) void tst_QTextScriptEngine::devanagari() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Devanagari).contains("Raghindi")) { QFont f("Raghindi"); @@ -233,7 +254,7 @@ void tst_QTextScriptEngine::devanagari() ++s; } } else { - QSKIP("couln't find Raghindi", SkipAll); + QSKIP("couldn't find Raghindi", SkipAll); } } @@ -296,6 +317,10 @@ void tst_QTextScriptEngine::devanagari() void tst_QTextScriptEngine::bengali() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Bengali).contains("Akaash")) { QFont f("Akaash"); @@ -403,7 +428,7 @@ void tst_QTextScriptEngine::bengali() ++s; } } else { - QSKIP("couln't find Akaash", SkipAll); + QSKIP("couldn't find Akaash", SkipAll); } } { @@ -508,7 +533,7 @@ void tst_QTextScriptEngine::bengali() ++s; } } else { - QSKIP("couln't find Mukti", SkipAll); + QSKIP("couldn't find Mukti", SkipAll); } } { @@ -536,7 +561,7 @@ void tst_QTextScriptEngine::bengali() ++s; } } else { - QSKIP("couln't find Likhan", SkipAll); + QSKIP("couldn't find Likhan", SkipAll); } } #else @@ -547,6 +572,10 @@ void tst_QTextScriptEngine::bengali() void tst_QTextScriptEngine::gurmukhi() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Gurmukhi).contains("Lohit Punjabi")) { QFont f("Lohit Punjabi"); @@ -563,7 +592,7 @@ void tst_QTextScriptEngine::gurmukhi() ++s; } } else { - QSKIP("couln't find Lohit Punjabi", SkipAll); + QSKIP("couldn't find Lohit Punjabi", SkipAll); } } #endif @@ -572,6 +601,10 @@ void tst_QTextScriptEngine::gurmukhi() void tst_QTextScriptEngine::oriya() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Oriya).contains("utkal")) { QFont f("utkal"); @@ -600,7 +633,7 @@ void tst_QTextScriptEngine::oriya() ++s; } } else { - QSKIP("couln't find utkal", SkipAll); + QSKIP("couldn't find utkal", SkipAll); } } #else @@ -612,6 +645,10 @@ void tst_QTextScriptEngine::oriya() void tst_QTextScriptEngine::tamil() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Tamil).contains("AkrutiTml1")) { QFont f("AkrutiTml1"); @@ -677,7 +714,7 @@ void tst_QTextScriptEngine::tamil() ++s; } } else { - QSKIP("couln't find AkrutiTml1", SkipAll); + QSKIP("couldn't find AkrutiTml1", SkipAll); } } #else @@ -689,6 +726,10 @@ void tst_QTextScriptEngine::tamil() void tst_QTextScriptEngine::telugu() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Telugu).contains("Pothana2000")) { QFont f("Pothana2000"); @@ -725,7 +766,7 @@ void tst_QTextScriptEngine::telugu() ++s; } } else { - QSKIP("couln't find Pothana2000", SkipAll); + QSKIP("couldn't find Pothana2000", SkipAll); } } #else @@ -772,7 +813,7 @@ void tst_QTextScriptEngine::kannada() ++s; } } else { - QSKIP("couln't find Sampige", SkipAll); + QSKIP("couldn't find Sampige", SkipAll); } } { @@ -803,7 +844,7 @@ void tst_QTextScriptEngine::kannada() ++s; } } else { - QSKIP("couln't find Tunga", SkipAll); + QSKIP("couldn't find Tunga", SkipAll); } } #else @@ -816,6 +857,10 @@ void tst_QTextScriptEngine::kannada() void tst_QTextScriptEngine::malayalam() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Malayalam).contains("AkrutiMal2")) { QFont f("AkrutiMal2"); @@ -864,7 +909,7 @@ void tst_QTextScriptEngine::malayalam() ++s; } } else { - QSKIP("couln't find AkrutiMal2", SkipAll); + QSKIP("couldn't find AkrutiMal2", SkipAll); } } { @@ -892,7 +937,7 @@ void tst_QTextScriptEngine::malayalam() ++s; } } else { - QSKIP("couln't find Rachana", SkipAll); + QSKIP("couldn't find Rachana", SkipAll); } } @@ -904,6 +949,10 @@ void tst_QTextScriptEngine::malayalam() void tst_QTextScriptEngine::sinhala() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Sinhala).contains("Malithi Web")) { QFont f("Malithi Web"); @@ -930,7 +979,7 @@ void tst_QTextScriptEngine::sinhala() ++s; } } else { - QSKIP("couln't find Malithi Web", SkipAll); + QSKIP("couldn't find Malithi Web", SkipAll); } } #else @@ -942,6 +991,10 @@ void tst_QTextScriptEngine::sinhala() void tst_QTextScriptEngine::khmer() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Khmer).contains("Khmer OS")) { QFont f("Khmer OS"); @@ -974,7 +1027,7 @@ void tst_QTextScriptEngine::khmer() ++s; } } else { - QSKIP("couln't find Khmer OS", SkipAll); + QSKIP("couldn't find Khmer OS", SkipAll); } } #else @@ -985,6 +1038,10 @@ void tst_QTextScriptEngine::khmer() void tst_QTextScriptEngine::linearB() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Any).contains("Penuturesu")) { QFont f("Penuturesu"); @@ -1001,7 +1058,7 @@ void tst_QTextScriptEngine::linearB() ++s; } } else { - QSKIP("couln't find Penuturesu", SkipAll); + QSKIP("couldn't find Penuturesu", SkipAll); } } #else @@ -1060,6 +1117,10 @@ static bool decomposedShaping( const QFont &f, const QChar &ch) void tst_QTextScriptEngine::greek() { #if defined(Q_WS_X11) + if (!haveTestFonts) { + QSKIP("Test fonts are not available", SkipAll); + } + { if (QFontDatabase().families(QFontDatabase::Any).contains("DejaVu Sans")) { QFont f("DejaVu Sans"); @@ -1075,7 +1136,7 @@ void tst_QTextScriptEngine::greek() QVERIFY( decomposedShaping(f, QChar(uc)) ); } } else { - QSKIP("couln't find DejaVu Sans", SkipAll); + QSKIP("couldn't find DejaVu Sans", SkipAll); } } @@ -1111,7 +1172,7 @@ void tst_QTextScriptEngine::greek() ++s; } } else { - QSKIP("couln't find SBL_grk", SkipAll); + QSKIP("couldn't find SBL_grk", SkipAll); } } #else diff --git a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp index c677d17fbe..6545df9189 100644 --- a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp @@ -491,7 +491,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (thread[y].wait(exited > 0 ? 3 : 1000)) { + if (thread[y].wait(exited > 0 ? 10 : 1000)) { thread_exited[y] = TRUE; ++exited; } @@ -535,7 +535,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (rwthread[y].wait(exited > 0 ? 3 : 1000)) { + if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { thread_exited[y] = TRUE; ++exited; } @@ -587,7 +587,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (thread[y].wait(exited > 0 ? 3 : 1000)) { + if (thread[y].wait(exited > 0 ? 10 : 1000)) { thread_exited[y] = TRUE; ++exited; } @@ -633,7 +633,7 @@ void tst_QWaitCondition::wakeOne() for (int y = 0; y < ThreadCount; ++y) { if (thread_exited[y]) continue; - if (rwthread[y].wait(exited > 0 ? 3 : 1000)) { + if (rwthread[y].wait(exited > 0 ? 10 : 1000)) { thread_exited[y] = TRUE; ++exited; } |