From e8f2a504205345fc95cfa42615b6584727210b9c Mon Sep 17 00:00:00 2001 From: Peter Fajdiga Date: Sun, 7 Sep 2025 14:39:11 +0200 Subject: [PATCH] tests: add test for kwin shortucts for moving windows to adjacent desktops --- src/tests/flows/followWindowToDesktop.ts | 10 ++++++++++ src/tests/utils/mocks/MockKwinClient.ts | 7 +++++++ src/tests/utils/mocks/MockWorkspace.ts | 11 ++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/tests/flows/followWindowToDesktop.ts diff --git a/src/tests/flows/followWindowToDesktop.ts b/src/tests/flows/followWindowToDesktop.ts new file mode 100644 index 0000000..c1a29d5 --- /dev/null +++ b/src/tests/flows/followWindowToDesktop.ts @@ -0,0 +1,10 @@ +tests.register("Move and follow window to desktop", 20, () => { + // This tests the Kwin shortcuts for moving windows to adjacent desktops. + + const config = getDefaultConfig(); + const { qtMock, workspaceMock, world } = init(config); + + const [client0, client1] = workspaceMock.createClients(2); + client1.moveAndFollowToDesktop(workspaceMock.desktops[1], workspaceMock); + Assert.equal(workspaceMock.activeWindow, client1); +}); diff --git a/src/tests/utils/mocks/MockKwinClient.ts b/src/tests/utils/mocks/MockKwinClient.ts index 15e8f4d..156e011 100644 --- a/src/tests/utils/mocks/MockKwinClient.ts +++ b/src/tests/utils/mocks/MockKwinClient.ts @@ -201,6 +201,13 @@ class MockKwinClient { }; } + public moveAndFollowToDesktop(desktop: KwinDesktop, workspaceMock: MockWorkspace) { + Assert.assert(workspaceMock.activeWindow === this); + this._desktops = [desktop]; + this.desktopsChanged.fire(); + workspaceMock.currentDesktop = desktop; + } + public get tile() { return this._tile; } diff --git a/src/tests/utils/mocks/MockWorkspace.ts b/src/tests/utils/mocks/MockWorkspace.ts index 2554e2e..87bb0da 100644 --- a/src/tests/utils/mocks/MockWorkspace.ts +++ b/src/tests/utils/mocks/MockWorkspace.ts @@ -6,12 +6,12 @@ class MockWorkspace { { __brand: "KwinDesktop", id: "desktop1" }, { __brand: "KwinDesktop", id: "desktop2" }, ]; - public currentDesktop = this.desktops[0]; public currentActivity = this.activities[0]; public activeScreen: Output = { __brand: "Output" }; public readonly windows: MockKwinClient[] = []; public cursorPos = new MockQmlPoint(0, 0); + private _currentDesktop = this.desktops[0]; private _activeWindow: KwinClient|null = null; public readonly currentDesktopChanged = new MockQSignal<[]>(); @@ -126,6 +126,15 @@ class MockWorkspace { window.interactiveMoveResizeFinished.fire(); } + public get currentDesktop() { + return this._currentDesktop; + } + + public set currentDesktop(currentDesktop: KwinDesktop) { + this._currentDesktop = currentDesktop; + this.currentDesktopChanged.fire(); + } + public get activeWindow() { return this._activeWindow; }