2020-12-09 12:36:18 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
|
2021-08-10 12:29:35 +00:00
|
|
|
SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
|
2020-12-09 12:36:18 +00:00
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
// Qt
|
|
|
|
#include <QHash>
|
2023-07-03 19:28:19 +00:00
|
|
|
#include <QSignalSpy>
|
|
|
|
#include <QTest>
|
2020-05-12 11:26:57 +00:00
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
// WaylandServer
|
2022-04-22 09:27:33 +00:00
|
|
|
#include "wayland/compositor_interface.h"
|
|
|
|
#include "wayland/datacontroldevice_v1_interface.h"
|
|
|
|
#include "wayland/datacontroldevicemanager_v1_interface.h"
|
|
|
|
#include "wayland/datacontrolsource_v1_interface.h"
|
|
|
|
#include "wayland/display.h"
|
|
|
|
#include "wayland/seat_interface.h"
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
#include <KWayland/Client/compositor.h>
|
|
|
|
#include <KWayland/Client/connection_thread.h>
|
|
|
|
#include <KWayland/Client/event_queue.h>
|
|
|
|
#include <KWayland/Client/registry.h>
|
|
|
|
#include <KWayland/Client/seat.h>
|
|
|
|
|
|
|
|
#include "qwayland-wlr-data-control-unstable-v1.h"
|
|
|
|
|
|
|
|
using namespace KWaylandServer;
|
|
|
|
|
|
|
|
// Faux-client API for tests
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
Q_DECLARE_OPAQUE_POINTER(::zwlr_data_control_offer_v1 *)
|
|
|
|
Q_DECLARE_METATYPE(::zwlr_data_control_offer_v1 *)
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
class DataControlDeviceManager : public QObject, public QtWayland::zwlr_data_control_manager_v1
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
};
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
class DataControlOffer : public QObject, public QtWayland::zwlr_data_control_offer_v1
|
2020-05-12 11:26:57 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-08-29 05:11:06 +00:00
|
|
|
~DataControlOffer()
|
|
|
|
{
|
2020-08-04 10:34:57 +00:00
|
|
|
destroy();
|
|
|
|
}
|
2021-08-29 05:11:06 +00:00
|
|
|
QStringList receivedOffers()
|
|
|
|
{
|
2020-05-12 11:26:57 +00:00
|
|
|
return m_receivedOffers;
|
|
|
|
}
|
2021-08-29 05:11:06 +00:00
|
|
|
|
2020-05-12 11:26:57 +00:00
|
|
|
protected:
|
2021-08-29 05:11:06 +00:00
|
|
|
virtual void zwlr_data_control_offer_v1_offer(const QString &mime_type) override
|
|
|
|
{
|
2020-05-12 11:26:57 +00:00
|
|
|
m_receivedOffers << mime_type;
|
|
|
|
}
|
2021-08-29 05:11:06 +00:00
|
|
|
|
2020-05-12 11:26:57 +00:00
|
|
|
private:
|
|
|
|
QStringList m_receivedOffers;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DataControlDevice : public QObject, public QtWayland::zwlr_data_control_device_v1
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-08-04 10:34:57 +00:00
|
|
|
public:
|
2021-08-29 05:11:06 +00:00
|
|
|
~DataControlDevice()
|
|
|
|
{
|
2020-08-04 10:34:57 +00:00
|
|
|
destroy();
|
|
|
|
}
|
2020-05-12 11:26:57 +00:00
|
|
|
Q_SIGNALS:
|
2021-08-29 05:11:06 +00:00
|
|
|
void dataControlOffer(DataControlOffer *offer); // our event receives a new ID, so we make a new object
|
2020-05-12 11:26:57 +00:00
|
|
|
void selection(struct ::zwlr_data_control_offer_v1 *id);
|
2021-08-10 12:29:35 +00:00
|
|
|
void primary_selection(struct ::zwlr_data_control_offer_v1 *id);
|
2021-08-29 05:11:06 +00:00
|
|
|
|
2020-05-12 11:26:57 +00:00
|
|
|
protected:
|
2021-08-29 05:11:06 +00:00
|
|
|
void zwlr_data_control_device_v1_data_offer(struct ::zwlr_data_control_offer_v1 *id) override
|
|
|
|
{
|
2020-05-12 11:26:57 +00:00
|
|
|
auto offer = new DataControlOffer;
|
|
|
|
offer->init(id);
|
|
|
|
Q_EMIT dataControlOffer(offer);
|
|
|
|
}
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
void zwlr_data_control_device_v1_selection(struct ::zwlr_data_control_offer_v1 *id) override
|
|
|
|
{
|
2020-05-12 11:26:57 +00:00
|
|
|
Q_EMIT selection(id);
|
|
|
|
}
|
2021-08-10 12:29:35 +00:00
|
|
|
|
|
|
|
void zwlr_data_control_device_v1_primary_selection(struct ::zwlr_data_control_offer_v1 *id) override
|
|
|
|
{
|
|
|
|
Q_EMIT primary_selection(id);
|
|
|
|
}
|
2020-05-12 11:26:57 +00:00
|
|
|
};
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
class DataControlSource : public QObject, public QtWayland::zwlr_data_control_source_v1
|
2020-05-12 11:26:57 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-08-04 10:34:57 +00:00
|
|
|
public:
|
2021-08-29 05:11:06 +00:00
|
|
|
~DataControlSource()
|
|
|
|
{
|
2020-08-04 10:34:57 +00:00
|
|
|
destroy();
|
|
|
|
}
|
2021-08-29 05:11:06 +00:00
|
|
|
|
2020-08-04 10:34:57 +00:00
|
|
|
public:
|
2020-05-12 11:26:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TestDataSource : public AbstractDataSource
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-08-29 05:11:06 +00:00
|
|
|
TestDataSource()
|
|
|
|
: AbstractDataSource(nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
~TestDataSource()
|
|
|
|
{
|
2021-05-13 09:33:08 +00:00
|
|
|
Q_EMIT aboutToBeDestroyed();
|
2020-08-04 10:34:57 +00:00
|
|
|
}
|
2021-08-29 05:11:06 +00:00
|
|
|
void requestData(const QString &mimeType, qint32 fd) override
|
|
|
|
{
|
2020-05-12 11:26:57 +00:00
|
|
|
};
|
2022-12-13 10:54:26 +00:00
|
|
|
void cancel() override{};
|
2021-08-29 05:11:06 +00:00
|
|
|
QStringList mimeTypes() const override
|
|
|
|
{
|
2020-05-12 11:26:57 +00:00
|
|
|
return {"text/test1", "text/test2"};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// The test itself
|
|
|
|
|
|
|
|
class DataControlInterfaceTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
2020-08-04 10:34:57 +00:00
|
|
|
void init();
|
|
|
|
void cleanup();
|
2020-05-12 11:26:57 +00:00
|
|
|
void testCopyToControl();
|
2021-08-10 12:29:35 +00:00
|
|
|
void testCopyToControlPrimarySelection();
|
2020-05-12 11:26:57 +00:00
|
|
|
void testCopyFromControl();
|
2021-08-10 12:29:35 +00:00
|
|
|
void testCopyFromControlPrimarySelection();
|
2020-08-04 11:58:43 +00:00
|
|
|
void testKlipperCase();
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
KWayland::Client::ConnectionThread *m_connection;
|
|
|
|
KWayland::Client::EventQueue *m_queue;
|
|
|
|
KWayland::Client::Compositor *m_clientCompositor;
|
|
|
|
KWayland::Client::Seat *m_clientSeat = nullptr;
|
|
|
|
|
|
|
|
QThread *m_thread;
|
2022-03-05 12:02:08 +00:00
|
|
|
KWaylandServer::Display *m_display;
|
2020-05-12 11:26:57 +00:00
|
|
|
SeatInterface *m_seat;
|
|
|
|
CompositorInterface *m_serverCompositor;
|
|
|
|
|
2020-05-28 07:25:56 +00:00
|
|
|
DataControlDeviceManagerV1Interface *m_dataControlDeviceManagerInterface;
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
DataControlDeviceManager *m_dataControlDeviceManager;
|
|
|
|
|
|
|
|
QVector<SurfaceInterface *> m_surfaces;
|
|
|
|
};
|
|
|
|
|
2020-08-04 10:34:57 +00:00
|
|
|
static const QString s_socketName = QStringLiteral("kwin-wayland-datacontrol-test-0");
|
2020-05-12 11:26:57 +00:00
|
|
|
|
2020-08-04 10:34:57 +00:00
|
|
|
void DataControlInterfaceTest::init()
|
2020-05-12 11:26:57 +00:00
|
|
|
{
|
2022-03-05 12:02:08 +00:00
|
|
|
m_display = new KWaylandServer::Display();
|
2020-10-19 15:52:56 +00:00
|
|
|
m_display->addSocketName(s_socketName);
|
2020-08-04 10:34:57 +00:00
|
|
|
m_display->start();
|
|
|
|
QVERIFY(m_display->isRunning());
|
2020-05-12 11:26:57 +00:00
|
|
|
|
2020-12-09 20:13:19 +00:00
|
|
|
m_seat = new SeatInterface(m_display, this);
|
|
|
|
m_serverCompositor = new CompositorInterface(m_display, this);
|
|
|
|
m_dataControlDeviceManagerInterface = new DataControlDeviceManagerV1Interface(m_display, this);
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
// setup connection
|
|
|
|
m_connection = new KWayland::Client::ConnectionThread;
|
|
|
|
QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected);
|
|
|
|
m_connection->setSocketName(s_socketName);
|
|
|
|
|
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_connection->moveToThread(m_thread);
|
|
|
|
m_thread->start();
|
|
|
|
|
|
|
|
m_connection->initConnection();
|
|
|
|
QVERIFY(connectedSpy.wait());
|
|
|
|
QVERIFY(!m_connection->connections().isEmpty());
|
|
|
|
|
|
|
|
m_queue = new KWayland::Client::EventQueue(this);
|
|
|
|
QVERIFY(!m_queue->isValid());
|
|
|
|
m_queue->setup(m_connection);
|
|
|
|
QVERIFY(m_queue->isValid());
|
|
|
|
|
2020-10-30 15:26:31 +00:00
|
|
|
KWayland::Client::Registry registry;
|
|
|
|
connect(®istry, &KWayland::Client::Registry::interfaceAnnounced, this, [this, ®istry](const QByteArray &interface, quint32 name, quint32 version) {
|
2020-05-12 11:26:57 +00:00
|
|
|
if (interface == "zwlr_data_control_manager_v1") {
|
|
|
|
m_dataControlDeviceManager = new DataControlDeviceManager;
|
2020-10-30 15:26:31 +00:00
|
|
|
m_dataControlDeviceManager->init(registry.registry(), name, version);
|
2020-05-12 11:26:57 +00:00
|
|
|
}
|
|
|
|
});
|
2020-10-30 15:26:31 +00:00
|
|
|
connect(®istry, &KWayland::Client::Registry::seatAnnounced, this, [this, ®istry](quint32 name, quint32 version) {
|
|
|
|
m_clientSeat = registry.createSeat(name, version);
|
2020-05-12 11:26:57 +00:00
|
|
|
});
|
2020-10-30 15:26:31 +00:00
|
|
|
registry.setEventQueue(m_queue);
|
|
|
|
QSignalSpy compositorSpy(®istry, &KWayland::Client::Registry::compositorAnnounced);
|
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
2020-05-12 11:26:57 +00:00
|
|
|
wl_display_flush(m_connection->display());
|
|
|
|
|
|
|
|
QVERIFY(compositorSpy.wait());
|
2020-10-30 15:26:31 +00:00
|
|
|
m_clientCompositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
2020-05-12 11:26:57 +00:00
|
|
|
QVERIFY(m_clientCompositor->isValid());
|
|
|
|
|
|
|
|
QVERIFY(m_dataControlDeviceManager);
|
|
|
|
}
|
|
|
|
|
2020-08-04 10:34:57 +00:00
|
|
|
void DataControlInterfaceTest::cleanup()
|
|
|
|
{
|
2022-04-19 10:14:26 +00:00
|
|
|
#define CLEANUP(variable) \
|
|
|
|
if (variable) { \
|
|
|
|
delete variable; \
|
|
|
|
variable = nullptr; \
|
2020-08-04 10:34:57 +00:00
|
|
|
}
|
|
|
|
CLEANUP(m_dataControlDeviceManager)
|
2020-09-11 11:28:48 +00:00
|
|
|
CLEANUP(m_clientSeat)
|
|
|
|
CLEANUP(m_clientCompositor)
|
2020-08-04 10:34:57 +00:00
|
|
|
CLEANUP(m_queue)
|
|
|
|
if (m_connection) {
|
|
|
|
m_connection->deleteLater();
|
|
|
|
m_connection = nullptr;
|
|
|
|
}
|
|
|
|
if (m_thread) {
|
|
|
|
m_thread->quit();
|
|
|
|
m_thread->wait();
|
|
|
|
delete m_thread;
|
|
|
|
m_thread = nullptr;
|
|
|
|
}
|
|
|
|
CLEANUP(m_display)
|
|
|
|
#undef CLEANUP
|
2020-10-30 13:36:24 +00:00
|
|
|
|
|
|
|
// these are the children of the display
|
|
|
|
m_seat = nullptr;
|
|
|
|
m_serverCompositor = nullptr;
|
2020-08-04 10:34:57 +00:00
|
|
|
}
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
void DataControlInterfaceTest::testCopyToControl()
|
|
|
|
{
|
|
|
|
// we set a dummy data source on the seat using abstract client directly
|
|
|
|
// then confirm we receive the offer despite not having a surface
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlDevice> dataControlDevice(new DataControlDevice);
|
2020-05-12 11:26:57 +00:00
|
|
|
dataControlDevice->init(m_dataControlDeviceManager->get_data_device(*m_clientSeat));
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
QSignalSpy newOfferSpy(dataControlDevice.get(), &DataControlDevice::dataControlOffer);
|
|
|
|
QSignalSpy selectionSpy(dataControlDevice.get(), &DataControlDevice::selection);
|
2020-05-12 11:26:57 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<TestDataSource> testSelection(new TestDataSource);
|
|
|
|
m_seat->setSelection(testSelection.get());
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
// selection will be sent after we've been sent a new offer object and the mimes have been sent to that object
|
|
|
|
selectionSpy.wait();
|
|
|
|
|
|
|
|
QCOMPARE(newOfferSpy.count(), 1);
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlOffer> offer(newOfferSpy.first().first().value<DataControlOffer *>());
|
2021-08-29 05:11:06 +00:00
|
|
|
QCOMPARE(selectionSpy.first().first().value<struct ::zwlr_data_control_offer_v1 *>(), offer->object());
|
2020-05-12 11:26:57 +00:00
|
|
|
|
|
|
|
QCOMPARE(offer->receivedOffers().count(), 2);
|
|
|
|
QCOMPARE(offer->receivedOffers()[0], "text/test1");
|
|
|
|
QCOMPARE(offer->receivedOffers()[1], "text/test2");
|
|
|
|
}
|
|
|
|
|
2021-08-10 12:29:35 +00:00
|
|
|
void DataControlInterfaceTest::testCopyToControlPrimarySelection()
|
|
|
|
{
|
|
|
|
// we set a dummy data source on the seat using abstract client directly
|
|
|
|
// then confirm we receive the offer despite not having a surface
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlDevice> dataControlDevice(new DataControlDevice);
|
2021-08-10 12:29:35 +00:00
|
|
|
dataControlDevice->init(m_dataControlDeviceManager->get_data_device(*m_clientSeat));
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
QSignalSpy newOfferSpy(dataControlDevice.get(), &DataControlDevice::dataControlOffer);
|
|
|
|
QSignalSpy selectionSpy(dataControlDevice.get(), &DataControlDevice::primary_selection);
|
2021-08-10 12:29:35 +00:00
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<TestDataSource> testSelection(new TestDataSource);
|
|
|
|
m_seat->setPrimarySelection(testSelection.get());
|
2021-08-10 12:29:35 +00:00
|
|
|
|
|
|
|
// selection will be sent after we've been sent a new offer object and the mimes have been sent to that object
|
|
|
|
selectionSpy.wait();
|
|
|
|
|
|
|
|
QCOMPARE(newOfferSpy.count(), 1);
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlOffer> offer(newOfferSpy.first().first().value<DataControlOffer *>());
|
2021-08-29 05:11:06 +00:00
|
|
|
QCOMPARE(selectionSpy.first().first().value<struct ::zwlr_data_control_offer_v1 *>(), offer->object());
|
2021-08-10 12:29:35 +00:00
|
|
|
|
|
|
|
QCOMPARE(offer->receivedOffers().count(), 2);
|
|
|
|
QCOMPARE(offer->receivedOffers()[0], "text/test1");
|
|
|
|
QCOMPARE(offer->receivedOffers()[1], "text/test2");
|
|
|
|
}
|
|
|
|
|
2020-05-12 11:26:57 +00:00
|
|
|
void DataControlInterfaceTest::testCopyFromControl()
|
|
|
|
{
|
|
|
|
// we create a data device and set a selection
|
|
|
|
// then confirm the server sees the new selection
|
|
|
|
QSignalSpy serverSelectionChangedSpy(m_seat, &SeatInterface::selectionChanged);
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlDevice> dataControlDevice(new DataControlDevice);
|
2020-05-12 11:26:57 +00:00
|
|
|
dataControlDevice->init(m_dataControlDeviceManager->get_data_device(*m_clientSeat));
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlSource> source(new DataControlSource);
|
2020-05-12 11:26:57 +00:00
|
|
|
source->init(m_dataControlDeviceManager->create_data_source());
|
|
|
|
source->offer("cheese/test1");
|
|
|
|
source->offer("cheese/test2");
|
|
|
|
|
|
|
|
dataControlDevice->set_selection(source->object());
|
|
|
|
|
|
|
|
serverSelectionChangedSpy.wait();
|
|
|
|
QVERIFY(m_seat->selection());
|
|
|
|
QCOMPARE(m_seat->selection()->mimeTypes(), QStringList({"cheese/test1", "cheese/test2"}));
|
2020-08-04 10:34:57 +00:00
|
|
|
}
|
2020-08-04 11:58:43 +00:00
|
|
|
|
2021-08-10 12:29:35 +00:00
|
|
|
void DataControlInterfaceTest::testCopyFromControlPrimarySelection()
|
|
|
|
{
|
|
|
|
// we create a data device and set a selection
|
|
|
|
// then confirm the server sees the new selection
|
|
|
|
QSignalSpy serverSelectionChangedSpy(m_seat, &SeatInterface::primarySelectionChanged);
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlDevice> dataControlDevice(new DataControlDevice);
|
2021-08-10 12:29:35 +00:00
|
|
|
dataControlDevice->init(m_dataControlDeviceManager->get_data_device(*m_clientSeat));
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlSource> source(new DataControlSource);
|
2021-08-10 12:29:35 +00:00
|
|
|
source->init(m_dataControlDeviceManager->create_data_source());
|
|
|
|
source->offer("cheese/test1");
|
|
|
|
source->offer("cheese/test2");
|
|
|
|
|
|
|
|
dataControlDevice->set_primary_selection(source->object());
|
|
|
|
|
|
|
|
serverSelectionChangedSpy.wait();
|
|
|
|
QVERIFY(m_seat->primarySelection());
|
|
|
|
QCOMPARE(m_seat->primarySelection()->mimeTypes(), QStringList({"cheese/test1", "cheese/test2"}));
|
|
|
|
}
|
|
|
|
|
2020-08-04 11:58:43 +00:00
|
|
|
void DataControlInterfaceTest::testKlipperCase()
|
|
|
|
{
|
|
|
|
// This tests the setup of klipper's real world operation and a race with a common pattern seen between clients and klipper
|
|
|
|
// The client's behaviour is faked with direct access to the seat
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlDevice> dataControlDevice(new DataControlDevice);
|
2020-08-04 11:58:43 +00:00
|
|
|
dataControlDevice->init(m_dataControlDeviceManager->get_data_device(*m_clientSeat));
|
|
|
|
|
2022-08-01 21:29:02 +00:00
|
|
|
QSignalSpy newOfferSpy(dataControlDevice.get(), &DataControlDevice::dataControlOffer);
|
|
|
|
QSignalSpy selectionSpy(dataControlDevice.get(), &DataControlDevice::selection);
|
2020-08-04 11:58:43 +00:00
|
|
|
QSignalSpy serverSelectionChangedSpy(m_seat, &SeatInterface::selectionChanged);
|
|
|
|
|
|
|
|
// Client A has a data source
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<TestDataSource> testSelection(new TestDataSource);
|
|
|
|
m_seat->setSelection(testSelection.get());
|
2020-08-04 11:58:43 +00:00
|
|
|
|
|
|
|
// klipper gets it
|
|
|
|
selectionSpy.wait();
|
|
|
|
|
|
|
|
// Client A deletes it
|
|
|
|
testSelection.reset();
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
// klipper gets told
|
2020-08-04 11:58:43 +00:00
|
|
|
selectionSpy.wait();
|
|
|
|
|
|
|
|
// Client A sets something else
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<TestDataSource> testSelection2(new TestDataSource);
|
|
|
|
m_seat->setSelection(testSelection2.get());
|
2020-08-04 11:58:43 +00:00
|
|
|
|
|
|
|
// Meanwhile klipper updates with the old content
|
2022-08-01 21:29:02 +00:00
|
|
|
std::unique_ptr<DataControlSource> source(new DataControlSource);
|
2020-08-04 11:58:43 +00:00
|
|
|
source->init(m_dataControlDeviceManager->create_data_source());
|
|
|
|
source->offer("fromKlipper/test1");
|
|
|
|
source->offer("application/x-kde-onlyReplaceEmpty");
|
|
|
|
|
|
|
|
dataControlDevice->set_selection(source->object());
|
|
|
|
|
|
|
|
QVERIFY(!serverSelectionChangedSpy.wait(10));
|
2022-08-01 21:29:02 +00:00
|
|
|
QCOMPARE(m_seat->selection(), testSelection2.get());
|
2020-05-12 11:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(DataControlInterfaceTest)
|
|
|
|
|
|
|
|
#include "test_datacontrol_interface.moc"
|