summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/client/datadevicev1/tst_datadevicev1.cpp')
-rw-r--r--tests/auto/client/datadevicev1/tst_datadevicev1.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
index 7368829d1..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();
};
@@ -66,7 +67,7 @@ void tst_datadevicev1::initTestCase()
{
QCOMPOSITOR_TRY_VERIFY(pointer());
QCOMPOSITOR_TRY_VERIFY(!pointer()->resourceMap().empty());
- QCOMPOSITOR_TRY_COMPARE(pointer()->resourceMap().first()->version(), 4);
+ QCOMPOSITOR_TRY_COMPARE(pointer()->resourceMap().first()->version(), 5);
QCOMPOSITOR_TRY_VERIFY(keyboard());
@@ -104,8 +105,11 @@ void tst_datadevicev1::pasteAscii()
keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol
pointer()->sendEnter(surface, {32, 32});
+ pointer()->sendFrame(client);
pointer()->sendButton(client, BTN_LEFT, 1);
+ pointer()->sendFrame(client);
pointer()->sendButton(client, BTN_LEFT, 0);
+ pointer()->sendFrame(client);
});
QTRY_COMPARE(window.m_text, "normal ascii");
}
@@ -139,8 +143,11 @@ void tst_datadevicev1::pasteUtf8()
keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol
pointer()->sendEnter(surface, {32, 32});
+ pointer()->sendFrame(client);
pointer()->sendButton(client, BTN_LEFT, 1);
+ pointer()->sendFrame(client);
pointer()->sendButton(client, BTN_LEFT, 0);
+ pointer()->sendFrame(client);
});
QTRY_COMPARE(window.m_text, "face with tears of joy: 😂");
}
@@ -209,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()