Move is_num_fullscreen to Test.pm

This commit is contained in:
Orestis Floros
2017-09-19 09:56:53 +03:00
parent 2592c63603
commit 759e051374
4 changed files with 60 additions and 63 deletions

View File

@ -5,6 +5,7 @@ use base 'Test::Builder::Module';
our @EXPORT = qw(
is_num_children
is_num_fullscreen
cmp_float
does_i3_live
);
@ -59,6 +60,25 @@ sub is_num_children {
$tb->is_num($got_num_children, $num_children, $name);
}
=head2 is_num_fullscreen($workspace, $expected, $test_name)
Gets the number of fullscreen containers on the given workspace and verifies that
they match the expected amount.
is_num_fullscreen('1', 0, 'no fullscreen containers on workspace 1');
=cut
sub is_num_fullscreen {
my ($workspace, $num_fullscreen, $name) = @_;
my $workspace_content = i3test::get_ws($workspace);
my $tb = $CLASS->builder;
my $nodes = scalar grep { $_->{fullscreen_mode} != 0 } @{$workspace_content->{nodes}->[0]->{nodes}};
my $cons = scalar grep { $_->{fullscreen_mode} != 0 } @{$workspace_content->{nodes}};
my $floating = scalar grep { $_->{fullscreen_mode} != 0 } @{$workspace_content->{floating_nodes}->[0]->{nodes}};
$tb->is_num($nodes + $cons + $floating, $num_fullscreen, $name);
}
=head2 cmp_float($a, $b)
Compares floating point numbers C<$a> and C<$b> and returns true if they differ