From b4e3563dc1478f9b4696653be81d34e628757d9a Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 17 Jul 2010 15:17:33 +0200 Subject: [PATCH] t/29-focus-after-close.t: add more tests (for a regression) --- testcases/t/29-focus-after-close.t | 61 +++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/testcases/t/29-focus-after-close.t b/testcases/t/29-focus-after-close.t index 916f6618..d189ead6 100644 --- a/testcases/t/29-focus-after-close.t +++ b/testcases/t/29-focus-after-close.t @@ -3,7 +3,8 @@ # # Check if the focus is correctly restored after closing windows. # -use i3test tests => 6; +use i3test tests => 9; +use List::Util qw(first); use Time::HiRes qw(sleep); my $i3 = i3("/tmp/nestedcons"); @@ -13,23 +14,18 @@ $i3->command("workspace $tmp")->recv; ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); -$i3->command('open')->recv; -my ($nodes, $focus) = get_ws_content($tmp); -my $first = $focus->[0]; +my $first = open_empty_con($i3); $i3->command('split v')->recv; -($nodes, $focus) = get_ws_content($tmp); +my ($nodes, $focus) = get_ws_content($tmp); is($nodes->[0]->{focused}, 0, 'split container not focused'); $i3->command('level up')->recv; ($nodes, $focus) = get_ws_content($tmp); is($nodes->[0]->{focused}, 1, 'split container focused after level up'); -$i3->command('open')->recv; - -($nodes, $focus) = get_ws_content($tmp); -my $second = $focus->[0]; +my $second = open_empty_con($i3); isnt($first, $second, 'different container focused'); @@ -54,4 +50,51 @@ sleep 0.25; is($nodes->[0]->{nodes}->[0]->{id}, $first, 'first container found'); is($nodes->[0]->{nodes}->[0]->{focused}, 1, 'first container focused'); +############################################################## +# another case, using a slightly different layout (regression) +############################################################## + +$tmp = get_unused_workspace(); +$i3->command("workspace $tmp")->recv; + +ok(@{get_ws_content($tmp)} == 0, 'no containers yet'); + +$i3->command('split v')->recv; +$first = open_empty_con($i3); +my $bottom = open_empty_con($i3); + +$i3->command('prev v')->recv; +$i3->command('split h')->recv; +my $middle = open_empty_con($i3); +my $right = open_empty_con($i3); +$i3->command('next v')->recv; + +# We have the following layout now (second is focused): +# .----------------------------. +# | .------------------------. | +# | | first | middle | right | | +# | `------------------------' | +# |----------------------------| +# | | +# | second | +# | | +# `----------------------------' + +# Check if the focus is restored to $right when we close $second +$i3->command('kill')->recv; + +is(get_focused($tmp), $right, 'top right container focused (in focus stack)'); + +($nodes, $focus) = get_ws_content($tmp); +my $tr = first { $_->{id} eq $right } @{$nodes->[0]->{nodes}}; +is($tr->{focused}, 1, 'top right container really has focus'); + +############################################################## +# and now for something completely different: +# check if the pointer position is relevant when restoring focus +# (it should not be relevant, of course) +############################################################## + +# TODO: add test code as soon as I can reproduce it + diag( "Testing i3, Perl $], $^X" ); -- 2.39.5