summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp')
-rw-r--r--tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
index 216db85cd..ee9fa110e 100644
--- a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
+++ b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
@@ -261,6 +261,7 @@ private slots:
void pasteAscii();
void pasteUtf8();
void destroysPreviousSelection();
+ void destroysSelectionOnLeave();
void copy();
};
@@ -411,6 +412,35 @@ void tst_primaryselectionv1::destroysPreviousSelection()
QCOMPOSITOR_TRY_COMPARE(primarySelectionDevice()->m_sentSelectionOffers.size(), 1);
}
+void tst_primaryselectionv1::destroysSelectionOnLeave()
+{
+ QRasterWindow window;
+ window.resize(64, 64);
+ window.show();
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
+
+ exec([&] {
+ auto *surface = xdgSurface()->m_surface;
+ keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol
+
+ auto *offer = primarySelectionDevice()->sendDataOffer({"text/plain"});
+ primarySelectionDevice()->sendSelection(offer);
+ });
+
+ QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Selection));
+ QTRY_VERIFY(QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText());
+
+ QSignalSpy selectionChangedSpy(QGuiApplication::clipboard(), &QClipboard::selectionChanged);
+
+ exec([&] {
+ auto *surface = xdgSurface()->m_surface;
+ keyboard()->sendLeave(surface);
+ });
+
+ QTRY_COMPARE(selectionChangedSpy.count(), 1);
+ QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText());
+}
+
void tst_primaryselectionv1::copy()
{
class Window : public QRasterWindow {
@@ -442,6 +472,7 @@ void tst_primaryselectionv1::copy()
});
QCOMPOSITOR_TRY_VERIFY(primarySelectionDevice()->m_selectionSource);
QCOMPOSITOR_TRY_VERIFY(mouseSerials.contains(primarySelectionDevice()->m_serial));
+ QVERIFY(QGuiApplication::clipboard()->ownsSelection());
QByteArray pastedBuf;
exec([&](){
auto *source = primarySelectionDevice()->m_selectionSource;