summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-12-13 10:01:14 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-01-30 15:02:44 +0000
commit401bdecabb950001ae3294e864ed397d1b76b3f4 (patch)
tree66a98b879f31b0cb6b4c137b3e8e6bb418ed7f1b /tests/auto
parent0ff8a6b14d2668ced57e83219b541cb9b70caae2 (diff)
Client test: Prefer UTF-8 when ASCII is also available
[ChangeLog][QPA plugin] Fixed a bug where pasting from the clipboard would prefer ASCII over UTF-8, causing loss of special characters. The bug was fixed in QtBase, this is just the test. Task-number: QTBUG-54786 Change-Id: Ibe08bf455ad0be8fdd7a3e082dec6131f19c25d6 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/client/datadevicev1/tst_datadevicev1.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
index 9b42cb280..a85b10c74 100644
--- a/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+++ b/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
@@ -57,6 +57,7 @@ private slots:
void cleanup() { QTRY_VERIFY2(isClean(), qPrintable(dirtyMessage())); }
void initTestCase();
void pasteAscii();
+ void pasteUtf8();
};
void tst_datadevicev1::initTestCase()
@@ -107,5 +108,42 @@ void tst_datadevicev1::pasteAscii()
QTRY_COMPARE(window.m_text, "normal ascii");
}
+void tst_datadevicev1::pasteUtf8()
+{
+ class Window : public QRasterWindow {
+ public:
+ void mousePressEvent(QMouseEvent *) override { m_text = QGuiApplication::clipboard()->text(); }
+ QString m_text;
+ };
+
+ Window window;
+ window.resize(64, 64);
+ window.show();
+
+ QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
+ exec([&] {
+ auto *offer = new DataOffer(client(), dataDeviceVersion); // Cleaned up by destroy_resource
+ connect(offer, &DataOffer::receive, [](QString mimeType, int fd) {
+ QFile file;
+ file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle);
+ QCOMPARE(mimeType, "text/plain;charset=utf-8");
+ file.write(QByteArray("face with tears of joy: 😂"));
+ file.close();
+ });
+ dataDevice()->sendDataOffer(offer);
+ offer->send_offer("text/plain");
+ offer->send_offer("text/plain;charset=utf-8");
+ dataDevice()->sendSelection(offer);
+
+ auto *surface = xdgSurface()->m_surface;
+ keyboard()->sendEnter(surface); // Need to set keyboard focus according to protocol
+
+ pointer()->sendEnter(surface, {32, 32});
+ pointer()->sendButton(client(), BTN_LEFT, 1);
+ pointer()->sendButton(client(), BTN_LEFT, 0);
+ });
+ QTRY_COMPARE(window.m_text, "face with tears of joy: 😂");
+}
+
QCOMPOSITOR_TEST_MAIN(tst_datadevicev1)
#include "tst_datadevicev1.moc"