Skip to content

Commit 0ec537d

Browse files
author
Tony Crisci
committed
test: add resize test
1 parent abd242b commit 0ec537d

File tree

5 files changed

+64
-2
lines changed

5 files changed

+64
-2
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ RUN git clone https://github.com/i3/i3 && \
3131

3232
ADD . /app
3333

34-
CMD ["./run-tests.py"]
34+
#CMD ["bash", "-c", "./run-tests.py ./test/aio/test_window.py"]
35+
CMD ["bash", "-c", "./run-tests.py"]

test/aio/ipctest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ async def command_checked(self, cmd):
5757
result = await i3.command(cmd)
5858

5959
assert type(result) is list
60+
assert result
6061

6162
for r in result:
6263
assert type(r) is CommandReply
63-
assert r.success is True
64+
assert r.success is True, r.error
6465

6566
return result
6667

test/aio/test_window.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,31 @@ async def test_marks(self, i3):
7272
await i3.command('mark foo')
7373
tree = await i3.get_tree()
7474
assert 'foo' in tree.find_focused().marks
75+
76+
@pytest.mark.asyncio
77+
async def test_resize(self, i3):
78+
79+
ws1 = await self.fresh_workspace()
80+
win = self.open_window()
81+
await self.command_checked(f'[id="{win}"] floating enable')
82+
83+
# XXX: uncomment and it will fail
84+
# ws2 = await self.fresh_workspace()
85+
86+
def height_width(c):
87+
return c.rect.height + c.deco_rect.height, c.rect.width
88+
89+
async def do_resize(h, w):
90+
result = await self.command_checked(f'[id="{win}"] resize set {w}px {h}px')
91+
92+
size1 = 200, 250
93+
size2 = 350, 300
94+
95+
await do_resize(*size1)
96+
con = (await i3.get_tree()).find_by_window(win)
97+
98+
await do_resize(*size2)
99+
con2 = (await i3.get_tree()).find_by_window(win)
100+
101+
assert height_width(con) == size1
102+
assert height_width(con2) == size2

test/ipctest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from subprocess import Popen
22
import pytest
33
import i3ipc
4+
from i3ipc import CommandReply
45
import math
56
from random import random
67
import time
@@ -58,3 +59,17 @@ def fresh_workspace(self):
5859
if not any(w for w in workspaces if w.name == new_name):
5960
i3.command('workspace %s' % new_name)
6061
return new_name
62+
63+
def command_checked(self, cmd):
64+
i3 = IpcTest.i3_conn
65+
assert i3
66+
67+
result = i3.command(cmd)
68+
69+
assert type(result) is list
70+
71+
for r in result:
72+
assert type(r) is CommandReply
73+
assert r.success is True
74+
75+
return result

test/test_window.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,20 @@ def on_window(i3, e):
6060
assert len(events)
6161
for e in events:
6262
assert e.change == 'focus'
63+
64+
def test_resize(self, i3):
65+
self.fresh_workspace()
66+
self.open_window()
67+
i3.command('floating enable')
68+
69+
self.command_checked('resize set height 200 px; resize set width 250 px')
70+
con = i3.get_tree().find_focused()
71+
72+
self.command_checked('resize set width 300 px; resize set height 350 px')
73+
con2 = i3.get_tree().find_focused()
74+
75+
def height_width(c):
76+
return (c.rect.height + c.deco_rect.height, c.rect.width)
77+
78+
assert height_width(con) == (200, 250)
79+
assert height_width(con2) == (350, 300)

0 commit comments

Comments
 (0)