2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2014-11-06 09:02:49 +00:00
|
|
|
// Qt
|
2023-07-03 19:28:19 +00:00
|
|
|
#include <QMimeType>
|
|
|
|
#include <QSignalSpy>
|
|
|
|
#include <QTest>
|
2022-04-22 09:27:33 +00:00
|
|
|
|
2023-09-13 05:52:59 +00:00
|
|
|
#include "wayland/compositor.h"
|
|
|
|
#include "wayland/datadevicemanager.h"
|
|
|
|
#include "wayland/datasource.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
#include "wayland/display.h"
|
2023-09-13 05:52:59 +00:00
|
|
|
#include "wayland/pointer.h"
|
|
|
|
#include "wayland/seat.h"
|
|
|
|
#include "wayland/surface.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
// KWayland
|
2021-08-29 05:11:06 +00:00
|
|
|
#include "KWayland/Client/compositor.h"
|
2020-04-29 13:59:23 +00:00
|
|
|
#include "KWayland/Client/connection_thread.h"
|
|
|
|
#include "KWayland/Client/datadevice.h"
|
|
|
|
#include "KWayland/Client/datadevicemanager.h"
|
|
|
|
#include "KWayland/Client/datasource.h"
|
2021-08-29 05:11:06 +00:00
|
|
|
#include "KWayland/Client/event_queue.h"
|
2020-04-29 13:59:23 +00:00
|
|
|
#include "KWayland/Client/keyboard.h"
|
|
|
|
#include "KWayland/Client/pointer.h"
|
|
|
|
#include "KWayland/Client/registry.h"
|
|
|
|
#include "KWayland/Client/seat.h"
|
|
|
|
#include "KWayland/Client/surface.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
// Wayland
|
|
|
|
#include <wayland-client.h>
|
|
|
|
|
2020-06-25 15:27:52 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
class TestDataDevice : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testCreate();
|
2018-08-25 10:36:29 +00:00
|
|
|
void testDrag_data();
|
2014-11-06 09:02:49 +00:00
|
|
|
void testDrag();
|
2018-08-25 10:36:29 +00:00
|
|
|
void testDragInternally_data();
|
2014-11-06 09:02:49 +00:00
|
|
|
void testDragInternally();
|
|
|
|
void testSetSelection();
|
2016-06-14 12:46:39 +00:00
|
|
|
void testSendSelectionOnSeat();
|
2016-09-12 06:57:07 +00:00
|
|
|
void testReplaceSource();
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
private:
|
2023-09-13 17:59:29 +00:00
|
|
|
KWin::Display *m_display = nullptr;
|
|
|
|
KWin::DataDeviceManagerInterface *m_dataDeviceManagerInterface = nullptr;
|
|
|
|
KWin::CompositorInterface *m_compositorInterface = nullptr;
|
|
|
|
KWin::SeatInterface *m_seatInterface = nullptr;
|
2014-11-06 09:02:49 +00:00
|
|
|
KWayland::Client::ConnectionThread *m_connection = nullptr;
|
|
|
|
KWayland::Client::DataDeviceManager *m_dataDeviceManager = nullptr;
|
|
|
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
|
|
KWayland::Client::Seat *m_seat = nullptr;
|
|
|
|
KWayland::Client::EventQueue *m_queue = nullptr;
|
|
|
|
QThread *m_thread = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("kwayland-test-wayland-datadevice-0");
|
|
|
|
|
|
|
|
void TestDataDevice::init()
|
|
|
|
{
|
2023-09-13 17:59:29 +00:00
|
|
|
qRegisterMetaType<KWin::DataSourceInterface *>();
|
|
|
|
using namespace KWin;
|
2014-11-06 09:02:49 +00:00
|
|
|
delete m_display;
|
2023-09-13 17:59:29 +00:00
|
|
|
m_display = new KWin::Display(this);
|
2020-10-19 15:52:56 +00:00
|
|
|
m_display->addSocketName(s_socketName);
|
2014-11-06 09:02:49 +00:00
|
|
|
m_display->start();
|
|
|
|
QVERIFY(m_display->isRunning());
|
|
|
|
|
|
|
|
// setup connection
|
|
|
|
m_connection = new KWayland::Client::ConnectionThread;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected);
|
2014-11-06 09:02:49 +00:00
|
|
|
m_connection->setSocketName(s_socketName);
|
|
|
|
|
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_connection->moveToThread(m_thread);
|
|
|
|
m_thread->start();
|
|
|
|
|
|
|
|
m_connection->initConnection();
|
|
|
|
QVERIFY(connectedSpy.wait());
|
|
|
|
|
|
|
|
m_queue = new KWayland::Client::EventQueue(this);
|
|
|
|
QVERIFY(!m_queue->isValid());
|
|
|
|
m_queue->setup(m_connection);
|
|
|
|
QVERIFY(m_queue->isValid());
|
|
|
|
|
|
|
|
KWayland::Client::Registry registry;
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy dataDeviceManagerSpy(®istry, &KWayland::Client::Registry::dataDeviceManagerAnnounced);
|
|
|
|
QSignalSpy seatSpy(®istry, &KWayland::Client::Registry::seatAnnounced);
|
|
|
|
QSignalSpy compositorSpy(®istry, &KWayland::Client::Registry::compositorAnnounced);
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(!registry.eventQueue());
|
|
|
|
registry.setEventQueue(m_queue);
|
|
|
|
QCOMPARE(registry.eventQueue(), m_queue);
|
|
|
|
registry.create(m_connection->display());
|
|
|
|
QVERIFY(registry.isValid());
|
|
|
|
registry.setup();
|
|
|
|
|
2020-12-09 20:13:19 +00:00
|
|
|
m_dataDeviceManagerInterface = new DataDeviceManagerInterface(m_display, m_display);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
QVERIFY(dataDeviceManagerSpy.wait());
|
2021-08-29 05:11:06 +00:00
|
|
|
m_dataDeviceManager =
|
|
|
|
registry.createDataDeviceManager(dataDeviceManagerSpy.first().first().value<quint32>(), dataDeviceManagerSpy.first().last().value<quint32>(), this);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2020-12-09 20:13:19 +00:00
|
|
|
m_seatInterface = new SeatInterface(m_display, m_display);
|
2014-11-06 09:02:49 +00:00
|
|
|
m_seatInterface->setHasPointer(true);
|
|
|
|
|
|
|
|
QVERIFY(seatSpy.wait());
|
2021-08-29 05:11:06 +00:00
|
|
|
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(m_seat->isValid());
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy pointerChangedSpy(m_seat, &KWayland::Client::Seat::hasPointerChanged);
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(pointerChangedSpy.wait());
|
|
|
|
|
2020-12-09 20:13:19 +00:00
|
|
|
m_compositorInterface = new CompositorInterface(m_display, m_display);
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(compositorSpy.wait());
|
2021-08-29 05:11:06 +00:00
|
|
|
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(m_compositor->isValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestDataDevice::cleanup()
|
|
|
|
{
|
|
|
|
if (m_dataDeviceManager) {
|
|
|
|
delete m_dataDeviceManager;
|
|
|
|
m_dataDeviceManager = nullptr;
|
|
|
|
}
|
|
|
|
if (m_seat) {
|
|
|
|
delete m_seat;
|
|
|
|
m_seat = nullptr;
|
|
|
|
}
|
|
|
|
if (m_compositor) {
|
|
|
|
delete m_compositor;
|
|
|
|
m_compositor = nullptr;
|
|
|
|
}
|
|
|
|
if (m_queue) {
|
|
|
|
delete m_queue;
|
|
|
|
m_queue = nullptr;
|
|
|
|
}
|
|
|
|
if (m_thread) {
|
|
|
|
m_thread->quit();
|
|
|
|
m_thread->wait();
|
|
|
|
delete m_thread;
|
|
|
|
m_thread = nullptr;
|
|
|
|
}
|
|
|
|
delete m_connection;
|
|
|
|
m_connection = nullptr;
|
|
|
|
|
|
|
|
delete m_display;
|
|
|
|
m_display = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestDataDevice::testCreate()
|
|
|
|
{
|
2023-09-13 17:59:29 +00:00
|
|
|
using namespace KWin;
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dataDeviceCreatedSpy(m_dataDeviceManagerInterface, &KWin::DataDeviceManagerInterface::dataDeviceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice(m_dataDeviceManager->getDataDevice(m_seat));
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(dataDevice->isValid());
|
|
|
|
|
|
|
|
QVERIFY(dataDeviceCreatedSpy.wait());
|
|
|
|
QCOMPARE(dataDeviceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto deviceInterface = dataDeviceCreatedSpy.first().first().value<DataDeviceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(deviceInterface);
|
|
|
|
QCOMPARE(deviceInterface->seat(), m_seatInterface);
|
|
|
|
QVERIFY(!deviceInterface->selection());
|
2020-05-18 13:43:38 +00:00
|
|
|
|
|
|
|
// this will probably fail, we need to make a selection client side
|
2016-06-21 09:14:46 +00:00
|
|
|
QVERIFY(!m_seatInterface->selection());
|
2020-05-18 13:43:38 +00:00
|
|
|
m_seatInterface->setSelection(deviceInterface->selection());
|
|
|
|
QCOMPARE(m_seatInterface->selection(), deviceInterface->selection());
|
2016-06-21 09:14:46 +00:00
|
|
|
|
2016-05-25 08:04:17 +00:00
|
|
|
// and destroy
|
|
|
|
QSignalSpy destroyedSpy(deviceInterface, &QObject::destroyed);
|
|
|
|
dataDevice.reset();
|
|
|
|
QVERIFY(destroyedSpy.wait());
|
2016-06-21 09:14:46 +00:00
|
|
|
QVERIFY(!m_seatInterface->selection());
|
2014-11-06 09:02:49 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 10:36:29 +00:00
|
|
|
void TestDataDevice::testDrag_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("hasGrab");
|
|
|
|
QTest::addColumn<bool>("hasPointerFocus");
|
|
|
|
QTest::addColumn<bool>("success");
|
|
|
|
|
|
|
|
QTest::newRow("grab and focus") << true << true << true;
|
|
|
|
QTest::newRow("no grab") << false << true << false;
|
|
|
|
QTest::newRow("no focus") << true << false << false;
|
|
|
|
QTest::newRow("no grab, no focus") << false << false << false;
|
|
|
|
}
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
void TestDataDevice::testDrag()
|
|
|
|
{
|
2023-09-13 17:59:29 +00:00
|
|
|
using namespace KWin;
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Pointer> pointer(m_seat->createPointer());
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dataDeviceCreatedSpy(m_dataDeviceManagerInterface, &KWin::DataDeviceManagerInterface::dataDeviceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice(m_dataDeviceManager->getDataDevice(m_seat));
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(dataDevice->isValid());
|
|
|
|
|
|
|
|
QVERIFY(dataDeviceCreatedSpy.wait());
|
|
|
|
QCOMPARE(dataDeviceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto deviceInterface = dataDeviceCreatedSpy.first().first().value<DataDeviceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(deviceInterface);
|
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dataSourceCreatedSpy(m_dataDeviceManagerInterface, &KWin::DataDeviceManagerInterface::dataSourceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource(m_dataDeviceManager->createDataSource());
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(dataSource->isValid());
|
|
|
|
|
|
|
|
QVERIFY(dataSourceCreatedSpy.wait());
|
|
|
|
QCOMPARE(dataSourceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto sourceInterface = dataSourceCreatedSpy.first().first().value<DataSourceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(sourceInterface);
|
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy surfaceCreatedSpy(m_compositorInterface, &KWin::CompositorInterface::surfaceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(surface->isValid());
|
|
|
|
|
|
|
|
QVERIFY(surfaceCreatedSpy.wait());
|
|
|
|
QCOMPARE(surfaceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto surfaceInterface = surfaceCreatedSpy.first().first().value<SurfaceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
// now we have all we need to start a drag operation
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dragStartedSpy(deviceInterface, &KWin::DataDeviceInterface::dragStarted);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
// first we need to fake the pointer enter
|
2018-08-25 10:36:29 +00:00
|
|
|
QFETCH(bool, hasGrab);
|
|
|
|
QFETCH(bool, hasPointerFocus);
|
|
|
|
QFETCH(bool, success);
|
|
|
|
if (!hasGrab) {
|
|
|
|
// in case we don't have grab, still generate a pointer serial to make it more interesting
|
2021-03-15 17:58:39 +00:00
|
|
|
m_seatInterface->notifyPointerButton(Qt::LeftButton, PointerButtonState::Pressed);
|
2021-03-11 08:24:47 +00:00
|
|
|
m_seatInterface->notifyPointerFrame();
|
2018-08-25 10:36:29 +00:00
|
|
|
}
|
|
|
|
if (hasPointerFocus) {
|
2022-02-23 19:03:51 +00:00
|
|
|
m_seatInterface->notifyPointerEnter(surfaceInterface, QPointF(0, 0));
|
2018-08-25 10:36:29 +00:00
|
|
|
}
|
|
|
|
if (hasGrab) {
|
2021-03-15 17:58:39 +00:00
|
|
|
m_seatInterface->notifyPointerButton(Qt::LeftButton, PointerButtonState::Pressed);
|
2021-03-11 08:24:47 +00:00
|
|
|
m_seatInterface->notifyPointerFrame();
|
2018-08-25 10:36:29 +00:00
|
|
|
}
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2018-08-25 10:36:29 +00:00
|
|
|
// TODO: This test would be better, if it could also test that a client trying to guess
|
|
|
|
// the last serial of a different client can't start a drag.
|
|
|
|
const quint32 pointerButtonSerial = success ? m_seatInterface->pointerButtonSerial(Qt::LeftButton) : 0;
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2018-08-25 10:36:29 +00:00
|
|
|
QCoreApplication::processEvents();
|
|
|
|
// finally start the drag
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->startDrag(pointerButtonSerial, dataSource.get(), surface.get());
|
2018-08-25 10:36:29 +00:00
|
|
|
QCOMPARE(dragStartedSpy.wait(500), success);
|
[autotests] Compare booleans to booleans
Summary:
Compiler errors:
17:06:23 /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/testDataDevice.dir/test_datadevice.cpp.o: in function `TestDataDevice::testDrag()':
17:06:23 /home/jenkins/workspace/Frameworks kwayland kf5-qt5 SUSEQt5.9/autotests/client/test_datadevice.cpp:290: undefined reference to `bool QTest::qCompare<int, bool>(int const&, bool const&, char const*, char const*, char const*, int)'
17:06:23 /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/testDataDevice.dir/test_datadevice.cpp.o: in function `TestDataDevice::testDragInternally()':
17:06:23 /home/jenkins/workspace/Frameworks kwayland kf5-qt5 SUSEQt5.9/autotests/client/test_datadevice.cpp:369: undefined reference to `bool QTest::qCompare<int, bool>(int const&, bool const&, char const*, char const*, char const*, int)'
Test Plan: Ran testDataDevice, still passes.
Reviewers: #kwin, romangg, broulik
Reviewed By: broulik
Subscribers: kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D15330
2018-09-07 11:25:19 +00:00
|
|
|
QCOMPARE(!dragStartedSpy.isEmpty(), success);
|
2021-09-03 12:27:16 +00:00
|
|
|
QCOMPARE(m_seatInterface->dragSource(), success ? sourceInterface : nullptr);
|
|
|
|
QCOMPARE(m_seatInterface->dragSurface(), success ? surfaceInterface : nullptr);
|
|
|
|
QVERIFY(!m_seatInterface->dragIcon());
|
2014-11-06 09:02:49 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 10:36:29 +00:00
|
|
|
void TestDataDevice::testDragInternally_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("hasGrab");
|
|
|
|
QTest::addColumn<bool>("hasPointerFocus");
|
|
|
|
QTest::addColumn<bool>("success");
|
|
|
|
|
|
|
|
QTest::newRow("grab and focus") << true << true << true;
|
|
|
|
QTest::newRow("no grab") << false << true << false;
|
|
|
|
QTest::newRow("no focus") << true << false << false;
|
|
|
|
QTest::newRow("no grab, no focus") << false << false << false;
|
|
|
|
}
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
void TestDataDevice::testDragInternally()
|
|
|
|
{
|
2023-09-13 17:59:29 +00:00
|
|
|
using namespace KWin;
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Pointer> pointer(m_seat->createPointer());
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dataDeviceCreatedSpy(m_dataDeviceManagerInterface, &KWin::DataDeviceManagerInterface::dataDeviceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice(m_dataDeviceManager->getDataDevice(m_seat));
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(dataDevice->isValid());
|
|
|
|
|
|
|
|
QVERIFY(dataDeviceCreatedSpy.wait());
|
|
|
|
QCOMPARE(dataDeviceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto deviceInterface = dataDeviceCreatedSpy.first().first().value<DataDeviceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(deviceInterface);
|
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy surfaceCreatedSpy(m_compositorInterface, &KWin::CompositorInterface::surfaceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(surface->isValid());
|
|
|
|
|
|
|
|
QVERIFY(surfaceCreatedSpy.wait());
|
|
|
|
QCOMPARE(surfaceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto surfaceInterface = surfaceCreatedSpy.first().first().value<SurfaceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> iconSurface(m_compositor->createSurface());
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(iconSurface->isValid());
|
|
|
|
|
|
|
|
QVERIFY(surfaceCreatedSpy.wait());
|
|
|
|
QCOMPARE(surfaceCreatedSpy.count(), 2);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto iconSurfaceInterface = surfaceCreatedSpy.last().first().value<SurfaceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
// now we have all we need to start a drag operation
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dragStartedSpy(deviceInterface, &KWin::DataDeviceInterface::dragStarted);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
// first we need to fake the pointer enter
|
2018-08-25 10:36:29 +00:00
|
|
|
QFETCH(bool, hasGrab);
|
|
|
|
QFETCH(bool, hasPointerFocus);
|
|
|
|
QFETCH(bool, success);
|
|
|
|
if (!hasGrab) {
|
|
|
|
// in case we don't have grab, still generate a pointer serial to make it more interesting
|
2021-03-15 17:58:39 +00:00
|
|
|
m_seatInterface->notifyPointerButton(Qt::LeftButton, PointerButtonState::Pressed);
|
2021-03-11 08:24:47 +00:00
|
|
|
m_seatInterface->notifyPointerFrame();
|
2018-08-25 10:36:29 +00:00
|
|
|
}
|
|
|
|
if (hasPointerFocus) {
|
2022-02-23 19:03:51 +00:00
|
|
|
m_seatInterface->notifyPointerEnter(surfaceInterface, QPointF(0, 0));
|
2018-08-25 10:36:29 +00:00
|
|
|
}
|
|
|
|
if (hasGrab) {
|
2021-03-15 17:58:39 +00:00
|
|
|
m_seatInterface->notifyPointerButton(Qt::LeftButton, PointerButtonState::Pressed);
|
2021-03-11 08:24:47 +00:00
|
|
|
m_seatInterface->notifyPointerFrame();
|
2018-08-25 10:36:29 +00:00
|
|
|
}
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2018-08-25 10:36:29 +00:00
|
|
|
// TODO: This test would be better, if it could also test that a client trying to guess
|
|
|
|
// the last serial of a different client can't start a drag.
|
|
|
|
const quint32 pointerButtonSerial = success ? m_seatInterface->pointerButtonSerial(Qt::LeftButton) : 0;
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2018-08-25 10:36:29 +00:00
|
|
|
QCoreApplication::processEvents();
|
|
|
|
// finally start the internal drag
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->startDragInternally(pointerButtonSerial, surface.get(), iconSurface.get());
|
2018-08-25 10:36:29 +00:00
|
|
|
QCOMPARE(dragStartedSpy.wait(500), success);
|
[autotests] Compare booleans to booleans
Summary:
Compiler errors:
17:06:23 /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/testDataDevice.dir/test_datadevice.cpp.o: in function `TestDataDevice::testDrag()':
17:06:23 /home/jenkins/workspace/Frameworks kwayland kf5-qt5 SUSEQt5.9/autotests/client/test_datadevice.cpp:290: undefined reference to `bool QTest::qCompare<int, bool>(int const&, bool const&, char const*, char const*, char const*, int)'
17:06:23 /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/testDataDevice.dir/test_datadevice.cpp.o: in function `TestDataDevice::testDragInternally()':
17:06:23 /home/jenkins/workspace/Frameworks kwayland kf5-qt5 SUSEQt5.9/autotests/client/test_datadevice.cpp:369: undefined reference to `bool QTest::qCompare<int, bool>(int const&, bool const&, char const*, char const*, char const*, int)'
Test Plan: Ran testDataDevice, still passes.
Reviewers: #kwin, romangg, broulik
Reviewed By: broulik
Subscribers: kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D15330
2018-09-07 11:25:19 +00:00
|
|
|
QCOMPARE(!dragStartedSpy.isEmpty(), success);
|
2021-09-03 12:27:16 +00:00
|
|
|
QVERIFY(!m_seatInterface->dragSource());
|
|
|
|
QCOMPARE(m_seatInterface->dragSurface(), success ? surfaceInterface : nullptr);
|
2020-10-29 08:29:30 +00:00
|
|
|
|
|
|
|
if (success) {
|
2021-09-03 12:27:16 +00:00
|
|
|
QCOMPARE(m_seatInterface->dragIcon()->surface(), iconSurfaceInterface);
|
2020-10-29 08:29:30 +00:00
|
|
|
} else {
|
2021-09-03 12:27:16 +00:00
|
|
|
QCOMPARE(m_seatInterface->dragIcon(), nullptr);
|
2020-10-29 08:29:30 +00:00
|
|
|
}
|
2014-11-06 09:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestDataDevice::testSetSelection()
|
|
|
|
{
|
2023-09-13 17:59:29 +00:00
|
|
|
using namespace KWin;
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Pointer> pointer(m_seat->createPointer());
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dataDeviceCreatedSpy(m_dataDeviceManagerInterface, &KWin::DataDeviceManagerInterface::dataDeviceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice(m_dataDeviceManager->getDataDevice(m_seat));
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(dataDevice->isValid());
|
|
|
|
|
|
|
|
QVERIFY(dataDeviceCreatedSpy.wait());
|
|
|
|
QCOMPARE(dataDeviceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto deviceInterface = dataDeviceCreatedSpy.first().first().value<DataDeviceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(deviceInterface);
|
|
|
|
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy dataSourceCreatedSpy(m_dataDeviceManagerInterface, &KWin::DataDeviceManagerInterface::dataSourceCreated);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource(m_dataDeviceManager->createDataSource());
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(dataSource->isValid());
|
2014-11-06 15:56:50 +00:00
|
|
|
dataSource->offer(QStringLiteral("text/plain"));
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
QVERIFY(dataSourceCreatedSpy.wait());
|
|
|
|
QCOMPARE(dataSourceCreatedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
auto sourceInterface = dataSourceCreatedSpy.first().first().value<DataSourceInterface *>();
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(sourceInterface);
|
|
|
|
|
|
|
|
// everything setup, now we can test setting the selection
|
2023-09-13 17:59:29 +00:00
|
|
|
QSignalSpy selectionChangedSpy(deviceInterface, &KWin::DataDeviceInterface::selectionChanged);
|
2014-11-06 09:02:49 +00:00
|
|
|
|
|
|
|
QVERIFY(!deviceInterface->selection());
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->setSelection(1, dataSource.get());
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(selectionChangedSpy.wait());
|
|
|
|
QCOMPARE(selectionChangedSpy.count(), 1);
|
2021-08-29 05:11:06 +00:00
|
|
|
QCOMPARE(selectionChangedSpy.first().first().value<DataSourceInterface *>(), sourceInterface);
|
2014-11-06 09:02:49 +00:00
|
|
|
QCOMPARE(deviceInterface->selection(), sourceInterface);
|
|
|
|
|
2014-11-06 15:56:50 +00:00
|
|
|
// send selection to datadevice
|
2022-08-01 21:29:02 +00:00
|
|
|
QSignalSpy selectionOfferedSpy(dataDevice.get(), &KWayland::Client::DataDevice::selectionOffered);
|
2020-05-18 13:43:38 +00:00
|
|
|
deviceInterface->sendSelection(deviceInterface->selection());
|
2014-11-06 15:56:50 +00:00
|
|
|
QVERIFY(selectionOfferedSpy.wait());
|
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 1);
|
2022-11-08 21:15:17 +00:00
|
|
|
auto dataOffer = selectionOfferedSpy.first().first().value<KWayland::Client::DataOffer *>();
|
2014-11-06 15:56:50 +00:00
|
|
|
QVERIFY(dataOffer);
|
|
|
|
QCOMPARE(dataOffer->offeredMimeTypes().count(), 1);
|
|
|
|
QCOMPARE(dataOffer->offeredMimeTypes().first().name(), QStringLiteral("text/plain"));
|
|
|
|
|
|
|
|
// sending a new mimetype to the selection, should be announced in the offer
|
2021-02-25 13:48:11 +00:00
|
|
|
QSignalSpy mimeTypeAddedSpy(dataOffer, &KWayland::Client::DataOffer::mimeTypeOffered);
|
2014-11-06 15:56:50 +00:00
|
|
|
dataSource->offer(QStringLiteral("text/html"));
|
|
|
|
QVERIFY(mimeTypeAddedSpy.wait());
|
|
|
|
QCOMPARE(mimeTypeAddedSpy.count(), 1);
|
|
|
|
QCOMPARE(mimeTypeAddedSpy.first().first().toString(), QStringLiteral("text/html"));
|
|
|
|
QCOMPARE(dataOffer->offeredMimeTypes().count(), 2);
|
|
|
|
QCOMPARE(dataOffer->offeredMimeTypes().first().name(), QStringLiteral("text/plain"));
|
|
|
|
QCOMPARE(dataOffer->offeredMimeTypes().last().name(), QStringLiteral("text/html"));
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
// now clear the selection
|
|
|
|
dataDevice->clearSelection(1);
|
2022-12-09 09:05:44 +00:00
|
|
|
QVERIFY(selectionChangedSpy.wait());
|
|
|
|
QCOMPARE(selectionChangedSpy.count(), 2);
|
2014-11-06 09:02:49 +00:00
|
|
|
QVERIFY(!deviceInterface->selection());
|
2016-06-15 07:33:10 +00:00
|
|
|
|
|
|
|
// set another selection
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->setSelection(2, dataSource.get());
|
2016-06-15 07:33:10 +00:00
|
|
|
QVERIFY(selectionChangedSpy.wait());
|
|
|
|
// now unbind the dataDevice
|
2020-06-25 15:27:52 +00:00
|
|
|
QSignalSpy unboundSpy(deviceInterface, &QObject::destroyed);
|
2016-06-15 07:33:10 +00:00
|
|
|
dataDevice.reset();
|
|
|
|
QVERIFY(unboundSpy.wait());
|
2014-11-06 09:02:49 +00:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:46:39 +00:00
|
|
|
void TestDataDevice::testSendSelectionOnSeat()
|
|
|
|
{
|
|
|
|
// this test verifies that the selection is sent when setting a focused keyboard
|
2023-09-13 17:59:29 +00:00
|
|
|
using namespace KWin;
|
2016-06-14 12:46:39 +00:00
|
|
|
// first add keyboard support to Seat
|
2022-11-08 21:15:17 +00:00
|
|
|
QSignalSpy keyboardChangedSpy(m_seat, &KWayland::Client::Seat::hasKeyboardChanged);
|
2016-06-14 12:46:39 +00:00
|
|
|
m_seatInterface->setHasKeyboard(true);
|
|
|
|
QVERIFY(keyboardChangedSpy.wait());
|
|
|
|
// now create DataDevice, Keyboard and a Surface
|
|
|
|
QSignalSpy dataDeviceCreatedSpy(m_dataDeviceManagerInterface, &DataDeviceManagerInterface::dataDeviceCreated);
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice(m_dataDeviceManager->getDataDevice(m_seat));
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(dataDevice->isValid());
|
|
|
|
QVERIFY(dataDeviceCreatedSpy.wait());
|
2021-08-29 05:11:06 +00:00
|
|
|
auto serverDataDevice = dataDeviceCreatedSpy.first().first().value<DataDeviceInterface *>();
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(serverDataDevice);
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Keyboard> keyboard(m_seat->createKeyboard());
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(keyboard->isValid());
|
|
|
|
QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated);
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(surface->isValid());
|
|
|
|
QVERIFY(surfaceCreatedSpy.wait());
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface *>();
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(serverSurface);
|
|
|
|
m_seatInterface->setFocusedKeyboardSurface(serverSurface);
|
|
|
|
|
|
|
|
// now set the selection
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource(m_dataDeviceManager->createDataSource());
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(dataSource->isValid());
|
|
|
|
dataSource->offer(QStringLiteral("text/plain"));
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->setSelection(1, dataSource.get());
|
2016-06-14 12:46:39 +00:00
|
|
|
// we should get a selection offered for that on the data device
|
2022-11-08 21:15:17 +00:00
|
|
|
QSignalSpy selectionOfferedSpy(dataDevice.get(), &KWayland::Client::DataDevice::selectionOffered);
|
2016-06-14 12:46:39 +00:00
|
|
|
QVERIFY(selectionOfferedSpy.wait());
|
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 1);
|
|
|
|
|
|
|
|
// now unfocus the keyboard
|
|
|
|
m_seatInterface->setFocusedKeyboardSurface(nullptr);
|
|
|
|
// if setting the same surface again, we should get another offer
|
|
|
|
m_seatInterface->setFocusedKeyboardSurface(serverSurface);
|
|
|
|
QVERIFY(selectionOfferedSpy.wait());
|
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 2);
|
|
|
|
|
|
|
|
// now let's try to destroy the data device and set a focused keyboard just while the data device is being destroyedd
|
|
|
|
m_seatInterface->setFocusedKeyboardSurface(nullptr);
|
2020-06-25 15:27:52 +00:00
|
|
|
QSignalSpy unboundSpy(serverDataDevice, &QObject::destroyed);
|
2016-06-14 12:46:39 +00:00
|
|
|
dataDevice.reset();
|
|
|
|
QVERIFY(unboundSpy.wait());
|
|
|
|
m_seatInterface->setFocusedKeyboardSurface(serverSurface);
|
|
|
|
}
|
|
|
|
|
2016-09-12 06:57:07 +00:00
|
|
|
void TestDataDevice::testReplaceSource()
|
|
|
|
{
|
|
|
|
// this test verifies that replacing a data source cancels the previous source
|
2023-09-13 17:59:29 +00:00
|
|
|
using namespace KWin;
|
2016-09-12 06:57:07 +00:00
|
|
|
// first add keyboard support to Seat
|
2022-11-08 21:15:17 +00:00
|
|
|
QSignalSpy keyboardChangedSpy(m_seat, &KWayland::Client::Seat::hasKeyboardChanged);
|
2016-09-12 06:57:07 +00:00
|
|
|
m_seatInterface->setHasKeyboard(true);
|
|
|
|
QVERIFY(keyboardChangedSpy.wait());
|
|
|
|
// now create DataDevice, Keyboard and a Surface
|
|
|
|
QSignalSpy dataDeviceCreatedSpy(m_dataDeviceManagerInterface, &DataDeviceManagerInterface::dataDeviceCreated);
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice(m_dataDeviceManager->getDataDevice(m_seat));
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(dataDevice->isValid());
|
|
|
|
QVERIFY(dataDeviceCreatedSpy.wait());
|
2021-08-29 05:11:06 +00:00
|
|
|
auto serverDataDevice = dataDeviceCreatedSpy.first().first().value<DataDeviceInterface *>();
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(serverDataDevice);
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Keyboard> keyboard(m_seat->createKeyboard());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(keyboard->isValid());
|
|
|
|
QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated);
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::Surface> surface(m_compositor->createSurface());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(surface->isValid());
|
|
|
|
QVERIFY(surfaceCreatedSpy.wait());
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface *>();
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(serverSurface);
|
|
|
|
m_seatInterface->setFocusedKeyboardSurface(serverSurface);
|
|
|
|
|
|
|
|
// now set the selection
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource(m_dataDeviceManager->createDataSource());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(dataSource->isValid());
|
|
|
|
dataSource->offer(QStringLiteral("text/plain"));
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->setSelection(1, dataSource.get());
|
2022-11-08 21:15:17 +00:00
|
|
|
QSignalSpy sourceCancelledSpy(dataSource.get(), &KWayland::Client::DataSource::cancelled);
|
2016-09-12 06:57:07 +00:00
|
|
|
// we should get a selection offered for that on the data device
|
2022-11-08 21:15:17 +00:00
|
|
|
QSignalSpy selectionOfferedSpy(dataDevice.get(), &KWayland::Client::DataDevice::selectionOffered);
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(selectionOfferedSpy.wait());
|
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 1);
|
|
|
|
|
|
|
|
// create a second data source and replace previous one
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource2(m_dataDeviceManager->createDataSource());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(dataSource2->isValid());
|
|
|
|
dataSource2->offer(QStringLiteral("text/plain"));
|
2022-11-08 21:15:17 +00:00
|
|
|
QSignalSpy sourceCancelled2Spy(dataSource2.get(), &KWayland::Client::DataSource::cancelled);
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->setSelection(1, dataSource2.get());
|
2016-09-12 06:57:07 +00:00
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 1);
|
|
|
|
QVERIFY(sourceCancelledSpy.wait());
|
2018-06-14 12:21:41 +00:00
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 2);
|
|
|
|
QVERIFY(sourceCancelled2Spy.isEmpty());
|
|
|
|
|
|
|
|
// replace the data source with itself, ensure that it did not get cancelled
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice->setSelection(1, dataSource2.get());
|
2018-06-14 12:21:41 +00:00
|
|
|
QVERIFY(!sourceCancelled2Spy.wait(500));
|
2016-09-12 06:57:07 +00:00
|
|
|
QCOMPARE(selectionOfferedSpy.count(), 2);
|
|
|
|
QVERIFY(sourceCancelled2Spy.isEmpty());
|
|
|
|
|
|
|
|
// create a new DataDevice and replace previous one
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataDevice> dataDevice2(m_dataDeviceManager->getDataDevice(m_seat));
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(dataDevice2->isValid());
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource3(m_dataDeviceManager->createDataSource());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(dataSource3->isValid());
|
|
|
|
dataSource3->offer(QStringLiteral("text/plain"));
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice2->setSelection(1, dataSource3.get());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(sourceCancelled2Spy.wait());
|
|
|
|
|
|
|
|
// try to crash by first destroying dataSource3 and setting a new DataSource
|
2022-11-08 21:15:17 +00:00
|
|
|
std::unique_ptr<KWayland::Client::DataSource> dataSource4(m_dataDeviceManager->createDataSource());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(dataSource4->isValid());
|
|
|
|
dataSource4->offer(QStringLiteral("text/plain"));
|
|
|
|
dataSource3.reset();
|
2022-08-01 21:29:02 +00:00
|
|
|
dataDevice2->setSelection(1, dataSource4.get());
|
2016-09-12 06:57:07 +00:00
|
|
|
QVERIFY(selectionOfferedSpy.wait());
|
2020-06-25 15:27:52 +00:00
|
|
|
|
2022-11-08 21:15:17 +00:00
|
|
|
auto dataOffer = selectionOfferedSpy.last()[0].value<KWayland::Client::DataOffer *>();
|
2020-06-25 15:27:52 +00:00
|
|
|
|
|
|
|
// try to crash by destroying the data source, then requesting data
|
|
|
|
dataSource4.reset();
|
2021-09-01 17:26:46 +00:00
|
|
|
int pipeFds[2] = {0, 0};
|
|
|
|
QVERIFY(pipe(pipeFds) == 0);
|
2020-06-25 15:27:52 +00:00
|
|
|
|
|
|
|
dataOffer->receive(QStringLiteral("text/plain"), pipeFds[1]);
|
|
|
|
close(pipeFds[1]);
|
|
|
|
|
2021-08-29 05:11:06 +00:00
|
|
|
// spin the event loop, nothing should explode
|
2020-06-25 15:27:52 +00:00
|
|
|
QTest::qWait(10);
|
|
|
|
|
|
|
|
close(pipeFds[0]);
|
2016-09-12 06:57:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-06 09:02:49 +00:00
|
|
|
QTEST_GUILESS_MAIN(TestDataDevice)
|
|
|
|
#include "test_datadevice.moc"
|