tests: implement sync_with_i3 and use it instead of sleep()
Also use open_standard_window() in a few more places where appropriate
This commit is contained in:
@ -16,6 +16,8 @@ my $tmp = fresh_workspace;
|
||||
my $first = open_standard_window($x);
|
||||
my $second = open_standard_window($x);
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second window focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
@ -34,12 +36,16 @@ $first = open_standard_window($x); # window 2
|
||||
$second = open_standard_window($x); # window 3
|
||||
my $third = open_standard_window($x); # window 4
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'last container focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
|
||||
cmd '[id="' . $second->id . '"] focus';
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second con focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
@ -47,7 +53,8 @@ cmd 'floating enable';
|
||||
# now kill the third one (it's floating). focus should stay unchanged
|
||||
cmd '[id="' . $third->id . '"] kill';
|
||||
|
||||
sleep 0.25;
|
||||
# TODO: wait for unmapnotify
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second con still focused after killing third');
|
||||
|
||||
@ -63,12 +70,16 @@ $first = open_standard_window($x, '#ff0000'); # window 5
|
||||
$second = open_standard_window($x, '#00ff00'); # window 6
|
||||
my $third = open_standard_window($x, '#0000ff'); # window 7
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'last container focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
|
||||
cmd '[id="' . $second->id . '"] focus';
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second con focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
@ -77,13 +88,14 @@ cmd 'floating enable';
|
||||
# also floating
|
||||
cmd 'kill';
|
||||
|
||||
sleep 0.25;
|
||||
# TODO: wait for unmapnotify
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'third con focused');
|
||||
|
||||
cmd 'kill';
|
||||
|
||||
sleep 0.25;
|
||||
# TODO: wait for unmapnotify
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
||||
|
||||
@ -99,29 +111,34 @@ cmd 'layout stacked';
|
||||
$second = open_standard_window($x, '#00ff00'); # window 6
|
||||
$third = open_standard_window($x, '#0000ff'); # window 7
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'last container focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
|
||||
cmd '[id="' . $second->id . '"] focus';
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second con focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
|
||||
sleep 0.5;
|
||||
sync_with_i3($x);
|
||||
|
||||
# now kill the second one. focus should fall back to the third one, which is
|
||||
# also floating
|
||||
cmd 'kill';
|
||||
|
||||
sleep 0.25;
|
||||
# TODO: wait for unmapnotify
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'second con focused');
|
||||
is($x->input_focus, $third->id, 'third con focused');
|
||||
|
||||
cmd 'kill';
|
||||
|
||||
sleep 0.25;
|
||||
# TODO: wait for unmapnotify
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
||||
|
||||
@ -134,6 +151,8 @@ $tmp = fresh_workspace;
|
||||
$first = open_standard_window($x, '#ff0000'); # window 8
|
||||
$second = open_standard_window($x, '#00ff00'); # window 9
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second container focused');
|
||||
|
||||
cmd 'floating enable';
|
||||
@ -142,31 +161,31 @@ is($x->input_focus, $second->id, 'second container focused');
|
||||
|
||||
cmd 'focus tiling';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
||||
|
||||
cmd 'focus floating';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second (floating) container focused');
|
||||
|
||||
cmd 'focus floating';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second (floating) container still focused');
|
||||
|
||||
cmd 'focus mode_toggle';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
||||
|
||||
cmd 'focus mode_toggle';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second (floating) container focused');
|
||||
|
||||
@ -180,35 +199,37 @@ $first = open_standard_window($x, '#ff0000', 1); # window 10
|
||||
$second = open_standard_window($x, '#00ff00', 1); # window 11
|
||||
$third = open_standard_window($x, '#0000ff', 1); # window 12
|
||||
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'third container focused');
|
||||
|
||||
cmd 'focus left';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'second container focused');
|
||||
|
||||
cmd 'focus left';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $first->id, 'first container focused');
|
||||
|
||||
cmd 'focus left';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $third->id, 'focus wrapped to third container');
|
||||
|
||||
cmd 'focus right';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $first->id, 'focus wrapped to first container');
|
||||
|
||||
cmd 'focus right';
|
||||
|
||||
sleep 0.25;
|
||||
sync_with_i3($x);
|
||||
|
||||
is($x->input_focus, $second->id, 'focus on second container');
|
||||
|
||||
|
Reference in New Issue
Block a user