]> git.sur5r.net Git - i3/i3/blob - testcases/t/164-kill-win-vs-client.t
Merge pull request #3475 from Gravemind/fix-i3bar-re-hidden-on-any-modifier
[i3/i3] / testcases / t / 164-kill-win-vs-client.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 # Tests if WM_STATE is WM_STATE_NORMAL when mapped and WM_STATE_WITHDRAWN when
18 # unmapped.
19 #
20 use i3test;
21
22 sub two_windows {
23     my $tmp = fresh_workspace;
24
25     ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
26
27     my $first = open_window;
28     my $second = open_window;
29
30     is($x->input_focus, $second->id, 'second window focused');
31     ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
32
33     return $tmp;
34 }
35
36 ##############################################################
37 # 1: open two windows (in the same client), kill one and see if
38 # the other one is still there
39 ##############################################################
40
41 my $tmp = two_windows;
42
43 cmd 'kill';
44 sync_with_i3;
45
46 ok(@{get_ws_content($tmp)} == 1, 'one container left after killing');
47
48 ##############################################################
49 # 2: same test case as test 1, but with the explicit variant
50 # 'kill window'
51 ##############################################################
52
53 $tmp = two_windows;
54
55 cmd 'kill window';
56 sync_with_i3;
57
58 ok(@{get_ws_content($tmp)} == 1, 'one container left after killing');
59
60 ##############################################################
61 # 3: open two windows (in the same client), use 'kill client'
62 # and check if both are gone
63 ##############################################################
64
65 $tmp = two_windows;
66
67 cmd 'kill client';
68 # We need to re-establish the X11 connection which we just killed :).
69 $x = i3test::X11->new;
70 sync_with_i3(no_cache => 1);
71
72 ok(@{get_ws_content($tmp)} == 0, 'no containers left after killing');
73
74 done_testing;