diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-06-14 08:45:29 +0200 |
---|---|---|
committer | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2019-09-09 20:00:43 +0200 |
commit | 481490ff476486534748275d544045e37badbc30 (patch) | |
tree | cdcdaeb14fe5cc1c1c90024b35b8d07ca6645f67 | |
parent | 9233216972fc9823e5824568cbac7c804b1a4481 (diff) | |
download | qtwayland-481490ff476486534748275d544045e37badbc30.tar.gz |
Client: Add test for starting a drag operation without input focus
This used to crash the client.
Task-number: QTBUG-76368
Change-Id: I855f3bda15b4b2bccbdb2aa8239e26c0eecf7cb3
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r-- | tests/auto/client/datadevicev1/tst_datadevicev1.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp index fe68d520..7368829d 100644 --- a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp +++ b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp @@ -30,9 +30,8 @@ #include <QtGui/QRasterWindow> #include <QtGui/QOpenGLWindow> - -//TODO: move? #include <QtGui/QClipboard> +#include <QtGui/QDrag> using namespace MockCompositor; @@ -60,6 +59,7 @@ private slots: void pasteUtf8(); void destroysPreviousSelection(); void destroysSelectionWithSurface(); + void dragWithoutFocus(); }; void tst_datadevicev1::initTestCase() @@ -209,5 +209,22 @@ void tst_datadevicev1::destroysSelectionWithSurface() QCOMPOSITOR_TRY_COMPARE(dataDevice()->m_sentSelectionOffers.size(), 0); } +// The application should not crash if it attempts to start a drag operation +// when it doesn't have input focus (QTBUG-76368) +void tst_datadevicev1::dragWithoutFocus() +{ + QRasterWindow window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + auto *mimeData = new QMimeData; + const QByteArray data("testData"); + mimeData->setData("text/plain", data); + QDrag drag(&window); + drag.setMimeData(mimeData); + drag.exec(); +} + QCOMPOSITOR_TEST_MAIN(tst_datadevicev1) #include "tst_datadevicev1.moc" |