tests: Assert.centeredGrid: add width parameter
This commit is contained in:
@@ -12,7 +12,7 @@ tests.register("Focus and move windows", 1, () => {
|
||||
|
||||
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
||||
qtMock.fireShortcut(shortcutName);
|
||||
Assert.grid(config, screen, grid, { skip: 1 });
|
||||
Assert.centeredGrid(config, screen, 100, grid, { skip: 1 });
|
||||
}
|
||||
|
||||
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
||||
|
||||
10
src/tests/flows/lazyScroller.ts
Normal file
10
src/tests/flows/lazyScroller.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// tests.register("LazyScroller", 100, () => {
|
||||
// const config = getDefaultConfig();
|
||||
// config.scrollingLazy = true;
|
||||
// config.scrollingCentered = false;
|
||||
// config.scrollingGrouped = false;
|
||||
// const { qtMock, workspaceMock, world } = init(config);
|
||||
|
||||
// const client1 = workspaceMock.createClientsWithWidths(300);
|
||||
// Assert.centeredGrid()
|
||||
// });
|
||||
@@ -6,34 +6,34 @@ tests.register("Pin", 20, () => {
|
||||
const screenHalfRight = new MockQmlRect(screen.width/2, 0, screen.width/2, screen.height);
|
||||
|
||||
const [pinned, tiled1, tiled2] = workspaceMock.createClients(3);
|
||||
Assert.grid(config, screen, [ [pinned], [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screen, 100, [ [pinned], [tiled1], [tiled2] ]);
|
||||
|
||||
pinned.pin(screenHalfLeft);
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfLeft);
|
||||
Assert.grid(config, screenHalfRight, [ [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screenHalfRight, 100, [ [tiled1], [tiled2] ]);
|
||||
|
||||
pinned.pin(screenHalfRight);
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screenHalfLeft, 100, [ [tiled1], [tiled2] ]);
|
||||
|
||||
pinned.unpin();
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screen, [ [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screen, 100, [ [tiled1], [tiled2] ]);
|
||||
|
||||
pinned.pin(screenHalfRight);
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screenHalfLeft, 100, [ [tiled1], [tiled2] ]);
|
||||
|
||||
pinned.minimized = true;
|
||||
Assert.grid(config, screen, [ [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screen, 100, [ [tiled1], [tiled2] ]);
|
||||
|
||||
pinned.minimized = false;
|
||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||
Assert.grid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
||||
Assert.centeredGrid(config, screenHalfLeft, 100, [ [tiled1], [tiled2] ]);
|
||||
|
||||
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, [ [tiled1], [tiled2], [pinned] ]);
|
||||
Assert.centeredGrid(config, screen, 100, [ [tiled1], [tiled2], [pinned] ]);
|
||||
});
|
||||
|
||||
@@ -123,21 +123,22 @@ namespace Assert {
|
||||
);
|
||||
}
|
||||
|
||||
export function grid(
|
||||
export function centeredGrid(
|
||||
config: Config,
|
||||
screen: QmlRect,
|
||||
columnWidth: number,
|
||||
grid: KwinClient[][],
|
||||
{ message, skip=0 }: Options = {},
|
||||
) {
|
||||
// assumes uniformly sized windows within columns of width 100
|
||||
// assumes uniformly sized windows within columns of uniform width
|
||||
function getRectInGrid(column: number, window: number, nColumns: number, nWindows: number) {
|
||||
const columnHeight = screen.height - config.gapsOuterTop - config.gapsOuterBottom;
|
||||
const columnsWidth = nColumns * 100 + (nColumns-1) * config.gapsInnerHorizontal;
|
||||
const columnsWidth = nColumns * columnWidth + (nColumns-1) * config.gapsInnerHorizontal;
|
||||
const windowHeight = (columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows;
|
||||
return new MockQmlRect(
|
||||
screen.x + column * (100 + config.gapsInnerHorizontal) + (screen.width-columnsWidth) / 2,
|
||||
screen.x + column * (columnWidth + config.gapsInnerHorizontal) + (screen.width-columnsWidth) / 2,
|
||||
screen.y + config.gapsOuterTop + (windowHeight + config.gapsInnerVertical) * window,
|
||||
100,
|
||||
columnWidth,
|
||||
(columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user