summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-04-10 08:16:20 +0200
committerLiang Qi <liang.qi@qt.io>2019-04-10 08:16:20 +0200
commita20da2353cc308aab15e3efa05ab7d899e9c6ca7 (patch)
tree63881eb44f19384ebfb0e0443291b8f9ab82f149 /tests/auto
parent95f787bfdc890c259e8b347bdad9123d534efe0f (diff)
parenteaf20420f8a4d72c804a9d3725c3e294b34c78c8 (diff)
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts: mkspecs/win32-clang-msvc/qmake.conf src/gui/image/qpnghandler.cpp Change-Id: Ied79d02912ffb3a307a99483df7db08c7f9d0cd8
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp7
-rw-r--r--tests/auto/network/kernel/qhostinfo/BLACKLIST2
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp68
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp75
4 files changed, 147 insertions, 5 deletions
diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
index e1bb3149c6..4160a00f71 100644
--- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
+++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp
@@ -538,8 +538,13 @@ void tst_QTimeZone::checkOffset_data()
int year, month, day, hour, min, sec;
int std, dst;
} table[] = {
- // Zone with no transitions (QTBUG-74614, when TZ backend uses minimalist data)
+ // Zone with no transitions (QTBUG-74614, QTBUG-74666, when TZ backend uses minimal data)
{ "Etc/UTC", "epoch", 1970, 1, 1, 0, 0, 0, 0, 0 },
+ { "Etc/UTC", "pre_int32", 1901, 12, 13, 20, 45, 51, 0, 0 },
+ { "Etc/UTC", "post_int32", 2038, 1, 19, 3, 14, 9, 0, 0 },
+ { "Etc/UTC", "post_uint32", 2106, 2, 7, 6, 28, 17, 0, 0 },
+ { "Etc/UTC", "initial", -292275056, 5, 16, 16, 47, 5, 0, 0 },
+ { "Etc/UTC", "final", 292278994, 8, 17, 7, 12, 55, 0, 0 },
// Kiev: regression test for QTBUG-64122 (on MS):
{ "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 },
{ "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 }
diff --git a/tests/auto/network/kernel/qhostinfo/BLACKLIST b/tests/auto/network/kernel/qhostinfo/BLACKLIST
index cd4d4eb03c..87c5fe991f 100644
--- a/tests/auto/network/kernel/qhostinfo/BLACKLIST
+++ b/tests/auto/network/kernel/qhostinfo/BLACKLIST
@@ -4,5 +4,3 @@
windows ci
[blockingLookup:a-plus-aaaa]
windows ci
-[reverseLookup:google-public-dns-a.google.com]
-ci
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index d85845284a..da6e02210b 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -393,6 +393,68 @@ void tst_QHostInfo::lookupConnectToLambda()
QCOMPARE(tmp.join(' '), expected.join(' '));
}
+static QStringList reverseLookupHelper(const QString &ip)
+{
+ QStringList results;
+
+ const QString pythonCode =
+ "import socket;"
+ "import sys;"
+ "print (socket.getnameinfo((sys.argv[1], 0), 0)[0]);";
+
+ QList<QByteArray> lines;
+ QProcess python;
+ python.setProcessChannelMode(QProcess::ForwardedErrorChannel);
+ python.start("python", QStringList() << QString("-c") << pythonCode << ip);
+ if (python.waitForFinished()) {
+ if (python.exitStatus() == QProcess::NormalExit && python.exitCode() == 0)
+ lines = python.readAllStandardOutput().split('\n');
+ for (QByteArray line : lines) {
+ if (!line.isEmpty())
+ results << line.trimmed();
+ }
+ if (!results.isEmpty())
+ return results;
+ }
+
+ qDebug() << "Python failed, falling back to nslookup";
+ QProcess lookup;
+ lookup.setProcessChannelMode(QProcess::ForwardedErrorChannel);
+ lookup.start("nslookup", QStringList(ip));
+ if (!lookup.waitForFinished()) {
+ results << "nslookup failure";
+ qDebug() << "nslookup failure";
+ return results;
+ }
+ lines = lookup.readAllStandardOutput().split('\n');
+
+ QByteArray name;
+
+ const QByteArray nameMarkerNix("name =");
+ const QByteArray nameMarkerWin("Name:");
+ const QByteArray addressMarkerWin("Address:");
+
+ for (QByteArray line : lines) {
+ int index = -1;
+ if ((index = line.indexOf(nameMarkerNix)) != -1) { // Linux and macOS
+ name = line.mid(index + nameMarkerNix.length()).chopped(1).trimmed();
+ results << name;
+ } else if (line.startsWith(nameMarkerWin)) { // Windows formatting
+ name = line.mid(line.lastIndexOf(" ")).trimmed();
+ } else if (line.startsWith(addressMarkerWin)) {
+ QByteArray address = line.mid(addressMarkerWin.length()).trimmed();
+ if (address == ip) {
+ results << name;
+ }
+ }
+ }
+
+ if (results.isEmpty()) {
+ qDebug() << "Failure to parse nslookup output: " << lines;
+ }
+ return results;
+}
+
void tst_QHostInfo::reverseLookup_data()
{
QTest::addColumn<QString>("address");
@@ -400,8 +462,8 @@ void tst_QHostInfo::reverseLookup_data()
QTest::addColumn<int>("err");
QTest::addColumn<bool>("ipv6");
- QTest::newRow("google-public-dns-a.google.com") << QString("8.8.8.8") << QStringList(QString("google-public-dns-a.google.com")) << 0 << false;
- QTest::newRow("gitorious.org") << QString("87.238.52.168") << QStringList(QString("gitorious.org")) << 0 << false;
+ QTest::newRow("dns.google") << QString("8.8.8.8") << reverseLookupHelper("8.8.8.8") << 0 << false;
+ QTest::newRow("one.one.one.one") << QString("1.1.1.1") << reverseLookupHelper("1.1.1.1") << 0 << false;
QTest::newRow("bogus-name") << QString("1::2::3::4") << QStringList() << 1 << true;
}
@@ -419,6 +481,8 @@ void tst_QHostInfo::reverseLookup()
QHostInfo info = QHostInfo::fromName(address);
if (err == 0) {
+ if (!hostNames.contains(info.hostName()))
+ qDebug() << "Failure: expecting" << hostNames << ",got " << info.hostName();
QVERIFY(hostNames.contains(info.hostName()));
QCOMPARE(info.addresses().first(), QHostAddress(address));
} else {
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index 431d6ba960..8b558aa56f 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -46,6 +46,9 @@
#include <private/qwindow_p.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
+#include <qpa/qwindowsysteminterface.h>
+#include <qpa/qplatformdrag.h>
+#include <private/qhighdpiscaling_p.h>
#include <QtTest/private/qtesthelpers_p.h>
@@ -87,6 +90,7 @@ private slots:
#if QT_CONFIG(draganddrop)
void tst_dnd();
void tst_dnd_events();
+ void tst_dnd_propagation();
#endif
void tst_qtbug35600();
@@ -744,6 +748,77 @@ void tst_QWidget_window::tst_dnd_events()
QCOMPARE(dndWidget._dndEvents, expectedDndEvents);
}
+
+class DropTarget : public QWidget
+{
+public:
+ explicit DropTarget()
+ {
+ setAcceptDrops(true);
+
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ auto width = availableGeometry.width() / 6;
+ auto height = availableGeometry.height() / 4;
+
+ setGeometry(availableGeometry.x() + 200, availableGeometry.y() + 200, width, height);
+
+ QLabel *label = new QLabel(QStringLiteral("Test"), this);
+ label->setGeometry(40, 40, 60, 60);
+ label->setAcceptDrops(true);
+ }
+
+ void dragEnterEvent(QDragEnterEvent *event) override
+ {
+ event->accept();
+ mDndEvents.append("enter ");
+ }
+
+ void dragMoveEvent(QDragMoveEvent *event) override
+ {
+ event->acceptProposedAction();
+ }
+
+ void dragLeaveEvent(QDragLeaveEvent *) override
+ {
+ mDndEvents.append("leave ");
+ }
+
+ void dropEvent(QDropEvent *event) override
+ {
+ event->accept();
+ mDndEvents.append("drop ");
+ }
+
+ QString mDndEvents;
+};
+
+void tst_QWidget_window::tst_dnd_propagation()
+{
+ QMimeData mimeData;
+ mimeData.setText(QLatin1String("testmimetext"));
+
+ DropTarget target;
+ target.show();
+ QVERIFY(QTest::qWaitForWindowActive(&target));
+
+ Qt::DropActions supportedActions = Qt::DropAction::CopyAction;
+ QWindow *window = target.windowHandle();
+
+ auto posInsideDropTarget = QHighDpi::toNativePixels(QPoint(20, 20), window->screen());
+ auto posInsideLabel = QHighDpi::toNativePixels(QPoint(60, 60), window->screen());
+
+ // Enter DropTarget.
+ QWindowSystemInterface::handleDrag(window, &mimeData, posInsideDropTarget, supportedActions, 0, 0);
+ // Enter QLabel. This will propagate because default QLabel does
+ // not accept the drop event in dragEnterEvent().
+ QWindowSystemInterface::handleDrag(window, &mimeData, posInsideLabel, supportedActions, 0, 0);
+ // Drop on QLabel. DropTarget will get dropEvent(), because it accepted the event.
+ QWindowSystemInterface::handleDrop(window, &mimeData, posInsideLabel, supportedActions, 0, 0);
+
+ QGuiApplication::processEvents();
+
+ QCOMPARE(target.mDndEvents, "enter leave enter drop ");
+}
#endif
void tst_QWidget_window::tst_qtbug35600()