]> git.sur5r.net Git - i3/i3/blob - testcases/t/17-workspace.t
Bugfix: Switch to appropriate workspace when using 'focus' (+test) (Thanks rogutes)
[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 List::Util qw(first);
8 use i3test;
9
10 my $tmp = fresh_workspace;
11 ok(workspace_exists($tmp), 'workspace created');
12 # if the workspace could not be created, we cannot run any other test
13 # (every test starts by creating its workspace)
14 if (!workspace_exists($tmp)) {
15     BAIL_OUT('Cannot create workspace, further tests make no sense');
16 }
17
18 my $otmp = fresh_workspace;
19 diag("Other temporary workspace name: $otmp\n");
20
21 # As the old workspace was empty, it should get
22 # cleaned up as we switch away from it
23 cmd "workspace $otmp";
24 ok(!workspace_exists($tmp), 'old workspace cleaned up');
25
26 # Switch to the same workspace again to make sure it doesn’t get cleaned up
27 cmd "workspace $otmp";
28 cmd "workspace $otmp";
29 ok(workspace_exists($otmp), 'other workspace still exists');
30
31
32 #####################################################################
33 # check if the workspace next / prev commands work
34 #####################################################################
35
36 cmd 'workspace next';
37
38 ok(!workspace_exists('next'), 'workspace "next" does not exist');
39
40 cmd "workspace $tmp";
41 cmd 'open';
42
43 ok(workspace_exists($tmp), 'workspace created');
44
45 cmd "workspace $otmp";
46 cmd 'open';
47
48 ok(workspace_exists($tmp), 'workspace tmp still exists');
49 ok(workspace_exists($otmp), 'workspace otmp created');
50
51 is(focused_ws(), $otmp, 'focused workspace is otmp');
52
53 cmd 'workspace prev';
54 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
55
56 cmd 'workspace next';
57 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
58
59
60 #####################################################################
61 # check that wrapping works
62 #####################################################################
63
64 cmd 'workspace next';
65 is(focused_ws(), '1', 'focused workspace is 1 after workspace next');
66
67 cmd 'workspace next';
68 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace next');
69
70 cmd 'workspace next';
71 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
72
73
74 cmd 'workspace prev';
75 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
76
77 cmd 'workspace prev';
78 is(focused_ws(), '1', 'focused workspace is tmp after workspace prev');
79
80 cmd 'workspace prev';
81 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace prev');
82
83
84 #####################################################################
85 # check if we can change to "next" / "prev"
86 #####################################################################
87
88 cmd 'workspace "next"';
89
90 ok(workspace_exists('next'), 'workspace "next" exists');
91 is(focused_ws(), 'next', 'now on workspace next');
92
93 cmd 'workspace "prev"';
94
95 ok(workspace_exists('prev'), 'workspace "prev" exists');
96 is(focused_ws(), 'prev', 'now on workspace prev');
97
98 done_testing;