diff options
Diffstat (limited to 'tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp')
-rw-r--r-- | tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp index d947d3006..53a048a35 100644 --- a/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp +++ b/tests/auto/client/primaryselectionv1/tst_primaryselectionv1.cpp @@ -1,11 +1,10 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "mockcompositor.h" #include <qwayland-server-wp-primary-selection-unstable-v1.h> -#include <QtOpenGL/QOpenGLWindow> #include <QtGui/QRasterWindow> #include <QtGui/QClipboard> #include <QtCore/private/qcore_unix_p.h> @@ -130,11 +129,6 @@ protected: { wl_resource_destroy(resource->handle); } - void zwp_primary_selection_device_v1_destroy_resource(Resource *resource) override - { - Q_UNUSED(resource); - delete this; - } }; class PrimarySelectionDeviceManagerV1 : public Global, public QtWaylandServer::zwp_primary_selection_device_manager_v1 @@ -145,9 +139,13 @@ public: : QtWaylandServer::zwp_primary_selection_device_manager_v1(compositor->m_display, version) , m_version(version) {} + ~PrimarySelectionDeviceManagerV1() override + { + qDeleteAll(m_devices); + } bool isClean() override { - for (auto *device : qAsConst(m_devices)) { + for (auto *device : std::as_const(m_devices)) { // The client should not leak selection offers, i.e. if this fails, there is a missing // zwp_primary_selection_offer_v1.destroy request if (!device->m_sentSelectionOffers.empty()) @@ -262,7 +260,7 @@ void tst_primaryselectionv1::createsPrimaryDevice() void tst_primaryselectionv1::createsPrimaryDeviceForNewSeats() { - exec([=] { add<Seat>(); }); + exec([&] { add<Seat>(); }); QCOMPOSITOR_TRY_VERIFY(primarySelectionDevice(1)); } @@ -292,13 +290,13 @@ void tst_primaryselectionv1::pasteAscii() auto *device = primarySelectionDevice(); auto *offer = device->sendDataOffer({"text/plain"}); - connect(offer, &PrimarySelectionOfferV1::receive, [](QString mimeType, int fd) { + connect(offer, &PrimarySelectionOfferV1::receive, offer, [](QString mimeType, int fd) { QFile file; file.open(fd, QIODevice::WriteOnly, QFile::FileHandleFlag::AutoCloseHandle); QCOMPARE(mimeType, "text/plain"); file.write(QByteArray("normal ascii")); file.close(); - }); + }, Qt::DirectConnection); device->sendSelection(offer); pointer()->sendEnter(surface, {32, 32}); @@ -338,13 +336,13 @@ void tst_primaryselectionv1::pasteUtf8() auto *device = primarySelectionDevice(); auto *offer = device->sendDataOffer({"text/plain", "text/plain;charset=utf-8"}); - connect(offer, &PrimarySelectionOfferV1::receive, [](QString mimeType, int fd) { + connect(offer, &PrimarySelectionOfferV1::receive, offer, [](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(); - }); + }, Qt::DirectConnection); device->sendSelection(offer); pointer()->sendEnter(surface, {32, 32}); @@ -409,7 +407,7 @@ void tst_primaryselectionv1::destroysSelectionOnLeave() keyboard()->sendLeave(surface); }); - QTRY_COMPARE(selectionChangedSpy.count(), 1); + QTRY_COMPARE(selectionChangedSpy.size(), 1); QVERIFY(!QGuiApplication::clipboard()->mimeData(QClipboard::Selection)->hasText()); } @@ -466,7 +464,7 @@ void tst_primaryselectionv1::copy() pastedBuf.append(buf, n); } }); - }); + }, Qt::DirectConnection); }); QCOMPOSITOR_TRY_VERIFY(pastedBuf.size()); // this assumes we got everything in one read |