tests: assert: create namespace
This commit is contained in:
@@ -28,21 +28,21 @@ tests.register("Focus and move windows", 1, () => {
|
|||||||
workspaceMock.createWindow(client2);
|
workspaceMock.createWindow(client2);
|
||||||
workspaceMock.createWindow(client3);
|
workspaceMock.createWindow(client3);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
assert(clientManager.hasClient(client1));
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
assert(clientManager.hasClient(client2));
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
assert(clientManager.hasClient(client3));
|
Assert.assert(clientManager.hasClient(client3));
|
||||||
});
|
});
|
||||||
assert(workspaceMock.activeWindow === client3);
|
Assert.assert(workspaceMock.activeWindow === client3);
|
||||||
|
|
||||||
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
||||||
qtMock.fireShortcut(shortcutName);
|
qtMock.fireShortcut(shortcutName);
|
||||||
const screen = new MockQmlRect(0, 0, screenWidth, screenHeight);
|
const screen = new MockQmlRect(0, 0, screenWidth, screenHeight);
|
||||||
assertGrid(config, screen, grid, 1);
|
Assert.grid(config, screen, grid, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
||||||
qtMock.fireShortcut(shortcutName);
|
qtMock.fireShortcut(shortcutName);
|
||||||
assert(workspaceMock.activeWindow === expectedFocus, `wrong activeWindow: ${workspaceMock.activeWindow?.pid}`, 1);
|
Assert.assert(workspaceMock.activeWindow === expectedFocus, `wrong activeWindow: ${workspaceMock.activeWindow?.pid}`, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
testLayout("karousel-column-move-right", [ [client1], [client2], [client3] ]);
|
testLayout("karousel-column-move-right", [ [client1], [client2], [client3] ]);
|
||||||
|
|||||||
@@ -12,28 +12,28 @@ tests.register("Maximization", 100, () => {
|
|||||||
|
|
||||||
workspaceMock.createWindow(kwinClient);
|
workspaceMock.createWindow(kwinClient);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
assert(clientManager.hasClient(kwinClient));
|
Assert.assert(clientManager.hasClient(kwinClient));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnLeftX = screenWidth/2 - 300/2;
|
const columnLeftX = screenWidth/2 - 300/2;
|
||||||
const columnTopY = config.gapsOuterTop;
|
const columnTopY = config.gapsOuterTop;
|
||||||
const columnHeight = screenHeight - config.gapsOuterTop - config.gapsOuterBottom;
|
const columnHeight = screenHeight - config.gapsOuterTop - config.gapsOuterBottom;
|
||||||
assertRect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
|
||||||
kwinClient.fullScreen = true;
|
kwinClient.fullScreen = true;
|
||||||
assertRect(kwinClient.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(kwinClient.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
|
|
||||||
kwinClient.fullScreen = false;
|
kwinClient.fullScreen = false;
|
||||||
assertRect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
|
||||||
kwinClient.setMaximize(true, true);
|
kwinClient.setMaximize(true, true);
|
||||||
assertRect(kwinClient.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(kwinClient.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
|
|
||||||
kwinClient.setMaximize(true, false);
|
kwinClient.setMaximize(true, false);
|
||||||
assertRect(kwinClient.frameGeometry, columnLeftX, 0, 300, screenHeight);
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, 0, 300, screenHeight);
|
||||||
|
|
||||||
kwinClient.setMaximize(false, false);
|
kwinClient.setMaximize(false, false);
|
||||||
assertRect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Maximize with transient", 100, () => {
|
tests.register("Maximize with transient", 100, () => {
|
||||||
@@ -58,21 +58,21 @@ tests.register("Maximize with transient", 100, () => {
|
|||||||
|
|
||||||
workspaceMock.createWindow(parent);
|
workspaceMock.createWindow(parent);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
assert(clientManager.hasClient(parent));
|
Assert.assert(clientManager.hasClient(parent));
|
||||||
});
|
});
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => parent.fullScreen = true,
|
() => parent.fullScreen = true,
|
||||||
() => parent.setMaximize(true, true),
|
() => parent.setMaximize(true, true),
|
||||||
);
|
);
|
||||||
assertRect(parent.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(parent.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
|
|
||||||
workspaceMock.createWindow(child);
|
workspaceMock.createWindow(child);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
assert(clientManager.hasClient(child));
|
Assert.assert(clientManager.hasClient(child));
|
||||||
});
|
});
|
||||||
assertRect(child.frameGeometry, 14, 24, 50, 50);
|
Assert.rect(child.frameGeometry, 14, 24, 50, 50);
|
||||||
assertRect(parent.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(parent.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Re-maximize disabled", 100, () => {
|
tests.register("Re-maximize disabled", 100, () => {
|
||||||
@@ -98,8 +98,8 @@ tests.register("Re-maximize disabled", 100, () => {
|
|||||||
workspaceMock.createWindow(client1);
|
workspaceMock.createWindow(client1);
|
||||||
workspaceMock.createWindow(client2);
|
workspaceMock.createWindow(client2);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
assert(clientManager.hasClient(client1));
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
assert(clientManager.hasClient(client2));
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
||||||
@@ -107,15 +107,15 @@ tests.register("Re-maximize disabled", 100, () => {
|
|||||||
const column2LeftX = column1LeftX + 300 + config.gapsInnerHorizontal;
|
const column2LeftX = column1LeftX + 300 + config.gapsInnerHorizontal;
|
||||||
const columnTopY = config.gapsOuterTop;
|
const columnTopY = config.gapsOuterTop;
|
||||||
const columnHeight = screenHeight - config.gapsOuterTop - config.gapsOuterBottom;
|
const columnHeight = screenHeight - config.gapsOuterTop - config.gapsOuterBottom;
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => client2.fullScreen = true,
|
() => client2.fullScreen = true,
|
||||||
() => client2.setMaximize(true, true),
|
() => client2.setMaximize(true, true),
|
||||||
);
|
);
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(client2.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => workspaceMock.activeWindow = client1,
|
() => workspaceMock.activeWindow = client1,
|
||||||
@@ -123,8 +123,8 @@ tests.register("Re-maximize disabled", 100, () => {
|
|||||||
() => qtMock.fireShortcut("karousel-focus-left"),
|
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||||
() => qtMock.fireShortcut("karousel-focus-start"),
|
() => qtMock.fireShortcut("karousel-focus-start"),
|
||||||
);
|
);
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => workspaceMock.activeWindow = client2,
|
() => workspaceMock.activeWindow = client2,
|
||||||
@@ -132,8 +132,8 @@ tests.register("Re-maximize disabled", 100, () => {
|
|||||||
() => qtMock.fireShortcut("karousel-focus-right"),
|
() => qtMock.fireShortcut("karousel-focus-right"),
|
||||||
() => qtMock.fireShortcut("karousel-focus-end"),
|
() => qtMock.fireShortcut("karousel-focus-end"),
|
||||||
);
|
);
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Re-maximize enabled", 100, () => {
|
tests.register("Re-maximize enabled", 100, () => {
|
||||||
@@ -159,8 +159,8 @@ tests.register("Re-maximize enabled", 100, () => {
|
|||||||
workspaceMock.createWindow(client1);
|
workspaceMock.createWindow(client1);
|
||||||
workspaceMock.createWindow(client2);
|
workspaceMock.createWindow(client2);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
assert(clientManager.hasClient(client1));
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
assert(clientManager.hasClient(client2));
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
||||||
@@ -168,15 +168,15 @@ tests.register("Re-maximize enabled", 100, () => {
|
|||||||
const column2LeftX = column1LeftX + 300 + config.gapsInnerHorizontal;
|
const column2LeftX = column1LeftX + 300 + config.gapsInnerHorizontal;
|
||||||
const columnTopY = config.gapsOuterTop;
|
const columnTopY = config.gapsOuterTop;
|
||||||
const columnHeight = screenHeight - config.gapsOuterTop - config.gapsOuterBottom;
|
const columnHeight = screenHeight - config.gapsOuterTop - config.gapsOuterBottom;
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => client2.fullScreen = true,
|
() => client2.fullScreen = true,
|
||||||
() => client2.setMaximize(true, true),
|
() => client2.setMaximize(true, true),
|
||||||
);
|
);
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(client2.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => workspaceMock.activeWindow = client1,
|
() => workspaceMock.activeWindow = client1,
|
||||||
@@ -184,8 +184,8 @@ tests.register("Re-maximize enabled", 100, () => {
|
|||||||
() => qtMock.fireShortcut("karousel-focus-left"),
|
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||||
() => qtMock.fireShortcut("karousel-focus-start"),
|
() => qtMock.fireShortcut("karousel-focus-start"),
|
||||||
);
|
);
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => workspaceMock.activeWindow = client2,
|
() => workspaceMock.activeWindow = client2,
|
||||||
@@ -193,6 +193,6 @@ tests.register("Re-maximize enabled", 100, () => {
|
|||||||
() => qtMock.fireShortcut("karousel-focus-right"),
|
() => qtMock.fireShortcut("karousel-focus-right"),
|
||||||
() => qtMock.fireShortcut("karousel-focus-end"),
|
() => qtMock.fireShortcut("karousel-focus-end"),
|
||||||
);
|
);
|
||||||
assertRect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
assertRect(client2.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(client2.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,34 +31,34 @@ tests.register("Pin", 20, () => {
|
|||||||
workspaceMock.createWindow(pinned);
|
workspaceMock.createWindow(pinned);
|
||||||
workspaceMock.createWindow(tiled1);
|
workspaceMock.createWindow(tiled1);
|
||||||
workspaceMock.createWindow(tiled2);
|
workspaceMock.createWindow(tiled2);
|
||||||
assertGrid(config, screenFull, [ [pinned], [tiled1], [tiled2] ]);
|
Assert.grid(config, screenFull, [ [pinned], [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
pinned.pin(screenHalfLeft);
|
pinned.pin(screenHalfLeft);
|
||||||
assertRectEqual(pinned.frameGeometry, screenHalfLeft);
|
Assert.equalRects(pinned.frameGeometry, screenHalfLeft);
|
||||||
assertGrid(config, screenHalfRight, [ [tiled1], [tiled2] ]);
|
Assert.grid(config, screenHalfRight, [ [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
pinned.pin(screenHalfRight);
|
pinned.pin(screenHalfRight);
|
||||||
assertRectEqual(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||||
assertGrid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
Assert.grid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
pinned.unpin();
|
pinned.unpin();
|
||||||
assertRectEqual(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||||
assertGrid(config, screenFull, [ [tiled1], [tiled2] ]);
|
Assert.grid(config, screenFull, [ [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
pinned.pin(screenHalfRight);
|
pinned.pin(screenHalfRight);
|
||||||
assertRectEqual(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||||
assertGrid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
Assert.grid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
pinned.minimized = true;
|
pinned.minimized = true;
|
||||||
assertGrid(config, screenFull, [ [tiled1], [tiled2] ]);
|
Assert.grid(config, screenFull, [ [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
pinned.minimized = false;
|
pinned.minimized = false;
|
||||||
assertRectEqual(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
||||||
assertGrid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
Assert.grid(config, screenHalfLeft, [ [tiled1], [tiled2] ]);
|
||||||
|
|
||||||
workspaceMock.activeWindow = pinned;
|
workspaceMock.activeWindow = pinned;
|
||||||
qtMock.fireShortcut("karousel-window-toggle-floating");
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
assert(pinned.tile === null);
|
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.
|
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.
|
||||||
assertGrid(config, screenFull, [ [tiled1], [tiled2], [pinned] ]);
|
Assert.grid(config, screenFull, [ [tiled1], [tiled2], [pinned] ]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,16 +23,16 @@ tests.register("Preset Widths default", 1, () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workspaceMock.createWindow(kwinClient);
|
workspaceMock.createWindow(kwinClient);
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(300));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(300));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(maxWidth));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(halfWidth));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(maxWidth));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth));
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Preset Widths custom", 1, () => {
|
tests.register("Preset Widths custom", 1, () => {
|
||||||
@@ -61,20 +61,20 @@ tests.register("Preset Widths custom", 1, () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workspaceMock.createWindow(kwinClient);
|
workspaceMock.createWindow(kwinClient);
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(300));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(300));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(250));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(250));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(100));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(100));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(500));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(500));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(halfWidth));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
assertRectEqual(kwinClient.frameGeometry, getRect(250));
|
Assert.equalRects(kwinClient.frameGeometry, getRect(250));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ tests.register("PresetWidths", 1, () => {
|
|||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
try {
|
try {
|
||||||
const presetWidths = new PresetWidths(testCase.str, spacing);
|
const presetWidths = new PresetWidths(testCase.str, spacing);
|
||||||
assert(!testCase.error);
|
Assert.assert(!testCase.error);
|
||||||
|
|
||||||
const result = presetWidths.get(minWidth, maxWidth);
|
const result = presetWidths.get(minWidth, maxWidth);
|
||||||
assertArrayEqual(result, testCase.result!);
|
Assert.equalArrays(result, testCase.result!);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assert(testCase.error === true);
|
Assert.assert(testCase.error === true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ tests.register("WindowRuleEnforcer", 1, () => {
|
|||||||
const enforcer = new WindowRuleEnforcer(JSON.parse(defaultWindowRules));
|
const enforcer = new WindowRuleEnforcer(JSON.parse(defaultWindowRules));
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
const kwinClient: any = createKwinClient(testCase.tiledByDefault, testCase.resourceClass, testCase.caption);
|
const kwinClient: any = createKwinClient(testCase.tiledByDefault, testCase.resourceClass, testCase.caption);
|
||||||
assert(enforcer.shouldTile(kwinClient) === testCase.shouldTile, "failed case: " + JSON.stringify(testCase));
|
Assert.assert(enforcer.shouldTile(kwinClient) === testCase.shouldTile, "failed case: " + JSON.stringify(testCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createKwinClient(normalWindow: boolean, resourceClass: string, caption: string) {
|
function createKwinClient(normalWindow: boolean, resourceClass: string, caption: string) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ tests.register("Clients.canTileEver", 1, () => {
|
|||||||
|
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
const kwinClient: any = createKwinClient(testCase.clientProperties);
|
const kwinClient: any = createKwinClient(testCase.clientProperties);
|
||||||
assert(Clients.canTileEver(kwinClient) === testCase.tileable, "failed case: " + JSON.stringify(testCase));
|
Assert.assert(Clients.canTileEver(kwinClient) === testCase.tileable, "failed case: " + JSON.stringify(testCase));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createKwinClient(properties: { resourceClass: string, caption: string }) {
|
function createKwinClient(properties: { resourceClass: string, caption: string }) {
|
||||||
|
|||||||
@@ -1,84 +1,86 @@
|
|||||||
function assert(assertion: boolean, message?: string, skip: number = 0) {
|
namespace Assert {
|
||||||
if (assertion) {
|
export function assert(assertion: boolean, message?: string, skip: number = 0) {
|
||||||
return;
|
if (assertion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message != undefined) {
|
||||||
|
console.assert(assertion, message);
|
||||||
|
} else {
|
||||||
|
console.assert(assertion);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(getStackTrace(skip+1));
|
||||||
|
|
||||||
|
console.log("Random branches:");
|
||||||
|
for (const message of runLog) {
|
||||||
|
console.log(" " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message != undefined) {
|
function getStackTrace(skip: number) {
|
||||||
console.assert(assertion, message);
|
return new Error().stack!.split("\n").slice(skip+2).join("\n");
|
||||||
} else {
|
|
||||||
console.assert(assertion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(getStackTrace(skip+1));
|
function buildMessage(actual: any, expected: any, header: string, message?: string) {
|
||||||
|
return `${header}
|
||||||
console.log("Random branches:");
|
Expected: ${expected}
|
||||||
for (const message of runLog) {
|
Actual: ${actual}` + (message === undefined ? "" : `
|
||||||
console.log(" " + message);
|
Message: ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.exit(1);
|
export function equal(actual: any, expected: any, skip: number = 0) {
|
||||||
}
|
assert(
|
||||||
|
expected == actual,
|
||||||
function getStackTrace(skip: number) {
|
buildMessage(actual, expected, "Values not equal"),
|
||||||
return new Error().stack!.split("\n").slice(skip+2).join("\n");
|
skip+1
|
||||||
}
|
|
||||||
|
|
||||||
function buildMessage(actual: any, expected: any, header: string, message?: string) {
|
|
||||||
return `${header}
|
|
||||||
Expected: ${expected}
|
|
||||||
Actual: ${actual}` + (message === undefined ? "" : `
|
|
||||||
Message: ${message}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertEqual(actual: any, expected: any, skip: number = 0) {
|
|
||||||
assert(
|
|
||||||
expected == actual,
|
|
||||||
buildMessage(actual, expected, "Values not equal"),
|
|
||||||
skip+1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertArrayEqual(actual: any[], expected: any[], skip: number = 0) {
|
|
||||||
assert(
|
|
||||||
actual.length === expected.length && actual.every((item, index) => item === expected[index]),
|
|
||||||
buildMessage(actual, expected, "Arrays not equal"),
|
|
||||||
skip+1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertRectEqual(actual: QmlRect, expected: QmlRect, skip: number = 0) {
|
|
||||||
assert(
|
|
||||||
rectEquals(expected, actual),
|
|
||||||
buildMessage(actual, expected, "QmlRect not equal"),
|
|
||||||
skip+1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertRect(actual: QmlRect, x: number, y: number, width: number, height: number, skip: number = 0) {
|
|
||||||
assertRectEqual(actual, new MockQmlRect(x, y, width, height), skip+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertGrid(config: Config, screen: QmlRect, grid: KwinClient[][], skip: number = 0) {
|
|
||||||
// assumes uniformly sized windows within columns of width 100
|
|
||||||
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 windowHeight = (columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows;
|
|
||||||
return new MockQmlRect(
|
|
||||||
screen.x + column * (100 + config.gapsInnerHorizontal) + (screen.width-columnsWidth) / 2,
|
|
||||||
screen.y + config.gapsOuterTop + (windowHeight + config.gapsInnerVertical) * window,
|
|
||||||
100,
|
|
||||||
(columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nColumns = grid.length;
|
export function equalArrays(actual: any[], expected: any[], skip: number = 0) {
|
||||||
for (let iColumn = 0; iColumn < nColumns; iColumn++) {
|
assert(
|
||||||
const column = grid[iColumn];
|
actual.length === expected.length && actual.every((item, index) => item === expected[index]),
|
||||||
const nWindows = column.length;
|
buildMessage(actual, expected, "Arrays not equal"),
|
||||||
for (let iWindow = 0; iWindow < nWindows; iWindow++) {
|
skip+1
|
||||||
const window = column[iWindow];
|
);
|
||||||
assertRectEqual(window.frameGeometry, getRectInGrid(iColumn, iWindow, nColumns, nWindows), skip+1);
|
}
|
||||||
|
|
||||||
|
export function equalRects(actual: QmlRect, expected: QmlRect, skip: number = 0) {
|
||||||
|
assert(
|
||||||
|
rectEquals(expected, actual),
|
||||||
|
buildMessage(actual, expected, "QmlRect not equal"),
|
||||||
|
skip+1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rect(actual: QmlRect, x: number, y: number, width: number, height: number, skip: number = 0) {
|
||||||
|
equalRects(actual, new MockQmlRect(x, y, width, height), skip+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function grid(config: Config, screen: QmlRect, grid: KwinClient[][], skip: number = 0) {
|
||||||
|
// assumes uniformly sized windows within columns of width 100
|
||||||
|
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 windowHeight = (columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows;
|
||||||
|
return new MockQmlRect(
|
||||||
|
screen.x + column * (100 + config.gapsInnerHorizontal) + (screen.width-columnsWidth) / 2,
|
||||||
|
screen.y + config.gapsOuterTop + (windowHeight + config.gapsInnerVertical) * window,
|
||||||
|
100,
|
||||||
|
(columnHeight - config.gapsInnerVertical * (nWindows-1)) / nWindows,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const nColumns = grid.length;
|
||||||
|
for (let iColumn = 0; iColumn < nColumns; iColumn++) {
|
||||||
|
const column = grid[iColumn];
|
||||||
|
const nWindows = column.length;
|
||||||
|
for (let iWindow = 0; iWindow < nWindows; iWindow++) {
|
||||||
|
const window = column[iWindow];
|
||||||
|
equalRects(window.frameGeometry, getRectInGrid(iColumn, iWindow, nColumns, nWindows), skip+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class MockQt {
|
|||||||
public fireShortcut(shortcutName: string) {
|
public fireShortcut(shortcutName: string) {
|
||||||
const shortcutHandler = this.shortcuts.get(shortcutName);
|
const shortcutHandler = this.shortcuts.get(shortcutName);
|
||||||
if (shortcutHandler === undefined) {
|
if (shortcutHandler === undefined) {
|
||||||
assert(false);
|
Assert.assert(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shortcutHandler.activated.fire();
|
shortcutHandler.activated.fire();
|
||||||
@@ -36,7 +36,7 @@ class MockQt {
|
|||||||
private static extractShortcutName(qml: string) {
|
private static extractShortcutName(qml: string) {
|
||||||
const nameLine = qml.split("\n").find((line) => line.trimStart().startsWith("name:"));
|
const nameLine = qml.split("\n").find((line) => line.trimStart().startsWith("name:"));
|
||||||
if (nameLine === undefined) {
|
if (nameLine === undefined) {
|
||||||
assert(false);
|
Assert.assert(false);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return nameLine.substring(
|
return nameLine.substring(
|
||||||
|
|||||||
Reference in New Issue
Block a user