From 869ea8436d9cf9d5748e6c089cc0b0b58358e75f Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Sat, 26 Sep 2026 22:23:04 +0100 Subject: Align GNOME shortcuts with the Sway setup --- tests/fixtures/workspace-cycle.js | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/fixtures/workspace-cycle.js (limited to 'tests/fixtures') diff --git a/tests/fixtures/workspace-cycle.js b/tests/fixtures/workspace-cycle.js new file mode 100644 index 0000000..13e1bc7 --- /dev/null +++ b/tests/fixtures/workspace-cycle.js @@ -0,0 +1,54 @@ +import assert from "node:assert/strict"; + +const bindings = new Map(); +const Extension = class { + getSettings() { + return {}; + } +}; +const Meta = { KeyBindingFlags: { NONE: 0 } }; +const Shell = { ActionMode: { NORMAL: 1, OVERVIEW: 2 } }; +const Main = { + wm: { + addKeybinding(name, settings, flags, mode, callback) { + assert.equal(mode, 3); + bindings.set(name, callback); + }, + removeKeybinding(name) { + bindings.delete(name); + }, + }, +}; +let active = 0; +let activations = 0; +global.workspace_manager = { + n_workspaces: 3, + get_active_workspace_index: () => active, + get_workspace_by_index: (index) => ({ + activate(time) { + assert.equal(time, 123); + active = index; + activations++; + }, + }), +}; +global.get_current_time = () => 123; + +// EXTENSION + +const extension = new WorkspaceCycle(); +extension.enable(); +bindings.get("previous-workspace")(); +assert.equal(active, 2); +bindings.get("next-workspace")(); +assert.equal(active, 0); +bindings.get("next-workspace")(); +assert.equal(active, 1); +global.workspace_manager.n_workspaces = 1; +extension.cycle(1); +assert.equal(activations, 3); +extension.disable(); +assert.equal(bindings.size, 0); +extension.enable(); +assert.equal(bindings.size, 2); +extension.disable(); -- cgit v1.3.1