2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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)
17 # Checks the workspace "empty" event semantics.
21 ################################################################################
22 # check that the workspace empty event is sent upon workspace switch when the
23 # old workspace is empty
24 ################################################################################
25 subtest 'Workspace empty event upon switch', sub {
26 my $ws2 = fresh_workspace;
27 my $w2 = open_window();
28 my $ws1 = fresh_workspace;
29 my $w1 = open_window();
31 cmd '[id="' . $w1->id . '"] kill';
33 my $cond = AnyEvent->condvar;
34 my @events = events_for(
35 sub { cmd "workspace $ws2" },
38 is(scalar @events, 2, 'Received 2 event');
39 is($events[1]->{change}, 'empty', '"Empty" event received upon workspace switch');
40 is($events[1]->{current}->{name}, $ws1, '"current" property should be set to the workspace con');
43 ################################################################################
44 # check that no workspace empty event is sent upon workspace switch if the
45 # workspace is not empty
46 ################################################################################
47 subtest 'No workspace empty event', sub {
48 my $ws2 = fresh_workspace;
49 my $w2 = open_window();
50 my $ws1 = fresh_workspace;
51 my $w1 = open_window();
53 my @events = events_for(
54 sub { cmd "workspace $ws2" },
57 is(scalar @events, 1, 'Received 1 event');
58 is($events[0]->{change}, 'focus', 'Event change is "focus"');
61 ################################################################################
62 # check that workspace empty event is sent when the last window has been closed
63 # on invisible workspace
64 ################################################################################
65 subtest 'Workspace empty event upon window close', sub {
66 my $ws1 = fresh_workspace;
67 my $w1 = open_window();
68 my $ws2 = fresh_workspace;
69 my $w2 = open_window();
71 my @events = events_for(
78 is(scalar @events, 1, 'Received 1 event');
79 is($events[0]->{change}, 'empty', '"Empty" event received upon window close');
80 is($events[0]->{current}->{name}, $ws1, '"current" property should be set to the workspace con');