2011-05-13 20:41:03 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
2012-09-10 14:09:01 +02:00
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
2011-05-13 20:41:03 +02:00
|
|
|
# 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');
|
|
|
|
|
2011-11-22 00:47:32 +01:00
|
|
|
my $first = open_window;
|
|
|
|
my $second = open_window;
|
2011-05-13 20:41:03 +02:00
|
|
|
|
|
|
|
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';
|
2012-02-21 14:28:37 +01:00
|
|
|
sync_with_i3;
|
2011-05-13 20:41:03 +02:00
|
|
|
|
|
|
|
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'
|
|
|
|
##############################################################
|
|
|
|
|
2011-11-21 21:04:00 +01:00
|
|
|
$tmp = two_windows;
|
2011-05-13 20:41:03 +02:00
|
|
|
|
|
|
|
cmd 'kill window';
|
2012-02-21 14:28:37 +01:00
|
|
|
sync_with_i3;
|
2011-05-13 20:41:03 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
##############################################################
|
|
|
|
|
2011-11-21 21:04:00 +01:00
|
|
|
$tmp = two_windows;
|
2011-05-13 20:41:03 +02:00
|
|
|
|
|
|
|
cmd 'kill client';
|
2012-02-21 14:28:37 +01:00
|
|
|
# We need to re-establish the X11 connection which we just killed :).
|
|
|
|
$x = i3test::X11->new;
|
|
|
|
sync_with_i3(no_cache => 1);
|
2011-05-13 20:41:03 +02:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers left after killing');
|
|
|
|
|
|
|
|
done_testing;
|