diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-12-30 17:39:21 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-02 09:58:44 +0100 |
commit | 0f315adf9199efcfafa44371464ab6d1fc866774 (patch) | |
tree | 35b67591255624c670aff0579e45b2973f56fd81 /tests | |
parent | 2b0eb3fac319a17dd92903106d501f0f06df871f (diff) | |
parent | 52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
.qmake.conf
sc/corelib/io/qfsfileengine_p.h
src/corelib/io/qstorageinfo_unix.cpp
src/platformsupport/eglconvenience/qeglpbuffer_p.h
src/platformsupport/input/libinput/qlibinputkeyboard.cpp
src/platformsupport/input/libinput/qlibinputpointer.cpp
src/plugins/platforms/cocoa/qcocoamenu.mm
src/plugins/platforms/ios/qiosscreen.h
src/plugins/platforms/ios/qioswindow.h
src/plugins/platforms/ios/quiview.mm
src/printsupport/dialogs/qpagesetupdialog_unix_p.h
src/printsupport/dialogs/qprintpreviewdialog.cpp
src/printsupport/widgets/qcupsjobwidget_p.h
src/widgets/widgets/qmenu.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'tests')
25 files changed, 438 insertions, 237 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a1ffe5b3ce..fbd89e4045 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -35,7 +35,7 @@ else:!qtConfig(process): SUBDIRS -= tools # Disable the QtDBus tests if we can't connect to the session bus !cross_compile:qtHaveModule(dbus) { - !system("dbus-send --session --type=signal / local.AutotestCheck.Hello >/dev/null 2>&1") { + !system("dbus-send --session --type=signal / local.AutotestCheck.Hello >$$QMAKE_SYSTEM_NULL_DEVICE 2>&1") { qtConfig(dbus-linked): \ error("QtDBus is enabled but session bus is not available. Please check the installation.") else: \ diff --git a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST index 8fc1b07502..a49ed2a617 100644 --- a/tests/auto/corelib/animation/qpauseanimation/BLACKLIST +++ b/tests/auto/corelib/animation/qpauseanimation/BLACKLIST @@ -4,3 +4,5 @@ osx-10.9 * [multipleSequentialGroups] osx +[noTimerUpdates] +osx diff --git a/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST b/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST index a7e95b1e97..a8719b241a 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST +++ b/tests/auto/corelib/animation/qpropertyanimation/BLACKLIST @@ -2,3 +2,5 @@ windows [startBackwardWithoutEndValue] windows +[startWithoutStartValue] +osx diff --git a/tests/auto/corelib/animation/qpropertyanimation/qpropertyanimation.pro b/tests/auto/corelib/animation/qpropertyanimation/qpropertyanimation.pro index bfeb183abf..72a36876b7 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/qpropertyanimation.pro +++ b/tests/auto/corelib/animation/qpropertyanimation/qpropertyanimation.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qpropertyanimation -QT = core gui widgets testlib +QT = core gui widgets testlib core-private SOURCES = tst_qpropertyanimation.cpp diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index cf4c4e1bdb..41a051a719 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <QtCore/qpropertyanimation.h> #include <QtCore/qvariantanimation.h> +#include <private/qabstractanimation_p.h> #include <QtGui/qtouchdevice.h> #include <QtWidgets/qwidget.h> @@ -74,6 +75,80 @@ public: MyObject o; }; +class TestAnimationDriver : public QAnimationDriver +{ +public: + TestAnimationDriver() + : QAnimationDriver() + , m_elapsed(0) + { + QUnifiedTimer::instance()->installAnimationDriver(this); + } + + ~TestAnimationDriver() + { + // This is to ensure that running animations are removed from the list of actual running + // animations. + QCoreApplication::sendPostedEvents(); + QUnifiedTimer::instance()->uninstallAnimationDriver(this); + } + + void wait(qint64 ms) + { + /* + * When QAbstractAnimation::start() is called it will end up calling + * QAnimationTimer::registerAnimation(). This will do + * + * QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection); // typeof(inst) == QAnimationTimer + * + * startAnimations() will again fire a queued connection to actually add the animation + * to the list of running animations: + * + * QMetaObject::invokeMethod(inst, "startTimers", Qt::QueuedConnection); // typeof(inst) == QUnifiedTimer + * + * We therefore have to call QCoreApplication::sendPostedEvents() twice here. + */ + QCoreApplication::sendPostedEvents(); + QCoreApplication::sendPostedEvents(); + + // Simulates the ideal animation update freqency (approx. 60Hz) + static const int interval = 1000/60; + qint64 until = m_elapsed + ms; + while (m_elapsed < until) { + advanceAnimation(m_elapsed); + m_elapsed += interval; + } + advanceAnimation(m_elapsed); + // This is to make sure that animations that were started with DeleteWhenStopped + // will actually delete themselves within the test function. + // Normally, they won't be deleted until the main event loop is processed. + // Therefore, have to explicitly say that we want to process DeferredDelete events. Same + // trick is used by QTest::qWait(). + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); + } + + qint64 elapsed() const override + { + return m_elapsed; + } + + void start() override + { + d_func()->running = true; + m_elapsed = 0; + emit started(); + } + + void stop() override + { + d_func()->running = false; + emit stopped(); + } + +private: + qint64 m_elapsed; + Q_DECLARE_PRIVATE(QAnimationDriver) +}; class tst_QPropertyAnimation : public QObject { @@ -261,40 +336,44 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(currentLoopSpy.count(), 2); runningSpy.clear(); - anim->start(); - QTest::qWait(1000); - QTRY_COMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 2); //started and stopped again - runningSpy.clear(); - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(anim->currentLoopTime(), 100); - QCOMPARE(anim->currentLoop(), 2); - QCOMPARE(currentLoopSpy.count(), 4); - - anim->start(); // auto-rewinds - QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(anim->currentTime(), 0); - QCOMPARE(anim->currentLoop(), 0); - QCOMPARE(currentLoopSpy.count(), 5); - QCOMPARE(runningSpy.count(), 1); // anim has started - QCOMPARE(finishedSpy.count(), 1); - QCOMPARE(anim->currentLoop(), 0); - runningSpy.clear(); - - QTest::qWait(1000); - - QCOMPARE(currentLoopSpy.count(), 7); - QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(anim->currentLoop(), 2); - QCOMPARE(runningSpy.count(), 1); // anim has stopped - QCOMPARE(finishedSpy.count(), 2); - QCOMPARE(anim->currentLoopTime(), 100); - - delete anim; + { + TestAnimationDriver timeDriver; + anim->start(); + timeDriver.wait(1000); + QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(runningSpy.count(), 2); //started and stopped again + runningSpy.clear(); + QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(anim->currentLoopTime(), 100); + QCOMPARE(anim->currentLoop(), 2); + QCOMPARE(currentLoopSpy.count(), 4); + + anim->start(); // auto-rewinds + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(anim->currentTime(), 0); + QCOMPARE(anim->currentLoop(), 0); + QCOMPARE(currentLoopSpy.count(), 5); + QCOMPARE(runningSpy.count(), 1); // anim has started + QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(anim->currentLoop(), 0); + runningSpy.clear(); + + timeDriver.wait(1000); + + QCOMPARE(currentLoopSpy.count(), 7); + QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(anim->currentLoop(), 2); + QCOMPARE(runningSpy.count(), 1); // anim has stopped + QCOMPARE(finishedSpy.count(), 2); + QCOMPARE(anim->currentLoopTime(), 100); + + delete anim; + } } void tst_QPropertyAnimation::deletion1() { + TestAnimationDriver timeDriver; QObject *object = new QWidget; QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object, "minimumWidth"); @@ -312,23 +391,23 @@ void tst_QPropertyAnimation::deletion1() QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); - QTest::qWait(100); + timeDriver.wait(100); QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); - QTest::qWait(150); + timeDriver.wait(150); QVERIFY(anim); //The animation should not have been deleted - QTRY_COMPARE(anim->state(), QAnimationGroup::Stopped); + QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(runningSpy.count(), 2); QCOMPARE(finishedSpy.count(), 1); anim->start(QVariantAnimation::DeleteWhenStopped); QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); - QTest::qWait(100); + timeDriver.wait(100); QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); - QTest::qWait(150); - QTRY_COMPARE(runningSpy.count(), 4); + timeDriver.wait(150); + QCOMPARE(runningSpy.count(), 4); QCOMPARE(finishedSpy.count(), 2); QVERIFY(!anim); //The animation must have been deleted delete object; @@ -336,6 +415,7 @@ void tst_QPropertyAnimation::deletion1() void tst_QPropertyAnimation::deletion2() { + TestAnimationDriver timeDriver; //test that the animation get deleted if the object is deleted QObject *object = new QWidget; QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object,"minimumWidth"); @@ -354,7 +434,7 @@ void tst_QPropertyAnimation::deletion2() anim->setDuration(200); anim->start(); - QTest::qWait(50); + timeDriver.wait(50); QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); @@ -363,7 +443,7 @@ void tst_QPropertyAnimation::deletion2() //we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop QTimer::singleShot(0, object, SLOT(deleteLater())); - QTest::qWait(50); + timeDriver.wait(50); QVERIFY(!anim->targetObject()); } @@ -371,6 +451,7 @@ void tst_QPropertyAnimation::deletion2() void tst_QPropertyAnimation::deletion3() { //test that the stopped signal is emit when the animation is destroyed + TestAnimationDriver timeDriver; QObject *object = new QWidget; QPropertyAnimation *anim = new QPropertyAnimation(object,"minimumWidth"); anim->setStartValue(10); @@ -385,7 +466,7 @@ void tst_QPropertyAnimation::deletion3() anim->start(); - QTest::qWait(50); + timeDriver.wait(50); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(runningSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); @@ -432,6 +513,7 @@ public: void tst_QPropertyAnimation::noStartValue() { + TestAnimationDriver timeDriver; StartValueTester o; o.setProperty("ole", 42); o.values.clear(); @@ -441,7 +523,8 @@ void tst_QPropertyAnimation::noStartValue() a.setDuration(250); a.start(); - QTRY_COMPARE(o.values.value(o.values.size() - 1, -1), 420); + timeDriver.wait(a.duration()); + QCOMPARE(o.values.value(o.values.size() - 1, -1), 420); QCOMPARE(o.values.first(), 42); } @@ -471,6 +554,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() StartValueTester o; o.setProperty("ole", 42); o.values.clear(); + TestAnimationDriver timeDriver; { //normal case: the animation finishes and is deleted @@ -479,18 +563,17 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() QSignalSpy runningSpy(anim.data(), &QVariantAnimation::stateChanged); QVERIFY(runningSpy.isValid()); anim->start(QVariantAnimation::DeleteWhenStopped); - QTest::qWait(anim->duration() + 100); - QTRY_COMPARE(runningSpy.count(), 2); //started and then stopped + timeDriver.wait(anim->duration()); + QCOMPARE(runningSpy.count(), 2); //started and then stopped QVERIFY(!anim); } - { QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole"); anim->setEndValue(100); QSignalSpy runningSpy(anim.data(), &QVariantAnimation::stateChanged); QVERIFY(runningSpy.isValid()); anim->start(QVariantAnimation::DeleteWhenStopped); - QTest::qWait(anim->duration()/2); + timeDriver.wait(anim->duration()/2); QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole"); anim2->setEndValue(100); QCOMPARE(runningSpy.count(), 1); @@ -498,11 +581,11 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() //anim2 will interrupt anim1 QMetaObject::invokeMethod(anim2, "start", Qt::QueuedConnection, Q_ARG(QAbstractAnimation::DeletionPolicy, QVariantAnimation::DeleteWhenStopped)); - QTest::qWait(50); + timeDriver.wait(50); QVERIFY(!anim); //anim should have been deleted QVERIFY(anim2); - QTest::qWait(anim2->duration()); - QTRY_VERIFY(!anim2); //anim2 is finished: it should have been deleted by now + timeDriver.wait(anim2->duration()); + QVERIFY(!anim2); //anim2 is finished: it should have been deleted by now QVERIFY(!anim); } @@ -559,6 +642,7 @@ void tst_QPropertyAnimation::easingcurve() void tst_QPropertyAnimation::startWithoutStartValue() { + TestAnimationDriver timeDriver; QObject o; o.setProperty("ole", 42); QCOMPARE(o.property("ole").toInt(), 42); @@ -568,14 +652,14 @@ void tst_QPropertyAnimation::startWithoutStartValue() anim.start(); - QTest::qWait(100); + timeDriver.wait(100); int current = anim.currentValue().toInt(); //it is somewhere in the animation QVERIFY(current > 42); QVERIFY(current < 100); - QTest::qWait(200); - QTRY_COMPARE(anim.state(), QVariantAnimation::Stopped); + timeDriver.wait(200); + QCOMPARE(anim.state(), QVariantAnimation::Stopped); current = anim.currentValue().toInt(); QCOMPARE(current, 100); QCOMPARE(o.property("ole").toInt(), current); @@ -586,7 +670,7 @@ void tst_QPropertyAnimation::startWithoutStartValue() // the default start value will reevaluate the current property // and set it to the end value of the last iteration QCOMPARE(current, 100); - QTest::qWait(100); + timeDriver.wait(100); current = anim.currentValue().toInt(); //it is somewhere in the animation QVERIFY(current >= 100); @@ -595,6 +679,7 @@ void tst_QPropertyAnimation::startWithoutStartValue() void tst_QPropertyAnimation::startBackwardWithoutEndValue() { + TestAnimationDriver timeDriver; QObject o; o.setProperty("ole", 42); QCOMPARE(o.property("ole").toInt(), 42); @@ -608,14 +693,14 @@ void tst_QPropertyAnimation::startBackwardWithoutEndValue() QCOMPARE(anim.state(), QAbstractAnimation::Running); QCOMPARE(o.property("ole").toInt(), 42); //the initial value - QTest::qWait(100); + timeDriver.wait(100); int current = anim.currentValue().toInt(); //it is somewhere in the animation QVERIFY(current > 42); QVERIFY(current < 100); - QTest::qWait(200); - QTRY_COMPARE(anim.state(), QVariantAnimation::Stopped); + timeDriver.wait(200); + QCOMPARE(anim.state(), QVariantAnimation::Stopped); current = anim.currentValue().toInt(); QCOMPARE(current, 100); QCOMPARE(o.property("ole").toInt(), current); @@ -626,7 +711,7 @@ void tst_QPropertyAnimation::startBackwardWithoutEndValue() // the default start value will reevaluate the current property // and set it to the end value of the last iteration QCOMPARE(current, 100); - QTest::qWait(100); + timeDriver.wait(100); current = anim.currentValue().toInt(); //it is somewhere in the animation QVERIFY(current >= 100); @@ -636,6 +721,7 @@ void tst_QPropertyAnimation::startBackwardWithoutEndValue() void tst_QPropertyAnimation::playForwardBackward() { + TestAnimationDriver timeDriver; QObject o; o.setProperty("ole", 0); QCOMPARE(o.property("ole").toInt(), 0); @@ -644,16 +730,16 @@ void tst_QPropertyAnimation::playForwardBackward() anim.setStartValue(0); anim.setEndValue(100); anim.start(); - QTest::qWait(anim.duration() + 100); - QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); + timeDriver.wait(anim.duration()); + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), anim.duration()); //the animation is at the end anim.setDirection(QVariantAnimation::Backward); anim.start(); QCOMPARE(anim.state(), QAbstractAnimation::Running); - QTest::qWait(anim.duration() + 100); - QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); + timeDriver.wait(anim.duration()); + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), 0); //the direction is backward @@ -661,8 +747,8 @@ void tst_QPropertyAnimation::playForwardBackward() anim.start(); QCOMPARE(anim.state(), QAbstractAnimation::Running); QCOMPARE(anim.currentTime(), anim.duration()); - QTest::qWait(anim.duration() + 100); - QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); + timeDriver.wait(anim.duration()); + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), 0); } @@ -1106,21 +1192,21 @@ void tst_QPropertyAnimation::restart() void tst_QPropertyAnimation::valueChanged() { - + TestAnimationDriver timeDriver; //we check that we receive the valueChanged signal MyErrorObject o; o.setOle(0); QCOMPARE(o.property("ole").toInt(), 0); QPropertyAnimation anim(&o, "ole"); anim.setEndValue(5); - anim.setDuration(1000); + anim.setDuration(200); QSignalSpy spy(&anim, &QPropertyAnimation::valueChanged); QVERIFY(spy.isValid()); anim.start(); + // Drive animation forward to its end + timeDriver.wait(anim.duration()); - QTest::qWait(anim.duration() + 100); - - QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), anim.duration()); //let's check that the values go forward @@ -1153,6 +1239,7 @@ public: void tst_QPropertyAnimation::twoAnimations() { + TestAnimationDriver timeDriver; MySyncObject o1, o2; o1.setOle(0); o2.setOle(0); @@ -1169,8 +1256,8 @@ void tst_QPropertyAnimation::twoAnimations() o1.anim.start(); o2.anim.start(); - QTest::qWait(o1.anim.duration() + 100); - QTRY_COMPARE(o1.anim.state(), QAbstractAnimation::Stopped); + timeDriver.wait(o1.anim.duration()); + QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped); QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped); QCOMPARE(o1.ole(), 1000); @@ -1209,6 +1296,7 @@ public: void tst_QPropertyAnimation::deletedInUpdateCurrentTime() { + TestAnimationDriver timeDriver; // this test case reproduces an animation being deleted in the updateCurrentTime of // another animation(was causing segfault). // the deleted animation must have been started after the animation that is deleting. @@ -1219,9 +1307,9 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime() MyComposedAnimation composedAnimation(&o, "value", "realValue"); composedAnimation.start(); QCOMPARE(composedAnimation.state(), QAbstractAnimation::Running); - QTest::qWait(composedAnimation.duration() + 100); + timeDriver.wait(composedAnimation.duration()); - QTRY_COMPARE(composedAnimation.state(), QAbstractAnimation::Stopped); + QCOMPARE(composedAnimation.state(), QAbstractAnimation::Stopped); QCOMPARE(o.value(), 1000); } @@ -1293,6 +1381,7 @@ public: void tst_QPropertyAnimation::recursiveAnimations() { + TestAnimationDriver timeDriver; RecursiveObject o; QPropertyAnimation anim; anim.setTargetObject(&o); @@ -1301,9 +1390,9 @@ void tst_QPropertyAnimation::recursiveAnimations() anim.setEndValue(4000); anim.start(); - QTest::qWait(anim.duration() + o.animation.duration()); - QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); - QTRY_COMPARE(o.animation.state(), QAbstractAnimation::Stopped); + timeDriver.wait(anim.duration() + o.animation.duration()); + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QCOMPARE(o.animation.state(), QAbstractAnimation::Stopped); QCOMPARE(o.y(), qreal(4000)); } diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index d2902f4944..241dccb90e 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -160,12 +160,14 @@ void tst_qfloat16::qNan() qfloat16 nan = qQNaN(); QVERIFY(!(0. > nan)); QVERIFY(!(0. < nan)); + QVERIFY(!qIsInf(nan)); QVERIFY(qIsNaN(nan)); QVERIFY(qIsNaN(nan + 1.f)); QVERIFY(qIsNaN(-nan)); qfloat16 inf = qInf(); QVERIFY(inf > qfloat16(0)); QVERIFY(-inf < qfloat16(0)); + QVERIFY(!qIsNaN(inf)); QVERIFY(qIsInf(inf)); QVERIFY(qIsInf(-inf)); QVERIFY(qIsInf(2.f*inf)); diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index bf2943a63c..af42efa7f6 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -72,7 +72,7 @@ void tst_GlobalTypes() qreal qr; Q_UNUSED(qr); - qssize_t qs; + qsizetype qs; qptrdiff qp; qintptr qip; quintptr qup; diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 44e79985d4..02b70c317e 100644..100755 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -64,6 +64,15 @@ #define Q_NO_SYMLINKS #endif +#if defined(Q_OS_WIN) +QT_BEGIN_NAMESPACE +extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; +QT_END_NAMESPACE +# ifndef Q_OS_WINRT +bool IsUserAdmin(); +# endif +#endif + inline bool qIsLikelyToBeFat(const QString &path) { QByteArray name = QStorageInfo(path).fileSystemType().toLower(); @@ -1592,6 +1601,15 @@ void tst_QFileInfo::isWritable() QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData()); QVERIFY(!fi.isWritable()); #endif + +#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT) + QScopedValueRollback<int> ntfsMode(qt_ntfs_permission_lookup); + qt_ntfs_permission_lookup = 1; + QFileInfo fi2(QFile::decodeName(qgetenv("SystemRoot") + "/system.ini")); + QVERIFY(fi2.exists()); + QCOMPARE(fi2.isWritable(), IsUserAdmin()); +#endif + #if defined (Q_OS_QNX) // On QNX /etc is usually on a read-only filesystem QVERIFY(!QFileInfo("/etc/passwd").isWritable()); #elif defined (Q_OS_UNIX) && !defined(Q_OS_VXWORKS) // VxWorks does not have users/groups @@ -1765,7 +1783,7 @@ void tst_QFileInfo::detachingOperations() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -BOOL IsUserAdmin() +bool IsUserAdmin() { BOOL b; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; @@ -1783,13 +1801,9 @@ BOOL IsUserAdmin() FreeSid(AdministratorsGroup); } - return(b); + return b != FALSE; } -QT_BEGIN_NAMESPACE -extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; -QT_END_NAMESPACE - #endif // Q_OS_WIN && !Q_OS_WINRT #ifndef Q_OS_WINRT diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp index 15c63d4acd..a74ea3a89e 100644 --- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp +++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp @@ -212,7 +212,7 @@ private slots: qunsetenv("QT_LOGGING_RULES"); qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit()); - registry.initalizeRules(); + registry.initializeRules(); QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0); QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0); @@ -220,7 +220,7 @@ private slots: // check that QT_LOGGING_RULES take precedence qputenv("QT_LOGGING_RULES", "Digia.*=true"); - registry.initalizeRules(); + registry.initializeRules(); QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 2); QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].at(1).enabled, true); } @@ -246,7 +246,7 @@ private slots: file.close(); QLoggingRegistry registry; - registry.initalizeRules(); + registry.initializeRules(); QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 1); // remove file again diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index f3ce902bbd..2d87c2193b 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -70,6 +70,7 @@ private slots: void io(); void openCloseOpenClose(); void removeAndReOpen(); + void removeUnnamed(); void size(); void resize(); void openOnRootDrives(); @@ -442,11 +443,13 @@ void tst_QTemporaryFile::removeAndReOpen() { QTemporaryFile file; file.open(); - fileName = file.fileName(); + fileName = file.fileName(); // materializes any unnamed file QVERIFY(QFile::exists(fileName)); - file.remove(); + QVERIFY(file.remove()); + QVERIFY(file.fileName().isEmpty()); QVERIFY(!QFile::exists(fileName)); + QVERIFY(!file.remove()); QVERIFY(file.open()); QCOMPARE(QFileInfo(file.fileName()).path(), QFileInfo(fileName).path()); @@ -456,6 +459,19 @@ void tst_QTemporaryFile::removeAndReOpen() QVERIFY(!QFile::exists(fileName)); } +void tst_QTemporaryFile::removeUnnamed() +{ + QTemporaryFile file; + file.open(); + + // we did not call fileName(), so the file name may not have a name + QVERIFY(file.remove()); + QVERIFY(file.fileName().isEmpty()); + + // if it was unnamed, this will succeed again, so we can't check the result + file.remove(); +} + void tst_QTemporaryFile::size() { QTemporaryFile file; diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp index 54c79e0893..9cf005af01 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp @@ -100,7 +100,7 @@ public: TestModel(QAbstractItemModel *sourceModel) : QSortFilterProxyModel() { - setRecursiveFiltering(true); + setRecursiveFilteringEnabled(true); setSourceModel(sourceModel); } @@ -213,6 +213,7 @@ private Q_SLOTS: QCOMPARE(treeAsString(model), sourceStr); TestModel proxy(&model); + QVERIFY(proxy.isRecursiveFilteringEnabled()); QCOMPARE(treeAsString(proxy), proxyStr); } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index f6feac29dc..c734cfe4dd 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -151,6 +151,7 @@ private slots: void deleteLaterInAboutToBlockHandler(); void mutableFunctor(); void checkArgumentsForNarrowing(); + void nullReceiver(); }; struct QObjectCreatedOnShutdown @@ -7422,6 +7423,16 @@ void tst_QObject::checkArgumentsForNarrowing() #undef FITS } +void tst_QObject::nullReceiver() +{ + QObject o; + QObject *nullObj = nullptr; // Passing nullptr directly doesn't compile with gcc 4.8 + QVERIFY(!connect(&o, &QObject::destroyed, nullObj, &QObject::deleteLater)); + QVERIFY(!connect(&o, &QObject::destroyed, nullObj, [] {})); + QVERIFY(!connect(&o, &QObject::destroyed, nullObj, Functor_noexcept())); + QVERIFY(!connect(&o, SIGNAL(destroyed()), nullObj, SLOT(deleteLater()))); +} + // Test for QtPrivate::HasQ_OBJECT_Macro Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value); Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value); diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index c30efe4e3b..b80c6ae811 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -101,6 +101,7 @@ Q_OBJECT public: SignalEmitter(QObject *parent = 0) : QObject(parent) {} +public Q_SLOTS: void emitSignalWithNoArg() { emit signalWithNoArg(); } void emitSignalWithIntArg(int arg) @@ -251,6 +252,7 @@ private slots: void qtbug_46059(); void qtbug_46703(); void postEventFromBeginSelectTransitions(); + void dontProcessSlotsWhenMachineIsNotRunning(); }; class TestState : public QState @@ -6658,5 +6660,35 @@ void tst_QStateMachine::postEventFromBeginSelectTransitions() QVERIFY(machine.isRunning()); } +void tst_QStateMachine::dontProcessSlotsWhenMachineIsNotRunning() +{ + QStateMachine machine; + QState initialState; + QFinalState finalState; + + struct Emitter : SignalEmitter + { + QThread thread; + Emitter(QObject *parent = nullptr) : SignalEmitter(parent) + { + moveToThread(&thread); + thread.start(); + } + } emitter; + + initialState.addTransition(&emitter, &Emitter::signalWithNoArg, &finalState); + QTimer::singleShot(0, [&]() { + metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); + metaObject()->invokeMethod(&emitter, "emitSignalWithNoArg"); + }); + machine.addState(&initialState); + machine.addState(&finalState); + machine.setInitialState(&initialState); + machine.start(); + connect(&machine, &QStateMachine::finished, &emitter.thread, &QThread::quit); + QSignalSpy signalSpy(&machine, &QStateMachine::finished); + QTRY_COMPARE_WITH_TIMEOUT(signalSpy.count(), 1, 100); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" diff --git a/tests/auto/corelib/tools/qdatetime/BLACKLIST b/tests/auto/corelib/tools/qdatetime/BLACKLIST new file mode 100644 index 0000000000..e78f5cfd87 --- /dev/null +++ b/tests/auto/corelib/tools/qdatetime/BLACKLIST @@ -0,0 +1,3 @@ +[operator_eqeq] +ubuntu-16.04 +b2qt diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index f4514e1374..8640666146 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2375,8 +2375,8 @@ void tst_QDateTime::fromStringStringFormat_data() QTest::newRow("data14") << QString("32.01.2004") << QString("dd.MM.yyyy") << invalidDateTime(); QTest::newRow("data15") << QString("Thu January 2004") << QString("ddd MMMM yyyy") << QDateTime(QDate(2004, 1, 1), QTime()); QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z") - << QString("yyyy-MM-ddThh:mm:ss.zZ") - << QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1)); + << QString("yyyy-MM-ddThh:mm:ss.zt") + << QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1), Qt::UTC); QTest::newRow("late") << QString("9999-12-31T23:59:59.999Z") << QString("yyyy-MM-ddThh:mm:ss.zZ") << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999)); diff --git a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp index 4174b85f4c..8a8aa8c6e1 100644 --- a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp @@ -461,9 +461,9 @@ void tst_QStringView::fromLiteral(const Char *arg) const const Char *null = nullptr; const Char empty[] = { 0 }; - QCOMPARE(QStringView(null).size(), qssize_t(0)); + QCOMPARE(QStringView(null).size(), qsizetype(0)); QCOMPARE(QStringView(null).data(), nullptr); - QCOMPARE(QStringView(empty).size(), qssize_t(0)); + QCOMPARE(QStringView(empty).size(), qsizetype(0)); QCOMPARE(static_cast<const void*>(QStringView(empty).data()), static_cast<const void*>(empty)); diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 56daea31fe..713109a214 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -245,6 +245,7 @@ private slots: void qhashInt() const { qhash<int>(); } void qhashMovable() const { qhash<Movable>(); } void qhashCustom() const { qhash<Custom>(); } + void removeAllWithAlias() const; void removeInt() const; void removeMovable() const; void removeCustom() const; @@ -1722,6 +1723,13 @@ void tst_QVector::prependCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +void tst_QVector::removeAllWithAlias() const +{ + QVector<QString> strings; + strings << "One" << "Two" << "Three" << "One" /* must be distinct, but equal */; + QCOMPARE(strings.removeAll(strings.front()), 2); // will trigger asan/ubsan +} + template<typename T> void tst_QVector::remove() const { diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 54eb8ab99c..7ad4a9e9bb 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -3441,10 +3441,10 @@ void tst_QImage::hugeQImage() QVERIFY(!image.isNull()); QCOMPARE(image.height(), 25000); QCOMPARE(image.width(), 25000); - QCOMPARE(image.sizeInBytes(), qssize_t(25000)*25000*4); + QCOMPARE(image.sizeInBytes(), qsizetype(25000)*25000*4); QCOMPARE(image.bytesPerLine(), 25000 * 4); - QCOMPARE(image.constScanLine(24990), image.constBits() + qssize_t(25000)*24990*4); + QCOMPARE(image.constScanLine(24990), image.constBits() + qsizetype(25000)*24990*4); image.setPixel(20000, 24990, 0xffaabbcc); QCOMPARE(image.pixel(20000, 24990), 0xffaabbcc); diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index d6fc717e37..1052239797 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -32,6 +32,8 @@ linux windows [putToFtp] windows ci +[putToFtpWithInvalidCredentials] +windows ci [putWithServerClosingConnectionImmediately] windows [qtbug28035browserDoesNotLoadQtProjectOrgCorrectly] diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index 5adb05d3f2..d58a850a1f 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -1,7 +1,3 @@ -[multicast:same bind, group ipv6 address] -* -[multicast] -osx [writeDatagramToNonExistingPeer] windows osx @@ -22,7 +18,12 @@ osx osx [broadcasting] osx +ubuntu-16.04 [zeroLengthDatagram] osx [linkLocalIPv6] redhatenterpriselinuxworkstation-6.6 +[pendingDatagramSize] +ubuntu-16.04 +[readyReadForEmptyDatagram] +ubuntu-16.04 diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 0f46caa7c2..bbac03b708 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -34,6 +34,7 @@ #include <qfileinfo.h> #include <qdatastream.h> #include <qdebug.h> +#include <qrandom.h> #include <qudpsocket.h> #include <qhostaddress.h> #include <qhostinfo.h> @@ -47,12 +48,6 @@ #include "../../../network-settings.h" #include "emulationdetector.h" -#ifndef QT_NO_BEARERMANAGEMENT -#include <QtNetwork/qnetworkconfigmanager.h> -#include <QtNetwork/qnetworkconfiguration.h> -#include <QtNetwork/qnetworksession.h> -#endif - #if defined(Q_OS_LINUX) #define SHOULD_CHECK_SYSCALL_SUPPORT #include <netinet/in.h> @@ -60,6 +55,13 @@ #include <errno.h> #endif +#ifdef Q_OS_UNIX +# include <sys/socket.h> +#endif +#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) || defined(SO_NREAD) +# define RELIABLE_BYTES_AVAILABLE +#endif + Q_DECLARE_METATYPE(QHostAddress) QT_FORWARD_DECLARE_CLASS(QUdpSocket) @@ -127,14 +129,12 @@ private: #ifdef SHOULD_CHECK_SYSCALL_SUPPORT bool ipv6SetsockoptionMissing(int level, int optname); #endif + QNetworkInterface interfaceForGroup(const QHostAddress &multicastGroup); bool m_skipUnsupportedIPv6Tests; QList<QHostAddress> allAddresses; -#ifndef QT_NO_BEARERMANAGEMENT - QNetworkConfigurationManager *netConfMan; - QNetworkConfiguration networkConfiguration; - QSharedPointer<QNetworkSession> networkSession; -#endif + QHostAddress multicastGroup4, multicastGroup6; + QVector<QHostAddress> linklocalMulticastGroups; QUdpSocket *m_asyncSender; QUdpSocket *m_asyncReceiver; }; @@ -176,6 +176,37 @@ bool tst_QUdpSocket::shouldSkipIpv6TestsForBrokenSetsockopt() return false; } +QNetworkInterface tst_QUdpSocket::interfaceForGroup(const QHostAddress &multicastGroup) +{ + if (multicastGroup.protocol() == QAbstractSocket::IPv4Protocol) + return QNetworkInterface(); + + QString scope = multicastGroup.scopeId(); + if (!scope.isEmpty()) + return QNetworkInterface::interfaceFromName(scope); + + static QNetworkInterface ipv6if = [=]() { + // find any link local address in the allAddress list + for (const QHostAddress &addr: qAsConst(allAddresses)) { + if (addr.isLoopback()) + continue; + + QString scope = addr.scopeId(); + if (!scope.isEmpty()) { + QNetworkInterface iface = QNetworkInterface::interfaceFromName(scope); + qDebug() << "Will bind IPv6 sockets to" << iface; + return iface; + } + } + + qWarning("interfaceForGroup(%s) could not find any link-local IPv6 address! " + "Make sure this test is behind a check of QtNetworkSettings::hasIPv6().", + qUtf8Printable(multicastGroup.toString())); + return QNetworkInterface(); + }(); + return ipv6if; +} + static QHostAddress makeNonAny(const QHostAddress &address, QHostAddress::SpecialAddress preferForAny = QHostAddress::LocalHost) { if (address == QHostAddress::Any) @@ -210,16 +241,6 @@ void tst_QUdpSocket::initTestCase_data() if (!newTestServer) QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); #endif - -#ifndef QT_NO_BEARERMANAGEMENT - netConfMan = new QNetworkConfigurationManager(this); - networkConfiguration = netConfMan->defaultConfiguration(); - networkSession = QSharedPointer<QNetworkSession>::create(networkConfiguration); - if (!networkSession->isOpen()) { - networkSession->open(); - QVERIFY(networkSession->waitForOpened(30000)); - } -#endif } void tst_QUdpSocket::initTestCase() @@ -229,6 +250,32 @@ void tst_QUdpSocket::initTestCase() allAddresses = QNetworkInterface::allAddresses(); m_skipUnsupportedIPv6Tests = shouldSkipIpv6TestsForBrokenSetsockopt(); + // Create a pair of random multicast groups so we avoid clashing with any + // other tst_qudpsocket running on the same network at the same time. + quint64 r[2] = { + // ff14:: is temporary, not prefix-based, admin-local + qToBigEndian(Q_UINT64_C(0xff14) << 48), + QRandomGenerator64::global()->generate64() + }; + multicastGroup6.setAddress(*reinterpret_cast<Q_IPV6ADDR *>(&r)); + + // 239.0.0.0/8 is "Organization-Local Scope" + multicastGroup4.setAddress((239U << 24) | (r[1] & 0xffffff)); + + // figure out some link-local IPv6 multicast groups + // ff12:: is temporary, not prefix-based, link-local + r[0] = qToBigEndian(Q_UINT64_C(0xff12) << 48); + QHostAddress llbase(*reinterpret_cast<Q_IPV6ADDR *>(&r)); + for (const QHostAddress &a : qAsConst(allAddresses)) { + QString scope = a.scopeId(); + if (scope.isEmpty()) + continue; + llbase.setScopeId(scope); + linklocalMulticastGroups << llbase; + } + + qDebug() << "Will use multicast groups" << multicastGroup4 << multicastGroup6 << linklocalMulticastGroups; + if (EmulationDetector::isRunningArmOnX86()) QSKIP("This test is unreliable due to QEMU emulation shortcomings."); } @@ -261,9 +308,6 @@ void tst_QUdpSocket::cleanup() void tst_QUdpSocket::constructing() { QUdpSocket socket; -#ifdef FORCE_SESSION - socket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(socket.isSequential()); QVERIFY(!socket.isOpen()); @@ -281,9 +325,6 @@ void tst_QUdpSocket::constructing() void tst_QUdpSocket::unconnectedServerAndClientTest() { QUdpSocket serverSocket; -#ifdef FORCE_SESSION - serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif qRegisterMetaType<QAbstractSocket::SocketState>("QAbstractSocket::SocketState"); @@ -296,9 +337,6 @@ void tst_QUdpSocket::unconnectedServerAndClientTest() QHostAddress serverAddress = makeNonAny(serverSocket.localAddress()); for (int i = 0; i < 3; ++i) { QUdpSocket clientSocket; -#ifdef FORCE_SESSION - clientSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QCOMPARE(int(clientSocket.writeDatagram(message[i], strlen(message[i]), serverAddress, serverSocket.localPort())), int(strlen(message[i]))); @@ -352,9 +390,6 @@ void tst_QUdpSocket::broadcasting() QSKIP("No interface can broadcast"); for (int i = 0; i < 4; ++i) { QUdpSocket serverSocket; -#ifdef FORCE_SESSION - serverSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(serverSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0), serverSocket.errorString().toLatin1().constData()); quint16 serverPort = serverSocket.localPort(); @@ -363,9 +398,6 @@ void tst_QUdpSocket::broadcasting() connect(&serverSocket, SIGNAL(readyRead()), SLOT(empty_readyReadSlot())); QUdpSocket broadcastSocket; -#ifdef FORCE_SESSION - broadcastSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif broadcastSocket.bind(QHostAddress(QHostAddress::AnyIPv4), 0); for (int j = 0; j < 10; ++j) { @@ -444,10 +476,6 @@ void tst_QUdpSocket::loop() QUdpSocket peter; QUdpSocket paul; -#ifdef FORCE_SESSION - peter.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // make sure we bind to IPv4 QHostAddress localhost = QHostAddress::LocalHost; @@ -518,10 +546,6 @@ void tst_QUdpSocket::ipv6Loop() QUdpSocket peter; QUdpSocket paul; -#ifdef FORCE_SESSION - peter.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - paul.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif int peterPort; int paulPort; @@ -745,10 +769,6 @@ void tst_QUdpSocket::connectToHost() { QUdpSocket socket1; QUdpSocket socket2; -#ifdef FORCE_SESSION - socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(socket1.bind(), socket1.errorString().toLatin1().constData()); @@ -763,11 +783,6 @@ void tst_QUdpSocket::bindAndConnectToHost() QUdpSocket socket1; QUdpSocket socket2; QUdpSocket dummysocket; -#ifdef FORCE_SESSION - socket1.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - dummysocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // we use the dummy socket to use up a file descriptor dummysocket.bind(); @@ -791,16 +806,10 @@ void tst_QUdpSocket::bindAndConnectToHost() void tst_QUdpSocket::pendingDatagramSize() { QUdpSocket server; -#ifdef FORCE_SESSION - server.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; -#ifdef FORCE_SESSION - client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(client.writeDatagram("this is", 7, serverAddress, server.localPort()) == 7); QVERIFY(client.writeDatagram(0, 0, serverAddress, server.localPort()) == 0); QVERIFY(client.writeDatagram("3 messages", 10, serverAddress, server.localPort()) == 10); @@ -839,16 +848,10 @@ void tst_QUdpSocket::pendingDatagramSize() void tst_QUdpSocket::writeDatagram() { QUdpSocket server; -#ifdef FORCE_SESSION - server.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; -#ifdef FORCE_SESSION - client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); @@ -886,16 +889,10 @@ void tst_QUdpSocket::performance() QByteArray arr(8192, '@'); QUdpSocket server; -#ifdef FORCE_SESSION - server.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); QHostAddress serverAddress = makeNonAny(server.localAddress()); QUdpSocket client; -#ifdef FORCE_SESSION - client.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif client.connectToHost(serverAddress, server.localPort()); QVERIFY(client.waitForConnected(10000)); @@ -932,14 +929,8 @@ void tst_QUdpSocket::bindMode() } QUdpSocket socket; -#ifdef FORCE_SESSION - socket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData()); QUdpSocket socket2; -#ifdef FORCE_SESSION - socket2.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(!socket2.bind(socket.localPort())); #if defined(Q_OS_UNIX) QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); @@ -991,9 +982,6 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer() quint16 peerPort = 33533 + int(bind); QUdpSocket sUdp; -#ifdef FORCE_SESSION - sUdp.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QSignalSpy sReadyReadSpy(&sUdp, SIGNAL(readyRead())); if (bind) QVERIFY(sUdp.bind()); @@ -1026,9 +1014,6 @@ void tst_QUdpSocket::writeToNonExistingPeer() qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); QUdpSocket sConnected; -#ifdef FORCE_SESSION - sConnected.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QSignalSpy sConnectedReadyReadSpy(&sConnected, SIGNAL(readyRead())); QSignalSpy sConnectedErrorSpy(&sConnected, SIGNAL(error(QAbstractSocket::SocketError))); sConnected.connectToHost(peerAddress, peerPort, QIODevice::ReadWrite); @@ -1198,18 +1183,12 @@ void tst_QUdpSocket::zeroLengthDatagram() return; QUdpSocket receiver; -#ifdef FORCE_SESSION - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(receiver.bind()); QVERIFY(!receiver.waitForReadyRead(100)); QVERIFY(!receiver.hasPendingDatagrams()); QUdpSocket sender; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QCOMPARE(sender.writeDatagram(QNetworkDatagram(QByteArray(), QHostAddress::LocalHost, receiver.localPort())), qint64(0)); QVERIFY2(receiver.waitForReadyRead(1000), QtNetworkSettings::msgSocketError(receiver).constData()); @@ -1262,9 +1241,6 @@ void tst_QUdpSocket::multicastTtlOption() } QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // bind, but ignore the result, we are only interested in initializing the socket (void) udpSocket.bind(bindAddress, 0); udpSocket.setSocketOption(QUdpSocket::MulticastTtlOption, ttl); @@ -1315,9 +1291,6 @@ void tst_QUdpSocket::multicastLoopbackOption() } QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // bind, but ignore the result, we are only interested in initializing the socket (void) udpSocket.bind(bindAddress, 0); udpSocket.setSocketOption(QUdpSocket::MulticastLoopbackOption, loopback); @@ -1327,9 +1300,11 @@ void tst_QUdpSocket::multicastLoopbackOption() void tst_QUdpSocket::multicastJoinBeforeBind_data() { QTest::addColumn<QHostAddress>("groupAddress"); - QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62"); + QTest::newRow("valid ipv4 group address") << multicastGroup4; QTest::newRow("invalid ipv4 group address") << QHostAddress(QHostAddress::Broadcast); - QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114"); + QTest::newRow("valid ipv6 group address") << multicastGroup6; + for (const QHostAddress &a : qAsConst(linklocalMulticastGroups)) + QTest::addRow("valid ipv6 %s-link group address", a.scopeId().toLatin1().constData()) << a; QTest::newRow("invalid ipv6 group address") << QHostAddress(QHostAddress::AnyIPv6); } @@ -1341,9 +1316,6 @@ void tst_QUdpSocket::multicastJoinBeforeBind() QFETCH(QHostAddress, groupAddress); QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // cannot join group before binding QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::joinMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState"); QVERIFY(!udpSocket.joinMulticastGroup(groupAddress)); @@ -1352,8 +1324,10 @@ void tst_QUdpSocket::multicastJoinBeforeBind() void tst_QUdpSocket::multicastLeaveAfterClose_data() { QTest::addColumn<QHostAddress>("groupAddress"); - QTest::newRow("ipv4") << QHostAddress("239.255.118.62"); - QTest::newRow("ipv6") << QHostAddress("FF01::114"); + QTest::newRow("ipv4") << multicastGroup4; + QTest::newRow("ipv6") << multicastGroup6; + for (const QHostAddress &a : qAsConst(linklocalMulticastGroups)) + QTest::addRow("ipv6-link-%s", a.scopeId().toLatin1().constData()) << a; } void tst_QUdpSocket::multicastLeaveAfterClose() @@ -1376,15 +1350,12 @@ void tst_QUdpSocket::multicastLeaveAfterClose() } QUdpSocket udpSocket; -#ifdef FORCE_SESSION - udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QHostAddress bindAddress = QHostAddress::AnyIPv4; if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) bindAddress = QHostAddress::AnyIPv6; QVERIFY2(udpSocket.bind(bindAddress, 0), qPrintable(udpSocket.errorString())); - QVERIFY2(udpSocket.joinMulticastGroup(groupAddress), + QVERIFY2(udpSocket.joinMulticastGroup(groupAddress, interfaceForGroup(groupAddress)), qPrintable(udpSocket.errorString())); udpSocket.close(); QTest::ignoreMessage(QtWarningMsg, "QUdpSocket::leaveMulticastGroup() called on a QUdpSocket when not in QUdpSocket::BoundState"); @@ -1443,9 +1414,9 @@ void tst_QUdpSocket::setMulticastInterface() void tst_QUdpSocket::multicast_data() { QHostAddress anyAddress = QHostAddress(QHostAddress::AnyIPv4); - QHostAddress groupAddress = QHostAddress("239.255.118.62"); + QHostAddress groupAddress = multicastGroup4; QHostAddress any6Address = QHostAddress(QHostAddress::AnyIPv6); - QHostAddress group6Address = QHostAddress("FF01::114"); + QHostAddress group6Address = multicastGroup6; QHostAddress dualAddress = QHostAddress(QHostAddress::Any); QTest::addColumn<QHostAddress>("bindAddress"); @@ -1454,12 +1425,16 @@ void tst_QUdpSocket::multicast_data() QTest::addColumn<bool>("joinResult"); QTest::newRow("valid bind, group ipv4 address") << anyAddress << true << groupAddress << true; QTest::newRow("valid bind, invalid group ipv4 address") << anyAddress << true << anyAddress << false; - QTest::newRow("same bind, group ipv4 address") << groupAddress << true << groupAddress << true; QTest::newRow("valid bind, group ipv6 address") << any6Address << true << group6Address << true; + for (const QHostAddress &a : qAsConst(linklocalMulticastGroups)) + QTest::addRow("valid bind, %s-link group ipv6 address", a.scopeId().toLatin1().constData()) + << any6Address << true << a << true; QTest::newRow("valid bind, invalid group ipv6 address") << any6Address << true << any6Address << false; - QTest::newRow("same bind, group ipv6 address") << group6Address << false << group6Address << false; QTest::newRow("dual bind, group ipv4 address") << dualAddress << true << groupAddress << false; QTest::newRow("dual bind, group ipv6 address") << dualAddress << true << group6Address << true; + for (const QHostAddress &a : qAsConst(linklocalMulticastGroups)) + QTest::addRow("dual bind, %s-link group ipv6 address", a.scopeId().toLatin1().constData()) + << dualAddress << true << a << true; } void tst_QUdpSocket::multicast() @@ -1487,9 +1462,6 @@ void tst_QUdpSocket::multicast() } QUdpSocket receiver; -#ifdef FORCE_SESSION - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif // bind first, then verify that we can join the multicast group QVERIFY2(receiver.bind(bindAddress, 0) == bindResult, @@ -1503,7 +1475,7 @@ void tst_QUdpSocket::multicast() "QAbstractSocket: cannot bind to QHostAddress::Any (or an IPv6 address) and join an IPv4 multicast group;" " bind to QHostAddress::AnyIPv4 instead if you want to do this"); } - QVERIFY2(receiver.joinMulticastGroup(groupAddress) == joinResult, + QVERIFY2(receiver.joinMulticastGroup(groupAddress, interfaceForGroup(groupAddress)) == joinResult, qPrintable(receiver.errorString())); if (!joinResult) return; @@ -1515,12 +1487,11 @@ void tst_QUdpSocket::multicast() << QByteArray("cdef"); QUdpSocket sender; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif sender.bind(); foreach (const QByteArray &datagram, datagrams) { - QCOMPARE(int(sender.writeDatagram(datagram, groupAddress, receiver.localPort())), + QNetworkDatagram dgram(datagram, groupAddress, receiver.localPort()); + dgram.setInterfaceIndex(interfaceForGroup(groupAddress).index()); + QCOMPARE(int(sender.writeDatagram(dgram)), int(datagram.size())); } @@ -1545,7 +1516,8 @@ void tst_QUdpSocket::multicast() } QCOMPARE(receivedDatagrams, datagrams); - QVERIFY2(receiver.leaveMulticastGroup(groupAddress), qPrintable(receiver.errorString())); + QVERIFY2(receiver.leaveMulticastGroup(groupAddress, interfaceForGroup(groupAddress)), + qPrintable(receiver.errorString())); } void tst_QUdpSocket::echo_data() @@ -1563,9 +1535,6 @@ void tst_QUdpSocket::echo() QHostAddress remote = info.addresses().first(); QUdpSocket sock; -#ifdef FORCE_SESSION - sock.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif if (connect) { sock.connectToHost(remote, 7); QVERIFY(sock.waitForConnected(10000)); @@ -1716,7 +1685,7 @@ void tst_QUdpSocket::linkLocalIPv4() foreach (QNetworkAddressEntry addr, iface.addressEntries()) { if (addr.ip().isInSubnet(localMask, 16)) { addresses << addr.ip(); - qDebug() << addr.ip(); + qDebug() << "Found IPv4 link local address" << addr.ip(); } } } @@ -1741,7 +1710,6 @@ void tst_QUdpSocket::linkLocalIPv4() QVERIFY(s->writeDatagram(testData, s->localAddress(), neutral.localPort())); QVERIFY2(neutral.waitForReadyRead(10000), QtNetworkSettings::msgSocketError(neutral).constData()); - QVERIFY2(s->waitForReadyRead(10000), QtNetworkSettings::msgSocketError(*s).constData()); QNetworkDatagram dgram = neutral.receiveDatagram(testData.length() * 2); QVERIFY(dgram.isValid()); QCOMPARE(dgram.senderAddress(), s->localAddress()); @@ -1764,7 +1732,7 @@ void tst_QUdpSocket::linkLocalIPv4() } QVERIFY(neutral.writeDatagram(dgram.makeReply(testData))); - + QVERIFY2(s->waitForReadyRead(10000), QtNetworkSettings::msgSocketError(*s).constData()); dgram = s->receiveDatagram(testData.length() * 2); QVERIFY(dgram.isValid()); QCOMPARE(dgram.data(), testData); @@ -1785,10 +1753,6 @@ void tst_QUdpSocket::readyRead() char buf[1]; QUdpSocket sender, receiver; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); quint16 port = receiver.localPort(); @@ -1806,7 +1770,9 @@ void tst_QUdpSocket::readyRead() // make sure only one signal was emitted QCOMPARE(spy.count(), 1); QVERIFY(receiver.hasPendingDatagrams()); +#ifdef RELIABLE_BYTES_AVAILABLE QCOMPARE(receiver.bytesAvailable(), qint64(2)); +#endif QCOMPARE(receiver.pendingDatagramSize(), qint64(2)); // write another datagram @@ -1828,7 +1794,9 @@ void tst_QUdpSocket::readyRead() QTest::qWait(100); QCOMPARE(spy.count(), 2); QVERIFY(receiver.hasPendingDatagrams()); +#ifdef RELIABLE_BYTES_AVAILABLE QCOMPARE(receiver.bytesAvailable(), qint64(3)); +#endif QCOMPARE(receiver.pendingDatagramSize(), qint64(3)); } @@ -1839,10 +1807,6 @@ void tst_QUdpSocket::readyReadForEmptyDatagram() return; QUdpSocket sender, receiver; -#ifdef FORCE_SESSION - sender.setProperty("_q_networksession", QVariant::fromValue(networkSession)); - receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(receiver.bind(QHostAddress(QHostAddress::AnyIPv4), 0)); quint16 port = receiver.localPort(); @@ -1860,7 +1824,9 @@ void tst_QUdpSocket::readyReadForEmptyDatagram() char buf[1]; QVERIFY(receiver.hasPendingDatagrams()); QCOMPARE(receiver.pendingDatagramSize(), qint64(0)); +#ifdef RELIABLE_BYTES_AVAILABLE QCOMPARE(receiver.bytesAvailable(), qint64(0)); +#endif QCOMPARE(receiver.readDatagram(buf, sizeof buf), qint64(0)); } @@ -1869,7 +1835,9 @@ void tst_QUdpSocket::async_readDatagramSlot() char buf[1]; QVERIFY(m_asyncReceiver->hasPendingDatagrams()); QCOMPARE(m_asyncReceiver->pendingDatagramSize(), qint64(1)); +#ifdef RELIABLE_BYTES_AVAILABLE QCOMPARE(m_asyncReceiver->bytesAvailable(), qint64(1)); +#endif QCOMPARE(m_asyncReceiver->readDatagram(buf, sizeof(buf)), qint64(1)); if (buf[0] == '2') { @@ -1891,10 +1859,6 @@ void tst_QUdpSocket::asyncReadDatagram() m_asyncSender = new QUdpSocket; m_asyncReceiver = new QUdpSocket; -#ifdef FORCE_SESSION - m_asyncSender->setProperty("_q_networksession", QVariant::fromValue(networkSession)); - m_asyncReceiver->setProperty("_q_networksession", QVariant::fromValue(networkSession)); -#endif QVERIFY(m_asyncReceiver->bind(QHostAddress(QHostAddress::AnyIPv4), 0)); quint16 port = m_asyncReceiver->localPort(); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 31df66e312..979d5c632e 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -239,13 +239,18 @@ void tst_QFileSystemModel::readOnly() QCOMPARE(model->isReadOnly(), true); QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat")); QVERIFY2(file.open(), qPrintable(file.errorString())); + const QString fileName = file.fileName(); + file.close(); + + const QFileInfo fileInfo(fileName); + QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo)); QModelIndex root = model->setRootPath(flatDirTestPath); QTRY_VERIFY(model->rowCount(root) > 0); - QVERIFY(!(model->flags(model->index(file.fileName())) & Qt::ItemIsEditable)); + QVERIFY(!(model->flags(model->index(fileName)) & Qt::ItemIsEditable)); model->setReadOnly(false); QCOMPARE(model->isReadOnly(), false); - QVERIFY(model->flags(model->index(file.fileName())) & Qt::ItemIsEditable); + QVERIFY(model->flags(model->index(fileName)) & Qt::ItemIsEditable); } class CustomFileIconProvider : public QFileIconProvider @@ -729,6 +734,9 @@ void tst_QFileSystemModel::sortPersistentIndex() { QTemporaryFile file(flatDirTestPath + QStringLiteral("/XXXXXX.dat")); QVERIFY2(file.open(), qPrintable(file.errorString())); + const QFileInfo fileInfo(file.fileName()); + file.close(); + QTRY_VERIFY(QDir(flatDirTestPath).entryInfoList().contains(fileInfo)); QModelIndex root = model->setRootPath(flatDirTestPath); QTRY_VERIFY(model->rowCount(root) > 0); diff --git a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp index a1cb729849..dfe5baba71 100644 --- a/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/widgets/effects/qgraphicseffect/tst_qgraphicseffect.cpp @@ -52,6 +52,7 @@ private slots: void boundingRect2(); void draw(); void opacity(); + void nestedOpaqueOpacity(); void grayscale(); void colorize(); void drawPixmapItem(); @@ -407,6 +408,26 @@ void tst_QGraphicsEffect::opacity() QCOMPARE(effect->m_opacity, qreal(0.5)); } +void tst_QGraphicsEffect::nestedOpaqueOpacity() +{ + // QTBUG-60231: Nesting widgets with a QGraphicsEffect on a toplevel with + // QGraphicsOpacityEffect caused crashes due to constructing several + // QPainter instances on a device in the fast path for + // QGraphicsOpacityEffect::opacity=1 + QWidget topLevel; + topLevel.setWindowTitle(QTest::currentTestFunction()); + topLevel.resize(320, 200); + QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect; + opacityEffect->setOpacity(1); + topLevel.setGraphicsEffect(opacityEffect); + QWidget *child = new QWidget(&topLevel); + child->resize(topLevel.size() / 2); + QGraphicsDropShadowEffect *childEffect = new QGraphicsDropShadowEffect; + child->setGraphicsEffect(childEffect); + topLevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); +} + void tst_QGraphicsEffect::grayscale() { if (qApp->desktop()->depth() < 24) diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 5293ba487a..0eec2e7c75 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -339,6 +339,17 @@ public: endRemoveColumns(); } + void removeAddLastColumnLayoutChanged() // for taskQTBUG_41124 + { + // make sure QHeaderView::_q_layoutChanged() is called + emit layoutAboutToBeChanged(); + --cols; + emit layoutChanged(); + emit layoutAboutToBeChanged(); + ++cols; + emit layoutChanged(); + } + void removeAllColumns() { beginRemoveColumns(QModelIndex(), 0, cols - 1); @@ -1344,6 +1355,18 @@ void tst_QTreeView::columnHidden() QCOMPARE(view.isColumnHidden(model.cols - 1), true); model.simulateMoveRows(); QCOMPARE(view.isColumnHidden(model.cols - 1), true); + + // QTBUG_41124: + // QHeaderViewPrivate::_q_layoutChanged was not called because it was + // disconnected in QTreeView::setModel(). _q_layoutChanged restores + // the hidden sections which is tested here + view.setColumnHidden(model.cols - 1, true); + model.removeAddLastColumnLayoutChanged(); + // we removed the last column and added a new one + // (with layoutToBeChanged/layoutChanged() for both) so column + // 1 is a new column and therefore must not be hidden when + // _q_layoutChanged() is called and is doing the right stuff + QCOMPARE(view.isColumnHidden(model.cols - 1), false); } void tst_QTreeView::rowHidden() diff --git a/tests/auto/widgets/widgets/qsplitter/BLACKLIST b/tests/auto/widgets/widgets/qsplitter/BLACKLIST new file mode 100644 index 0000000000..1352805cd7 --- /dev/null +++ b/tests/auto/widgets/widgets/qsplitter/BLACKLIST @@ -0,0 +1,2 @@ +[replaceWidget:visible, not collapsed] +xcb |