2 # vim:ts=4:sw=4:expandtab
4 # Tests whether we can switch to a non-existant workspace
5 # (necessary for further tests)
7 use List::Util qw(first);
10 # to ensure that workspace 1 stays open
13 my $tmp = fresh_workspace;
14 ok(workspace_exists($tmp), 'workspace created');
15 # if the workspace could not be created, we cannot run any other test
16 # (every test starts by creating its workspace)
17 if (!workspace_exists($tmp)) {
18 BAIL_OUT('Cannot create workspace, further tests make no sense');
21 my $otmp = fresh_workspace;
22 diag("Other temporary workspace name: $otmp\n");
24 # As the old workspace was empty, it should get
25 # cleaned up as we switch away from it
26 cmd "workspace $otmp";
27 ok(!workspace_exists($tmp), 'old workspace cleaned up');
29 # Switch to the same workspace again to make sure it doesn’t get cleaned up
30 cmd "workspace $otmp";
31 cmd "workspace $otmp";
32 ok(workspace_exists($otmp), 'other workspace still exists');
35 #####################################################################
36 # check if the workspace next / prev commands work
37 #####################################################################
41 ok(!workspace_exists('next'), 'workspace "next" does not exist');
46 ok(workspace_exists($tmp), 'workspace created');
48 cmd "workspace $otmp";
51 ok(workspace_exists($tmp), 'workspace tmp still exists');
52 ok(workspace_exists($otmp), 'workspace otmp created');
54 is(focused_ws(), $otmp, 'focused workspace is otmp');
57 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
60 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
63 #####################################################################
64 # check that wrapping works
65 #####################################################################
68 is(focused_ws(), '1', 'focused workspace is 1 after workspace next');
71 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace next');
74 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
78 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
81 is(focused_ws(), '1', 'focused workspace is tmp after workspace prev');
84 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace prev');
87 #####################################################################
88 # check if we can change to "next" / "prev"
89 #####################################################################
91 cmd 'workspace "next"';
93 ok(workspace_exists('next'), 'workspace "next" exists');
94 is(focused_ws(), 'next', 'now on workspace next');
96 cmd 'workspace "prev"';
98 ok(workspace_exists('prev'), 'workspace "prev" exists');
99 is(focused_ws(), 'prev', 'now on workspace prev');
101 #####################################################################
102 # check that the numbers are assigned/recognized correctly
103 #####################################################################
105 cmd "workspace 3: $tmp";
106 my $ws = get_ws("3: $tmp");
107 ok(defined($ws), "workspace 3: $tmp was created");
108 is($ws->{num}, 3, 'workspace number is 3');
110 cmd "workspace 0: $tmp";
111 $ws = get_ws("0: $tmp");
112 ok(defined($ws), "workspace 0: $tmp was created");
113 is($ws->{num}, 0, 'workspace number is 0');
115 cmd "workspace aa: $tmp";
116 $ws = get_ws("aa: $tmp");
117 ok(defined($ws), "workspace aa: $tmp was created");
118 is($ws->{num}, -1, 'workspace number is -1');