]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/17-workspace.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 17-workspace.t
index 32f8296905148b57348f12899f3edc8d9d7d8894..3c3b6cc675421a510dc8c25b723198c2e8bf5006 100644 (file)
@@ -7,10 +7,8 @@
 use List::Util qw(first);
 use i3test;
 
-sub workspace_exists {
-    my ($name) = @_;
-    ($name ~~ @{get_workspace_names()})
-}
+# to ensure that workspace 1 stays open
+cmd 'open';
 
 my $tmp = fresh_workspace;
 ok(workspace_exists($tmp), 'workspace created');
@@ -53,24 +51,6 @@ cmd 'open';
 ok(workspace_exists($tmp), 'workspace tmp still exists');
 ok(workspace_exists($otmp), 'workspace otmp created');
 
-sub focused_ws_con {
-    my $i3 = i3("/tmp/nestedcons");
-    my $tree = $i3->get_tree->recv;
-    my @outputs = @{$tree->{nodes}};
-    my @cons;
-    for my $output (@outputs) {
-        # get the first CT_CON of each output
-        my $content = first { $_->{type} == 2 } @{$output->{nodes}};
-        my @focused = @{$content->{focus}};
-        return first { $_->{id} == $focused[0] } @{$content->{nodes}};
-    }
-}
-
-sub focused_ws {
-    my $con = focused_ws_con;
-    return $con->{name};
-}
-
 is(focused_ws(), $otmp, 'focused workspace is otmp');
 
 cmd 'workspace prev';
@@ -118,4 +98,23 @@ cmd 'workspace "prev"';
 ok(workspace_exists('prev'), 'workspace "prev" exists');
 is(focused_ws(), 'prev', 'now on workspace prev');
 
+#####################################################################
+# check that the numbers are assigned/recognized correctly
+#####################################################################
+
+cmd "workspace 3: $tmp";
+my $ws = get_ws("3: $tmp");
+ok(defined($ws), "workspace 3: $tmp was created");
+is($ws->{num}, 3, 'workspace number is 3');
+
+cmd "workspace 0: $tmp";
+my $ws = get_ws("0: $tmp");
+ok(defined($ws), "workspace 0: $tmp was created");
+is($ws->{num}, 0, 'workspace number is 0');
+
+cmd "workspace aa: $tmp";
+my $ws = get_ws("aa: $tmp");
+ok(defined($ws), "workspace aa: $tmp was created");
+is($ws->{num}, -1, 'workspace number is -1');
+
 done_testing;