tests: add test for dragging a tiled window
This commit is contained in:
34
src/tests/flows/dragTiled.ts
Normal file
34
src/tests/flows/dragTiled.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
tests.register("Drag tiled window, untile", 20, () => {
|
||||
const config = getDefaultConfig();
|
||||
config.untileOnDrag = true;
|
||||
const { qtMock, workspaceMock, world } = init(config);
|
||||
const clientManager = getClientManager(world);
|
||||
|
||||
const [client0, client1] = workspaceMock.createClients(2);
|
||||
Assert.tiledClient(clientManager, client0);
|
||||
Assert.tiledClient(clientManager, client1);
|
||||
Assert.grid(config, screen, 100, [[client0], [client1]], true);
|
||||
|
||||
workspaceMock.moveWindow(client0, new MockQmlPoint(10, 10));
|
||||
Assert.notTiledClient(clientManager, client0);
|
||||
Assert.tiledClient(clientManager, client1);
|
||||
Assert.grid(config, screen, 100, [[client1]], true);
|
||||
});
|
||||
|
||||
tests.register("Drag tiled window, keep tiled", 20, () => {
|
||||
const config = getDefaultConfig();
|
||||
config.untileOnDrag = false;
|
||||
const { qtMock, workspaceMock, world } = init(config);
|
||||
const clientManager = getClientManager(world);
|
||||
|
||||
const [client0, client1] = workspaceMock.createClients(2);
|
||||
Assert.tiledClient(clientManager, client0);
|
||||
Assert.tiledClient(clientManager, client1);
|
||||
Assert.grid(config, screen, 100, [[client0], [client1]], true);
|
||||
|
||||
const move = new MockQmlPoint(10, 10);
|
||||
workspaceMock.moveWindow(client0, move, move, move, move, move, move, move, move, move); // many moves in order to trigger externalFrameGeometryChangedRateLimiter
|
||||
Assert.tiledClient(clientManager, client0);
|
||||
Assert.tiledClient(clientManager, client1);
|
||||
Assert.grid(config, screen, 100, [[client0], [client1]], true);
|
||||
});
|
||||
@@ -219,4 +219,26 @@ namespace Assert {
|
||||
}
|
||||
equal(columns[columns.length-1].frameGeometry.right, tilingArea.right, options);
|
||||
}
|
||||
|
||||
export function tiledClient(
|
||||
clientManager: ClientManager,
|
||||
client: KwinClient,
|
||||
{ message, skip=0 }: Options = {},
|
||||
) {
|
||||
assert(
|
||||
clientManager.findTiledWindow(client) !== null,
|
||||
{ message: message, skip: skip+1 },
|
||||
);
|
||||
}
|
||||
|
||||
export function notTiledClient(
|
||||
clientManager: ClientManager,
|
||||
client: KwinClient,
|
||||
{ message, skip=0 }: Options = {},
|
||||
) {
|
||||
assert(
|
||||
clientManager.findTiledWindow(client) === null,
|
||||
{ message: message, skip: skip+1 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,3 +44,10 @@ function getWindowHeight(windowsInColumn: number) {
|
||||
const totalGaps = (windowsInColumn-1) * gapV;
|
||||
return Math.round((tilingArea.height - totalGaps) / windowsInColumn);
|
||||
}
|
||||
|
||||
function getClientManager(world: World): ClientManager {
|
||||
// don't do this outside of tests
|
||||
let clientManager;
|
||||
world.do((cm, dm) => clientManager = cm);
|
||||
return clientManager!;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class MockKwinClient {
|
||||
public caption = "App";
|
||||
public minSize: Readonly<QmlSize> = new MockQmlSize(0, 0);
|
||||
public readonly transient: boolean;
|
||||
public readonly move: boolean = false;
|
||||
public move: boolean = false;
|
||||
public resize: boolean = false;
|
||||
public readonly fullScreenable: boolean = true;
|
||||
public readonly maximizable: boolean = true;
|
||||
|
||||
@@ -62,6 +62,28 @@ class MockWorkspace {
|
||||
};
|
||||
}
|
||||
|
||||
public moveWindow(window: MockKwinClient, ...deltas: QmlPoint[]) {
|
||||
const frame = window.getFrameGeometryCopy();
|
||||
window.move = true;
|
||||
window.interactiveMoveResizeStarted.fire();
|
||||
|
||||
for (const delta of deltas) {
|
||||
if (delta.x !== 0) {
|
||||
frame.x += delta.x;
|
||||
}
|
||||
if (delta.y !== 0) {
|
||||
frame.y += delta.y;
|
||||
}
|
||||
runOneOf(
|
||||
() => window.frameGeometry.set(frame),
|
||||
() => window.frameGeometry = frame,
|
||||
);
|
||||
}
|
||||
|
||||
window.move = false;
|
||||
window.interactiveMoveResizeFinished.fire();
|
||||
}
|
||||
|
||||
public resizeWindow(window: MockKwinClient, edgeResize: boolean, leftEdge: boolean, topEdge: boolean, ...deltas: QmlSize[]) {
|
||||
const frame = window.getFrameGeometryCopy();
|
||||
if (edgeResize) {
|
||||
@@ -94,7 +116,7 @@ class MockWorkspace {
|
||||
runOneOf(
|
||||
() => window.frameGeometry.set(frame),
|
||||
() => window.frameGeometry = frame,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
window.resize = false;
|
||||
|
||||
Reference in New Issue
Block a user