summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-10-22 10:17:56 +0200
committerJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-10-24 11:07:03 +0200
commit1c67c2e281f8a5e1af5ae2ef697e570bdd50514b (patch)
tree872f25bd18fcdfd1c5b9683875501c2eaa2e3b85 /tests
parente306847cd46e68d86b1d5478c0c05b9a5acb026c (diff)
Fix missing emission of QClipboard::selectionChanged
And add a test to verify we've fixed it. Change-Id: Ic6d5e64b3000444465935f7caf7e32ec9c4f1012 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp
index 216db85cd..b3fa2b13c 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 {