2010-04-16 14:52:31 +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)
|
|
|
|
#
|
2010-04-16 14:52:31 +02:00
|
|
|
# Tests whether opening an empty container and killing it again works
|
|
|
|
#
|
2010-07-03 15:29:44 +02:00
|
|
|
use List::Util qw(first);
|
2011-03-09 20:25:17 +01:00
|
|
|
use i3test;
|
2010-04-16 14:52:31 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
my $tmp = fresh_workspace;
|
2010-04-16 14:52:31 +02:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
|
|
|
|
|
|
|
# Open a new container
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd 'open';
|
2010-04-16 14:52:31 +02:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 1, 'container opened');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd 'kill';
|
2010-04-16 14:52:31 +02:00
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'container killed');
|
|
|
|
|
2010-04-16 15:30:07 +02: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 20:25:17 +01:00
|
|
|
cmd 'open';
|
|
|
|
cmd 'open';
|
2010-04-16 15:30:07 +02:00
|
|
|
ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
|
|
|
|
|
|
|
|
my $content = get_ws_content($tmp);
|
2010-07-03 15:29:44 +02:00
|
|
|
my $not_focused = first { !$_->{focused} } @{$content};
|
|
|
|
my $id = $not_focused->{id};
|
2010-04-16 15:30:07 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "[con_id=\"$id\"] kill";
|
2010-04-16 15:30:07 +02:00
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'one container killed');
|
|
|
|
ok($content->[0]->{id} != $id, 'correct window killed');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
done_testing;
|