diff options
author | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2016-01-21 04:27:06 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-01-21 04:27:06 +0000 |
commit | 7b2fb038ae4b8b9231ae989ad309b6eca107a858 (patch) | |
tree | 04001416e9589b7e79a6a5b1490e7eaabc22e82a /tests | |
parent | 9c0de96454570aec3fe88ba6b5d7c61b666b5753 (diff) | |
parent | 8f569c740a91b98365dcdaee2444038ce4957a76 (diff) |
Merge "Merge remote-tracking branch 'origin/5.5' into 5.6" into refs/staging/5.6
Diffstat (limited to 'tests')
15 files changed, 231 insertions, 83 deletions
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 3aa06d237d..8a9ae0cd72 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -1588,10 +1588,17 @@ void tst_QTextCodec::utf8bom_data() << QString("a"); } - { + { // test the non-SIMD code-path static const ushort data[] = { 0x61, 0xfeff, 0x62 }; - QTest::newRow("middle-bom") - << QByteArray("a\357\273\277b", 5) + QTest::newRow("middle-bom (non SIMD)") + << QByteArray("a\357\273\277b") + << QString::fromUtf16(data, sizeof(data)/sizeof(short)); + } + + { // test the SIMD code-path + static const ushort data[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0xfeff, 0x6d }; + QTest::newRow("middle-bom (SIMD)") + << QByteArray("abcdefghijkl\357\273\277m") << QString::fromUtf16(data, sizeof(data)/sizeof(short)); } } diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 334f5aba05..f637ffcfc5 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -75,16 +75,15 @@ void tst_QIODevice::getSetCheck() { // OpenMode QIODevice::openMode() // void QIODevice::setOpenMode(OpenMode) - class MyIODevice : public QIODevice { + class MyIODevice : public QTcpSocket { public: - void setOpenMode(OpenMode openMode) { QIODevice::setOpenMode(openMode); } + using QTcpSocket::setOpenMode; }; - QTcpSocket var1; - MyIODevice *obj1 = reinterpret_cast<MyIODevice*>(&var1); - obj1->setOpenMode(QIODevice::OpenMode(QIODevice::NotOpen)); - QCOMPARE(QIODevice::OpenMode(QIODevice::NotOpen), obj1->openMode()); - obj1->setOpenMode(QIODevice::OpenMode(QIODevice::ReadWrite)); - QCOMPARE(QIODevice::OpenMode(QIODevice::ReadWrite), obj1->openMode()); + MyIODevice var1; + var1.setOpenMode(QIODevice::OpenMode(QIODevice::NotOpen)); + QCOMPARE(QIODevice::OpenMode(QIODevice::NotOpen), var1.openMode()); + var1.setOpenMode(QIODevice::OpenMode(QIODevice::ReadWrite)); + QCOMPARE(QIODevice::OpenMode(QIODevice::ReadWrite), var1.openMode()); } //---------------------------------------------------------------------------------- diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 10ffa06245..c74a43b682 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -369,40 +369,40 @@ void tst_QMetaType::normalizedTypes() } #define TYPENAME_DATA(MetaTypeName, MetaTypeId, RealType)\ - QTest::newRow(#RealType) << QMetaType::MetaTypeName << #RealType; + QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << #RealType; void tst_QMetaType::typeName_data() { - QTest::addColumn<QMetaType::Type>("aType"); + QTest::addColumn<int>("aType"); QTest::addColumn<QString>("aTypeName"); QT_FOR_EACH_STATIC_TYPE(TYPENAME_DATA) - QTest::newRow("QMetaType::UnknownType") << QMetaType::UnknownType << static_cast<const char*>(0); + QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << static_cast<const char*>(0); - QTest::newRow("Whity<double>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<double> >()) << QString::fromLatin1("Whity<double>"); - QTest::newRow("Whity<int>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<int> >()) << QString::fromLatin1("Whity<int>"); - QTest::newRow("Testspace::Foo") << static_cast<QMetaType::Type>(::qMetaTypeId<TestSpace::Foo>()) << QString::fromLatin1("TestSpace::Foo"); + QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << QString::fromLatin1("Whity<double>"); + QTest::newRow("Whity<int>") << ::qMetaTypeId<Whity<int> >() << QString::fromLatin1("Whity<int>"); + QTest::newRow("Testspace::Foo") << ::qMetaTypeId<TestSpace::Foo>() << QString::fromLatin1("TestSpace::Foo"); - QTest::newRow("-1") << QMetaType::Type(-1) << QString(); - QTest::newRow("-124125534") << QMetaType::Type(-124125534) << QString(); - QTest::newRow("124125534") << QMetaType::Type(124125534) << QString(); + QTest::newRow("-1") << -1 << QString(); + QTest::newRow("-124125534") << -124125534 << QString(); + QTest::newRow("124125534") << 124125534 << QString(); // automatic registration - QTest::newRow("QList<int>") << static_cast<QMetaType::Type>(::qMetaTypeId<QList<int> >()) << QString::fromLatin1("QList<int>"); - QTest::newRow("QHash<int,int>") << static_cast<QMetaType::Type>(::qMetaTypeId<QHash<int, int> >()) << QString::fromLatin1("QHash<int,int>"); - QTest::newRow("QMap<int,int>") << static_cast<QMetaType::Type>(::qMetaTypeId<QMap<int, int> >()) << QString::fromLatin1("QMap<int,int>"); - QTest::newRow("QVector<QList<int>>") << static_cast<QMetaType::Type>(::qMetaTypeId<QVector<QList<int> > >()) << QString::fromLatin1("QVector<QList<int> >"); - QTest::newRow("QVector<QMap<int,int>>") << static_cast<QMetaType::Type>(::qMetaTypeId<QVector<QMap<int, int> > >()) << QString::fromLatin1("QVector<QMap<int,int> >"); + QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QList<int>"); + QTest::newRow("QHash<int,int>") << ::qMetaTypeId<QHash<int, int> >() << QString::fromLatin1("QHash<int,int>"); + QTest::newRow("QMap<int,int>") << ::qMetaTypeId<QMap<int, int> >() << QString::fromLatin1("QMap<int,int>"); + QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QVector<QList<int> >"); + QTest::newRow("QVector<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QVector<QMap<int,int> >"); - QTest::newRow("CustomQObject*") << static_cast<QMetaType::Type>(::qMetaTypeId<CustomQObject*>()) << QString::fromLatin1("CustomQObject*"); - QTest::newRow("CustomGadget") << static_cast<QMetaType::Type>(::qMetaTypeId<CustomGadget>()) << QString::fromLatin1("CustomGadget"); - QTest::newRow("CustomQObject::CustomQEnum") << static_cast<QMetaType::Type>(::qMetaTypeId<CustomQObject::CustomQEnum>()) << QString::fromLatin1("CustomQObject::CustomQEnum"); - QTest::newRow("Qt::ArrowType") << static_cast<QMetaType::Type>(::qMetaTypeId<Qt::ArrowType>()) << QString::fromLatin1("Qt::ArrowType"); + QTest::newRow("CustomQObject*") << ::qMetaTypeId<CustomQObject*>() << QString::fromLatin1("CustomQObject*"); + QTest::newRow("CustomGadget") << ::qMetaTypeId<CustomGadget>() << QString::fromLatin1("CustomGadget"); + QTest::newRow("CustomQObject::CustomQEnum") << ::qMetaTypeId<CustomQObject::CustomQEnum>() << QString::fromLatin1("CustomQObject::CustomQEnum"); + QTest::newRow("Qt::ArrowType") << ::qMetaTypeId<Qt::ArrowType>() << QString::fromLatin1("Qt::ArrowType"); } void tst_QMetaType::typeName() { - QFETCH(QMetaType::Type, aType); + QFETCH(int, aType); QFETCH(QString, aTypeName); QString name = QString::fromLatin1(QMetaType::typeName(aType)); @@ -413,15 +413,15 @@ void tst_QMetaType::typeName() void tst_QMetaType::type_data() { - QTest::addColumn<QMetaType::Type>("aType"); + QTest::addColumn<int>("aType"); QTest::addColumn<QByteArray>("aTypeName"); #define TST_QMETATYPE_TYPE_DATA(MetaTypeName, MetaTypeId, RealType)\ - QTest::newRow(#RealType) << QMetaType::MetaTypeName << QByteArray( #RealType ); + QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << QByteArray( #RealType ); #define TST_QMETATYPE_TYPE_DATA_ALIAS(MetaTypeName, MetaTypeId, AliasType, RealTypeString)\ - QTest::newRow(RealTypeString) << QMetaType::MetaTypeName << QByteArray( #AliasType ); + QTest::newRow(RealTypeString) << int(QMetaType::MetaTypeName) << QByteArray( #AliasType ); - QTest::newRow("empty") << QMetaType::UnknownType << QByteArray(); + QTest::newRow("empty") << int(QMetaType::UnknownType) << QByteArray(); QT_FOR_EACH_STATIC_TYPE(TST_QMETATYPE_TYPE_DATA) QT_FOR_EACH_STATIC_ALIAS_TYPE(TST_QMETATYPE_TYPE_DATA_ALIAS) @@ -432,13 +432,13 @@ void tst_QMetaType::type_data() void tst_QMetaType::type() { - QFETCH(QMetaType::Type, aType); + QFETCH(int, aType); QFETCH(QByteArray, aTypeName); // QMetaType::type(QByteArray) - QCOMPARE(QMetaType::type(aTypeName), int(aType)); + QCOMPARE(QMetaType::type(aTypeName), aType); // QMetaType::type(const char *) - QCOMPARE(QMetaType::type(aTypeName.constData()), int(aType)); + QCOMPARE(QMetaType::type(aTypeName.constData()), aType); } void tst_QMetaType::type_fromSubString_data() @@ -727,9 +727,9 @@ template<> struct TestValueFactory<QMetaType::QVariant> { void tst_QMetaType::create_data() { - QTest::addColumn<QMetaType::Type>("type"); + QTest::addColumn<int>("type"); #define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ - QTest::newRow(QMetaType::typeName(QMetaType::MetaTypeName)) << QMetaType::MetaTypeName; + QTest::newRow(QMetaType::typeName(QMetaType::MetaTypeName)) << int(QMetaType::MetaTypeName); FOR_EACH_CORE_METATYPE(ADD_METATYPE_TEST_ROW) #undef ADD_METATYPE_TEST_ROW } @@ -781,7 +781,7 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_FUNCTION) } }; - QFETCH(QMetaType::Type, type); + QFETCH(int, type); TypeTestFunctionGetter::get(type)(); } @@ -832,33 +832,33 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_COPY_FUNCTION) } }; - QFETCH(QMetaType::Type, type); + QFETCH(int, type); TypeTestFunctionGetter::get(type)(); } void tst_QMetaType::sizeOf_data() { - QTest::addColumn<QMetaType::Type>("type"); + QTest::addColumn<int>("type"); QTest::addColumn<size_t>("size"); - QTest::newRow("QMetaType::UnknownType") << QMetaType::UnknownType << size_t(0); + QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << size_t(0); #define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ - QTest::newRow(#RealType) << QMetaType::MetaTypeName << size_t(QTypeInfo<RealType>::sizeOf); + QTest::newRow(#RealType) << int(QMetaType::MetaTypeName) << size_t(QTypeInfo<RealType>::sizeOf); FOR_EACH_CORE_METATYPE(ADD_METATYPE_TEST_ROW) #undef ADD_METATYPE_TEST_ROW - QTest::newRow("Whity<double>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<double> >()) << sizeof(Whity<double>); -QTest::newRow("Whity<int>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<int> >()) << sizeof(Whity<int>); - QTest::newRow("Testspace::Foo") << static_cast<QMetaType::Type>(::qMetaTypeId<TestSpace::Foo>()) << sizeof(TestSpace::Foo); + QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << sizeof(Whity<double>); + QTest::newRow("Whity<int>") << ::qMetaTypeId<Whity<int> >() << sizeof(Whity<int>); + QTest::newRow("Testspace::Foo") << ::qMetaTypeId<TestSpace::Foo>() << sizeof(TestSpace::Foo); - QTest::newRow("-1") << QMetaType::Type(-1) << size_t(0); - QTest::newRow("-124125534") << QMetaType::Type(-124125534) << size_t(0); - QTest::newRow("124125534") << QMetaType::Type(124125534) << size_t(0); + QTest::newRow("-1") << -1 << size_t(0); + QTest::newRow("-124125534") << -124125534 << size_t(0); + QTest::newRow("124125534") << 124125534 << size_t(0); } void tst_QMetaType::sizeOf() { - QFETCH(QMetaType::Type, type); + QFETCH(int, type); QFETCH(size_t, size); QCOMPARE(size_t(QMetaType::sizeOf(type)), size); } @@ -870,7 +870,7 @@ void tst_QMetaType::sizeOfStaticLess_data() void tst_QMetaType::sizeOfStaticLess() { - QFETCH(QMetaType::Type, type); + QFETCH(int, type); QFETCH(size_t, size); QCOMPARE(size_t(QMetaType(type).sizeOf()), size); } @@ -1126,7 +1126,7 @@ FOR_EACH_CORE_METATYPE(RETURN_CONSTRUCT_FUNCTION) } }; - QFETCH(QMetaType::Type, type); + QFETCH(int, type); TypeTestFunctionGetter::get(type)(); } @@ -1194,7 +1194,7 @@ FOR_EACH_CORE_METATYPE(RETURN_CONSTRUCT_COPY_FUNCTION) } }; - QFETCH(QMetaType::Type, type); + QFETCH(int, type); TypeTestFunctionGetter::get(type)(); } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index a3c6d8e9df..f7c1f03c0f 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -5987,7 +5987,7 @@ class GetSenderObject : public QObject { Q_OBJECT public: - QObject *accessSender() { return sender(); } + using QObject::sender; // make public public Q_SLOTS: void triggerSignal() { Q_EMIT aSignal(); } @@ -6003,8 +6003,8 @@ struct CountedStruct CountedStruct(GetSenderObject *sender) : sender(sender) { ++countedStructObjectsCount; } CountedStruct(const CountedStruct &o) : sender(o.sender) { ++countedStructObjectsCount; } CountedStruct &operator=(const CountedStruct &) { return *this; } - // accessSender here allows us to check if there's a deadlock - ~CountedStruct() { --countedStructObjectsCount; if (sender != Q_NULLPTR) (void)sender->accessSender(); } + // calling sender() here allows us to check if there's a deadlock + ~CountedStruct() { --countedStructObjectsCount; if (sender) (void)sender->sender(); } void operator()() const { } GetSenderObject *sender; @@ -6396,7 +6396,8 @@ void tst_QObject::noDeclarativeParentChangedOnDestruction() QObject *parent = new QObject; QObject *child = new QObject; - QAbstractDeclarativeData dummy; + QAbstractDeclarativeDataImpl dummy; + dummy.ownedByQml1 = false; QObjectPrivate::get(child)->declarativeData = &dummy; parentChangeCalled = false; diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index cfbb88a123..8c76809c48 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -252,6 +252,7 @@ private slots: void conflictingTransition2(); void qtbug_46059(); void qtbug_46703(); + void postEventFromBeginSelectTransitions(); }; class TestState : public QState @@ -6606,5 +6607,33 @@ void tst_QStateMachine::qtbug_46703() QVERIFY(machine.isRunning()); } +void tst_QStateMachine::postEventFromBeginSelectTransitions() +{ + class StateMachine : public QStateMachine { + protected: + void beginSelectTransitions(QEvent* e) Q_DECL_OVERRIDE { + if (e->type() == QEvent::Type(QEvent::User + 2)) + postEvent(new QEvent(QEvent::Type(QEvent::User + 1)), QStateMachine::HighPriority); + } + } machine; + QState a(&machine); + QState success(&machine); + + machine.setInitialState(&a); + a.addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), &success)); + + machine.start(); + + QTRY_COMPARE(machine.configuration().contains(&a), true); + QTRY_COMPARE(machine.configuration().contains(&success), false); + + machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 2)), QStateMachine::NormalPriority); + + QTRY_COMPARE(machine.configuration().contains(&a), false); + QTRY_COMPARE(machine.configuration().contains(&success), true); + + QVERIFY(machine.isRunning()); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index b63485e91e..ab5bc410f6 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -254,8 +254,10 @@ void tst_QSharedPointer::basics() QCOMPARE(ptr.data(), aData); QCOMPARE(ptr.operator->(), aData); - Data &dataReference = *ptr; - QCOMPARE(&dataReference, aData); + if (!isNull) { + Data &dataReference = *ptr; + QCOMPARE(&dataReference, aData); + } QVERIFY(ptr == aData); QVERIFY(!(ptr != aData)); diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index b03a117f83..5254e755d4 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -24,7 +24,7 @@ SUBDIRS=\ qopenglwindow \ qrasterwindow -win32:!wince*:!winrt: SUBDIRS += noqteventloop +win32:!wince:!winrt:qtHaveModule(network): SUBDIRS += noqteventloop !qtHaveModule(widgets): SUBDIRS -= \ qmouseevent_modal \ diff --git a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro index de5715e147..a42b359f29 100644 --- a/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro +++ b/tests/auto/gui/kernel/noqteventloop/noqteventloop.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_noqteventloop -QT += core-private gui-private testlib +QT += core-private network gui-private testlib SOURCES += tst_noqteventloop.cpp diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp index d21569dcc0..735d23b137 100644 --- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp +++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp @@ -36,6 +36,9 @@ #include <QEvent> #include <QtCore/qthread.h> #include <QtGui/qguiapplication.h> +#include <QtNetwork/qtcpserver.h> +#include <QtNetwork/qtcpsocket.h> +#include <QtCore/qelapsedtimer.h> #include <QtCore/qt_windows.h> @@ -47,6 +50,7 @@ private slots: void initTestCase(); void cleanup(); void consumeMouseEvents(); + void consumeSocketEvents(); }; @@ -265,6 +269,36 @@ void tst_NoQtEventLoop::consumeMouseEvents() } +void tst_NoQtEventLoop::consumeSocketEvents() +{ + int argc = 1; + char *argv[] = { const_cast<char *>("test"), 0 }; + QGuiApplication app(argc, argv); + QTcpServer server; + QTcpSocket client; + + QVERIFY(server.listen(QHostAddress::LocalHost)); + client.connectToHost(server.serverAddress(), server.serverPort()); + QVERIFY(client.waitForConnected()); + + QElapsedTimer elapsedTimer; + elapsedTimer.start(); + + // Exec own message loop + MSG msg; + forever { + if (elapsedTimer.hasExpired(3000) || server.hasPendingConnections()) + break; + + if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + } + + QVERIFY(server.hasPendingConnections()); +} + #include <tst_noqteventloop.moc> QTEST_APPLESS_MAIN(tst_NoQtEventLoop) diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 8103f27911..e2ad502a52 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -39,6 +39,7 @@ #include <QtGui/QOpenGLVertexArrayObject> #include <QtGui/QOpenGLBuffer> #include <QtGui/QOpenGLPaintDevice> +#include <QtGui/QOpenGLTexture> #include <QtGui/QPainter> #include <QtGui/QScreen> #include <QtGui/QWindow> @@ -99,8 +100,8 @@ private slots: void textureblitterFullTargetRectTransform(); void textureblitterPartTargetRectTransform(); void defaultSurfaceFormat(); - void imageFormatPainting(); + void nullTextureInitializtion(); #ifdef USE_GLX void glxContextWrap(); @@ -1524,6 +1525,18 @@ void tst_QOpenGL::bufferMapRange() ctx->doneCurrent(); } +void tst_QOpenGL::nullTextureInitializtion() +{ + QScopedPointer<QSurface> surface(createSurface(QSurface::Window)); + QOpenGLContext ctx; + ctx.create(); + ctx.makeCurrent(surface.data()); + + QImage i; + QOpenGLTexture t(i); + QVERIFY(!t.isCreated()); +} + QTEST_MAIN(tst_QOpenGL) #include "tst_qopengl.moc" diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index abbc560414..cde453c191 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -201,6 +201,7 @@ private slots: void setSocketOption(); void clientSendDataOnDelayedDisconnect(); void serverDisconnectWithBuffered(); + void readNotificationsAfterBind(); protected slots: void nonBlockingIMAP_hostFound(); @@ -3028,5 +3029,25 @@ void tst_QTcpSocket::serverDisconnectWithBuffered() delete socket; } +// Test that the socket does not enable the read notifications in bind() +void tst_QTcpSocket::readNotificationsAfterBind() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QAbstractSocket socket(QAbstractSocket::TcpSocket, Q_NULLPTR); + QVERIFY2(socket.bind(), "Bind error!"); + + connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); + QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead())); + socket.connectToHost(QtNetworkSettings::serverName(), 12346); + + QTestEventLoop::instance().enterLoop(10); + QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong"); + QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!"); + QCOMPARE(spyReadyRead.count(), 0); +} + QTEST_MAIN(tst_QTcpSocket) #include "tst_qtcpsocket.moc" diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 7ce385121c..7ef830d89f 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -171,14 +171,16 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout { QElapsedTimer timer; timer.start(); + int t = timeout; forever { if (socket->bytesAvailable() >= minBytesAvailable) return true; - timeout = qt_subtract_from_timeout(timeout, timer.elapsed()); - if (socket->state() == QAbstractSocket::UnconnectedState - || timeout == 0) + if (socket->state() == QAbstractSocket::UnconnectedState) return false; - if (!socket->waitForReadyRead(timeout)) + if (!socket->waitForReadyRead(t)) + return false; + t = qt_subtract_from_timeout(timeout, timer.elapsed()); + if (t == 0) return false; } } @@ -199,6 +201,7 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) #endif QTime timer; timer.start(); + int t = timeout; forever { if (socket->bytesToWrite() == 0 #ifndef QT_NO_SSL @@ -206,11 +209,12 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) #endif ) return true; - timeout = qt_subtract_from_timeout(timeout, timer.elapsed()); - if (socket->state() == QAbstractSocket::UnconnectedState - || timeout == 0) + if (socket->state() == QAbstractSocket::UnconnectedState) + return false; + if (!socket->waitForBytesWritten(t)) return false; - if (!socket->waitForBytesWritten(timeout)) + t = qt_subtract_from_timeout(timeout, timer.elapsed()); + if (t == 0) return false; } } diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index d5769554be..37afa7f0a5 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -51,6 +51,14 @@ QT_FORWARD_DECLARE_CLASS(QDialog) +// work around function being protected +class DummyDialog : public QDialog +{ +public: + DummyDialog(): QDialog(0, Qt::X11BypassWindowManagerHint) {} + using QDialog::showExtension; +}; + class tst_QDialog : public QObject { Q_OBJECT @@ -85,7 +93,7 @@ private slots: void dialogInGraphicsView(); private: - QDialog *testWidget; + DummyDialog *testWidget; }; // Testing get/set functions @@ -111,13 +119,6 @@ void tst_QDialog::getSetCheck() QCOMPARE(INT_MAX, obj1.result()); } -// work around function being protected -class DummyDialog : public QDialog { -public: - DummyDialog(): QDialog(0) {} - void showExtension( bool b ) { QDialog::showExtension( b ); } -}; - class ToolDialog : public QDialog { public: @@ -155,7 +156,7 @@ tst_QDialog::tst_QDialog() void tst_QDialog::initTestCase() { // Create the test class - testWidget = new QDialog(0, Qt::X11BypassWindowManagerHint); + testWidget = new DummyDialog; testWidget->resize(200,200); testWidget->show(); qApp->setActiveWindow(testWidget); @@ -200,7 +201,7 @@ void tst_QDialog::showExtension() QPoint oldPosition = testWidget->pos(); // show - ((DummyDialog*)testWidget)->showExtension( true ); + testWidget->showExtension( true ); // while ( testWidget->size() == dlgSize ) // qApp->processEvents(); @@ -209,7 +210,7 @@ void tst_QDialog::showExtension() QCOMPARE(testWidget->pos(), oldPosition); // hide extension. back to old size ? - ((DummyDialog*)testWidget)->showExtension( false ); + testWidget->showExtension( false ); QCOMPARE( testWidget->size(), dlgSize ); testWidget->setExtension( 0 ); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 8760dc176c..d8a8ed6b4b 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3685,6 +3685,7 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 const QSize size = availableGeometry.size() / 5; QGraphicsScene scene; QGraphicsView view(&scene); + view.setTransform(QTransform::fromScale(2, 2)); // QTBUG-50136, use transform. view.setWindowTitle(QTest::currentTestFunction()); view.resize(size); view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100)); @@ -3707,10 +3708,15 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2, msgPointMismatch(embeddedCenterGlobal, viewCenter).constData()); - // Same test with child centered on embeddedWidget + // Same test with child centered on embeddedWidget. The correct + // mapping is not implemented yet, but at least make sure + // the roundtrip maptoGlobal()/mapFromGlobal() returns the same + // point since that is important for mouse event handling (QTBUG-50030, + // QTBUG-50136). const QPoint childCenter = childWidget->rect().center(); const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter); QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter); + QEXPECT_FAIL("", "Not implemented for child widgets of embedded widgets", Continue); QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4, msgPointMismatch(childCenterGlobal, viewCenter).constData()); } diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 0b22dc7893..ae516639a6 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -166,6 +166,7 @@ private slots: void updateDelegateOnEditableChange(); void respectChangedOwnershipOfItemView(); void task_QTBUG_39088_inputMethodHints(); + void task_QTBUG_49831_scrollerNotActivated(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -3206,6 +3207,36 @@ void tst_QComboBox::respectChangedOwnershipOfItemView() QCOMPARE(spy2.count(), 1); } +void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated() +{ + QStringList modelData; + for (int i = 0; i < 1000; i++) + modelData << QStringLiteral("Item %1").arg(i); + QStringListModel model(modelData); + + QComboBox box; + box.setModel(&model); + box.setCurrentIndex(500); + box.show(); + QTest::qWaitForWindowShown(&box); + QTest::mouseMove(&box, QPoint(5, 5), 100); + box.showPopup(); + QFrame *container = box.findChild<QComboBoxPrivateContainer *>(); + QVERIFY(container); + QTest::qWaitForWindowShown(container); + + QList<QComboBoxPrivateScroller *> scrollers = container->findChildren<QComboBoxPrivateScroller *>(); + // Not all styles support scrollers. We rely only on those platforms that do to catch any regression. + if (!scrollers.isEmpty()) { + Q_FOREACH (QComboBoxPrivateScroller *scroller, scrollers) { + if (scroller->isVisible()) { + QSignalSpy doScrollSpy(scroller, SIGNAL(doScroll(int))); + QTest::mouseMove(scroller, QPoint(5, 5), 500); + QTRY_VERIFY(doScrollSpy.count() > 0); + } + } + } +} QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" |