aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/164-kill-win-vs-client.t
blob: fe3fd011cda147456c043a36ee4541644ee9d1ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
#   (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
#   (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
#   (or docs/ipc)
#
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
#   (unless you are already familiar with Perl)
#
# Tests if WM_STATE is WM_STATE_NORMAL when mapped and WM_STATE_WITHDRAWN when
# unmapped.
#
use i3test;

sub two_windows {
    my $tmp = fresh_workspace;

    ok(@{get_ws_content($tmp)} == 0, 'no containers yet');

    my $first = open_window;
    my $second = open_window;

    is($x->input_focus, $second->id, 'second window focused');
    ok(@{get_ws_content($tmp)} == 2, 'two containers opened');

    return $tmp;
}

##############################################################
# 1: open two windows (in the same client), kill one and see if
# the other one is still there
##############################################################

my $tmp = two_windows;

cmd 'kill';
sync_with_i3;

ok(@{get_ws_content($tmp)} == 1, 'one container left after killing');

##############################################################
# 2: same test case as test 1, but with the explicit variant
# 'kill window'
##############################################################

$tmp = two_windows;

cmd 'kill window';
sync_with_i3;

ok(@{get_ws_content($tmp)} == 1, 'one container left after killing');

##############################################################
# 3: open two windows (in the same client), use 'kill client'
# and check if both are gone
##############################################################

$tmp = two_windows;

cmd 'kill client';
# We need to re-establish the X11 connection which we just killed :).
$x = i3test::X11->new;
sync_with_i3(no_cache => 1);

ok(@{get_ws_content($tmp)} == 0, 'no containers left after killing');

done_testing;