tests: Assert.grid: pass tilingArea instead of screen
This commit is contained in:
@@ -13,7 +13,7 @@ tests.register("Center focused", 1, () => {
|
||||
|
||||
// center client2
|
||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||
Assert.centered(config, screen, client2);
|
||||
Assert.centered(config, tilingArea, client2);
|
||||
Assert.fullyVisible(client1.frameGeometry);
|
||||
Assert.fullyVisible(client2.frameGeometry);
|
||||
|
||||
@@ -23,13 +23,13 @@ tests.register("Center focused", 1, () => {
|
||||
|
||||
// center client2
|
||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||
Assert.centered(config, screen, client2);
|
||||
Assert.centered(config, tilingArea, client2);
|
||||
Assert.fullyVisible(client1.frameGeometry);
|
||||
Assert.fullyVisible(client2.frameGeometry);
|
||||
|
||||
// focus client1 (no scrolling should occur)
|
||||
qtMock.fireShortcut("karousel-focus-left");
|
||||
Assert.centered(config, screen, client2, { message: "No scrolling should have occured" });
|
||||
Assert.centered(config, tilingArea, client2, { message: "No scrolling should have occured" });
|
||||
Assert.fullyVisible(client1.frameGeometry);
|
||||
Assert.fullyVisible(client2.frameGeometry);
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ tests.register("Drag tiled window, untile", 20, () => {
|
||||
const [client0, client1] = workspaceMock.createClients(2);
|
||||
Assert.tiledClient(clientManager, client0);
|
||||
Assert.tiledClient(clientManager, client1);
|
||||
Assert.grid(config, screen, 100, [[client0], [client1]], true);
|
||||
Assert.grid(config, tilingArea, 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);
|
||||
Assert.grid(config, tilingArea, 100, [[client1]], true);
|
||||
});
|
||||
|
||||
tests.register("Drag tiled window, keep tiled", 20, () => {
|
||||
@@ -24,11 +24,11 @@ tests.register("Drag tiled window, keep tiled", 20, () => {
|
||||
const [client0, client1] = workspaceMock.createClients(2);
|
||||
Assert.tiledClient(clientManager, client0);
|
||||
Assert.tiledClient(clientManager, client1);
|
||||
Assert.grid(config, screen, 100, [[client0], [client1]], true);
|
||||
Assert.grid(config, tilingArea, 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);
|
||||
Assert.grid(config, tilingArea, 100, [[client0], [client1]], true);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ tests.register("Focus and move windows", 1, () => {
|
||||
|
||||
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
||||
qtMock.fireShortcut(shortcutName);
|
||||
Assert.grid(config, screen, 100, grid, true, [], { skip: 1 });
|
||||
Assert.grid(config, tilingArea, 100, grid, true, [], { skip: 1 });
|
||||
}
|
||||
|
||||
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
||||
|
||||
@@ -6,13 +6,13 @@ tests.register("LazyScroller", 20, () => {
|
||||
const { qtMock, workspaceMock, world } = init(config);
|
||||
|
||||
const [client1] = workspaceMock.createClientsWithWidths(300);
|
||||
Assert.grid(config, screen, 300, [[client1]], true);
|
||||
Assert.grid(config, tilingArea, 300, [[client1]], true);
|
||||
|
||||
const [client2] = workspaceMock.createClientsWithWidths(300);
|
||||
Assert.grid(config, screen, 300, [[client1], [client2]], true);
|
||||
Assert.grid(config, tilingArea, 300, [[client1], [client2]], true);
|
||||
|
||||
const [client3] = workspaceMock.createClientsWithWidths(300);
|
||||
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.equal(client3.frameGeometry.right, tilingArea.right);
|
||||
|
||||
runOneOf(
|
||||
@@ -20,7 +20,7 @@ tests.register("LazyScroller", 20, () => {
|
||||
() => qtMock.fireShortcut("karousel-focus-2"),
|
||||
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||
);
|
||||
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.equal(client3.frameGeometry.right, tilingArea.right);
|
||||
|
||||
runOneOf(
|
||||
@@ -30,18 +30,18 @@ tests.register("LazyScroller", 20, () => {
|
||||
() => qtMock.fireShortcut("karousel-focus-start"),
|
||||
);
|
||||
workspaceMock.activeWindow = client1;
|
||||
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.equal(client1.frameGeometry.left, tilingArea.left);
|
||||
|
||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.grid(config, screen, 300, [[client1]], true);
|
||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.grid(config, tilingArea, 300, [[client1]], true);
|
||||
|
||||
runOneOf(
|
||||
() => workspaceMock.activeWindow = client2,
|
||||
() => qtMock.fireShortcut("karousel-focus-2"),
|
||||
() => qtMock.fireShortcut("karousel-focus-right"),
|
||||
);
|
||||
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||
Assert.equal(client1.frameGeometry.left, tilingArea.left);
|
||||
});
|
||||
|
||||
@@ -160,14 +160,14 @@ tests.register("Start full-screen", 100, () => {
|
||||
Assert.assert(clientManager.hasClient(fullScreenClient));
|
||||
});
|
||||
|
||||
Assert.centered(config, screen, windowedClient);
|
||||
Assert.centered(config, tilingArea, windowedClient);
|
||||
Assert.equalRects(fullScreenClient.frameGeometry, screen);
|
||||
Assert.equal(Workspace.activeWindow, fullScreenClient);
|
||||
|
||||
{
|
||||
qtMock.fireShortcut("karousel-focus-left");
|
||||
const opts = { message: "fullScreenClient is not in the grid, so we can't move focus directionally" };
|
||||
Assert.centered(config, screen, windowedClient, opts);
|
||||
Assert.centered(config, tilingArea, windowedClient, opts);
|
||||
Assert.equalRects(fullScreenClient.frameGeometry, screen, opts);
|
||||
Assert.equal(Workspace.activeWindow, fullScreenClient, opts);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ tests.register("Start full-screen", 100, () => {
|
||||
{
|
||||
qtMock.fireShortcut("karousel-focus-1");
|
||||
const opts = { message: "fullScreenClient is not in grid, so it should stay full-screen" };
|
||||
Assert.centered(config, screen, windowedClient, opts);
|
||||
Assert.centered(config, tilingArea, windowedClient, opts);
|
||||
Assert.equalRects(fullScreenClient.frameGeometry, screen, opts);
|
||||
Assert.equal(Workspace.activeWindow, windowedClient);
|
||||
}
|
||||
|
||||
@@ -5,35 +5,48 @@ tests.register("Pin", 20, () => {
|
||||
const screenHalfLeft = new MockQmlRect(0, 0, screen.width/2, screen.height);
|
||||
const screenHalfRight = new MockQmlRect(screen.width/2, 0, screen.width/2, screen.height);
|
||||
|
||||
const tilingAreaHalfLeft = new MockQmlRect(
|
||||
tilingArea.x,
|
||||
tilingArea.y,
|
||||
screen.width/2 - config.gapsOuterLeft - config.gapsOuterRight,
|
||||
tilingArea.height,
|
||||
);
|
||||
const tilingAreaHalfRight = new MockQmlRect(
|
||||
screen.width/2 + config.gapsOuterLeft,
|
||||
tilingArea.y,
|
||||
screen.width/2 - config.gapsOuterLeft - config.gapsOuterRight,
|
||||
tilingArea.height,
|
||||
);
|
||||
|
||||
const [pinned, tiled1, tiled2] = workspaceMock.createClients(3);
|
||||
Assert.grid(config, screen, 100, [ [pinned], [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingArea, 100, [ [pinned], [tiled1], [tiled2] ], true);
|
||||
|
||||
pinned.pin(screenHalfLeft);
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfLeft);
|
||||
Assert.grid(config, screenHalfRight, 100, [ [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingAreaHalfRight, 100, [ [tiled1], [tiled2] ], true);
|
||||
|
||||
pinned.pin(screenHalfRight);
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screenHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||
|
||||
pinned.unpin();
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screen, 100, [ [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2] ], true);
|
||||
|
||||
pinned.pin(screenHalfRight);
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screenHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||
|
||||
pinned.minimized = true;
|
||||
Assert.grid(config, screen, 100, [ [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2] ], true);
|
||||
|
||||
pinned.minimized = false;
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screenHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||
|
||||
workspaceMock.activeWindow = pinned;
|
||||
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||
Assert.assert(pinned.tile === null);
|
||||
pinned.frameGeometry = new MockQmlRect(10, 20, 100, 200); // This is needed because the window's preferredWidth can change when pinning, because frameGeometryChanged can fire before tileChanged. TODO: Ensure pinned window keeps its preferredWidth.
|
||||
Assert.grid(config, screen, 100, [ [tiled1], [tiled2], [pinned] ], true);
|
||||
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2], [pinned] ], true);
|
||||
});
|
||||
|
||||
@@ -8,23 +8,23 @@ tests.register("Stacked", 5, () => {
|
||||
qtMock.fireShortcut("karousel-window-move-left");
|
||||
workspaceMock.activeWindow = leftBottom;
|
||||
qtMock.fireShortcut("karousel-window-move-left");
|
||||
Assert.grid(config, screen, 100, grid, true);
|
||||
Assert.grid(config, tilingArea, 100, grid, true);
|
||||
|
||||
qtMock.fireShortcut("karousel-column-toggle-stacked");
|
||||
Assert.grid(config, screen, 100, grid, true, [0]);
|
||||
Assert.grid(config, tilingArea, 100, grid, true, [0]);
|
||||
|
||||
qtMock.fireShortcut("karousel-focus-up");
|
||||
Assert.grid(config, screen, 100, grid, true, [0]);
|
||||
Assert.grid(config, tilingArea, 100, grid, true, [0]);
|
||||
|
||||
qtMock.fireShortcut("karousel-focus-down");
|
||||
Assert.grid(config, screen, 100, grid, true, [0]);
|
||||
Assert.grid(config, tilingArea, 100, grid, true, [0]);
|
||||
|
||||
qtMock.fireShortcut("karousel-window-move-up");
|
||||
Assert.grid(config, screen, 100, [[leftBottom, leftTop], [rightTop, rightBottom]], true, [0]);
|
||||
Assert.grid(config, tilingArea, 100, [[leftBottom, leftTop], [rightTop, rightBottom]], true, [0]);
|
||||
|
||||
qtMock.fireShortcut("karousel-window-move-down");
|
||||
Assert.grid(config, screen, 100, grid, true, [0]);
|
||||
Assert.grid(config, tilingArea, 100, grid, true, [0]);
|
||||
|
||||
qtMock.fireShortcut("karousel-column-toggle-stacked");
|
||||
Assert.grid(config, screen, 100, grid, true);
|
||||
Assert.grid(config, tilingArea, 100, grid, true);
|
||||
});
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Assert {
|
||||
|
||||
export function grid(
|
||||
config: Config,
|
||||
screen: QmlRect,
|
||||
tilingArea: QmlRect,
|
||||
columnWidth: number,
|
||||
grid: KwinClient[][],
|
||||
centered: boolean,
|
||||
@@ -133,20 +133,19 @@ namespace Assert {
|
||||
{ message, skip=0 }: Options = {},
|
||||
) {
|
||||
const nColumns = grid.length;
|
||||
const columnHeight = screen.height - config.gapsOuterTop - config.gapsOuterBottom;
|
||||
const columnsWidth = nColumns * columnWidth + (nColumns-1) * config.gapsInnerHorizontal;
|
||||
const startX = centered ?
|
||||
screen.x + (screen.width - columnsWidth) / 2 :
|
||||
tilingArea.x + (tilingArea.width - columnsWidth) / 2 :
|
||||
grid[0][0].frameGeometry.x;
|
||||
|
||||
// assumes uniformly sized windows within columns of uniform width
|
||||
function getRectInGrid(column: number, window: number, nColumns: number, nWindows: number) {
|
||||
const windowHeight = (columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows;
|
||||
const windowHeight = (tilingArea.height - config.gapsInnerVertical * (nWindows-1)) / nWindows;
|
||||
return new MockQmlRect(
|
||||
startX + column * (columnWidth + config.gapsInnerHorizontal),
|
||||
screen.y + config.gapsOuterTop + (windowHeight + config.gapsInnerVertical) * window,
|
||||
tilingArea.y + (windowHeight + config.gapsInnerVertical) * window,
|
||||
columnWidth,
|
||||
(columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows,
|
||||
(tilingArea.height - config.gapsInnerVertical * (nWindows-1)) / nWindows,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -154,9 +153,9 @@ namespace Assert {
|
||||
const columnX = startX + column * (columnWidth + config.gapsInnerHorizontal);
|
||||
return new MockQmlRect(
|
||||
columnX + window * Column.stackOffsetX,
|
||||
screen.y + config.gapsOuterTop + window * Column.stackOffsetY,
|
||||
tilingArea.y + window * Column.stackOffsetY,
|
||||
columnWidth - (nWindows-1) * Column.stackOffsetX,
|
||||
columnHeight - (nWindows-1) * Column.stackOffsetY,
|
||||
tilingArea.height - (nWindows-1) * Column.stackOffsetY,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -178,13 +177,13 @@ namespace Assert {
|
||||
|
||||
export function centered(
|
||||
config: Config,
|
||||
screen: QmlRect,
|
||||
tilingArea: QmlRect,
|
||||
client:KwinClient,
|
||||
{ message, skip=0 }: Options = {},
|
||||
) {
|
||||
grid(
|
||||
config,
|
||||
screen,
|
||||
tilingArea,
|
||||
client.frameGeometry.width,
|
||||
[[client]],
|
||||
true,
|
||||
|
||||
Reference in New Issue
Block a user