tests: add test for kwin shortucts for moving windows to adjacent desktops

This commit is contained in:
Peter Fajdiga
2025-09-07 14:39:11 +02:00
parent 9910bc7041
commit e8f2a50420
3 changed files with 27 additions and 1 deletions

View File

@@ -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);
});

View File

@@ -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;
}

View File

@@ -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;
}