2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
19 my $i3 = i3(get_socket_path());
22 ################################
23 # Workspaces requests and events
24 ################################
26 my $old_ws = get_ws(focused_ws());
30 # We are switching to an empty workpspace from an empty workspace, so we expect
31 # to receive "init", "focus", and "empty".
32 my $init = AnyEvent->condvar;
33 my $focus = AnyEvent->condvar;
34 my $empty = AnyEvent->condvar;
38 if ($event->{change} eq 'init') {
40 } elsif ($event->{change} eq 'focus') {
42 } elsif ($event->{change} eq 'empty') {
60 my $init_event = $init->recv;
61 my $focus_event = $focus->recv;
62 my $empty_event = $empty->recv;
64 my $current_ws = get_ws(focused_ws());
66 ok($init_event, 'workspace "init" event received');
67 is($init_event->{current}->{id}, $current_ws->{id}, 'the "current" property should contain the initted workspace con');
69 ok($focus_event, 'workspace "focus" event received');
70 is($focus_event->{current}->{id}, $current_ws->{id}, 'the "current" property should contain the focused workspace con');
71 is($focus_event->{old}->{id}, $old_ws->{id}, 'the "old" property should contain the workspace con that was focused last');
73 ok($empty_event, 'workspace "empty" event received');
74 is($empty_event->{current}->{id}, $old_ws->{id}, 'the "current" property should contain the emptied workspace con');