]> git.sur5r.net Git - i3/i3/blobdiff - testcases/lib/i3test/Test.pm
Move is_num_fullscreen to Test.pm
[i3/i3] / testcases / lib / i3test / Test.pm
index 0253bc2d5dfb912e6eab5f45fa1c7fba4a4ae625..552ae8b48367a6edaaa94095246f2f31d5ee8199 100644 (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