diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-26 03:06:36 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-26 03:06:36 +0200 |
commit | 3c5a3654c1f68cd7ee7e801ab098510ebc6a9071 (patch) | |
tree | 69e425ccc47b575d50e232b21208109ed0ddf925 /tests/auto/client/datadevicev1/tst_datadevicev1.cpp | |
parent | 3d161cef55eacafc4495e3ba0bcb86089c544dc1 (diff) | |
parent | 137966a6293b50f6b248d130a2e36e67df49335e (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: If09bb13aa7a0aadd5cfb8265166d3b9d1b22e2f1
Diffstat (limited to 'tests/auto/client/datadevicev1/tst_datadevicev1.cpp')
-rw-r--r-- | tests/auto/client/datadevicev1/tst_datadevicev1.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp index e3babceb5..1568b3b96 100644 --- a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp +++ b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp @@ -59,6 +59,7 @@ private slots: void pasteUtf8(); void destroysPreviousSelection(); void destroysSelectionWithSurface(); + void destroysSelectionOnLeave(); void dragWithoutFocus(); }; @@ -215,6 +216,35 @@ void tst_datadevicev1::destroysSelectionWithSurface() QCOMPOSITOR_TRY_COMPARE(dataDevice()->m_sentSelectionOffers.size(), 0); } +void tst_datadevicev1::destroysSelectionOnLeave() +{ + QRasterWindow window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial); + + exec([&] { + auto *offer = dataDevice()->sendDataOffer(client(), {"text/plain"}); + dataDevice()->sendSelection(offer); + + auto *surface = xdgSurface()->m_surface; + keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol + }); + + QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)); + QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)->hasText()); + + QSignalSpy dataChangedSpy(QGuiApplication::clipboard(), &QClipboard::dataChanged); + + exec([&] { + auto *surface = xdgSurface()->m_surface; + keyboard()->sendLeave(surface); + }); + + QTRY_COMPARE(dataChangedSpy.count(), 1); + QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Clipboard)->hasText()); +} + // 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() |