miracle-wm/tests/ipc/test_change_workspace.py
Matthew Kosarek e48e3feaf2
feature: workspace switching IPC support (#256)
- Add support for "workspace next/prev/next_on_output/prev_on_output"
- Add support for "workspace back_and_forth"
- Add support for "workspace <name>"
- Add support for "workspace number <name>"
- Integration tests
2024-10-10 23:46:00 +00:00

80 lines
2.2 KiB
Python

from i3ipc import Connection
from time import sleep
class TestChangeWorkspace:
def check_workspace_number(conn, num, index):
root = conn.get_tree()
output = root.nodes[0]
workspace = output.nodes[index]
assert workspace.num == num
def test_change_workspace(self, server):
conn = Connection(server.ipc)
conn.command("workspace 4")
TestChangeWorkspace.check_workspace_number(conn, 4, 0)
def test_next_workspace(self, server):
conn = Connection(server.ipc)
p1 = server.open_app("gedit")
sleep(1)
conn.command("workspace 4")
p2 = server.open_app("gnome-chess")
sleep(1)
conn.command("workspace next")
TestChangeWorkspace.check_workspace_number(conn, 1, 0)
conn.command("workspace next")
TestChangeWorkspace.check_workspace_number(conn, 4, 1)
def test_prev_workspace(self, server):
conn = Connection(server.ipc)
p1 = server.open_app("gedit")
sleep(1)
conn.command("workspace 4")
p2 = server.open_app("gnome-chess")
sleep(1)
conn.command("workspace prev")
TestChangeWorkspace.check_workspace_number(conn, 1, 0)
conn.command("workspace prev")
TestChangeWorkspace.check_workspace_number(conn, 4, 1)
def test_next_workspace_on_output(self, server):
conn = Connection(server.ipc)
p1 = server.open_app("gedit")
sleep(1)
conn.command("workspace 4")
p2 = server.open_app("gnome-chess")
sleep(1)
conn.command("workspace next_on_output")
TestChangeWorkspace.check_workspace_number(conn, 1, 0)
conn.command("workspace next_on_output")
TestChangeWorkspace.check_workspace_number(conn, 4, 1)
def test_prev_workspace_on_output(self, server):
conn = Connection(server.ipc)
p1 = server.open_app("gedit")
sleep(1)
conn.command("workspace 4")
p2 = server.open_app("gnome-chess")
sleep(1)
conn.command("workspace prev_on_output")
TestChangeWorkspace.check_workspace_number(conn, 1, 0)
conn.command("workspace prev_on_output")
TestChangeWorkspace.check_workspace_number(conn, 4, 1)