diff --git a/src/wayland/autotests/client/test_plasmashell.cpp b/src/wayland/autotests/client/test_plasmashell.cpp index 57090269c1..d75ad87dd0 100644 --- a/src/wayland/autotests/client/test_plasmashell.cpp +++ b/src/wayland/autotests/client/test_plasmashell.cpp @@ -47,6 +47,8 @@ private Q_SLOTS: void testRole(); void testPosition(); void testSkipTaskbar(); + void testPanelBehavior_data(); + void testPanelBehavior(); void testDisconnect(); private: @@ -286,6 +288,52 @@ void TestPlasmaShell::testSkipTaskbar() QVERIFY(!sps->skipTaskbar()); } +void TestPlasmaShell::testPanelBehavior_data() +{ + QTest::addColumn("client"); + QTest::addColumn("server"); + + QTest::newRow("autohide") << PlasmaShellSurface::PanelBehavior::AutoHide << PlasmaShellSurfaceInterface::PanelBehavior::AutoHide; + QTest::newRow("can cover") << PlasmaShellSurface::PanelBehavior::WindowsCanCover << PlasmaShellSurfaceInterface::PanelBehavior::WindowsCanCover; + QTest::newRow("go below") << PlasmaShellSurface::PanelBehavior::WindowsGoBelow << PlasmaShellSurfaceInterface::PanelBehavior::WindowsGoBelow; +} + +void TestPlasmaShell::testPanelBehavior() +{ + // this test verifies that the panel behavior is properly passed to the server + QSignalSpy plasmaSurfaceCreatedSpy(m_plasmaShellInterface, &PlasmaShellInterface::surfaceCreated); + QVERIFY(plasmaSurfaceCreatedSpy.isValid()); + + QScopedPointer s(m_compositor->createSurface()); + QScopedPointer ps(m_plasmaShell->createSurface(s.data())); + ps->setRole(PlasmaShellSurface::Role::Panel); + QVERIFY(plasmaSurfaceCreatedSpy.wait()); + QCOMPARE(plasmaSurfaceCreatedSpy.count(), 1); + + // verify that we got a plasma shell surface + auto sps = plasmaSurfaceCreatedSpy.first().first().value(); + QVERIFY(sps); + QVERIFY(sps->surface()); + QCOMPARE(sps->panelBehavior(), PlasmaShellSurfaceInterface::PanelBehavior::AlwaysVisible); + + // now change the behavior + QSignalSpy behaviorChangedSpy(sps, &PlasmaShellSurfaceInterface::panelBehaviorChanged); + QVERIFY(behaviorChangedSpy.isValid()); + QFETCH(PlasmaShellSurface::PanelBehavior, client); + ps->setPanelBehavior(client); + QVERIFY(behaviorChangedSpy.wait()); + QTEST(sps->panelBehavior(), "server"); + + // changing to same should not trigger the signal + ps->setPanelBehavior(client); + QVERIFY(!behaviorChangedSpy.wait(100)); + + // but changing back to Always Visible should work + ps->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible); + QVERIFY(behaviorChangedSpy.wait()); + QCOMPARE(sps->panelBehavior(), PlasmaShellSurfaceInterface::PanelBehavior::AlwaysVisible); +} + void TestPlasmaShell::testDisconnect() { // this test verifies that a disconnect cleans up diff --git a/src/wayland/plasmashell_interface.h b/src/wayland/plasmashell_interface.h index ae7d23a50f..4fa7b5616e 100644 --- a/src/wayland/plasmashell_interface.h +++ b/src/wayland/plasmashell_interface.h @@ -171,5 +171,6 @@ private: } Q_DECLARE_METATYPE(KWayland::Server::PlasmaShellSurfaceInterface::Role) +Q_DECLARE_METATYPE(KWayland::Server::PlasmaShellSurfaceInterface::PanelBehavior) #endif