]> git.sur5r.net Git - i3/i3/blob - testcases/t/17-workspace.t
bugfix: don’t clean up workspace when switching to the same workspace
[i3/i3] / testcases / t / 17-workspace.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Tests whether we can switch to a non-existant workspace
5 # (necessary for further tests)
6 #
7 use i3test tests => 3;
8 use v5.10;
9
10 my $i3 = i3("/tmp/nestedcons");
11
12 sub workspace_exists {
13     my ($name) = @_;
14     ($name ~~ @{get_workspace_names()})
15 }
16
17 my $tmp = get_unused_workspace();
18 diag("Temporary workspace name: $tmp\n");
19
20 $i3->command("workspace $tmp")->recv;
21 ok(workspace_exists($tmp), 'workspace created');
22 # if the workspace could not be created, we cannot run any other test
23 # (every test starts by creating its workspace)
24 if (!workspace_exists($tmp)) {
25     BAIL_OUT('Cannot create workspace, further tests make no sense');
26 }
27
28 my $otmp = get_unused_workspace();
29 diag("Other temporary workspace name: $otmp\n");
30
31 # As the old workspace was empty, it should get
32 # cleaned up as we switch away from it
33 $i3->command("workspace $otmp")->recv;
34 ok(!workspace_exists($tmp), 'old workspace cleaned up');
35
36 # Switch to the same workspace again to make sure it doesn’t get cleaned up
37 $i3->command("workspace $otmp")->recv;
38 $i3->command("workspace $otmp")->recv;
39 ok(workspace_exists($otmp), 'other workspace still exists');
40
41 diag( "Testing i3, Perl $], $^X" );