From 243c8403903781a28832e0bf34ce962058300e99 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 26 Mar 2019 00:02:22 +0100 Subject: Drag'n'Drop: fix dnd regression DragEnter events always should start with the default state, which is accepted = false. This was a copy-and-paste error introduced by f8944a7f07112c85dc4f66848cabb490514cd28e. Fixes: QTBUG-73977 Change-Id: I34b3ea97c9b4f4fc040a9e6f1befd6124533361d Reviewed-by: Friedemann Kleint --- .../kernel/qwidget_window/tst_qwidget_window.cpp | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'tests/auto') 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 #include #include +#include +#include +#include #include @@ -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() -- cgit v1.2.3 From 82ad4be4a2e0c2bccb6cd8ea2440aefee4ec48ec Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 27 Mar 2019 17:01:40 +0000 Subject: Fix various uncommon cases in QTzTimeZonePrivate backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes a fixup for 03fadc26e7617aece89949bc7d0acf50f6f050a9, which removed the check on empty transition list, needed when no data are available. Ensured that such a data-free zone would in fact be noticed as invalid during init(). Fixed handling of times before the epoch (we still want to consult a POSIX rule, if that's all that's available) while ensuring we (as documented) ignore DST for such times. Fixed handling of large times (milliseconds since epoch outside int range) when looking up POSIX rules. Gave QTimeZonePrivate a YearRange enum (to be moved to QTimeZone once this merges up to dev) so as to eliminate a magic number (and avoid adding another). Moved year-munging in POSIX rules after the one early return, which doesn't need the year range. Added test-cases for the distant past/future (just checking UTC's offsets; SLES has a minimal version of the UTC data-file that triggers the bugs fixed here for them). Fixes: QTBUG-74666 Fixes: QTBUG-74550 Change-Id: Ief7b7e55c62cf11064700934f404b2fc283614e1 Reviewed-by: Tony Sarajärvi Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index eff9835776..bb6c48a2ed 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -539,8 +539,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 } -- cgit v1.2.3