diff options
Diffstat (limited to 'tests')
6 files changed, 121 insertions, 2 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 0d08e912f8..4eb3e4fc98 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -101,6 +101,13 @@ void tst_QGlobal::for_each() QCOMPARE(i, counter++); } QCOMPARE(counter, list.count()); + + // check whether we can pass a constructor as container argument + counter = 0; + foreach (int i, QList<int>(list)) { + QCOMPARE(i, counter++); + } + QCOMPARE(counter, list.count()); } void tst_QGlobal::qassert() diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 20a31fc98f..7247b02498 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -77,6 +77,7 @@ private slots: void testAllWritableLocations_data(); void testAllWritableLocations(); void testCleanPath(); + void testXdgPathCleanup(); private: #ifdef Q_XDG_PLATFORM @@ -477,6 +478,8 @@ void tst_qstandardpaths::testAllWritableLocations() QString loc = QStandardPaths::writableLocation(location); if (loc.size() > 1) // workaround for unlikely case of locations that return '/' QCOMPARE(loc.endsWith(QLatin1Char('/')), false); + QVERIFY(loc.contains(QLatin1Char('/'))); + QVERIFY(!loc.contains(QLatin1Char('\\'))); } void tst_qstandardpaths::testCleanPath() @@ -491,6 +494,19 @@ void tst_qstandardpaths::testCleanPath() } } +void tst_qstandardpaths::testXdgPathCleanup() +{ +#ifdef Q_XDG_PLATFORM + setCustomLocations(); + const QString uncleanGlobalAppDir = "/./" + QFile::encodeName(m_globalAppDir); + qputenv("XDG_DATA_DIRS", QFile::encodeName(uncleanGlobalAppDir) + "::relative/path"); + const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation); + QVERIFY(!appsDirs.contains("/applications")); + QVERIFY(!appsDirs.contains(uncleanGlobalAppDir + "/applications")); + QVERIFY(!appsDirs.contains("relative/path/applications")); +#endif +} + QTEST_MAIN(tst_qstandardpaths) #include "tst_qstandardpaths.moc" diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index ac8aae8d3a..1c0a495116 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -147,6 +147,7 @@ private slots: void connectFunctorOverloads(); void connectFunctorQueued(); void connectFunctorWithContext(); + void connectFunctorDeadlock(); void connectStaticSlotWithObject(); void disconnectDoesNotLeakFunctor(); void contextDoesNotLeakFunctor(); @@ -5740,6 +5741,47 @@ void tst_QObject::connectFunctorWithContext() context->deleteLater(); } +class MyFunctor +{ +public: + explicit MyFunctor(QObject *objectToDisconnect) + : m_objectToDisconnect(objectToDisconnect) + {} + + ~MyFunctor() { + // Do operations that will lock the internal signalSlotLock mutex on many QObjects. + // The more QObjects, the higher the chance that the signalSlotLock mutex used + // is already in use. If the number of objects is higher than the number of mutexes in + // the pool (currently 131), the deadlock should always trigger. Use an even higher number + // to be on the safe side. + const int objectCount = 1024; + SenderObject lotsOfObjects[objectCount]; + for (int i = 0; i < objectCount; ++i) { + QObject::connect(&lotsOfObjects[i], &SenderObject::signal1, + &lotsOfObjects[i], &SenderObject::aPublicSlot); + } + } + + void operator()() { + // This will cause the slot object associated with this functor to be destroyed after + // this function returns. That in turn will destroy this functor. + // If our dtor runs with the signalSlotLock held, the bunch of connect() + // performed there will deadlock trying to lock that lock again. + m_objectToDisconnect->disconnect(); + } + +private: + QObject *m_objectToDisconnect; +}; + +void tst_QObject::connectFunctorDeadlock() +{ + SenderObject sender; + MyFunctor functor(&sender); + QObject::connect(&sender, &SenderObject::signal1, functor); + sender.emitSignal1(); +} + static int s_static_slot_checker = 1; class StaticSlotChecker : public QObject diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 91c06ab0b2..e4340451ce 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -202,6 +202,9 @@ private slots: void linearGradientSymmetry(); void gradientInterpolation(); + void gradientPixelFormat_data(); + void gradientPixelFormat(); + void fpe_pixmapTransform(); void fpe_zeroLengthLines(); void fpe_divByZero(); @@ -3727,6 +3730,49 @@ void tst_QPainter::linearGradientSymmetry() QCOMPARE(a, b); } +void tst_QPainter::gradientPixelFormat_data() +{ + QTest::addColumn<QImage::Format>("format"); + + QTest::newRow("argb32") << QImage::Format_ARGB32; + QTest::newRow("rgb32") << QImage::Format_RGB32; + QTest::newRow("rgb888") << QImage::Format_RGB888; + QTest::newRow("rgbx8888") << QImage::Format_RGBX8888; + QTest::newRow("rgba8888") << QImage::Format_RGBA8888; + QTest::newRow("rgba8888_pm") << QImage::Format_RGBA8888_Premultiplied; +} + +void tst_QPainter::gradientPixelFormat() +{ + QFETCH(QImage::Format, format); + + QImage a(8, 64, QImage::Format_ARGB32_Premultiplied); + QImage b(8, 64, format); + + + QGradientStops stops; + stops << qMakePair(qreal(0.0), QColor(Qt::blue)); + stops << qMakePair(qreal(0.3), QColor(Qt::red)); + stops << qMakePair(qreal(0.6), QColor(Qt::green)); + stops << qMakePair(qreal(1.0), QColor(Qt::black)); + + a.fill(0); + b.fill(0); + + QLinearGradient gradient(QRectF(b.rect()).topLeft(), QRectF(b.rect()).bottomLeft()); + gradient.setStops(stops); + + QPainter pa(&a); + pa.fillRect(a.rect(), gradient); + pa.end(); + + QPainter pb(&b); + pb.fillRect(b.rect(), gradient); + pb.end(); + + QCOMPARE(a, b.convertToFormat(QImage::Format_ARGB32_Premultiplied)); +} + void tst_QPainter::gradientInterpolation() { QImage image(256, 8, QImage::Format_ARGB32_Premultiplied); diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 47ab7c2e99..8e0090e486 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -160,7 +160,6 @@ void tst_QHttpNetworkConnection::head_data() QTest::addColumn<int>("contentLength"); QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962; - QTest::newRow("success-external") << "http://" << "www.ietf.org" << "/rfc/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962; QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1; QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1; @@ -217,7 +216,6 @@ void tst_QHttpNetworkConnection::get_data() QTest::addColumn<int>("downloadSize"); QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; - QTest::newRow("success-external") << "http://" << "www.ietf.org" << "/rfc/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << -1; QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << -1; diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp index cebd4883a4..aaff322c4b 100644 --- a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp +++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp @@ -63,6 +63,7 @@ private slots: void collapseTextOnPriority(); void task230994_iconSize(); void task176137_autoRepeatOfAction(); + void qtbug_26956_popupTimerDone(); protected slots: void sendMouseClick(); @@ -223,5 +224,14 @@ void tst_QToolButton::sendMouseClick() QTest::mouseClick(w, Qt::LeftButton, 0, QPoint(7,7)); } +void tst_QToolButton::qtbug_26956_popupTimerDone() +{ + QToolButton *tb = new QToolButton; + tb->setMenu(new QMenu(tb)); + tb->menu()->addAction("Qt"); + tb->deleteLater(); + tb->showMenu(); +} + QTEST_MAIN(tst_QToolButton) #include "tst_qtoolbutton.moc" |