18#include <xcb/xcb_icccm.h>
23static const QString s_socketName = QStringLiteral(
"wayland_test_kwin_xwayland_server_restart-0");
34void XwaylandServerRestartTest::initTestCase()
39 QRect(0, 0, 1280, 1024),
40 QRect(1280, 0, 1280, 1024),
43 KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
44 KConfigGroup xwaylandGroup = config->group(QStringLiteral(
"Xwayland"));
45 xwaylandGroup.writeEntry(QStringLiteral(
"XwaylandCrashPolicy"), QStringLiteral(
"Restart"));
47 kwinApp()->setConfig(config);
50 QVERIFY(applicationStartedSpy.wait());
53static void kwin_safe_kill(QProcess *process)
56 QTimer::singleShot(1, process, &QProcess::kill);
59void XwaylandServerRestartTest::testRestart()
63 Xwl::Xwayland *xwayland =
static_cast<Xwl::Xwayland *
>(kwinApp()->xwayland());
69 QTRY_COMPARE(startedSpy.count(), 1);
72 kwin_safe_kill(xwayland->xwaylandLauncher()->process());
74 QTRY_COMPARE(stoppedSpy.count(), 1);
78 QVERIFY(!xcb_connection_has_error(c.get()));
80 QTRY_COMPARE(startedSpy.count(), 2);
81 const QRect rect(0, 0, 100, 200);
82 xcb_window_t windowId = xcb_generate_id(c.get());
83 xcb_create_window(c.get(), XCB_COPY_FROM_PARENT, windowId,
rootWindow(),
84 rect.x(), rect.y(), rect.width(), rect.height(), 0,
85 XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0,
nullptr);
86 xcb_size_hints_t hints;
87 memset(&hints, 0,
sizeof(hints));
88 xcb_icccm_size_hints_set_position(&hints, 1, rect.x(), rect.y());
89 xcb_icccm_size_hints_set_size(&hints, 1, rect.width(), rect.height());
90 xcb_icccm_size_hints_set_min_size(&hints, rect.width(), rect.height());
91 xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints);
92 xcb_map_window(c.get(), windowId);
96 QVERIFY(windowCreatedSpy.wait());
97 X11Window *window = windowCreatedSpy.last().first().value<X11Window *>();
99 QCOMPARE(window->window(), windowId);
100 QVERIFY(window->isDecorated());
105 QVERIFY(frameRenderedSpy.wait());
108 xcb_destroy_window(c.get(), windowId);
116#include "xwaylandserver_restart_test.moc"
WorkspaceScene * scene() const
static Compositor * self()
void windowAdded(KWin::Window *)
#define WAYLANDTEST_MAIN(TestObject)
void setOutputConfig(const QList< QRect > &geometries)
XcbConnectionPtr createX11Connection()
std::unique_ptr< xcb_connection_t, XcbConnectionDeleter > XcbConnectionPtr
bool waitForWindowClosed(Window *window)
KWIN_EXPORT xcb_window_t rootWindow()
WaylandServer * waylandServer()