[autotests] Add test cases for verifying that Toplevel::window() is only set for X11
Also at the same time verifies that root info active client is only set on X11.icc-effect-5.14.5
parent
35c278e525
commit
1557f102f4
|
@ -73,6 +73,8 @@ private Q_SLOTS:
|
|||
void testCaptionSimplified();
|
||||
void testKillWindow_data();
|
||||
void testKillWindow();
|
||||
void testX11WindowId_data();
|
||||
void testX11WindowId();
|
||||
};
|
||||
|
||||
void TestShellClient::initTestCase()
|
||||
|
@ -688,5 +690,24 @@ void TestShellClient::testKillWindow()
|
|||
QVERIFY(!finishedSpy.isEmpty());
|
||||
}
|
||||
|
||||
void TestShellClient::testX11WindowId_data()
|
||||
{
|
||||
QTest::addColumn<Test::ShellSurfaceType>("type");
|
||||
|
||||
QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell;
|
||||
QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5;
|
||||
}
|
||||
|
||||
void TestShellClient::testX11WindowId()
|
||||
{
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QFETCH(Test::ShellSurfaceType, type);
|
||||
QScopedPointer<QObject> shellSurface(Test::createShellSurface(type, surface.data()));
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(c);
|
||||
QVERIFY(c->windowId() != 0);
|
||||
QCOMPARE(c->window(), 0u);
|
||||
}
|
||||
|
||||
WAYLANDTEST_MAIN(TestShellClient)
|
||||
#include "shell_client_test.moc"
|
||||
|
|
|
@ -50,6 +50,7 @@ private Q_SLOTS:
|
|||
void testCaptionSimplified();
|
||||
void testFullscreenLayerWithActiveWaylandWindow();
|
||||
void testFocusInWithWaylandLastActiveWindow();
|
||||
void testX11WindowId();
|
||||
};
|
||||
|
||||
void X11ClientTest::initTestCase()
|
||||
|
@ -316,5 +317,64 @@ void X11ClientTest::testFocusInWithWaylandLastActiveWindow()
|
|||
xcb_flush(c.data());
|
||||
}
|
||||
|
||||
void X11ClientTest::testX11WindowId()
|
||||
{
|
||||
// create an X11 window
|
||||
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
|
||||
QVERIFY(!xcb_connection_has_error(c.data()));
|
||||
const QRect windowGeometry(0, 0, 100, 200);
|
||||
xcb_window_t w = xcb_generate_id(c.data());
|
||||
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
|
||||
windowGeometry.x(),
|
||||
windowGeometry.y(),
|
||||
windowGeometry.width(),
|
||||
windowGeometry.height(),
|
||||
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
||||
xcb_size_hints_t hints;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
||||
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
||||
xcb_icccm_set_wm_normal_hints(c.data(), w, &hints);
|
||||
xcb_map_window(c.data(), w);
|
||||
xcb_flush(c.data());
|
||||
|
||||
// we should get a client for it
|
||||
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
|
||||
QVERIFY(windowCreatedSpy.isValid());
|
||||
QVERIFY(windowCreatedSpy.wait());
|
||||
Client *client = windowCreatedSpy.first().first().value<Client*>();
|
||||
QVERIFY(client);
|
||||
QCOMPARE(client->windowId(), w);
|
||||
QVERIFY(client->isActive());
|
||||
QCOMPARE(client->window(), w);
|
||||
|
||||
NETRootInfo rootInfo(c.data(), NET::WMAllProperties);
|
||||
QCOMPARE(rootInfo.activeWindow(), client->window());
|
||||
|
||||
// activate a wayland window
|
||||
QScopedPointer<Surface> surface(Test::createSurface());
|
||||
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
|
||||
auto waylandClient = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
QVERIFY(waylandClient);
|
||||
QVERIFY(waylandClient->isActive());
|
||||
xcb_flush(kwinApp()->x11Connection());
|
||||
|
||||
NETRootInfo rootInfo2(c.data(), NET::WMAllProperties);
|
||||
QCOMPARE(rootInfo2.activeWindow(), 0u);
|
||||
|
||||
// back to X11 client
|
||||
shellSurface.reset();
|
||||
surface.reset();
|
||||
QVERIFY(Test::waitForWindowDestroyed(waylandClient));
|
||||
|
||||
QTRY_VERIFY(client->isActive());
|
||||
NETRootInfo rootInfo3(c.data(), NET::WMAllProperties);
|
||||
QCOMPARE(rootInfo3.activeWindow(), client->window());
|
||||
|
||||
// and destroy the window again
|
||||
xcb_unmap_window(c.data(), w);
|
||||
xcb_flush(c.data());
|
||||
}
|
||||
|
||||
WAYLANDTEST_MAIN(X11ClientTest)
|
||||
#include "x11_client_test.moc"
|
||||
|
|
Loading…
Reference in New Issue