Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_xdg_shell_v5.cpp
- This file was added.
1 | #include "test_xdg_shell.h" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | class XdgShellTestV5 : public XdgShellTest { | ||||
4 | Q_OBJECT | ||||
5 | public: | ||||
6 | XdgShellTestV5() : | ||||
7 | XdgShellTest(KWayland::Server::XdgShellInterfaceVersion::UnstableV5) {} | ||||
8 | private Q_SLOTS: | ||||
9 | void testPopup(); | ||||
10 | }; | ||||
11 | | ||||
12 | void XdgShellTestV5::testPopup() | ||||
13 | { | ||||
14 | // this test verifies that the creation of popups works correctly | ||||
15 | SURFACE | ||||
16 | QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated); | ||||
17 | QVERIFY(surfaceCreatedSpy.isValid()); | ||||
18 | QSignalSpy xdgPopupSpy(m_xdgShellInterface, &XdgShellInterface::popupCreated); | ||||
19 | | ||||
20 | //check as well as the compat signal, the new signal is also fired | ||||
21 | QSignalSpy xdgPopupSpyNew(m_xdgShellInterface, &XdgShellInterface::xdgPopupCreated); | ||||
22 | | ||||
23 | | ||||
24 | QVERIFY(xdgPopupSpy.isValid()); | ||||
25 | | ||||
26 | QScopedPointer<Surface> popupSurface(m_compositor->createSurface()); | ||||
27 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
28 | | ||||
29 | // TODO: proper serial | ||||
30 | QScopedPointer<XdgShellPopup> xdgPopup(m_xdgShell->createPopup(popupSurface.data(), surface.data(), m_seat, 120, QPoint(10, 20))); | ||||
31 | QVERIFY(xdgPopupSpy.wait()); | ||||
32 | QCOMPARE(xdgPopupSpy.count(), 1); | ||||
33 | QCOMPARE(xdgPopupSpyNew.count(), 1); | ||||
34 | | ||||
35 | | ||||
36 | QCOMPARE(xdgPopupSpy.first().at(1).value<SeatInterface*>(), m_seatInterface); | ||||
37 | QCOMPARE(xdgPopupSpy.first().at(2).value<quint32>(), 120u); | ||||
38 | auto serverXdgPopup = xdgPopupSpy.first().first().value<XdgShellPopupInterface*>(); | ||||
39 | QVERIFY(serverXdgPopup); | ||||
40 | | ||||
41 | QCOMPARE(serverXdgPopup->surface(), surfaceCreatedSpy.first().first().value<SurfaceInterface*>()); | ||||
42 | QCOMPARE(serverXdgPopup->transientFor().data(), serverXdgSurface->surface()); | ||||
43 | QCOMPARE(serverXdgPopup->transientOffset(), QPoint(10, 20)); | ||||
44 | | ||||
45 | // now also a popup for the popup | ||||
46 | QScopedPointer<Surface> popup2Surface(m_compositor->createSurface()); | ||||
47 | QScopedPointer<XdgShellPopup> xdgPopup2(m_xdgShell->createPopup(popup2Surface.data(), popupSurface.data(), m_seat, 121, QPoint(5, 7))); | ||||
48 | QVERIFY(xdgPopupSpy.wait()); | ||||
49 | QCOMPARE(xdgPopupSpy.count(), 2); | ||||
50 | QCOMPARE(xdgPopupSpy.last().at(1).value<SeatInterface*>(), m_seatInterface); | ||||
51 | QCOMPARE(xdgPopupSpy.last().at(2).value<quint32>(), 121u); | ||||
52 | auto serverXdgPopup2 = xdgPopupSpy.last().first().value<XdgShellPopupInterface*>(); | ||||
53 | QVERIFY(serverXdgPopup2); | ||||
54 | | ||||
55 | QCOMPARE(serverXdgPopup2->surface(), surfaceCreatedSpy.last().first().value<SurfaceInterface*>()); | ||||
56 | QCOMPARE(serverXdgPopup2->transientFor().data(), serverXdgPopup->surface()); | ||||
57 | QCOMPARE(serverXdgPopup2->transientOffset(), QPoint(5, 7)); | ||||
58 | | ||||
59 | QSignalSpy popup2DoneSpy(xdgPopup2.data(), &XdgShellPopup::popupDone); | ||||
60 | QVERIFY(popup2DoneSpy.isValid()); | ||||
61 | serverXdgPopup2->popupDone(); | ||||
62 | QVERIFY(popup2DoneSpy.wait()); | ||||
63 | // TODO: test that this sends also the done to all parents | ||||
64 | } | ||||
65 | | ||||
66 | | ||||
67 | | ||||
68 | | ||||
69 | QTEST_GUILESS_MAIN(XdgShellTestV5) | ||||
70 | | ||||
71 | #include "test_xdg_shell_v5.moc" | ||||
72 | |