Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/xwayland_selections_test.cpp
- This file was moved from autotests/integration/xclipboardsync_test.cpp.
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright 2016 Martin Gräßlin <mgraesslin@kde.org> | ||
6 | Copyright 2019 Roman Gilg <subdiff@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 13 Lines | |||||
27 | 28 | | |||
28 | #include <KWayland/Server/datadevice_interface.h> | 29 | #include <KWayland/Server/datadevice_interface.h> | ||
29 | 30 | | |||
30 | #include <QProcess> | 31 | #include <QProcess> | ||
31 | #include <QProcessEnvironment> | 32 | #include <QProcessEnvironment> | ||
32 | 33 | | |||
33 | using namespace KWin; | 34 | using namespace KWin; | ||
34 | 35 | | |||
35 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_xclipboard_sync-0"); | 36 | static const QString s_socketName = QStringLiteral("wayland_test_kwin_xwayland_selections-0"); | ||
36 | 37 | | |||
37 | class XClipboardSyncTest : public QObject | 38 | class XwaylandSelectionsTest : public QObject | ||
38 | { | 39 | { | ||
39 | Q_OBJECT | 40 | Q_OBJECT | ||
40 | private Q_SLOTS: | 41 | private Q_SLOTS: | ||
41 | void initTestCase(); | 42 | void initTestCase(); | ||
42 | void cleanup(); | 43 | void cleanup(); | ||
43 | void testSync_data(); | 44 | void testSync_data(); | ||
44 | void testSync(); | 45 | void testSync(); | ||
45 | 46 | | |||
46 | private: | 47 | private: | ||
47 | QProcess *m_copyProcess = nullptr; | 48 | QProcess *m_copyProcess = nullptr; | ||
48 | QProcess *m_pasteProcess = nullptr; | 49 | QProcess *m_pasteProcess = nullptr; | ||
49 | }; | 50 | }; | ||
50 | 51 | | |||
51 | void XClipboardSyncTest::initTestCase() | 52 | void XwaylandSelectionsTest::initTestCase() | ||
52 | { | 53 | { | ||
53 | QSKIP("Skipped as it fails for unknown reasons on build.kde.org"); | 54 | QSKIP("Skipped as it fails for unknown reasons on build.kde.org"); | ||
54 | qRegisterMetaType<KWin::ShellClient*>(); | 55 | qRegisterMetaType<KWin::ShellClient*>(); | ||
55 | qRegisterMetaType<KWin::AbstractClient*>(); | 56 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
56 | qRegisterMetaType<QProcess::ExitStatus>(); | 57 | qRegisterMetaType<QProcess::ExitStatus>(); | ||
57 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 58 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
58 | QVERIFY(workspaceCreatedSpy.isValid()); | 59 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
59 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 60 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
60 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 61 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
61 | QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated}; | 62 | // QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated}; | ||
62 | QVERIFY(clipboardSyncDevicedCreated.isValid()); | 63 | // QVERIFY(clipboardSyncDevicedCreated.isValid()); | ||
63 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 64 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
64 | 65 | | |||
65 | kwinApp()->start(); | 66 | kwinApp()->start(); | ||
66 | QVERIFY(workspaceCreatedSpy.wait()); | 67 | QVERIFY(workspaceCreatedSpy.wait()); | ||
67 | QCOMPARE(screens()->count(), 2); | 68 | QCOMPARE(screens()->count(), 2); | ||
68 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 69 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
69 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 70 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
70 | waylandServer()->initWorkspace(); | 71 | waylandServer()->initWorkspace(); | ||
71 | // // wait till the xclipboard sync data device is created | 72 | // // wait till the xclipboard sync data device is created | ||
72 | // if (clipboardSyncDevicedCreated.empty()) { | 73 | // if (clipboardSyncDevicedCreated.empty()) { | ||
73 | // QVERIFY(clipboardSyncDevicedCreated.wait()); | 74 | // QVERIFY(clipboardSyncDevicedCreated.wait()); | ||
74 | // } | 75 | // } | ||
75 | // wait till the DataBridge sync data device is created | 76 | // wait till the DataBridge sync data device is created | ||
76 | while (Xwl::DataBridge::self()->dataDeviceIface() == nullptr) { | 77 | while (Xwl::DataBridge::self()->dataDeviceIface() == nullptr) { | ||
77 | QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); | 78 | QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); | ||
78 | } | 79 | } | ||
79 | QVERIFY(Xwl::DataBridge::self()->dataDeviceIface() != nullptr); | 80 | QVERIFY(Xwl::DataBridge::self()->dataDeviceIface() != nullptr); | ||
80 | } | 81 | } | ||
81 | 82 | | |||
82 | void XClipboardSyncTest::cleanup() | 83 | void XwaylandSelectionsTest::cleanup() | ||
83 | { | 84 | { | ||
84 | if (m_copyProcess) { | 85 | if (m_copyProcess) { | ||
85 | m_copyProcess->terminate(); | 86 | m_copyProcess->terminate(); | ||
86 | QVERIFY(m_copyProcess->waitForFinished()); | 87 | QVERIFY(m_copyProcess->waitForFinished()); | ||
87 | m_copyProcess = nullptr; | 88 | m_copyProcess = nullptr; | ||
88 | } | 89 | } | ||
89 | if (m_pasteProcess) { | 90 | if (m_pasteProcess) { | ||
90 | m_pasteProcess->terminate(); | 91 | m_pasteProcess->terminate(); | ||
91 | QVERIFY(m_pasteProcess->waitForFinished()); | 92 | QVERIFY(m_pasteProcess->waitForFinished()); | ||
92 | m_pasteProcess = nullptr; | 93 | m_pasteProcess = nullptr; | ||
93 | } | 94 | } | ||
94 | } | 95 | } | ||
95 | 96 | | |||
96 | void XClipboardSyncTest::testSync_data() | 97 | void XwaylandSelectionsTest::testSync_data() | ||
97 | { | 98 | { | ||
98 | QTest::addColumn<QString>("copyPlatform"); | 99 | QTest::addColumn<QString>("copyPlatform"); | ||
99 | QTest::addColumn<QString>("pastePlatform"); | 100 | QTest::addColumn<QString>("pastePlatform"); | ||
100 | 101 | | |||
101 | QTest::newRow("x11->wayland") << QStringLiteral("xcb") << QStringLiteral("wayland"); | 102 | QTest::newRow("x11->wayland") << QStringLiteral("xcb") << QStringLiteral("wayland"); | ||
102 | QTest::newRow("wayland->x11") << QStringLiteral("wayland") << QStringLiteral("xcb"); | 103 | QTest::newRow("wayland->x11") << QStringLiteral("wayland") << QStringLiteral("xcb"); | ||
103 | } | 104 | } | ||
104 | 105 | | |||
105 | void XClipboardSyncTest::testSync() | 106 | void XwaylandSelectionsTest::testSync() | ||
106 | { | 107 | { | ||
107 | // this test verifies the syncing of X11 to Wayland clipboard | 108 | // this test verifies the syncing of X11 to Wayland clipboard | ||
108 | const QString copy = QFINDTESTDATA(QStringLiteral("copy")); | 109 | const QString copy = QFINDTESTDATA(QStringLiteral("copy")); | ||
109 | QVERIFY(!copy.isEmpty()); | 110 | QVERIFY(!copy.isEmpty()); | ||
110 | const QString paste = QFINDTESTDATA(QStringLiteral("paste")); | 111 | const QString paste = QFINDTESTDATA(QStringLiteral("paste")); | ||
111 | QVERIFY(!paste.isEmpty()); | 112 | QVERIFY(!paste.isEmpty()); | ||
112 | 113 | | |||
113 | QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded); | 114 | QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
187 | QVERIFY(finishedSpy.wait()); | 188 | QVERIFY(finishedSpy.wait()); | ||
188 | QCOMPARE(finishedSpy.first().first().toInt(), 0); | 189 | QCOMPARE(finishedSpy.first().first().toInt(), 0); | ||
189 | delete m_pasteProcess; | 190 | delete m_pasteProcess; | ||
190 | m_pasteProcess = nullptr; | 191 | m_pasteProcess = nullptr; | ||
191 | delete m_copyProcess; | 192 | delete m_copyProcess; | ||
192 | m_copyProcess = nullptr; | 193 | m_copyProcess = nullptr; | ||
193 | } | 194 | } | ||
194 | 195 | | |||
195 | WAYLANDTEST_MAIN(XClipboardSyncTest) | 196 | WAYLANDTEST_MAIN(XwaylandSelectionsTest) | ||
196 | #include "xclipboardsync_test.moc" | 197 | #include "xwayland_selections_test.moc" |