diff options
Diffstat (limited to 'tests')
19 files changed, 236 insertions, 15 deletions
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 30c1f2be59..f756588e80 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -58,6 +58,7 @@ private slots: void readLine2(); void peekBug(); + void readAllKeepPosition(); }; void tst_QIODevice::initTestCase() @@ -584,5 +585,48 @@ void tst_QIODevice::peekBug() } +class SequentialReadBuffer : public QIODevice +{ +public: + SequentialReadBuffer(const char *data) : QIODevice(), buf(data), offset(0) { } + + bool isSequential() const Q_DECL_OVERRIDE { return true; } + const QByteArray &buffer() const { return buf; } + +protected: + qint64 readData(char *data, qint64 maxSize) Q_DECL_OVERRIDE + { + maxSize = qMin(maxSize, qint64(buf.size() - offset)); + memcpy(data, buf.constData() + offset, maxSize); + offset += maxSize; + return maxSize; + } + qint64 writeData(const char * /* data */, qint64 /* maxSize */) Q_DECL_OVERRIDE + { + return -1; + } + +private: + QByteArray buf; + int offset; +}; + +// Test readAll() on position change for sequential device +void tst_QIODevice::readAllKeepPosition() +{ + SequentialReadBuffer buffer("Hello world!"); + buffer.open(QIODevice::ReadOnly); + char c; + + QVERIFY(buffer.getChar(&c)); + QCOMPARE(buffer.pos(), qint64(0)); + buffer.ungetChar(c); + QCOMPARE(buffer.pos(), qint64(0)); + + QByteArray resultArray = buffer.readAll(); + QCOMPARE(buffer.pos(), qint64(0)); + QCOMPARE(resultArray, buffer.buffer()); +} + QTEST_MAIN(tst_QIODevice) #include "tst_qiodevice.moc" diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index e969724117..a0edf29607 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -460,6 +460,7 @@ void tst_QMimeDatabase::mimeTypeForData_data() QTest::newRow("tnef data, needs smi >= 0.20") << QByteArray("\x78\x9f\x3e\x22") << "application/vnd.ms-tnef"; QTest::newRow("PDF magic") << QByteArray("%PDF-") << "application/pdf"; QTest::newRow("PHP, High-priority rule") << QByteArray("<?php") << "application/x-php"; + QTest::newRow("diff\\t") << QByteArray("diff\t") << "text/x-patch"; QTest::newRow("unknown") << QByteArray("\001abc?}") << "application/octet-stream"; } diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 8f37b265f6..f31aed6976 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -260,19 +260,33 @@ void tst_QUuid::generate() void tst_QUuid::less() { - QVERIFY( !(uuidA < uuidB) ); + QVERIFY( uuidB < uuidA); + QVERIFY( uuidB <= uuidA); + QVERIFY(!(uuidA < uuidB) ); + QVERIFY(!(uuidA <= uuidB)); QUuid null_uuid; QVERIFY(null_uuid < uuidA); // Null uuid is always less than a valid one + QVERIFY(null_uuid <= uuidA); + + QVERIFY(null_uuid <= null_uuid); + QVERIFY(uuidA <= uuidA); } void tst_QUuid::more() { - QVERIFY( uuidA > uuidB ); + QVERIFY( uuidA > uuidB); + QVERIFY( uuidA >= uuidB); + QVERIFY(!(uuidB > uuidA)); + QVERIFY(!(uuidB >= uuidA)); QUuid null_uuid; - QVERIFY( !(null_uuid > uuidA) ); // Null uuid is always less than a valid one + QVERIFY(!(null_uuid > uuidA)); // Null uuid is always less than a valid one + QVERIFY(!(null_uuid >= uuidA)); + + QVERIFY(null_uuid >= null_uuid); + QVERIFY(uuidA >= uuidA); } diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 449fefbaa2..719daad3b6 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -840,6 +840,7 @@ void tst_QVarLengthArray::initializeList() T val3(101); T val4(114); + // QVarLengthArray(std::initializer_list<>) QVarLengthArray<T> v1 {val1, val2, val3}; QCOMPARE(v1, QVarLengthArray<T>() << val1 << val2 << val3); QCOMPARE(v1, (QVarLengthArray<T> {val1, val2, val3})); @@ -851,6 +852,25 @@ void tst_QVarLengthArray::initializeList() QVarLengthArray<T> v4({}); QCOMPARE(v4.size(), 0); + + // operator=(std::initializer_list<>) + + QVarLengthArray<T> v5({val2, val1}); + v1 = { val1, val2 }; // make array smaller + v4 = { val1, val2 }; // make array bigger + v5 = { val1, val2 }; // same size + QCOMPARE(v1, QVarLengthArray<T>() << val1 << val2); + QCOMPARE(v4, v1); + QCOMPARE(v5, v1); + + QVarLengthArray<T, 1> v6 = { val1 }; + v6 = { val1, val2 }; // force allocation on heap + QCOMPARE(v6.size(), 2); + QCOMPARE(v6.first(), val1); + QCOMPARE(v6.last(), val2); + + v6 = {}; // assign empty + QCOMPARE(v6.size(), 0); #else QSKIP("This tests requires a compiler that supports initializer lists."); #endif diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 0f9bdc7a1a..660809fb16 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -2480,6 +2480,7 @@ void tst_QImage::inplaceConversion_data() QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("dest_format"); + QTest::newRow("Format_RGB32 -> RGB16") << QImage::Format_RGB32 << QImage::Format_RGB16; QTest::newRow("Format_ARGB32 -> Format_RGBA8888") << QImage::Format_ARGB32 << QImage::Format_RGBA8888; QTest::newRow("Format_RGB888 -> Format_ARGB6666_Premultiplied") << QImage::Format_RGB888 << QImage::Format_ARGB6666_Premultiplied; QTest::newRow("Format_RGB16 -> Format_RGB555") << QImage::Format_RGB16 << QImage::Format_RGB555; @@ -2518,16 +2519,21 @@ void tst_QImage::inplaceConversion() QCOMPARE(imageConverted.constScanLine(0), originalPtr); { - // Test attempted inplace conversion of images created on existing, readonly buffer + // Test attempted inplace conversion of images created on existing buffer static const quint32 readOnlyData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U }; + quint32 readWriteData[] = { 0x00010203U, 0x04050607U, 0x08091011U, 0x12131415U }; QImage roImage((const uchar *)readOnlyData, 2, 2, format); - QImage inplaceConverted = std::move(roImage).convertToFormat(dest_format); + QImage roInplaceConverted = std::move(roImage).convertToFormat(dest_format); + + QImage rwImage((uchar *)readWriteData, 2, 2, format); + QImage rwInplaceConverted = std::move(rwImage).convertToFormat(dest_format); QImage roImage2((const uchar *)readOnlyData, 2, 2, format); QImage normalConverted = roImage2.convertToFormat(dest_format); - QCOMPARE(normalConverted, inplaceConverted); + QCOMPARE(normalConverted, roInplaceConverted); + QCOMPARE(normalConverted, rwInplaceConverted); } #endif } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index f6167262a9..6582755aec 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -291,6 +291,10 @@ private slots: void RasterOp_NotDestination(); void drawTextNoHinting(); + + void drawPolyline_data(); + void drawPolyline(); + private: void fillData(); void setPenColor(QPainter& p); @@ -4874,6 +4878,39 @@ void tst_QPainter::drawTextNoHinting() QVERIFY(true); } +void tst_QPainter::drawPolyline_data() +{ + QTest::addColumn< QVector<QPointF> >("points"); + + QTest::newRow("basic") << (QVector<QPointF>() << QPointF(10, 10) << QPointF(20, 10) << QPointF(20, 20) << QPointF(10, 20)); + QTest::newRow("clipped") << (QVector<QPointF>() << QPoint(-10, 100) << QPoint(-1, 100) << QPoint(-1, -2) << QPoint(100, -2) << QPoint(100, 40)); // QTBUG-31579 + QTest::newRow("shortsegment") << (QVector<QPointF>() << QPoint(20, 100) << QPoint(20, 99) << QPoint(21, 99) << QPoint(21, 104)); // QTBUG-42398 +} + +void tst_QPainter::drawPolyline() +{ + QFETCH(QVector<QPointF>, points); + QImage images[2]; + + for (int r = 0; r < 2; r++) { + images[r] = QImage(150, 150, QImage::Format_ARGB32); + images[r].fill(Qt::transparent); + QPainter p(images + r); + QPen pen(Qt::red, 0, Qt::SolidLine, Qt::FlatCap); + p.setPen(pen); + QVERIFY(p.pen().isCosmetic()); + if (r) { + for (int i = 0; i < points.count()-1; i++) { + p.drawLine(points.at(i), points.at(i+1)); + } + } else { + p.drawPolyline(points); + } + } + + QCOMPARE(images[0], images[1]); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" diff --git a/tests/auto/network/access/qnetworkreply/BLACKLIST b/tests/auto/network/access/qnetworkreply/BLACKLIST index 84ccb49e58..54dcff071e 100644 --- a/tests/auto/network/access/qnetworkreply/BLACKLIST +++ b/tests/auto/network/access/qnetworkreply/BLACKLIST @@ -1,7 +1,9 @@ [ioGetFromBuiltinHttp:http+limited] osx +ubuntu-14.04 [ioGetFromBuiltinHttp:https+limited] osx +ubuntu-14.04 [ioGetFromHttpBrokenServer:no-newline] osx [synchronousRequest:https] diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index 42e1bf93b5..301a915dd6 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -67,8 +67,8 @@ private slots: void tst_QDnsLookup::initTestCase() { QTest::addColumn<QString>("tld"); - QTest::newRow("normal") << ".test.macieira.org"; - QTest::newRow("idn") << ".alqualond\xc3\xab.test.macieira.org"; + QTest::newRow("normal") << ".test.qt-project.org"; + QTest::newRow("idn") << ".alqualond\xc3\xab.test.qt-project.org"; } QString tst_QDnsLookup::domainName(const QString &input) @@ -145,12 +145,16 @@ void tst_QDnsLookup::lookup_data() QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; - QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns3.macieira.info." << "" << "" << ""; - QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "gondolin.macieira.info.;ns3.macieira.info." << "" << "" << ""; + QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns11.cloudns.net." << "" << "" << ""; + QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "ns11.cloudns.net.;ns12.cloudns.net." << "" << "" << ""; QTest::newRow("ptr-empty") << int(QDnsLookup::PTR) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; QTest::newRow("ptr-notfound") << int(QDnsLookup::PTR) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; +#if 0 + // temporarily disabled since the new hosting provider can't insert + // PTR records outside of the in-addr.arpa zone QTest::newRow("ptr-single") << int(QDnsLookup::PTR) << "ptr-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "a-single" << "" << ""; +#endif QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST b/tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST new file mode 100644 index 0000000000..73570c98b7 --- /dev/null +++ b/tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST @@ -0,0 +1,2 @@ +[genericSystemProxy] +ubuntu-14.04 diff --git a/tests/auto/other/networkselftest/networkselftest.pro b/tests/auto/other/networkselftest/networkselftest.pro index c8b870128d..22208e02fb 100644 --- a/tests/auto/other/networkselftest/networkselftest.pro +++ b/tests/auto/other/networkselftest/networkselftest.pro @@ -2,7 +2,7 @@ CONFIG += testcase TARGET = tst_networkselftest SOURCES += tst_networkselftest.cpp -QT = core network testlib +QT = core core-private network testlib win32:CONFIG += insignificant_test # QTBUG-27571 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index 761b5c28d7..5612260cca 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -34,6 +34,7 @@ #include <QtTest/QtTest> #include <QtNetwork/QtNetwork> #include <QtCore/QDateTime> +#include <QtCore/private/qiodevice_p.h> #ifndef QT_NO_BEARERMANAGEMENT #include <QtNetwork/qnetworkconfigmanager.h> @@ -171,10 +172,11 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout forever { if (socket->bytesAvailable() >= minBytesAvailable) return true; + timeout = qt_subtract_from_timeout(timeout, timer.elapsed()); if (socket->state() == QAbstractSocket::UnconnectedState - || timer.elapsed() >= timeout) + || timeout == 0) return false; - if (!socket->waitForReadyRead(timeout - timer.elapsed())) + if (!socket->waitForReadyRead(timeout)) return false; } } @@ -202,10 +204,11 @@ static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) #endif ) return true; + timeout = qt_subtract_from_timeout(timeout, timer.elapsed()); if (socket->state() == QAbstractSocket::UnconnectedState - || timer.elapsed() >= timeout) + || timeout == 0) return false; - if (!socket->waitForBytesWritten(timeout - timer.elapsed())) + if (!socket->waitForBytesWritten(timeout)) return false; } } diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST new file mode 100644 index 0000000000..717c791280 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/BLACKLIST @@ -0,0 +1,2 @@ +[hoverEnterLeaveEvent] +ubuntu-14.04 diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST new file mode 100644 index 0000000000..be7a7e398b --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -0,0 +1,4 @@ +[task255529_transformationAnchorMouseAndViewportMargins] +ubuntu-14.04 +[cursor] +ubuntu-14.04 diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST new file mode 100644 index 0000000000..5db5c97917 --- /dev/null +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/BLACKLIST @@ -0,0 +1,2 @@ +[initialShow2] +ubuntu-14.04 diff --git a/tests/auto/widgets/kernel/qaction/BLACKLIST b/tests/auto/widgets/kernel/qaction/BLACKLIST new file mode 100644 index 0000000000..f67a3c471e --- /dev/null +++ b/tests/auto/widgets/kernel/qaction/BLACKLIST @@ -0,0 +1,2 @@ +[setStandardKeys] +ubuntu-14.04 diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST new file mode 100644 index 0000000000..ed40f98051 --- /dev/null +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -0,0 +1,16 @@ +[normalGeometry] +ubuntu-14.04 +[saveRestoreGeometry] +ubuntu-14.04 +[restoreVersion1Geometry] +ubuntu-14.04 +[updateWhileMinimized] +ubuntu-14.04 +[focusProxyAndInputMethods] +ubuntu-14.04 +[touchEventSynthesizedMouseEvent] +ubuntu-14.04 +[grabMouse] +ubuntu-14.04 +[largerThanScreen_QTBUG30142] +ubuntu-14.04 diff --git a/tests/auto/widgets/util/qcompleter/BLACKLIST b/tests/auto/widgets/util/qcompleter/BLACKLIST new file mode 100644 index 0000000000..ffbcc94a1f --- /dev/null +++ b/tests/auto/widgets/util/qcompleter/BLACKLIST @@ -0,0 +1,2 @@ +[QTBUG_14292_filesystem] +ubuntu-14.04 diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 7b4b65e841..c409698ec0 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -160,6 +160,7 @@ private slots: void highlightedSignal(); void itemData(); void task_QTBUG_31146_popupCompletion(); + void task_QTBUG_41288_completerChangesCurrentIndex(); void keyboardSelection(); void setCustomModelAndView(); void updateDelegateOnEditableChange(); @@ -530,6 +531,23 @@ void tst_QComboBox::sizeAdjustPolicy() QCOMPARE(testWidget->sizeHint(), content); testWidget->setMinimumContentsLength(0); QVERIFY(testWidget->sizeHint().width() < content.width()); + + // check AdjustToContents changes when model changes + content = testWidget->sizeHint(); + QStandardItemModel *model = new QStandardItemModel(2, 1, testWidget); + testWidget->setModel(model); + QVERIFY(testWidget->sizeHint().width() < content.width()); + + // check AdjustToContents changes when a row is inserted into the model + content = testWidget->sizeHint(); + QStandardItem *item = new QStandardItem(QStringLiteral("This is an item")); + model->appendRow(item); + QVERIFY(testWidget->sizeHint().width() > content.width()); + + // check AdjustToContents changes when model is reset + content = testWidget->sizeHint(); + model->clear(); + QVERIFY(testWidget->sizeHint().width() < content.width()); } void tst_QComboBox::clear() @@ -3059,6 +3077,44 @@ void tst_QComboBox::task_QTBUG_31146_popupCompletion() QCOMPARE(comboBox.currentIndex(), 0); } +void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex() +{ + QComboBox comboBox; + comboBox.setEditable(true); + + comboBox.addItems(QStringList() << QStringLiteral("111") << QStringLiteral("222")); + + comboBox.show(); + comboBox.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&comboBox)); + + { + // change currentIndex() by keyboard + comboBox.lineEdit()->selectAll(); + QTest::keyClicks(comboBox.lineEdit(), "222"); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 1); + + QTest::keyClick(&comboBox, Qt::Key_Up); + comboBox.lineEdit()->selectAll(); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 0); + } + + { + // change currentIndex() programmatically + comboBox.lineEdit()->selectAll(); + QTest::keyClicks(comboBox.lineEdit(), "222"); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 1); + + comboBox.setCurrentIndex(0); + comboBox.lineEdit()->selectAll(); + QTest::keyClick(comboBox.lineEdit(), Qt::Key_Enter); + QCOMPARE(comboBox.currentIndex(), 0); + } +} + void tst_QComboBox::keyboardSelection() { QComboBox comboBox; diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST new file mode 100644 index 0000000000..53ea4a9148 --- /dev/null +++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST @@ -0,0 +1,4 @@ +[check_menuPosition] +ubuntu-14.04 +[taskQTBUG4965_escapeEaten] +ubuntu-14.04 |