tests: Assert: rename function to truth
This commit is contained in:
@@ -28,11 +28,11 @@ 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.assert(clientManager.hasClient(client1));
|
Assert.truth(clientManager.hasClient(client1));
|
||||||
Assert.assert(clientManager.hasClient(client2));
|
Assert.truth(clientManager.hasClient(client2));
|
||||||
Assert.assert(clientManager.hasClient(client3));
|
Assert.truth(clientManager.hasClient(client3));
|
||||||
});
|
});
|
||||||
Assert.assert(workspaceMock.activeWindow === client3);
|
Assert.truth(workspaceMock.activeWindow === client3);
|
||||||
|
|
||||||
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
||||||
qtMock.fireShortcut(shortcutName);
|
qtMock.fireShortcut(shortcutName);
|
||||||
@@ -42,7 +42,7 @@ tests.register("Focus and move windows", 1, () => {
|
|||||||
|
|
||||||
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
||||||
qtMock.fireShortcut(shortcutName);
|
qtMock.fireShortcut(shortcutName);
|
||||||
Assert.assert(workspaceMock.activeWindow === expectedFocus, {
|
Assert.truth(workspaceMock.activeWindow === expectedFocus, {
|
||||||
message: `wrong activeWindow: ${workspaceMock.activeWindow?.pid}`,
|
message: `wrong activeWindow: ${workspaceMock.activeWindow?.pid}`,
|
||||||
skip: 1,
|
skip: 1,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ tests.register("Maximization", 100, () => {
|
|||||||
|
|
||||||
workspaceMock.createWindow(kwinClient);
|
workspaceMock.createWindow(kwinClient);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
Assert.assert(clientManager.hasClient(kwinClient));
|
Assert.truth(clientManager.hasClient(kwinClient));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnLeftX = screenWidth/2 - 300/2;
|
const columnLeftX = screenWidth/2 - 300/2;
|
||||||
@@ -58,7 +58,7 @@ tests.register("Maximize with transient", 100, () => {
|
|||||||
|
|
||||||
workspaceMock.createWindow(parent);
|
workspaceMock.createWindow(parent);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
Assert.assert(clientManager.hasClient(parent));
|
Assert.truth(clientManager.hasClient(parent));
|
||||||
});
|
});
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
@@ -69,7 +69,7 @@ tests.register("Maximize with transient", 100, () => {
|
|||||||
|
|
||||||
workspaceMock.createWindow(child);
|
workspaceMock.createWindow(child);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
Assert.assert(clientManager.hasClient(child));
|
Assert.truth(clientManager.hasClient(child));
|
||||||
});
|
});
|
||||||
Assert.rect(child.frameGeometry, 14, 24, 50, 50);
|
Assert.rect(child.frameGeometry, 14, 24, 50, 50);
|
||||||
Assert.rect(parent.frameGeometry, 0, 0, screenWidth, screenHeight);
|
Assert.rect(parent.frameGeometry, 0, 0, screenWidth, screenHeight);
|
||||||
@@ -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.assert(clientManager.hasClient(client1));
|
Assert.truth(clientManager.hasClient(client1));
|
||||||
Assert.assert(clientManager.hasClient(client2));
|
Assert.truth(clientManager.hasClient(client2));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
||||||
@@ -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.assert(clientManager.hasClient(client1));
|
Assert.truth(clientManager.hasClient(client1));
|
||||||
Assert.assert(clientManager.hasClient(client2));
|
Assert.truth(clientManager.hasClient(client2));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ tests.register("Pin", 20, () => {
|
|||||||
|
|
||||||
workspaceMock.activeWindow = pinned;
|
workspaceMock.activeWindow = pinned;
|
||||||
qtMock.fireShortcut("karousel-window-toggle-floating");
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
Assert.assert(pinned.tile === null);
|
Assert.truth(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.
|
||||||
Assert.grid(config, screenFull, [ [tiled1], [tiled2], [pinned] ]);
|
Assert.grid(config, screenFull, [ [tiled1], [tiled2], [pinned] ]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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.assert(!testCase.error);
|
Assert.truth(!testCase.error);
|
||||||
|
|
||||||
const result = presetWidths.get(minWidth, maxWidth);
|
const result = presetWidths.get(minWidth, maxWidth);
|
||||||
Assert.equalArrays(result, testCase.result!);
|
Assert.equalArrays(result, testCase.result!);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Assert.assert(testCase.error === true);
|
Assert.truth(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.assert(
|
Assert.truth(
|
||||||
enforcer.shouldTile(kwinClient) === testCase.shouldTile,
|
enforcer.shouldTile(kwinClient) === testCase.shouldTile,
|
||||||
{ message: "failed case: " + JSON.stringify(testCase) },
|
{ message: "failed case: " + JSON.stringify(testCase) },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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.assert(
|
Assert.truth(
|
||||||
Clients.canTileEver(kwinClient) === testCase.tileable,
|
Clients.canTileEver(kwinClient) === testCase.tileable,
|
||||||
{ message: "failed case: " + JSON.stringify(testCase) },
|
{ message: "failed case: " + JSON.stringify(testCase) },
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace Assert {
|
|||||||
skip?: number,
|
skip?: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function assert(
|
export function truth(
|
||||||
assertion: boolean,
|
assertion: boolean,
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
@@ -44,7 +44,7 @@ namespace Assert {
|
|||||||
expected: any,
|
expected: any,
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
assert(
|
truth(
|
||||||
expected == actual,
|
expected == actual,
|
||||||
{
|
{
|
||||||
message: buildMessage(actual, expected, "Values not equal", message),
|
message: buildMessage(actual, expected, "Values not equal", message),
|
||||||
@@ -58,7 +58,7 @@ namespace Assert {
|
|||||||
expected: any[],
|
expected: any[],
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
assert(
|
truth(
|
||||||
actual.length === expected.length && actual.every((item, index) => item === expected[index]),
|
actual.length === expected.length && actual.every((item, index) => item === expected[index]),
|
||||||
{
|
{
|
||||||
message: buildMessage(actual, expected, "Arrays not equal", message),
|
message: buildMessage(actual, expected, "Arrays not equal", message),
|
||||||
@@ -72,7 +72,7 @@ namespace Assert {
|
|||||||
expected: QmlRect,
|
expected: QmlRect,
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
assert(
|
truth(
|
||||||
rectEquals(expected, actual),
|
rectEquals(expected, actual),
|
||||||
{
|
{
|
||||||
message: buildMessage(actual, expected, "QmlRect not equal", message),
|
message: buildMessage(actual, expected, "QmlRect not equal", message),
|
||||||
|
|||||||
@@ -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.assert(false);
|
Assert.truth(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.assert(false);
|
Assert.truth(false);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return nameLine.substring(
|
return nameLine.substring(
|
||||||
|
|||||||
Reference in New Issue
Block a user