summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-01 11:27:03 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-04-01 11:27:03 +0000
commit26a9783d55da551984b8c408faa837ff83df8c50 (patch)
treead8ec0b16013fecbd6dc99bbf8999db4c6073b67 /tests
parentf53621af053f313eff7fa7b204b5cceff675cb64 (diff)
parentce9519593a0b3deb99d1dd2529770f7e9fffef92 (diff)
Merge "Merge remote-tracking branch 'origin/5.4' into 5.5" into refs/staging/5.5
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp1
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp12
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp37
-rw-r--r--tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp12
-rw-r--r--tests/auto/other/networkselftest/networkselftest.pro2
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp11
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp39
7 files changed, 102 insertions, 12 deletions
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/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/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/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/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 7b4b65e841..97416135db 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();
@@ -3059,6 +3060,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;