diff --git a/autotests/integration/kwinbindings_test.cpp b/autotests/integration/kwinbindings_test.cpp
index 80c96cf0d6..f6a854d7a8 100644
--- a/autotests/integration/kwinbindings_test.cpp
+++ b/autotests/integration/kwinbindings_test.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see .
#include "shell_client.h"
#include "scripting/scripting.h"
#include "useractions.h"
+#include "virtualdesktops.h"
#include "wayland_server.h"
#include "workspace.h"
@@ -50,6 +51,8 @@ private Q_SLOTS:
void testSwitchWindow();
void testSwitchWindowScript();
+ void testWindowToDesktop_data();
+ void testWindowToDesktop();
};
@@ -196,5 +199,69 @@ void KWinBindingsTest::testSwitchWindowScript()
QTRY_COMPARE(workspace()->activeClient(), c4);
}
+void KWinBindingsTest::testWindowToDesktop_data()
+{
+ QTest::addColumn("desktop");
+
+ QTest::newRow("2") << 2;
+ QTest::newRow("3") << 3;
+ QTest::newRow("4") << 4;
+ QTest::newRow("5") << 5;
+ QTest::newRow("6") << 6;
+ QTest::newRow("7") << 7;
+ QTest::newRow("8") << 8;
+ QTest::newRow("9") << 9;
+ QTest::newRow("10") << 10;
+ QTest::newRow("11") << 11;
+ QTest::newRow("12") << 12;
+ QTest::newRow("13") << 13;
+ QTest::newRow("14") << 14;
+ QTest::newRow("15") << 15;
+ QTest::newRow("16") << 16;
+ QTest::newRow("17") << 17;
+ QTest::newRow("18") << 18;
+ QTest::newRow("19") << 19;
+ QTest::newRow("20") << 20;
+}
+
+void KWinBindingsTest::testWindowToDesktop()
+{
+ // first go to desktop one
+ VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().first());
+
+ // now create a window
+ QScopedPointer surface(Test::createSurface());
+ QScopedPointer shellSurface(Test::createShellSurface(surface.data()));
+ auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
+ QSignalSpy desktopChangedSpy(c, &AbstractClient::desktopChanged);
+ QVERIFY(desktopChangedSpy.isValid());
+ QCOMPARE(workspace()->activeClient(), c);
+
+ QFETCH(int, desktop);
+ VirtualDesktopManager::self()->setCount(desktop);
+
+ // now trigger the shortcut
+ auto invokeShortcut = [] (int desktop) {
+ auto msg = QDBusMessage::createMethodCall(
+ QStringLiteral("org.kde.kglobalaccel"),
+ QStringLiteral("/component/kwin"),
+ QStringLiteral("org.kde.kglobalaccel.Component"),
+ QStringLiteral("invokeShortcut"));
+ msg.setArguments(QList{QStringLiteral("Window to Desktop %1").arg(desktop)});
+ QDBusConnection::sessionBus().asyncCall(msg);
+ };
+ invokeShortcut(desktop);
+ QVERIFY(desktopChangedSpy.wait());
+ QCOMPARE(c->desktop(), desktop);
+ // back to desktop 1
+ invokeShortcut(1);
+ QVERIFY(desktopChangedSpy.wait());
+ QCOMPARE(c->desktop(), 1);
+ // invoke with one desktop too many
+ invokeShortcut(desktop + 1);
+ // that should fail
+ QVERIFY(!desktopChangedSpy.wait(100));
+}
+
WAYLANDTEST_MAIN(KWinBindingsTest)
#include "kwinbindings_test.moc"