-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regression: handle change type correctly
fixes #126
- Loading branch information
Tony Crisci
committed
Sep 1, 2019
1 parent
674e33c
commit acb1eb5
Showing
4 changed files
with
118 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,62 @@ | ||
from i3ipc import Event | ||
|
||
import time | ||
from ipctest import IpcTest | ||
from threading import Timer | ||
|
||
|
||
class TestWindow(IpcTest): | ||
event = None | ||
def test_window_event(self, i3): | ||
event = None | ||
|
||
def on_window(self, i3, e): | ||
TestWindow.event = e | ||
i3.main_quit() | ||
def on_window(i3, e): | ||
nonlocal event | ||
event = e | ||
i3.main_quit() | ||
|
||
def test_window_event(self, i3): | ||
self.fresh_workspace() | ||
i3.get_workspaces() | ||
i3.on('window', self.on_window) | ||
Timer(0.1, self.open_window).start() | ||
i3.on('window', on_window) | ||
Timer(0.001, self.open_window).start() | ||
i3.main(timeout=2) | ||
assert self.event is not None | ||
|
||
assert event is not None | ||
i3.off(on_window) | ||
|
||
def test_marks(self, i3): | ||
self.fresh_workspace() | ||
self.open_window() | ||
i3.command('mark foo') | ||
assert 'foo' in i3.get_tree().find_focused().marks | ||
|
||
def test_detailed_window_event(self, i3): | ||
events = [] | ||
|
||
def generate_events(): | ||
win1 = self.open_window() | ||
win2 = self.open_window() | ||
i3.command(f'[id={win1}] kill; [id={win2}] kill') | ||
# TODO sync protocol | ||
time.sleep(0.01) | ||
i3.main_quit() | ||
|
||
def on_window(i3, e): | ||
nonlocal events | ||
events.append(e) | ||
|
||
i3.on(Event.WINDOW_NEW, on_window) | ||
Timer(0.001, generate_events).start() | ||
i3.main(timeout=2) | ||
|
||
assert len(events) | ||
for e in events: | ||
assert e.change == 'new' | ||
|
||
events.clear() | ||
i3.off(on_window) | ||
|
||
i3.on(Event.WINDOW_FOCUS, on_window) | ||
Timer(0.001, generate_events).start() | ||
i3.main(timeout=2) | ||
|
||
assert len(events) | ||
for e in events: | ||
assert e.change == 'focus' |