diff --git a/src/wayland/autotests/client/test_wayland_windowmanagement.cpp b/src/wayland/autotests/client/test_wayland_windowmanagement.cpp index 9d34fcb64b..8678934e97 100644 --- a/src/wayland/autotests/client/test_wayland_windowmanagement.cpp +++ b/src/wayland/autotests/client/test_wayland_windowmanagement.cpp @@ -61,6 +61,9 @@ private Q_SLOTS: void testRequests(); void testRequestsBoolean_data(); void testRequestsBoolean(); + void testShowingDesktop(); + void testRequestShowingDesktop_data(); + void testRequestShowingDesktop(); void cleanup(); @@ -97,6 +100,7 @@ TestWindowManagement::TestWindowManagement(QObject *parent) void TestWindowManagement::init() { using namespace KWayland::Server; + qRegisterMetaType("ShowingDesktopState"); delete m_display; m_display = new Display(this); m_display->setSocketName(s_socketName); @@ -418,5 +422,53 @@ void TestWindowManagement::testRequestsBoolean() QCOMPARE(requestSpy.last().first().toBool(), false); } +void TestWindowManagement::testShowingDesktop() +{ + using namespace KWayland::Server; + // this test verifies setting the showing desktop state + QVERIFY(!m_windowManagement->isShowingDesktop()); + QSignalSpy showingDesktopChangedSpy(m_windowManagement, &KWayland::Client::PlasmaWindowManagement::showingDesktopChanged); + QVERIFY(showingDesktopChangedSpy.isValid()); + m_windowManagementInterface->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Enabled); + QVERIFY(showingDesktopChangedSpy.wait()); + QCOMPARE(showingDesktopChangedSpy.count(), 1); + QCOMPARE(showingDesktopChangedSpy.first().first().toBool(), true); + QVERIFY(m_windowManagement->isShowingDesktop()); + // setting to same should not change + m_windowManagementInterface->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Enabled); + QVERIFY(!showingDesktopChangedSpy.wait(100)); + QCOMPARE(showingDesktopChangedSpy.count(), 1); + // setting to other state should change + m_windowManagementInterface->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled); + QVERIFY(showingDesktopChangedSpy.wait()); + QCOMPARE(showingDesktopChangedSpy.count(), 2); + QCOMPARE(showingDesktopChangedSpy.first().first().toBool(), true); + QCOMPARE(showingDesktopChangedSpy.last().first().toBool(), false); + QVERIFY(!m_windowManagement->isShowingDesktop()); +} + +void TestWindowManagement::testRequestShowingDesktop_data() +{ + using namespace KWayland::Server; + QTest::addColumn("value"); + QTest::addColumn("expectedValue"); + + QTest::newRow("enable") << true << PlasmaWindowManagementInterface::ShowingDesktopState::Enabled; + QTest::newRow("disable") << false << PlasmaWindowManagementInterface::ShowingDesktopState::Disabled; +} + +void TestWindowManagement::testRequestShowingDesktop() +{ + // this test verifies requesting show desktop state + using namespace KWayland::Server; + QSignalSpy requestSpy(m_windowManagementInterface, &PlasmaWindowManagementInterface::requestChangeShowingDesktop); + QVERIFY(requestSpy.isValid()); + QFETCH(bool, value); + m_windowManagement->setShowingDesktop(value); + QVERIFY(requestSpy.wait()); + QCOMPARE(requestSpy.count(), 1); + QTEST(requestSpy.first().first().value(), "expectedValue"); +} + QTEST_GUILESS_MAIN(TestWindowManagement) #include "test_wayland_windowmanagement.moc" diff --git a/src/wayland/plasmawindowmanagement_interface.h b/src/wayland/plasmawindowmanagement_interface.h index d004519d68..ef561138b3 100644 --- a/src/wayland/plasmawindowmanagement_interface.h +++ b/src/wayland/plasmawindowmanagement_interface.h @@ -195,4 +195,6 @@ private: } } +Q_DECLARE_METATYPE(KWayland::Server::PlasmaWindowManagementInterface::ShowingDesktopState) + #endif