]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/117-workspace.t
Merge pull request #3203 from orestisf1993/free
[i3/i3] / testcases / t / 117-workspace.t
index 2283ddc1370591c767ba496a2b9dfbd8660b136b..c97d4fbffb95fbc6cf99e417a414b6d583daa3b8 100644 (file)
@@ -2,13 +2,13 @@
 # vim:ts=4:sw=4:expandtab
 #
 # Please read the following documents before working on tests:
-# • http://build.i3wm.org/docs/testsuite.html
+# • https://build.i3wm.org/docs/testsuite.html
 #   (or docs/testsuite)
 #
-# • http://build.i3wm.org/docs/lib-i3test.html
+# • https://build.i3wm.org/docs/lib-i3test.html
 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
 #
-# • http://build.i3wm.org/docs/ipc.html
+# • https://build.i3wm.org/docs/ipc.html
 #   (or docs/ipc)
 #
 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
@@ -196,8 +196,7 @@ sub workspace_numbers_sorted {
     my @outputs = @{$tree->{nodes}};
     my @workspaces;
     for my $output (@outputs) {
-        # get the first CT_CON of each output
-        my $content = first { $_->{type} == 2 } @{$output->{nodes}};
+        my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
         @workspaces = (@workspaces, @{$content->{nodes}});
     }
 
@@ -254,13 +253,51 @@ $ws = get_ws('qux');
 is($ws->{num}, -1, 'number correctly changed');
 workspace_numbers_sorted();
 
-# 5: already existing workspace
+# 4: rename current workspace
+cmd 'workspace 4711';
+is(focused_ws(), '4711', 'now on workspace 4711');
+
+ok(!workspace_exists('42'), 'workspace 42 does not exist yet');
+cmd 'rename workspace to 42';
+ok(!workspace_exists('4711'), 'workspace 4711 does not exist anymore');
+is(focused_ws(), '42', 'now on workspace 42');
+$ws = get_ws('42');
+is($ws->{num}, 42, 'number correctly changed');
+workspace_numbers_sorted();
+
+# 5: special cases
+cmd 'workspace bla';
+is(focused_ws(), 'bla', 'now on workspace to');
+
+ok(!workspace_exists('to'), 'workspace to does not exist yet');
+cmd 'rename workspace bla to to';
+ok(!workspace_exists('bla'), 'workspace bla does not exist anymore');
+is(focused_ws(), 'to', 'now on workspace to');
+cmd 'rename workspace to to bla';
+ok(!workspace_exists('to'), 'workspace to does not exist anymore');
+is(focused_ws(), 'bla', 'now on workspace bla');
+cmd 'rename workspace to to';
+ok(!workspace_exists('bla'), 'workspace bla does not exist anymore');
+is(focused_ws(), 'to', 'now on workspace to');
+cmd 'rename workspace to bla';
+ok(!workspace_exists('to'), 'workspace to does not exist anymore');
+is(focused_ws(), 'bla', 'now on workspace bla');
+cmd 'rename workspace to tosomething';
+ok(!workspace_exists('bla'), 'workspace bla does not exist anymore');
+is(focused_ws(), 'tosomething', 'now on workspace tosomething');
+
+# 6: already existing workspace
 my $result = cmd 'rename workspace qux to 11: bar';
 ok(!$result->[0]->{success}, 'renaming workspace to an already existing one failed');
 
-# 6: non-existing old workspace (verify command result)
+# 7: non-existing old workspace (verify command result)
 $result = cmd 'rename workspace notexistant to bleh';
 ok(!$result->[0]->{success}, 'renaming workspace which does not exist failed');
 
+# 8: change case
+ok(!workspace_exists('11: BAR'), 'workspace 11: BAR does not exist yet');
+$result = cmd 'rename workspace "11: bar" to "11: BAR"';
+ok($result->[0]->{success}, 'renaming workspace from 11: bar to 11: BAR worked');
+ok(workspace_exists('11: BAR'), 'workspace 11: BAR now exists');
 
 done_testing;