]> git.sur5r.net Git - i3/i3/blob - testcases/t/115-ipc-workspaces.t
Update ewmh focused only when new focus is different (#3496)
[i3/i3] / testcases / t / 115-ipc-workspaces.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16
17 use i3test;
18
19 my $old_ws = get_ws(focused_ws());
20
21 # We are switching to an empty workpspace from an empty workspace, so we expect
22 # to receive "init", "focus", and "empty".
23 my @events = events_for(
24     sub { cmd 'workspace 2' },
25     'workspace');
26
27 my $current_ws = get_ws(focused_ws());
28
29 is(scalar @events, 3, 'Received 3 events');
30 is($events[0]->{change}, 'init', 'First event has change = init');
31 is($events[0]->{current}->{id}, $current_ws->{id}, 'the "current" property contains the initted workspace con');
32
33 is($events[1]->{change}, 'focus', 'Second event has change = focus');
34 is($events[1]->{current}->{id}, $current_ws->{id}, 'the "current" property should contain the focused workspace con');
35 is($events[1]->{old}->{id}, $old_ws->{id}, 'the "old" property should contain the workspace con that was focused last');
36
37 is($events[2]->{change}, 'empty', 'Third event has change = empty');
38 is($events[2]->{current}->{id}, $old_ws->{id}, 'the "current" property should contain the emptied workspace con');
39
40 done_testing;