2010-04-16 08:52:31 -04:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
2012-09-10 08:09:01 -04:00
|
|
|
# Please read the following documents before working on tests:
|
|
|
|
# • http://build.i3wm.org/docs/testsuite.html
|
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
|
|
|
# • http://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)
|
|
|
|
#
|
2010-04-16 08:52:31 -04:00
|
|
|
# Tests whether opening an empty container and killing it again works
|
|
|
|
#
|
2010-07-03 09:29:44 -04:00
|
|
|
use List::Util qw(first);
|
2011-03-09 14:25:17 -05:00
|
|
|
use i3test;
|
2010-04-16 08:52:31 -04:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
my $tmp = fresh_workspace;
|
2010-04-16 08:52:31 -04:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
|
|
|
|
|
|
|
# Open a new container
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd 'open';
|
2010-04-16 08:52:31 -04:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 1, 'container opened');
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd 'kill';
|
2010-04-16 08:52:31 -04:00
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'container killed');
|
|
|
|
|
2010-04-16 09:30:07 -04:00
|
|
|
##############################################################
|
|
|
|
# open two containers and kill the one which is not focused
|
|
|
|
# by its ID to test if the parser correctly matches the window
|
|
|
|
##############################################################
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd 'open';
|
|
|
|
cmd 'open';
|
2010-04-16 09:30:07 -04:00
|
|
|
ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
|
|
|
|
|
|
|
|
my $content = get_ws_content($tmp);
|
2010-07-03 09:29:44 -04:00
|
|
|
my $not_focused = first { !$_->{focused} } @{$content};
|
|
|
|
my $id = $not_focused->{id};
|
2010-04-16 09:30:07 -04:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
cmd "[con_id=\"$id\"] kill";
|
2010-04-16 09:30:07 -04:00
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'one container killed');
|
|
|
|
ok($content->[0]->{id} != $id, 'correct window killed');
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
done_testing;
|