diff options
Diffstat (limited to 'tests')
33 files changed, 718 insertions, 195 deletions
diff --git a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp index b00fd0dfd4..d1aadab7d8 100644 --- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp +++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp @@ -53,11 +53,7 @@ public: // test data: QTextCodec *codec; QString (*from8BitPtr)(const char *, int); -#ifdef Q_COMPILER_REF_QUALIFIERS - QByteArray (QString:: *to8Bit)() const &; -#else - QByteArray (QString:: *to8Bit)() const; -#endif + static QByteArray to8Bit(const QString &); inline QString from8Bit(const QByteArray &ba) { return from8BitPtr(ba.constData(), ba.length()); } @@ -97,14 +93,21 @@ void tst_Utf8::init() if (useLocale) { codec = QTextCodec::codecForLocale(); from8BitPtr = &QString::fromLocal8Bit; - to8Bit = &QString::toLocal8Bit; } else { codec = QTextCodec::codecForMib(106); from8BitPtr = &QString::fromUtf8; - to8Bit = &QString::toUtf8; } } +QByteArray tst_Utf8::to8Bit(const QString &s) +{ + QFETCH_GLOBAL(bool, useLocale); + if (useLocale) + return s.toLocal8Bit(); + else + return s.toUtf8(); +} + void tst_Utf8::roundTrip_data() { QTest::addColumn<QByteArray>("utf8"); @@ -114,10 +117,10 @@ void tst_Utf8::roundTrip_data() QTest::newRow("nul") << QByteArray("", 1) << QString(QChar(QChar::Null)); static const char ascii[] = "This is a standard US-ASCII message"; - QTest::newRow("ascii") << QByteArray(ascii) << ascii; + QTest::newRow("ascii") << QByteArray(ascii) << QString::fromLatin1(ascii); static const char ascii2[] = "\1This\2is\3an\4US-ASCII\020 message interspersed with control chars"; - QTest::newRow("ascii2") << QByteArray(ascii2) << ascii2; + QTest::newRow("ascii2") << QByteArray(ascii2) << QString::fromLatin1(ascii2); static const char utf8_1[] = "\302\240"; // NBSP QTest::newRow("utf8_1") << QByteArray(utf8_1) << QString(QChar(QChar::Nbsp)); @@ -161,11 +164,20 @@ void tst_Utf8::roundTrip() QFETCH(QByteArray, utf8); QFETCH(QString, utf16); - QCOMPARE((utf16.*to8Bit)(), utf8); + QCOMPARE(to8Bit(utf16), utf8); + QCOMPARE(from8Bit(utf8), utf16); + + QCOMPARE(to8Bit(from8Bit(utf8)), utf8); + QCOMPARE(from8Bit(to8Bit(utf16)), utf16); + + // repeat with a longer message + utf8.prepend("12345678901234"); + utf16.prepend(QLatin1String("12345678901234")); + QCOMPARE(to8Bit(utf16), utf8); QCOMPARE(from8Bit(utf8), utf16); - QCOMPARE((from8Bit(utf8).*to8Bit)(), utf8); - QCOMPARE(from8Bit((utf16.*to8Bit)()), utf16); + QCOMPARE(to8Bit(from8Bit(utf8)), utf8); + QCOMPARE(from8Bit(to8Bit(utf16)), utf16); } void tst_Utf8::charByChar_data() diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index a58c7dfb4b..4f7ddce9c3 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -405,6 +405,13 @@ void tst_QFileSystemWatcher::removePaths() watcher.removePaths(paths); } +static QByteArray msgFileOperationFailed(const char *what, const QFile &f) +{ + return what + QByteArrayLiteral(" failed on \"") + + QDir::toNativeSeparators(f.fileName()).toLocal8Bit() + + QByteArrayLiteral("\": ") + f.errorString().toLocal8Bit(); +} + void tst_QFileSystemWatcher::watchFileAndItsDirectory() { QFETCH(QString, backend); @@ -420,14 +427,10 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QString testFileName = testDir.filePath("testFile.txt"); QString secondFileName = testDir.filePath("testFile2.txt"); - QFile::remove(secondFileName); QFile testFile(testFileName); - testFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner); - testFile.remove(); - - QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate)); - testFile.write(QByteArray("hello")); + QVERIFY2(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgFileOperationFailed("open", testFile)); + QVERIFY2(testFile.write(QByteArrayLiteral("hello")) > 0, msgFileOperationFailed("write", testFile)); testFile.close(); QFileSystemWatcher watcher; @@ -449,8 +452,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() // wait before modifying the directory... QTest::qWait(2000); - QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate)); - testFile.write(QByteArray("hello again")); + QVERIFY2(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgFileOperationFailed("open", testFile)); + QVERIFY2(testFile.write(QByteArrayLiteral("hello again")), msgFileOperationFailed("write", testFile)); testFile.close(); #ifdef Q_OS_MAC @@ -472,8 +475,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() fileChangedSpy.clear(); dirChangedSpy.clear(); QFile secondFile(secondFileName); - secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate); - secondFile.write("Foo"); + QVERIFY2(secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate), msgFileOperationFailed("open", secondFile)); + QVERIFY2(secondFile.write(QByteArrayLiteral("Foo")) > 0, msgFileOperationFailed("write", secondFile)); secondFile.close(); timer.start(3000); @@ -491,17 +494,17 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() dirChangedSpy.clear(); - QFile::remove(testFileName); + QVERIFY(QFile::remove(testFileName)); QTRY_VERIFY(fileChangedSpy.count() > 0); - QCOMPARE(dirChangedSpy.count(), 1); + QTRY_COMPARE(dirChangedSpy.count(), 1); fileChangedSpy.clear(); dirChangedSpy.clear(); // removing a deleted file should fail QVERIFY(!watcher.removePath(testFileName)); - QFile::remove(secondFileName); + QVERIFY(QFile::remove(secondFileName)); timer.start(3000); eventLoop.exec(); diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index c19e80bff3..2ae085cb0b 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -247,6 +247,13 @@ private: QString testFileName; }; +void runOnExit() +{ + QByteArray buffer; + QTextStream(&buffer) << "This will try to use QTextCodec::codecForLocale" << endl; +} +Q_DESTRUCTOR_FUNCTION(runOnExit) + tst_QTextStream::tst_QTextStream() : tempDir(QDir::tempPath() + "/tst_qtextstream.XXXXXX") { diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 6e183f3212..cdcbd19ae8 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -1863,7 +1863,7 @@ void tst_QByteArray::reserve() QCOMPARE(qba.capacity(), capacity); QCOMPARE(copy.capacity(), capacity); - copy = qba; + qba = copy; qba.reserve(capacity * 2); QCOMPARE(qba.size(), capacity); QCOMPARE(qba.capacity(), capacity * 2); diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index bda5fc707a..8f9376f8b6 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -715,6 +715,10 @@ void tst_QDateTime::toString_isoDate_data() QTest::newRow("negative OffsetFromUTC") << dt << QString("1978-11-09T13:28:34-02:00"); + dt.setUtcOffset(-900); + QTest::newRow("negative non-integral OffsetFromUTC") + << dt + << QString("1978-11-09T13:28:34-00:15"); QTest::newRow("invalid") << QDateTime(QDate(-1, 11, 9), QTime(13, 28, 34), Qt::UTC) << QString(); @@ -1895,8 +1899,12 @@ void tst_QDateTime::fromStringDateFormat_data() // Test Qt::ISODate format. QTest::newRow("ISO +01:00") << QString::fromLatin1("1987-02-13T13:24:51+01:00") << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(12, 24, 51), Qt::UTC); + QTest::newRow("ISO +00:01") << QString::fromLatin1("1987-02-13T13:24:51+00:01") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(13, 23, 51), Qt::UTC); QTest::newRow("ISO -01:00") << QString::fromLatin1("1987-02-13T13:24:51-01:00") << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(14, 24, 51), Qt::UTC); + QTest::newRow("ISO -00:01") << QString::fromLatin1("1987-02-13T13:24:51-00:01") + << Qt::ISODate << QDateTime(QDate(1987, 2, 13), QTime(13, 25, 51), Qt::UTC); QTest::newRow("ISO +0000") << QString::fromLatin1("1970-01-01T00:12:34+0000") << Qt::ISODate << QDateTime(QDate(1970, 1, 1), QTime(0, 12, 34), Qt::UTC); QTest::newRow("ISO +00:00") << QString::fromLatin1("1970-01-01T00:12:34+00:00") diff --git a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp index e1ce12d7d5..57a4a19179 100644 --- a/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp +++ b/tests/auto/dbus/qdbusabstractadaptor/tst_qdbusabstractadaptor.cpp @@ -367,11 +367,11 @@ void emitSignalPeer(const QString &interface, const QString &name, const QVarian QTest::qWait(1000); } -const char* slotSpyPeer() +QString slotSpyPeer() { QDBusMessage req = QDBusMessage::createMethodCall(serviceName, objectPath, interfaceName, "slotSpyServer"); QDBusMessage reply = QDBusConnection::sessionBus().call(req); - return reply.arguments().at(0).toString().toLatin1().data(); + return reply.arguments().at(0).toString(); } QString valueSpyPeer() @@ -1108,7 +1108,7 @@ void tst_QDBusAbstractAdaptor::methodCallsPeer() // simple call: one such method exists QCOMPARE(if2.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface2::method()"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface2::method()")); if (!nInterfaces--) return; @@ -1121,24 +1121,24 @@ void tst_QDBusAbstractAdaptor::methodCallsPeer() QCOMPARE(if2.call(QDBus::BlockWithGui, "methodString").type(), QDBusMessage::ErrorMessage); QCOMPARE(if3.call(QDBus::BlockWithGui, "methodVoid").type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface3::methodVoid()"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface3::methodVoid()")); QCOMPARE(if3.call(QDBus::BlockWithGui, "methodInt", 42).type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface3::methodInt(int)"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface3::methodInt(int)")); QCOMPARE(if3.call(QDBus::BlockWithGui, "methodString", QString("")).type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface3::methodString(QString)"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface3::methodString(QString)")); if (!nInterfaces--) return; // method overloading: different interfaces QCOMPARE(if4.call(QDBus::BlockWithGui, "method").type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface4::method()"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface4::method()")); // method overloading: different parameters QCOMPARE(if4.call(QDBus::BlockWithGui, "method.i", 42).type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface4::method(int)"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface4::method(int)")); QCOMPARE(if4.call(QDBus::BlockWithGui, "method.s", QString()).type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface4::method(QString)"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface4::method(QString)")); } void tst_QDBusAbstractAdaptor::methodCallScriptablePeer() @@ -1152,7 +1152,7 @@ void tst_QDBusAbstractAdaptor::methodCallScriptablePeer() QDBusInterface if2(QString(), "/", "local.Interface2", con); QCOMPARE(if2.call(QDBus::BlockWithGui,"scriptableMethod").type(), QDBusMessage::ReplyMessage); - QCOMPARE(slotSpyPeer(), "void Interface2::scriptableMethod()"); + QCOMPARE(slotSpyPeer(), QStringLiteral("void Interface2::scriptableMethod()")); } void tst_QDBusAbstractAdaptor::signalEmissionsPeer_data() diff --git a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro index b863135b68..5001ec2cd2 100644 --- a/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro +++ b/tests/auto/dbus/qdbusabstractinterface/qpinger/qpinger.pro @@ -1,5 +1,7 @@ SOURCES = qpinger.cpp ../interface.cpp HEADERS = ../interface.h TARGET = qpinger +CONFIG -= app_bundle +CONFIG += console QT = core dbus DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro b/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro index d652036034..ffc538f2ab 100644 --- a/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro +++ b/tests/auto/dbus/qdbusmarshall/qpong/qpong.pro @@ -1,5 +1,7 @@ SOURCES = qpong.cpp TARGET = qpong QT = core dbus +CONFIG -= app_bundle +CONFIG += console DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 6ef9957fa1..e551d99959 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -48,6 +48,10 @@ #include <qpa/qwindowsysteminterface.h> #include <qgenericplugin.h> +#if defined(Q_OS_QNX) +#include <QOpenGLContext> +#endif + #include <QDebug> #include "tst_qcoreapplication.h" @@ -124,6 +128,9 @@ void tst_QGuiApplication::focusObject() const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); DummyWindow window1; +#if defined(Q_OS_QNX) + window1.setSurfaceType(QSurface::OpenGLSurface); +#endif window1.resize(windowSize, windowSize); window1.setTitle(QStringLiteral("focusObject:window1")); window1.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); @@ -134,6 +141,15 @@ void tst_QGuiApplication::focusObject() window1.show(); +#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store + // and then post the window in order for screen to show the window + QOpenGLContext context; + context.create(); + context.makeCurrent(&window1); + QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window + context.swapBuffers(&window1); +#endif + QSignalSpy spy(&app, SIGNAL(focusObjectChanged(QObject*))); @@ -279,15 +295,35 @@ void tst_QGuiApplication::changeFocusWindow() // focus is changed between FocusAboutToChange and FocusChanged FocusChangeWindow window1; +#if defined(Q_OS_QNX) + window1.setSurfaceType(QSurface::OpenGLSurface); +#endif window1.resize(windowSize, windowSize); window1.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); window1.setTitle(QStringLiteral("changeFocusWindow:window1")); window1.show(); +#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store + // and then post the window in order for screen to show the window + QOpenGLContext context; + context.create(); + context.makeCurrent(&window1); + QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window + context.swapBuffers(&window1); +#endif FocusChangeWindow window2; +#if defined(Q_OS_QNX) + window2.setSurfaceType(QSurface::OpenGLSurface); +#endif window2.resize(windowSize, windowSize); window2.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); window2.setTitle(QStringLiteral("changeFocusWindow:window2")); window2.show(); +#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store + // and then post the window in order for screen to show the window + context.makeCurrent(&window2); + QTest::qWaitForWindowExposed(&window2); // Buffer swap only succeeds with exposed window + context.swapBuffers(&window2); +#endif QVERIFY(QTest::qWaitForWindowExposed(&window1)); QVERIFY(QTest::qWaitForWindowExposed(&window2)); window1.requestActivate(); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index eefa85a745..589f3e66e1 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -88,6 +88,10 @@ private slots: void visibility(); void mask(); void initialSize(); + void modalDialog(); + void modalDialogClosingOneOfTwoModal(); + void modalWithChildWindow(); + void modalWindowModallity(); void initTestCase() { @@ -1316,6 +1320,115 @@ void tst_QWindow::initialSize() } } +void tst_QWindow::modalDialog() +{ + QWindow normalWindow; + normalWindow.resize(400, 400); + normalWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&normalWindow)); + + QWindow dialog; + dialog.resize(200,200); + dialog.setModality(Qt::ApplicationModal); + dialog.setFlags(Qt::Dialog); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + + normalWindow.requestActivate(); + + QGuiApplication::sync(); + QGuiApplication::processEvents(); + QTRY_COMPARE(QGuiApplication::focusWindow(), &dialog); +} + +void tst_QWindow::modalDialogClosingOneOfTwoModal() +{ + QWindow normalWindow; + normalWindow.resize(400, 400); + normalWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&normalWindow)); + + QWindow first_dialog; + first_dialog.resize(200,200); + first_dialog.setModality(Qt::ApplicationModal); + first_dialog.setFlags(Qt::Dialog); + first_dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&first_dialog)); + + { + QWindow second_dialog; + second_dialog.resize(200,200); + second_dialog.setModality(Qt::ApplicationModal); + second_dialog.setFlags(Qt::Dialog); + second_dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&second_dialog)); + + QTRY_COMPARE(QGuiApplication::focusWindow(), &second_dialog); + + second_dialog.close(); + } + + QGuiApplication::sync(); + QGuiApplication::processEvents(); + QTRY_COMPARE(QGuiApplication::focusWindow(), &first_dialog); +} + +void tst_QWindow::modalWithChildWindow() +{ + QWindow normalWindow; + normalWindow.resize(400, 400); + normalWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&normalWindow)); + + QWindow tlw_dialog; + tlw_dialog.resize(400,200); + tlw_dialog.setModality(Qt::ApplicationModal); + tlw_dialog.setFlags(Qt::Dialog); + tlw_dialog.create(); + + QWindow sub_window(&tlw_dialog); + sub_window.resize(200,300); + sub_window.show(); + + tlw_dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&tlw_dialog)); + QVERIFY(QTest::qWaitForWindowExposed(&sub_window)); + + QTRY_COMPARE(QGuiApplication::focusWindow(), &tlw_dialog); + + sub_window.requestActivate(); + QGuiApplication::sync(); + QGuiApplication::processEvents(); + QTRY_COMPARE(QGuiApplication::focusWindow(), &sub_window); +} + +void tst_QWindow::modalWindowModallity() +{ + QWindow normal_window; + normal_window.resize(400, 400); + normal_window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&normal_window)); + + QWindow parent_to_modal; + parent_to_modal.resize(400, 400); + parent_to_modal.show(); + QVERIFY(QTest::qWaitForWindowExposed(&parent_to_modal)); + QTRY_COMPARE(QGuiApplication::focusWindow(), &parent_to_modal); + + QWindow modal_dialog; + modal_dialog.resize(400,200); + modal_dialog.setModality(Qt::WindowModal); + modal_dialog.setFlags(Qt::Dialog); + modal_dialog.setTransientParent(&parent_to_modal); + modal_dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&modal_dialog)); + QTRY_COMPARE(QGuiApplication::focusWindow(), &modal_dialog); + + normal_window.requestActivate(); + QTRY_COMPARE(QGuiApplication::focusWindow(), &normal_window); + +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index e589d520cb..122ac63034 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -331,8 +331,8 @@ void tst_QTcpSocket::initTestCase_data() qDebug() << QtNetworkSettings::serverName(); QTest::newRow("WithoutProxy") << false << 0 << false; - QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; - QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; + //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 + //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 QTest::newRow("WithHttpProxy") << true << int(HttpProxy) << false; QTest::newRow("WithHttpProxyBasicAuth") << true << int(HttpProxy | AuthBasic) << false; @@ -340,8 +340,8 @@ void tst_QTcpSocket::initTestCase_data() #ifndef QT_NO_SSL QTest::newRow("WithoutProxy SSL") << false << 0 << true; - QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; - QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; + //QTest::newRow("WithSocks5Proxy SSL") << true << int(Socks5Proxy) << true; ### temporarily disabled, QTBUG-38385 + //QTest::newRow("WithSocks5AuthProxy SSL") << true << int(Socks5Proxy | AuthBasic) << true; ### temporarily disabled, QTBUG-38385 QTest::newRow("WithHttpProxy SSL") << true << int(HttpProxy) << true; QTest::newRow("WithHttpProxyBasicAuth SSL") << true << int(HttpProxy | AuthBasic) << true; diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 74c3f7833b..4f62076870 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -81,6 +81,7 @@ private slots: void emptyConstructor(); void constructor_data(); void constructor(); + void constructor_device(); void constructingGarbage(); void copyAndAssign_data(); void copyAndAssign(); @@ -110,6 +111,8 @@ private slots: void verify(); void extensions(); void threadSafeConstMethods(); + void version_data(); + void version(); // helper for verbose test failure messages QString toString(const QList<QSslError>&); @@ -225,6 +228,47 @@ void tst_QSslCertificate::constructor() QVERIFY(!certificate.isNull()); } +void tst_QSslCertificate::constructor_device() +{ + if (!QSslSocket::supportsSsl()) + return; + + QFile f(testDataDir + "/verify-certs/test-ocsp-good-cert.pem"); + bool ok = f.open(QIODevice::ReadOnly); + QVERIFY(ok); + + QSslCertificate cert(&f); + QVERIFY(!cert.isNull()); + f.close(); + + // Check opening a DER as a PEM fails + QFile f2(testDataDir + "/certificates/cert.der"); + ok = f2.open(QIODevice::ReadOnly); + QVERIFY(ok); + + QSslCertificate cert2(&f2); + QVERIFY(cert2.isNull()); + f2.close(); + + // Check opening a DER as a DER works + QFile f3(testDataDir + "/certificates/cert.der"); + ok = f3.open(QIODevice::ReadOnly); + QVERIFY(ok); + + QSslCertificate cert3(&f3, QSsl::Der); + QVERIFY(!cert3.isNull()); + f3.close(); + + // Check opening a PEM as a DER fails + QFile f4(testDataDir + "/verify-certs/test-ocsp-good-cert.pem"); + ok = f4.open(QIODevice::ReadOnly); + QVERIFY(ok); + + QSslCertificate cert4(&f4, QSsl::Der); + QVERIFY(cert4.isNull()); + f4.close(); +} + void tst_QSslCertificate::constructingGarbage() { if (!QSslSocket::supportsSsl()) @@ -1150,6 +1194,33 @@ void tst_QSslCertificate::threadSafeConstMethods() } +void tst_QSslCertificate::version_data() +{ + QTest::addColumn<QSslCertificate>("certificate"); + QTest::addColumn<QByteArray>("result"); + + QTest::newRow("null certificate") << QSslCertificate() << QByteArray(); + + QList<QSslCertificate> certs; + certs << QSslCertificate::fromPath(testDataDir + "/verify-certs/test-ocsp-good-cert.pem"); + + QTest::newRow("v3 certificate") << certs.first() << QByteArrayLiteral("3"); + + certs.clear(); + certs << QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem"); + QTest::newRow("v1 certificate") << certs.first() << QByteArrayLiteral("1"); +} + +void tst_QSslCertificate::version() +{ + if (!QSslSocket::supportsSsl()) + return; + + QFETCH(QSslCertificate, certificate); + QFETCH(QByteArray, result); + QCOMPARE(certificate.version(), result); +} + #endif // QT_NO_SSL QTEST_MAIN(tst_QSslCertificate) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index baaf21e6bb..30a9e19138 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -273,10 +273,12 @@ void tst_QSslSocket::initTestCase_data() void tst_QSslSocket::initTestCase() { +#ifndef QT_NO_SSL qDebug("Using SSL library %s (%ld)", qPrintable(QSslSocket::sslLibraryVersionString()), QSslSocket::sslLibraryVersionNumber()); QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); +#endif } void tst_QSslSocket::init() diff --git a/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp b/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp index 915f503b3f..a8a9deb25f 100644 --- a/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp +++ b/tests/auto/opengl/qglbuffer/tst_qglbuffer.cpp @@ -207,6 +207,10 @@ void tst_QGLBuffer::bufferSharing() QSKIP("Unreproducible timeout on Windows (MSVC/MinGW) CI bots"); #endif +#if defined(Q_OS_QNX) + QSKIP("Crashes on QNX when destroying the second QGLWidget (see QTBUG-38275)"); +#endif + QGLWidget *w1 = new QGLWidget(); w1->makeCurrent(); diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index fcc5581bea..54c56eb18b 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1928,7 +1928,7 @@ void tst_QAccessibility::lineEditTest() QVERIFY(iface->state().movable); QVERIFY(iface->state().focusable); QVERIFY(iface->state().selectable); - QVERIFY(iface->state().hasPopup); + QVERIFY(!iface->state().hasPopup); QCOMPARE(bool(iface->state().focused), le->hasFocus()); QString secret(QLatin1String("secret")); @@ -1956,7 +1956,7 @@ void tst_QAccessibility::lineEditTest() QVERIFY(!(iface->state().movable)); QVERIFY(iface->state().focusable); QVERIFY(iface->state().selectable); - QVERIFY(iface->state().hasPopup); + QVERIFY(!iface->state().hasPopup); QCOMPARE(bool(iface->state().focused), le->hasFocus()); QLineEdit *le2 = new QLineEdit(toplevel); @@ -3283,7 +3283,7 @@ void tst_QAccessibility::comboBoxTest() QVERIFY(!combo.view()->isVisible()); QVERIFY(iface->actionInterface()); - QCOMPARE(iface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction()); + QCOMPARE(iface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction() << QAccessibleActionInterface::pressAction()); iface->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction()); QTRY_VERIFY(combo.view()->isVisible()); diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 55cb67eed9..824f042ffc 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -195,6 +195,9 @@ private slots: void task_233829_data() { generic_data("QPSQL"); } void task_233829(); + void QTBUG_12477_data() { generic_data("QPSQL"); } + void QTBUG_12477(); + void sqlServerReturn0_data() { generic_data(); } void sqlServerReturn0(); @@ -1247,6 +1250,26 @@ void tst_QSqlQuery::seek() QVERIFY( q.seek( 0 ) ); QCOMPARE( q.at(), 0 ); QCOMPARE( q.value( 0 ).toInt(), 1 ); + + QVERIFY(!q.seek(QSql::BeforeFirstRow)); + QCOMPARE(q.at(), int(QSql::BeforeFirstRow)); + QVERIFY(q.seek(1, true)); + QCOMPARE(q.at(), 0); + QCOMPARE(q.value(0).toInt(), 1); + + qint32 count = 1; + while (q.next()) ++count; + + QCOMPARE(q.at(), int(QSql::AfterLastRow)); + + if (!q.isForwardOnly()) { + QVERIFY(q.seek(-1, true)); + QCOMPARE(q.at(), count - 1); + QCOMPARE(q.value(0).toInt(), count); + } else { + QVERIFY(!q.seek(-1, true)); + QCOMPARE(q.at(), int(QSql::AfterLastRow)); + } } void tst_QSqlQuery::seekForwardOnlyQuery() @@ -2992,6 +3015,47 @@ void tst_QSqlQuery::task_233829() QVERIFY_SQL(q,exec()); } +void tst_QSqlQuery::QTBUG_12477() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + if (!db.driverName().startsWith("QPSQL")) + QSKIP("PostgreSQL specific test"); + + QSqlQuery q(db); + QVERIFY_SQL(q, exec("SELECT 1::bit, '10101010000111101101'::varbit, " + "'10101111011'::varbit(15), '22222.20'::numeric(16,2), " + "'333333'::numeric(18), '444444'::numeric")); + QVERIFY_SQL(q, next()); + QSqlRecord r = q.record(); + QSqlField f; + + f = r.field(0); + QCOMPARE(f.length(), 1); + QCOMPARE(f.precision(), -1); + + f = r.field(1); + QCOMPARE(f.length(), -1); + QCOMPARE(f.precision(), -1); + + f = r.field(2); + QCOMPARE(f.length(), 15); + QCOMPARE(f.precision(), -1); + + f = r.field(3); + QCOMPARE(f.length(), 16); + QCOMPARE(f.precision(), 2); + + f = r.field(4); + QCOMPARE(f.length(), 18); + QCOMPARE(f.precision(), 0); + + f = r.field(5); + QCOMPARE(f.length(), -1); + QCOMPARE(f.precision(), -1); +} + void tst_QSqlQuery::sqlServerReturn0() { QFETCH( QString, dbName ); diff --git a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp index e85c64db8e..881f2b5c7c 100644 --- a/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp +++ b/tests/auto/sql/kernel/qsqlthread/tst_qsqlthread.cpp @@ -50,7 +50,7 @@ #include "qdebug.h" #ifdef Q_OS_LINUX -#include <pthread.h> +#include <sched.h> #endif const QString qtest(qTableName("qtest", __FILE__, QSqlDatabase())); @@ -159,7 +159,7 @@ public: q.bindValue(2, 10); QVERIFY_SQL(q, exec()); #ifdef Q_OS_LINUX - pthread_yield(); + sched_yield(); #endif } } @@ -197,7 +197,7 @@ public: q1.clear(); QVERIFY_SQL(q2, exec()); #ifdef Q_OS_LINUX - pthread_yield(); + sched_yield(); #endif } } diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index d360a646f1..096658ae02 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -43,6 +43,7 @@ #include <QtTest/QtTest> #include <qcoreapplication.h> +#include <qfile.h> #include <qdebug.h> #include <qsharedpointer.h> #include <qfiledialog.h> @@ -72,6 +73,7 @@ #include <QFileSystemModel> #if defined(Q_OS_UNIX) +#include <unistd.h> // for pathconf() on OS X #ifdef QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT QString qt_tildeExpansion(const QString &path, bool *expanded = 0); @@ -79,6 +81,19 @@ QT_END_NAMESPACE #endif #endif +static inline bool isCaseSensitiveFileSystem(const QString &path) +{ + Q_UNUSED(path) +#if defined(Q_OS_MAC) + return pathconf(QFile::encodeName(path).constData(), _PC_CASE_SENSITIVE); +#elif defined(Q_OS_WIN) + return false; +#else + return true; +#endif +} + + class QNonNativeFileDialog : public QFileDialog { Q_OBJECT @@ -130,6 +145,7 @@ private slots: void selectFile_data(); void selectFile(); void selectFiles(); + void selectFileWrongCaseSaveAs(); void selectFilter(); void viewMode(); void proxymodel(); @@ -147,6 +163,7 @@ private slots: void clearLineEdit(); void enableChooseButton(); void widgetlessNativeDialog(); + void selectedFilesWithoutWidgets(); void trailingDotsAndSpaces(); #ifdef Q_OS_UNIX #ifdef QT_BUILD_INTERNAL @@ -154,6 +171,7 @@ private slots: void tildeExpansion(); #endif // QT_BUILD_INTERNAL #endif + void getFileUrl(); private: QByteArray userSettings; @@ -857,36 +875,59 @@ void tst_QFiledialog::selectFile() { QFETCH(QString, file); QFETCH(int, count); - QNonNativeFileDialog fd; - QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); + QScopedPointer<QNonNativeFileDialog> fd(new QNonNativeFileDialog); + QFileSystemModel *model = fd->findChild<QFileSystemModel*>("qt_filesystem_model"); QVERIFY(model); - fd.setDirectory(QDir::currentPath()); + fd->setDirectory(QDir::currentPath()); // default value - QCOMPARE(fd.selectedFiles().count(), 1); + QCOMPARE(fd->selectedFiles().count(), 1); - QTemporaryFile tempFile(QDir::tempPath() + "/aXXXXXX"); - bool inTemp = (file == "temp"); - if (inTemp) { - tempFile.open(); - file = tempFile.fileName(); + QScopedPointer<QTemporaryFile> tempFile; + if (file == QLatin1String("temp")) { + tempFile.reset(new QTemporaryFile(QDir::tempPath() + QStringLiteral("/aXXXXXX"))); + QVERIFY(tempFile->open()); + file = tempFile->fileName(); } - fd.selectFile(file); - QCOMPARE(fd.selectedFiles().count(), count); - if (inTemp) { - QCOMPARE(model->index(fd.directory().path()), model->index(QDir::tempPath())); + fd->selectFile(file); + QCOMPARE(fd->selectedFiles().count(), count); + if (tempFile.isNull()) { + QCOMPARE(model->index(fd->directory().path()), model->index(QDir::currentPath())); } else { - QCOMPARE(model->index(fd.directory().path()), model->index(QDir::currentPath())); + QCOMPARE(model->index(fd->directory().path()), model->index(QDir::tempPath())); } + fd.reset(); // Ensure the file dialog let's go of the temporary file for "temp". +} + +void tst_QFiledialog::selectFileWrongCaseSaveAs() +{ + const QString home = QDir::homePath(); + if (isCaseSensitiveFileSystem(home)) + QSKIP("This test is intended for case-insensitive file systems only."); + // QTBUG-38162: when passing a wrongly capitalized path to selectFile() + // on a case-insensitive file system, the line edit should only + // contain the file name ("c:\PRogram files\foo.txt" -> "foo.txt"). + const QString fileName = QStringLiteral("foo.txt"); + const QString path = home + QLatin1Char('/') + fileName; + QString wrongCasePath = path; + for (int c = 0; c < wrongCasePath.size(); c += 2) + wrongCasePath[c] = wrongCasePath.at(c).isLower() ? wrongCasePath.at(c).toUpper() : wrongCasePath.at(c).toLower(); + QNonNativeFileDialog fd(0, "QTBUG-38162", wrongCasePath); + fd.setAcceptMode(QFileDialog::AcceptSave); + fd.selectFile(wrongCasePath); + const QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); + QVERIFY(lineEdit); + QCOMPARE(lineEdit->text().compare(fileName, Qt::CaseInsensitive), 0); } void tst_QFiledialog::selectFiles() { - QNonNativeFileDialog fd; - fd.setViewMode(QFileDialog::List); QTemporaryDir tempDir; QVERIFY(tempDir.isValid()); const QString tempPath = tempDir.path(); + { + QNonNativeFileDialog fd; + fd.setViewMode(QFileDialog::List); fd.setDirectory(tempPath); QSignalSpy spyCurrentChanged(&fd, SIGNAL(currentChanged(QString))); QSignalSpy spyDirectoryEntered(&fd, SIGNAL(directoryEntered(QString))); @@ -931,17 +972,20 @@ void tst_QFiledialog::selectFiles() QCOMPARE(spyFilesSelected.count(), 0); QCOMPARE(spyFilterSelected.count(), 0); - //If the selection is invalid then we fill the line edit but without the / - QNonNativeFileDialog * dialog = new QNonNativeFileDialog( 0, "Save" ); - dialog->setFileMode( QFileDialog::AnyFile ); - dialog->setAcceptMode( QFileDialog::AcceptSave ); - dialog->selectFile(tempPath + QStringLiteral("/blah")); - dialog->show(); - QVERIFY(QTest::qWaitForWindowExposed(dialog)); - QLineEdit *lineEdit = dialog->findChild<QLineEdit*>("fileNameEdit"); - QVERIFY(lineEdit); - QCOMPARE(lineEdit->text(),QLatin1String("blah")); - delete dialog; + } + + { + //If the selection is invalid then we fill the line edit but without the / + QNonNativeFileDialog dialog( 0, "Save" ); + dialog.setFileMode( QFileDialog::AnyFile ); + dialog.setAcceptMode( QFileDialog::AcceptSave ); + dialog.selectFile(tempPath + QStringLiteral("/blah")); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + QLineEdit *lineEdit = dialog.findChild<QLineEdit*>("fileNameEdit"); + QVERIFY(lineEdit); + QCOMPARE(lineEdit->text(),QLatin1String("blah")); + } } void tst_QFiledialog::viewMode() @@ -1321,6 +1365,14 @@ void tst_QFiledialog::widgetlessNativeDialog() QVERIFY(!button); } +void tst_QFiledialog::selectedFilesWithoutWidgets() +{ + // Test for a crash when widgets are not instantiated yet. + QFileDialog fd; + fd.setAcceptMode(QFileDialog::AcceptOpen); + QVERIFY(fd.selectedFiles().size() >= 0); +} + void tst_QFiledialog::trailingDotsAndSpaces() { #ifndef Q_OS_WIN @@ -1378,5 +1430,49 @@ void tst_QFiledialog::tildeExpansion() #endif // QT_BUILD_INTERNAL #endif +class DialogRejecter : public QObject +{ + Q_OBJECT +public: + DialogRejecter() + { + QTimer *timer = new QTimer(this); + timer->setInterval(1000); + connect(timer, &QTimer::timeout, this, &DialogRejecter::rejectFileDialog); + timer->start(); + } + +public slots: + void rejectFileDialog() + { + if (QWidget *w = QApplication::activeModalWidget()) + if (QDialog *d = qobject_cast<QDialog *>(w)) + d->reject(); + } +}; + +void tst_QFiledialog::getFileUrl() +{ + // QTBUG-38672 , static functions should return empty Urls + const QFileDialog::Options options = QFileDialog::DontUseNativeDialog; + DialogRejecter dr; + + QUrl url = QFileDialog::getOpenFileUrl(0, QStringLiteral("getOpenFileUrl"), + QUrl(), QString(), Q_NULLPTR, options); + QVERIFY(url.isEmpty()); + QVERIFY(!url.isValid()); + + url = QFileDialog::getExistingDirectoryUrl(0, QStringLiteral("getExistingDirectoryUrl"), + QUrl(), options | QFileDialog::ShowDirsOnly); + QVERIFY(url.isEmpty()); + QVERIFY(!url.isValid()); + + url = QFileDialog::getSaveFileUrl(0, QStringLiteral("getSaveFileUrl"), + QUrl(), QString(), Q_NULLPTR, options); + QVERIFY(url.isEmpty()); + QVERIFY(!url.isValid()); + +} + QTEST_MAIN(tst_QFiledialog) #include "tst_qfiledialog.moc" diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 9e0446388e..3925090465 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -476,13 +476,19 @@ void tst_QFileSystemModel::rowCount() void tst_QFileSystemModel::rowsInserted_data() { QTest::addColumn<int>("count"); - QTest::addColumn<int>("assending"); + QTest::addColumn<int>("ascending"); for (int i = 0; i < 4; ++i) { QTest::newRow(QString("Qt::AscendingOrder %1").arg(i).toLocal8Bit().constData()) << i << (int)Qt::AscendingOrder; QTest::newRow(QString("Qt::DescendingOrder %1").arg(i).toLocal8Bit().constData()) << i << (int)Qt::DescendingOrder; } } +static inline QString lastEntry(const QModelIndex &root) +{ + const QAbstractItemModel *model = root.model(); + return model->index(model->rowCount(root) - 1, 0, root).data().toString(); +} + void tst_QFileSystemModel::rowsInserted() { #if defined(Q_OS_WINCE) @@ -492,9 +498,9 @@ void tst_QFileSystemModel::rowsInserted() rowCount(); QModelIndex root = model->index(model->rootPath()); - QFETCH(int, assending); + QFETCH(int, ascending); QFETCH(int, count); - model->sort(0, (Qt::SortOrder)assending); + model->sort(0, (Qt::SortOrder)ascending); QSignalSpy spy0(model, SIGNAL(rowsInserted(QModelIndex,int,int))); QSignalSpy spy1(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); @@ -505,7 +511,6 @@ void tst_QFileSystemModel::rowsInserted() QVERIFY(createFiles(tmp, files, 5)); TRY_WAIT(model->rowCount(root) == oldCount + count); QTRY_COMPARE(model->rowCount(root), oldCount + count); - QTest::qWait(100); // Let the sort settle. int totalRowsInserted = 0; for (int i = 0; i < spy0.count(); ++i) { int start = spy0[i].value(1).toInt(); @@ -513,12 +518,9 @@ void tst_QFileSystemModel::rowsInserted() totalRowsInserted += end - start + 1; } QCOMPARE(totalRowsInserted, count); - if (assending == (Qt::SortOrder)Qt::AscendingOrder) { - QString letter = model->index(model->rowCount(root) - 1, 0, root).data().toString(); - QCOMPARE(letter, QString("j")); - } else { - QCOMPARE(model->index(model->rowCount(root) - 1, 0, root).data().toString(), QString("b")); - } + const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b"); + QTRY_COMPARE(lastEntry(root), expected); + if (spy0.count() > 0) { if (count == 0) QCOMPARE(spy0.count(), 0); @@ -548,8 +550,8 @@ void tst_QFileSystemModel::rowsRemoved() QModelIndex root = model->index(model->rootPath()); QFETCH(int, count); - QFETCH(int, assending); - model->sort(0, (Qt::SortOrder)assending); + QFETCH(int, ascending); + model->sort(0, (Qt::SortOrder)ascending); QTest::qWait(WAITTIME); QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 4c07b48c00..a932a2e859 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -2605,6 +2605,9 @@ void tst_QWizard::task161658_alignments() void tst_QWizard::task177022_setFixedSize() { +#ifdef Q_OS_BLACKBERRY + QSKIP("Window is forced fullscreen"); +#endif int width = 300; int height = 200; QWizard wiz; @@ -2622,7 +2625,7 @@ void tst_QWizard::task177022_setFixedSize() QCOMPARE(wiz.maximumWidth(), width); QCOMPARE(wiz.maximumHeight(), height); - wiz.show(); + wiz.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&wiz)); QCOMPARE(wiz.size(), QSize(width, height)); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 5b178903cf..8f57eca0a7 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -2502,9 +2502,6 @@ void tst_QGraphicsProxyWidget::popup_basic() void tst_QGraphicsProxyWidget::popup_subwidget() { -#ifdef Q_OS_WIN - QSKIP("This test crashes on Windows, QTBUG-33213"); -#endif QGroupBox *groupBox = new QGroupBox; groupBox->setTitle("GroupBox"); groupBox->setCheckable(true); @@ -3183,10 +3180,6 @@ void tst_QGraphicsProxyWidget::actionsContextMenu() void tst_QGraphicsProxyWidget::deleteProxyForChildWidget() { -#if defined(Q_OS_WIN) - QSKIP("This test is crashing on windows, it needs to be fixed. QTBUG-29684"); -#endif - QDialog dialog; dialog.resize(320, 120); dialog.move(80, 40); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 83c4582645..daca1d1516 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -1257,7 +1257,7 @@ void tst_QAbstractItemView::task250754_fontChange() tree.setModel(m); tree.setHeaderHidden(true); // The header is (in certain styles) dpi dependent - w.resize(160, 300); // Minimum width for windows with frame on Windows 8 + w.resize(160, 350); // Minimum width for windows with frame on Windows 8 centerOnScreen(&w); moveCursorAway(&w); w.showNormal(); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 0579914940..d12fb06daa 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -261,6 +261,7 @@ private slots: void taskQTBUG_18539_emitLayoutChanged(); void taskQTBUG_8176_emitOnExpandAll(); void taskQTBUG_34717_collapseAtBottom(); + void taskQTBUG_37813_crash(); void testInitialFocus(); }; @@ -2488,7 +2489,7 @@ void tst_QTreeView::extendedSelection_data() QTest::addColumn<int>("selectedCount"); QTest::newRow("select") << QPoint(10, 10) << 2; - QTest::newRow("unselect") << QPoint(10, 150) << 0; + QTest::newRow("unselect") << QPoint(10, 300) << 0; } void tst_QTreeView::extendedSelection() @@ -2499,7 +2500,7 @@ void tst_QTreeView::extendedSelection() QStandardItemModel model(5, 2); QWidget topLevel; QTreeView view(&topLevel); - view.resize(qMax(mousePressPos.x() * 2, 200), qMax(mousePressPos.y() * 2, 200)); + view.resize(qMax(mousePressPos.x() * 2, 300), qMax(mousePressPos.y() * 2, 350)); view.setModel(&model); view.setSelectionMode(QAbstractItemView::ExtendedSelection); topLevel.show(); @@ -4327,5 +4328,31 @@ void tst_QTreeView::quickExpandCollapse() } #endif +void tst_QTreeView::taskQTBUG_37813_crash() +{ + // QTBUG_37813: Crash in visual / logical index mapping in QTreeViewPrivate::adjustViewOptionsForIndex() + // when hiding/moving columns. It is reproduceable with a QTreeWidget only. +#ifdef QT_BUILD_INTERNAL + QTreeWidget treeWidget; + treeWidget.setDragEnabled(true); + treeWidget.setColumnCount(2); + QList<QTreeWidgetItem *> items; + for (int r = 0; r < 2; ++r) { + QTreeWidgetItem *item = new QTreeWidgetItem(); + for (int c = 0; c < treeWidget.columnCount(); ++c) + item->setText(c, QString::fromLatin1("Row %1 Column %2").arg(r).arg(c)); + items.append(item); + } + treeWidget.addTopLevelItems(items); + treeWidget.setColumnHidden(0, true); + treeWidget.header()->moveSection(0, 1); + QItemSelection sel(treeWidget.model()->index(0, 0), treeWidget.model()->index(0, 1)); + QRect rect; + QAbstractItemViewPrivate *av = static_cast<QAbstractItemViewPrivate*>(qt_widget_private(&treeWidget)); + const QPixmap pixmap = av->renderToPixmap(sel.indexes(), &rect); + QVERIFY(pixmap.size().isValid()); +#endif // QT_BUILD_INTERNAL +} + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index dd3d041f56..2a70431223 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4631,32 +4631,28 @@ void tst_QWidget::windowMoveResize() QTest::qWait(10); QTRY_COMPARE(widget.pos(), rect.topLeft()); - if (m_platform == QStringLiteral("windows")) { - QEXPECT_FAIL("130,100 0x200, flags 0", "QTBUG-26424", Continue); - QEXPECT_FAIL("130,50 0x0, flags 0", "QTBUG-26424", Continue); - } - QTRY_COMPARE(widget.size(), rect.size()); + // Windows: Minimum size of decorated windows. + const bool expectResizeFail = (!windowFlags && (rect.width() < 160 || rect.height() < 40)) + && m_platform == QStringLiteral("windows"); + if (!expectResizeFail) + QTRY_COMPARE(widget.size(), rect.size()); // move() while shown foreach (const QRect &r, rects) { - if (m_platform == QStringLiteral("xcb") - && ((widget.width() == 0 || widget.height() == 0) && r.width() != 0 && r.height() != 0)) { - QEXPECT_FAIL("130,100 0x200, flags 0", - "First resize after show of zero-sized gets wrong win_gravity.", - Continue); - QEXPECT_FAIL("100,50 200x0, flags 0", - "First resize after show of zero-sized gets wrong win_gravity.", - Continue); - QEXPECT_FAIL("130,50 0x0, flags 0", - "First resize after show of zero-sized gets wrong win_gravity.", - Continue); - } - + // XCB: First resize after show of zero-sized gets wrong win_gravity. + const bool expectMoveFail = !windowFlags + && ((widget.width() == 0 || widget.height() == 0) && r.width() != 0 && r.height() != 0) + && m_platform == QStringLiteral("xcb") + && (rect == QRect(QPoint(130, 100), QSize(0, 200)) + || rect == QRect(QPoint(100, 50), QSize(200, 0)) + || rect == QRect(QPoint(130, 50), QSize(0, 0))); widget.move(r.topLeft()); widget.resize(r.size()); QApplication::processEvents(); - QTRY_COMPARE(widget.pos(), r.topLeft()); - QTRY_COMPARE(widget.size(), r.size()); + if (!expectMoveFail) { + QTRY_COMPARE(widget.pos(), r.topLeft()); + QTRY_COMPARE(widget.size(), r.size()); + } } widget.move(rect.topLeft()); widget.resize(rect.size()); diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 5a36ffc671..14d59d3630 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -49,6 +49,12 @@ #include "../../../qtest-config.h" +static inline void centerOnScreen(QWidget *w) +{ + const QPoint offset = QPoint(w->width() / 2, w->height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + class tst_QStyleSheetStyle : public QObject { Q_OBJECT @@ -142,6 +148,8 @@ tst_QStyleSheetStyle::~tst_QStyleSheetStyle() void tst_QStyleSheetStyle::numinstances() { QWidget w; + w.resize(200, 200); + centerOnScreen(&w); QCommonStyle *style = new QCommonStyle; style->setParent(&w); QWidget c(&w); @@ -531,7 +539,14 @@ void tst_QStyleSheetStyle::dynamicProperty() qApp->setStyleSheet(QString()); QString appStyle = qApp->style()->metaObject()->className(); - QPushButton pb1, pb2; + QPushButton pb1(QStringLiteral("dynamicProperty_pb1")); + pb1.setMinimumWidth(160); + pb1.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100)); + + QPushButton pb2(QStringLiteral("dynamicProperty_pb2")); + pb2.setMinimumWidth(160); + pb2.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 200)); + pb1.setProperty("type", "critical"); qApp->setStyleSheet("*[class~=\"QPushButton\"] { color: red; } *[type=\"critical\"] { background: white; }"); QVERIFY(COLOR(pb1) == Qt::red); @@ -675,6 +690,8 @@ void tst_QStyleSheetStyle::onWidgetDestroyed() void tst_QStyleSheetStyle::fontPrecedence() { QLineEdit edit; + edit.setMinimumWidth(200); + centerOnScreen(&edit); edit.show(); QFont font; QVERIFY(FONTSIZE(edit) != 22); // Sanity check to make sure this test makes sense. @@ -737,8 +754,9 @@ void tst_QStyleSheetStyle::focusColors() // ten pixels of the right color requires quite a many characters, as the // majority of the pixels will have slightly different colors due to the // anti-aliasing effect. -#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) && !(defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL)) - QSKIP("This is a fragile test which fails on many esoteric platforms because of focus problems. " +#if !defined(Q_OS_WIN32) && !(defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(Q_CC_INTEL)) + QSKIP("This is a fragile test which fails on many esoteric platforms because of focus problems" + " (for example, QTBUG-33959)." "That doesn't mean that the feature doesn't work in practice."); #endif QList<QWidget *> widgets; @@ -768,6 +786,7 @@ void tst_QStyleSheetStyle::focusColors() layout->addWidget(widget); frame.setLayout(layout); + centerOnScreen(&frame); frame.show(); QApplication::setActiveWindow(&frame); QVERIFY(QTest::qWaitForWindowActive(&frame)); @@ -795,6 +814,9 @@ void tst_QStyleSheetStyle::focusColors() #ifndef QTEST_NO_CURSOR void tst_QStyleSheetStyle::hoverColors() { +#ifdef Q_OS_OSX + QSKIP("This test is fragile on Mac, most likely due to QTBUG-33959."); +#endif QList<QWidget *> widgets; widgets << new QPushButton("TESTING TESTING"); widgets << new QLineEdit("TESTING TESTING"); @@ -822,31 +844,22 @@ void tst_QStyleSheetStyle::hoverColors() layout->addWidget(widget); frame.setLayout(layout); + centerOnScreen(&frame); frame.show(); QApplication::setActiveWindow(&frame); QVERIFY(QTest::qWaitForWindowActive(&frame)); //move the mouse inside the widget, it should be colored QTest::mouseMove ( widget, QPoint(6,6)); - QTest::qWait(60); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "Numerous failures related to Qt::WA_UnderMouse, see QTBUGT-23685", Continue); -#endif - QVERIFY(widget->testAttribute(Qt::WA_UnderMouse)); + QTRY_VERIFY(widget->testAttribute(Qt::WA_UnderMouse)); QImage image(frame.width(), frame.height(), QImage::Format_ARGB32); frame.render(&image); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "Numerous failures related to Qt::WA_UnderMouse, see QTBUGT-23685", Continue); -#endif QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), (QString::fromLatin1(widget->metaObject()->className()) + " did not contain background color #e8ff66").toLocal8Bit().constData()); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "Numerous failures related to Qt::WA_UnderMouse, see QTBUGT-23685", Continue); -#endif QVERIFY2(testForColors(image, QColor(0xff, 0x00, 0x84)), (QString::fromLatin1(widget->metaObject()->className()) + " did not contain text color #ff0084").toLocal8Bit().constData()); @@ -866,9 +879,7 @@ void tst_QStyleSheetStyle::hoverColors() //move the mouse again inside the widget, it should be colored QTest::mouseMove (widget, QPoint(5,5)); - QTest::qWait(60); - - QVERIFY(widget->testAttribute(Qt::WA_UnderMouse)); + QTRY_VERIFY(widget->testAttribute(Qt::WA_UnderMouse)); frame.render(&image); @@ -904,35 +915,47 @@ public: void tst_QStyleSheetStyle::background() { - const int number = 4; - QWidget* widgets[number]; + typedef QSharedPointer<QWidget> WidgetPtr; + + const QString styleSheet = QStringLiteral("* { background-color: #e8ff66; }"); + QVector<WidgetPtr> widgets; + const QPoint topLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft(); // Testing inheritance styling of QDialog. - widgets[0] = new SingleInheritanceDialog; - widgets[0]->setStyleSheet("* { background-color: #e8ff66; }"); - widgets[1] = new DoubleInheritanceDialog; - widgets[1]->setStyleSheet("* { background-color: #e8ff66; }"); + WidgetPtr toplevel(new SingleInheritanceDialog); + toplevel->resize(200, 200); + toplevel->move(topLeft + QPoint(20, 20)); + toplevel->setStyleSheet(styleSheet); + widgets.append(toplevel); + + toplevel = WidgetPtr(new DoubleInheritanceDialog); + toplevel->resize(200, 200); + toplevel->move(topLeft + QPoint(20, 320)); + toplevel->setStyleSheet(styleSheet); + widgets.append(toplevel); // Testing gradients in QComboBox. - QLayout* layout; - QComboBox* cb; // First color - widgets[2] = new QDialog; - layout = new QGridLayout; - cb = new QComboBox; + toplevel = WidgetPtr(new QDialog); + toplevel->move(topLeft + QPoint(320, 20)); + QGridLayout *layout = new QGridLayout(toplevel.data()); + QComboBox* cb = new QComboBox; + cb->setMinimumWidth(160); cb->setStyleSheet("* { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #e8ff66, stop:1 #000000); }"); - layout->addWidget(cb); - widgets[2]->setLayout(layout); + layout->addWidget(cb, 0, 0); + widgets.append(toplevel); // Second color - widgets[3] = new QDialog; - layout = new QGridLayout; + toplevel = WidgetPtr(new QDialog); + toplevel->move(topLeft + QPoint(320, 320)); + layout = new QGridLayout(toplevel.data()); cb = new QComboBox; + cb->setMinimumWidth(160); cb->setStyleSheet("* { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 #e8ff66, stop:1 #000000); }"); - layout->addWidget(cb); - widgets[3]->setLayout(layout); - - for (int c = 0; c < number; ++c) { - QWidget* widget = widgets[c]; + layout->addWidget(cb, 0, 0); + widgets.append(toplevel); + for (int c = 0; c < widgets.size(); ++c) { + QWidget *widget = widgets.at(c).data(); + widget->setWindowTitle(QStringLiteral("background ") + QString::number(c)); widget->show(); QVERIFY(QTest::qWaitForWindowExposed(widget)); @@ -941,12 +964,15 @@ void tst_QStyleSheetStyle::background() if (image.depth() < 24) QSKIP("Test doesn't support color depth < 24"); + if (c == 2 && !QApplication::style()->objectName().compare(QLatin1String("fusion"), Qt::CaseInsensitive)) + QEXPECT_FAIL("", "QTBUG-21468", Abort); + QVERIFY2(testForColors(image, QColor(0xe8, 0xff, 0x66)), - (QString::fromLatin1(widget->metaObject()->className()) + (QString::number(c) + QLatin1Char(' ') + QString::fromLatin1(widget->metaObject()->className()) + " did not contain background image with color #e8ff66") .toLocal8Bit().constData()); - delete widget; + widget->hide(); } } @@ -956,6 +982,7 @@ void tst_QStyleSheetStyle::tabAlignement() QTabWidget tabWidget(&topLevel); tabWidget.addTab(new QLabel("tab1"),"tab1"); tabWidget.resize(QSize(400,400)); + centerOnScreen(&topLevel); topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QTabBar *bar = tabWidget.findChild<QTabBar*>(); @@ -1023,6 +1050,7 @@ void tst_QStyleSheetStyle::minmaxSizes() tabWidget.setStyleSheet("QTabBar::tab { min-width:100px; max-width:130px; }"); + centerOnScreen(&tabWidget); tabWidget.show(); QTest::qWait(50); //i allow 4px additional border from the native style (hence the -2, <=2) @@ -1050,6 +1078,7 @@ void tst_QStyleSheetStyle::task206238_twice() tw->addTab(new QLabel("foo"), "test"); w.setCentralWidget(tw); w.setStyleSheet("background: red;"); + centerOnScreen(&w); w.show(); QTest::qWait(20); QCOMPARE(BACKGROUND(w) , QColor("red")); @@ -1219,6 +1248,8 @@ void tst_QStyleSheetStyle::proxyStyle() QString styleSheet("QPushButton {background-color: red; }"); QWidget *w = new QWidget; + w->setMinimumWidth(160); + centerOnScreen(w); QVBoxLayout *layout = new QVBoxLayout(w); QPushButton *pb1 = new QPushButton(qApp->style()->objectName(), w); @@ -1294,6 +1325,7 @@ void tst_QStyleSheetStyle::emptyStyleSheet() layout.addWidget(new QDateEdit(&w)); layout.addWidget(new QGroupBox("some text", &w)); + centerOnScreen(&w); w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); //workaround the fact that the label sizehint is one pixel different the first time. @@ -1315,13 +1347,30 @@ void tst_QStyleSheetStyle::emptyStyleSheet() img2.save("emptyStyleSheet_img2.png"); } + QEXPECT_FAIL("", "QTBUG-21468", Abort); QCOMPARE(img1,img2); } +class ApplicationStyleSetter +{ +public: + explicit inline ApplicationStyleSetter(QStyle *s) : m_oldStyleName(QApplication::style()->objectName()) + { QApplication::setStyle(s); } + inline ~ApplicationStyleSetter() + { QApplication::setStyle(QStyleFactory::create(m_oldStyleName)); } + +private: + const QString m_oldStyleName; +}; + void tst_QStyleSheetStyle::toolTip() { qApp->setStyleSheet(QString()); QWidget w; + // Use "Fusion" to prevent the Vista style from clobbering the tooltip palette in polish(). + QStyle *fusionStyle = QStyleFactory::create(QLatin1String("Fusion")); + QVERIFY(fusionStyle); + ApplicationStyleSetter as(fusionStyle); QHBoxLayout layout(&w); w.setLayout(&layout); @@ -1349,11 +1398,12 @@ void tst_QStyleSheetStyle::toolTip() wid4->setToolTip("this is wid4"); wid4->setObjectName("wid4"); + centerOnScreen(&w); w.show(); qApp->setActiveWindow(&w); QVERIFY(QTest::qWaitForWindowActive(&w)); - QColor normalToolTip = qApp->palette().toolTipBase().color(); + const QColor normalToolTip = QToolTip::palette().color(QPalette::Inactive, QPalette::ToolTipBase); QList<QWidget *> widgets; QList<QColor> colors; @@ -1372,12 +1422,13 @@ void tst_QStyleSheetStyle::toolTip() QWidget *tooltip = 0; foreach (QWidget *widget, QApplication::topLevelWidgets()) { - if (widget->inherits("QTipLabel") && widget->isVisible()) { + if (widget->inherits("QTipLabel")) { tooltip = widget; break; } } QVERIFY(tooltip); + QTRY_VERIFY(tooltip->isVisible()); // Wait until Roll-Effect is finished (Windows Vista) QCOMPARE(tooltip->palette().color(tooltip->backgroundRole()), col); } @@ -1394,6 +1445,8 @@ void tst_QStyleSheetStyle::embeddedFonts() { //task 235622 and 210551 QSpinBox spin; + spin.setMinimumWidth(160); + spin.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 20)); spin.show(); spin.setStyleSheet("QSpinBox { font-size: 32px; }"); QTest::qWait(20); @@ -1411,6 +1464,8 @@ void tst_QStyleSheetStyle::embeddedFonts() //task 242556 QComboBox box; + box.setMinimumWidth(160); + box.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 120)); box.setEditable(true); box.addItems(QStringList() << "First" << "Second" << "Third"); box.setStyleSheet("QComboBox { font-size: 32px; }"); @@ -1483,6 +1538,7 @@ void tst_QStyleSheetStyle::complexWidgetFocus() layout->addWidget(widget); frame.setLayout(layout); + centerOnScreen(&frame); frame.show(); QApplication::setActiveWindow(&frame); QVERIFY(QTest::qWaitForWindowActive(&frame)); @@ -1507,6 +1563,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground() { QTreeView tree; tree.setStyleSheet( "QTreeView:disabled { background-color:#ab1251; }" ); + tree.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(20, 100)); tree.show(); QTest::qWait(20); QImage image(tree.width(), tree.height(), QImage::Format_ARGB32); @@ -1527,6 +1584,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground() QTableWidget table(12, 12); table.setItem(0, 0, new QTableWidgetItem()); table.setStyleSheet( "QTableView {background-color: #ff0000}" ); + table.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(300, 100)); table.show(); QTest::qWait(20); image = QImage(table.width(), table.height(), QImage::Format_ARGB32); @@ -1560,6 +1618,7 @@ void tst_QStyleSheetStyle::task232085_spinBoxLineEditBg() layout->addWidget(spinbox); frame.setLayout(layout); + centerOnScreen(&frame); frame.show(); QApplication::setActiveWindow(&frame); spinbox->setFocus(); @@ -1619,6 +1678,7 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash() Widget(QWidget *parent = 0) : QWidget(parent) { + setMinimumWidth(160); QVBoxLayout* pLayout = new QVBoxLayout(this); QCheckBox* pCheckBox = new QCheckBox(this); pLayout->addWidget(pCheckBox); @@ -1633,6 +1693,7 @@ void tst_QStyleSheetStyle::QTBUG11658_cachecrash() Widget *w = new Widget(); delete w; w = new Widget(); + centerOnScreen(w); w->show(); QVERIFY(QTest::qWaitForWindowExposed(w)); @@ -1653,6 +1714,8 @@ void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget() } } w; w.setStyleSheet("* { background-color: white; color:black; border 3px solid yellow }"); + w.setMinimumWidth(160); + centerOnScreen(&w); w.show(); QVERIFY(QTest::qWaitForWindowExposed(&w)); } @@ -1675,6 +1738,7 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup() // parsing of this stylesheet must not crash, and it must be correctly applied widget.setStyleSheet(QStringLiteral("QHeaderView::section:vertical { background-color: #FF0000 }")); + centerOnScreen(&widget); widget.show(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); @@ -1685,6 +1749,8 @@ void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup() QHeaderView *verticalHeader = widget.verticalHeader(); QImage image(verticalHeader->size(), QImage::Format_ARGB32); verticalHeader->render(&image); + if (!QApplication::style()->objectName().compare(QLatin1String("fusion"), Qt::CaseInsensitive)) + QEXPECT_FAIL("", "QTBUG-21468", Abort); QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00))); } diff --git a/tests/auto/widgets/styles/styles.pro b/tests/auto/widgets/styles/styles.pro index 1791279b72..508b6ecd41 100644 --- a/tests/auto/widgets/styles/styles.pro +++ b/tests/auto/widgets/styles/styles.pro @@ -12,5 +12,5 @@ SUBDIRS=\ !mac:SUBDIRS -= \ qmacstyle \ -!contains( styles, motif ):SUBDIRS -= \ +ios|android|qnx|*wince*:SUBDIRS -= \ qstylesheetstyle \ diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 509ccc37b6..abc0129f8b 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2064,7 +2064,7 @@ void tst_QComboBox::itemListPosition() topLevel.move(screen.width() - topLevel.sizeHint().width() - 10, 0); //puts the combo to the top-right corner - topLevel.show(); + topLevel.showNormal(); //wait because the window manager can move the window if there is a right panel QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); @@ -2232,7 +2232,7 @@ void tst_QComboBox::task190205_setModelAdjustToContents() box.move(100, 100); box.setSizeAdjustPolicy(QComboBox::AdjustToContents); box.addItems(initialContent); - box.show(); + box.showNormal(); //wait needed in order to get the combo initial size QTRY_VERIFY(box.isVisible()); @@ -2244,7 +2244,7 @@ void tst_QComboBox::task190205_setModelAdjustToContents() correctBox.move(400, 100); correctBox.addItems(finalContent); - correctBox.show(); + correctBox.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&box)); QVERIFY(QTest::qWaitForWindowExposed(&correctBox)); @@ -2266,7 +2266,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize() comboBox.setGeometry(desktopSize.width() - (desktopSize.width() / 4), (desktopSize.width() / 4), (desktopSize.width() / 2), (desktopSize.width() / 4)); - comboBox.show(); + comboBox.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&comboBox)); QTRY_VERIFY(comboBox.isVisible()); comboBox.showPopup(); @@ -2274,7 +2274,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize() QTest::qWaitForWindowExposed(comboBox.view()); QTRY_VERIFY(comboBox.view()->isVisible()); -#ifdef QT_BUILD_INTERNAL +#if defined QT_BUILD_INTERNAL && !defined Q_OS_BLACKBERRY QFrame *container = comboBox.findChild<QComboBoxPrivateContainer *>(); QVERIFY(container); QTRY_VERIFY(desktop.screenGeometry(container).contains(container->geometry())); @@ -2609,7 +2609,7 @@ void tst_QComboBox::keyBoardNavigationWithMouse() for (int i = 0; i < 80; i++) combo.addItem( QString::number(i)); - combo.show(); + combo.showNormal(); centerCursor(&combo); // QTBUG-33973, cursor needs to be within view from start on Mac. QApplication::setActiveWindow(&combo); QVERIFY(QTest::qWaitForWindowActive(&combo)); @@ -2629,7 +2629,7 @@ void tst_QComboBox::keyBoardNavigationWithMouse() QCOMPARE(combo.currentText(), QLatin1String("0")); // When calling cursor function, Windows CE responds with: This function is not supported on this system. -#ifndef Q_OS_WINCE +#if !defined Q_OS_WINCE && !defined Q_OS_QNX // Force cursor movement to prevent QCursor::setPos() from returning prematurely on QPA: centerCursor(combo.view()); QTest::qWait(200); diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index 6551a88232..095fa3347d 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -801,13 +801,16 @@ void tst_QDockWidget::task237438_setFloatingCrash() void tst_QDockWidget::task248604_infiniteResize() { +#if defined Q_OS_BLACKBERRY + QSKIP("Top level window is stretched to fullscreen"); +#endif QDockWidget d; QTabWidget *t = new QTabWidget; t->addTab(new QWidget, "Foo"); d.setWidget(t); d.setContentsMargins(2, 2, 2, 2); d.setMinimumSize(320, 240); - d.show(); + d.showNormal(); QTest::qWait(400); QCOMPARE(d.size(), QSize(320, 240)); } diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index 6784ee477b..6b763f5a4c 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -825,6 +825,8 @@ void tst_QDoubleSpinBox::editingFinished() QCOMPARE(editingFinishedSpy1.count(), 4); QCOMPARE(editingFinishedSpy2.count(), 4); + testFocusWidget->show(); // On BlackBerry this is our root window we need to show it again + // otherwise subsequent tests will fail } void tst_QDoubleSpinBox::removeAll() diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 077e1aa1df..36f14cb1ba 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -1322,7 +1322,7 @@ void tst_QLineEdit::undo_keypressevents_data() // unselect any current selection keys.addKeyClick(Qt::Key_Right); -#ifdef Q_OS_WIN //Mac has a specialcase to handle jumping to the end of a selection +#if defined Q_OS_WIN || defined Q_OS_QNX //Windows and QNX do not jump to the beginning of the selection keys.addKeyClick(Qt::Key_Left); #endif @@ -3206,7 +3206,7 @@ void tst_QLineEdit::leftKeyOnSelectedText() QCOMPARE(testWidget->cursorPosition(), 2); QCOMPARE(testWidget->selectedText(), QString("23")); QTest::keyClick(testWidget, Qt::Key_Left); -#ifdef Q_OS_WIN +#if defined Q_OS_WIN || defined Q_OS_QNX QCOMPARE(testWidget->cursorPosition(), 1); #else // Selection is cleared ands cursor remains at position 2. diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index bc2e4caacd..59021108a2 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -1007,7 +1007,7 @@ void tst_QMdiArea::activeSubWindow() qApp->setActiveWindow(&mainWindow); QCOMPARE(mdiArea->activeSubWindow(), subWindow); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) +#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) && !defined(Q_OS_QNX) qApp->setActiveWindow(0); QVERIFY(!mdiArea->activeSubWindow()); #endif @@ -1088,7 +1088,7 @@ void tst_QMdiArea::currentSubWindow() QVERIFY(mdiArea.activeSubWindow()); QVERIFY(mdiArea.currentSubWindow()); -#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) +#if !defined(Q_OS_MAC) && !defined(Q_OS_WIN) && !defined(Q_OS_QNX) qApp->setActiveWindow(0); QVERIFY(!mdiArea.activeSubWindow()); QVERIFY(mdiArea.currentSubWindow()); @@ -1701,7 +1701,7 @@ void tst_QMdiArea::tileSubWindows() qApp->processEvents(); QTRY_COMPARE(workspace.size(), QSize(350, 150)); - const QSize minSize(300, 100); + const QSize minSize(600, 130); foreach (QMdiSubWindow *subWindow, workspace.subWindowList()) subWindow->setMinimumSize(minSize); @@ -1908,6 +1908,9 @@ void tst_QMdiArea::dontMaximizeSubWindowOnActivation() for (int i = 0; i < 5; ++i) { QMdiSubWindow *window = mdiArea.addSubWindow(new QWidget); window->show(); +#if defined Q_OS_QNX + QEXPECT_FAIL("", "QTBUG-38231", Abort); +#endif QVERIFY(window->isMaximized()); qApp->processEvents(); } diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 268638a504..ffc3e3b67d 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -206,6 +206,7 @@ private slots: void task_233197(); void task_226929(); void styleChange(); + void testFullScreenState(); }; void tst_QMdiSubWindow::initTestCase() @@ -2007,6 +2008,19 @@ void tst_QMdiSubWindow::styleChange() QCOMPARE(spy.count(), 0); } +void tst_QMdiSubWindow::testFullScreenState() +{ + QMdiArea mdiArea; + mdiArea.showMaximized(); + + QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget); + subWindow->setGeometry(0, 0, 300, 300); + subWindow->showFullScreen(); // QMdiSubWindow does not support the fullscreen state. This call + // should be equivalent to setVisible(true) (and not showNormal()) + QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); + QCOMPARE(subWindow->size(), QSize(300, 300)); +} + QTEST_MAIN(tst_QMdiSubWindow) #include "tst_qmdisubwindow.moc" diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp index 6a3bcc7a7d..fadfc0b48a 100644 --- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -60,26 +60,26 @@ class XmlServer : public QThread { Q_OBJECT public: - XmlServer(); + XmlServer(QObject *parent = 0) : QThread(parent), quit_soon(false), listening(false) {} + bool quit_soon; + bool listening; protected: virtual void run(); }; -XmlServer::XmlServer() -{ - quit_soon = false; -} - -#define CHUNK_SIZE 1 +#define CHUNK_SIZE 2048 void XmlServer::run() { QTcpServer srv; - if (!srv.listen(QHostAddress::Any, TEST_PORT)) + listening = srv.listen(QHostAddress::Any, TEST_PORT); + if (!listening) { + qWarning() << "Failed to listen on" << TEST_PORT << srv.errorString(); return; + } for (;;) { srv.waitForNewConnection(100); @@ -168,12 +168,9 @@ class tst_QXmlSimpleReader : public QObject QString prefix; }; -tst_QXmlSimpleReader::tst_QXmlSimpleReader() +tst_QXmlSimpleReader::tst_QXmlSimpleReader() : server(new XmlServer(this)) { - server = new XmlServer(); - server->setParent(this); server->start(); - QTest::qSleep(1000); } tst_QXmlSimpleReader::~tst_QXmlSimpleReader() @@ -568,16 +565,13 @@ void tst_QXmlSimpleReader::inputFromSocket() { QFETCH(QString, file_name); + QTRY_VERIFY(server->listening); + QTcpSocket sock; sock.connectToHost(QHostAddress::LocalHost, TEST_PORT); - - const bool connectionSuccess = sock.waitForConnected(); - if(!connectionSuccess) { - QTextStream out(stderr); - out << "QTcpSocket::errorString()" << sock.errorString(); - } - - QVERIFY(connectionSuccess); + QVERIFY2(sock.waitForConnected(), + qPrintable(QStringLiteral("Cannot connect on port ") + QString::number(TEST_PORT) + + QStringLiteral(": ") + sock.errorString())); sock.write(file_name.toLocal8Bit() + "\n"); QVERIFY(sock.waitForBytesWritten()); |