tests: Extract focused_output in library
This commit is contained in:
@ -31,13 +31,6 @@ my $i3 = i3(get_socket_path());
|
||||
# use 'focus output' and verify that focus gets changed appropriately
|
||||
################################################################################
|
||||
|
||||
sub focused_output {
|
||||
my $tree = $i3->get_tree->recv;
|
||||
my $focused = $tree->{focus}->[0];
|
||||
my $output = first { $_->{id} == $focused } @{$tree->{nodes}};
|
||||
return $output->{name};
|
||||
}
|
||||
|
||||
sync_with_i3;
|
||||
$x->root->warp_pointer(0, 0);
|
||||
sync_with_i3;
|
||||
|
@ -149,32 +149,25 @@ sync_with_i3;
|
||||
# Ensure that focusing right/left works in the expected order.
|
||||
############################################################################
|
||||
|
||||
sub get_focused_output {
|
||||
my $tree = i3(get_socket_path())->get_tree->recv;
|
||||
my ($focused_id) = @{$tree->{focus}};
|
||||
my ($output) = grep { $_->{id} == $focused_id } @{$tree->{nodes}};
|
||||
return $output->{name};
|
||||
}
|
||||
|
||||
is(get_focused_output(), 'fake-0', 'focus on fake-0');
|
||||
is(focused_output, 'fake-0', 'focus on fake-0');
|
||||
|
||||
cmd 'focus output right';
|
||||
is(get_focused_output(), 'fake-1', 'focus on fake-1');
|
||||
is(focused_output, 'fake-1', 'focus on fake-1');
|
||||
|
||||
cmd 'focus output right';
|
||||
is(get_focused_output(), 'fake-2', 'focus on fake-2');
|
||||
is(focused_output, 'fake-2', 'focus on fake-2');
|
||||
|
||||
cmd 'focus output left';
|
||||
is(get_focused_output(), 'fake-1', 'focus on fake-1');
|
||||
is(focused_output, 'fake-1', 'focus on fake-1');
|
||||
|
||||
cmd 'focus output left';
|
||||
is(get_focused_output(), 'fake-0', 'focus on fake-0');
|
||||
is(focused_output, 'fake-0', 'focus on fake-0');
|
||||
|
||||
cmd 'focus output left';
|
||||
is(get_focused_output(), 'fake-2', 'focus on fake-2 (wrapping)');
|
||||
is(focused_output, 'fake-2', 'focus on fake-2 (wrapping)');
|
||||
|
||||
cmd 'focus output right';
|
||||
is(get_focused_output(), 'fake-0', 'focus on fake-0 (wrapping)');
|
||||
is(focused_output, 'fake-0', 'focus on fake-0 (wrapping)');
|
||||
|
||||
exit_gracefully($pid);
|
||||
|
||||
|
Reference in New Issue
Block a user