diff --git a/src/wayland/autotests/client/test_plasma_window_model.cpp b/src/wayland/autotests/client/test_plasma_window_model.cpp index c3809a0d69..c44e13cb3a 100644 --- a/src/wayland/autotests/client/test_plasma_window_model.cpp +++ b/src/wayland/autotests/client/test_plasma_window_model.cpp @@ -592,6 +592,10 @@ void PlasmaWindowModelTest::testRequests() QVERIFY(resizeRequestedSpy.isValid()); QSignalSpy virtualDesktopRequestedSpy(w, &PlasmaWindowInterface::virtualDesktopRequested); QVERIFY(virtualDesktopRequestedSpy.isValid()); + QSignalSpy keepAboveRequestedSpy(w, &PlasmaWindowInterface::keepAboveRequested); + QVERIFY(keepAboveRequestedSpy.isValid()); + QSignalSpy keepBelowRequestedSpy(w, &PlasmaWindowInterface::keepBelowRequested); + QVERIFY(keepBelowRequestedSpy.isValid()); QSignalSpy minimizedRequestedSpy(w, &PlasmaWindowInterface::minimizedRequested); QVERIFY(minimizedRequestedSpy.isValid()); QSignalSpy maximizeRequestedSpy(w, &PlasmaWindowInterface::maximizedRequested); @@ -603,6 +607,8 @@ void PlasmaWindowModelTest::testRequests() model->requestActivate(-1); model->requestClose(-1); model->requestVirtualDesktop(-1, 1); + model->requestToggleKeepAbove(-1); + model->requestToggleKeepBelow(-1); model->requestToggleMinimized(-1); model->requestToggleMaximized(-1); model->requestActivate(1); @@ -610,6 +616,8 @@ void PlasmaWindowModelTest::testRequests() model->requestMove(1); model->requestResize(1); model->requestVirtualDesktop(1, 1); + model->requestToggleKeepAbove(1); + model->requestToggleKeepBelow(1); model->requestToggleMinimized(1); model->requestToggleMaximized(1); model->requestToggleShaded(1); @@ -682,6 +690,30 @@ void PlasmaWindowModelTest::testRequests() QCOMPARE(minimizedRequestedSpy.count(), 0); QCOMPARE(maximizeRequestedSpy.count(), 0); QCOMPARE(shadeRequestedSpy.count(), 0); + // keep above + model->requestToggleKeepAbove(0); + QVERIFY(keepAboveRequestedSpy.wait()); + QCOMPARE(keepAboveRequestedSpy.count(), 1); + QCOMPARE(keepAboveRequestedSpy.first().first().toBool(), true); + QCOMPARE(activateRequestedSpy.count(), 1); + QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveRequestedSpy.count(), 1); + QCOMPARE(resizeRequestedSpy.count(), 1); + QCOMPARE(virtualDesktopRequestedSpy.count(), 1); + QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); + // keep Below + model->requestToggleKeepBelow(0); + QVERIFY(keepBelowRequestedSpy.wait()); + QCOMPARE(keepBelowRequestedSpy.count(), 1); + QCOMPARE(keepBelowRequestedSpy.first().first().toBool(), true); + QCOMPARE(activateRequestedSpy.count(), 1); + QCOMPARE(closeRequestedSpy.count(), 1); + QCOMPARE(moveRequestedSpy.count(), 1); + QCOMPARE(resizeRequestedSpy.count(), 1); + QCOMPARE(virtualDesktopRequestedSpy.count(), 1); + QCOMPARE(maximizeRequestedSpy.count(), 0); + QCOMPARE(shadeRequestedSpy.count(), 0); // minimize model->requestToggleMinimized(0); QVERIFY(minimizedRequestedSpy.wait()); @@ -721,6 +753,20 @@ void PlasmaWindowModelTest::testRequests() // the toggles can also support a different state QSignalSpy dataChangedSpy(model, &PlasmaWindowModel::dataChanged); QVERIFY(dataChangedSpy.isValid()); + // keepAbove + w->setKeepAbove(true); + QVERIFY(dataChangedSpy.wait()); + model->requestToggleKeepAbove(0); + QVERIFY(keepAboveRequestedSpy.wait()); + QCOMPARE(keepAboveRequestedSpy.count(), 2); + QCOMPARE(keepAboveRequestedSpy.last().first().toBool(), false); + // keepBelow + w->setKeepBelow(true); + QVERIFY(dataChangedSpy.wait()); + model->requestToggleKeepBelow(0); + QVERIFY(keepBelowRequestedSpy.wait()); + QCOMPARE(keepBelowRequestedSpy.count(), 2); + QCOMPARE(keepBelowRequestedSpy.last().first().toBool(), false); // minimize w->setMinimized(true); QVERIFY(dataChangedSpy.wait()); diff --git a/src/wayland/autotests/client/test_wayland_windowmanagement.cpp b/src/wayland/autotests/client/test_wayland_windowmanagement.cpp index 22679ac2ad..2ec42f77ac 100644 --- a/src/wayland/autotests/client/test_wayland_windowmanagement.cpp +++ b/src/wayland/autotests/client/test_wayland_windowmanagement.cpp @@ -61,6 +61,8 @@ private Q_SLOTS: void testRequests(); void testRequestsBoolean_data(); void testRequestsBoolean(); + void testKeepAbove(); + void testKeepBelow(); void testShowingDesktop(); void testRequestShowingDesktop_data(); void testRequestShowingDesktop(); @@ -477,6 +479,50 @@ void TestWindowManagement::testRequestShowingDesktop() QTEST(requestSpy.first().first().value(), "expectedValue"); } +void TestWindowManagement::testKeepAbove() +{ + using namespace KWayland::Server; + // this test verifies setting the keep above state + QVERIFY(!m_window->isKeepAbove()); + QSignalSpy keepAboveChangedSpy(m_window, &KWayland::Client::PlasmaWindow::keepAboveChanged); + QVERIFY(keepAboveChangedSpy.isValid()); + m_windowInterface->setKeepAbove(true); + QVERIFY(keepAboveChangedSpy.wait()); + QCOMPARE(keepAboveChangedSpy.count(), 1); + QVERIFY(m_window->isKeepAbove()); + // setting to same should not change + m_windowInterface->setKeepAbove(true); + QVERIFY(!keepAboveChangedSpy.wait(100)); + QCOMPARE(keepAboveChangedSpy.count(), 1); + // setting to other state should change + m_windowInterface->setKeepAbove(false); + QVERIFY(keepAboveChangedSpy.wait()); + QCOMPARE(keepAboveChangedSpy.count(), 2); + QVERIFY(!m_window->isKeepAbove()); +} + +void TestWindowManagement::testKeepBelow() +{ + using namespace KWayland::Server; + // this test verifies setting the keep below state + QVERIFY(!m_window->isKeepBelow()); + QSignalSpy keepBelowChangedSpy(m_window, &KWayland::Client::PlasmaWindow::keepBelowChanged); + QVERIFY(keepBelowChangedSpy.isValid()); + m_windowInterface->setKeepBelow(true); + QVERIFY(keepBelowChangedSpy.wait()); + QCOMPARE(keepBelowChangedSpy.count(), 1); + QVERIFY(m_window->isKeepBelow()); + // setting to same should not change + m_windowInterface->setKeepBelow(true); + QVERIFY(!keepBelowChangedSpy.wait(100)); + QCOMPARE(keepBelowChangedSpy.count(), 1); + // setting to other state should change + m_windowInterface->setKeepBelow(false); + QVERIFY(keepBelowChangedSpy.wait()); + QCOMPARE(keepBelowChangedSpy.count(), 2); + QVERIFY(!m_window->isKeepBelow()); +} + void TestWindowManagement::testParentWindow() { using namespace KWayland::Client;