[autotests] Add test for PlasmaShellSurface::setPanelBehavior

Also adds the metatypes on client and server side.
master
Martin Gräßlin 8 years ago
parent 8e28a6c1c2
commit 33c8634c00

@ -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<PlasmaShellSurface::PanelBehavior>("client");
QTest::addColumn<PlasmaShellSurfaceInterface::PanelBehavior>("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<Surface> s(m_compositor->createSurface());
QScopedPointer<PlasmaShellSurface> 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<PlasmaShellSurfaceInterface*>();
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

@ -171,5 +171,6 @@ private:
}
Q_DECLARE_METATYPE(KWayland::Server::PlasmaShellSurfaceInterface::Role)
Q_DECLARE_METATYPE(KWayland::Server::PlasmaShellSurfaceInterface::PanelBehavior)
#endif

Loading…
Cancel
Save