]> git.sur5r.net Git - i3/i3/blob - testcases/t/17-workspace.t
Merge branch 'fix-focus-ipc'
[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 # to ensure that workspace 1 stays open
11 cmd 'open';
12
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');
19 }
20
21 my $otmp = fresh_workspace;
22 diag("Other temporary workspace name: $otmp\n");
23
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');
28
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');
33
34
35 #####################################################################
36 # check if the workspace next / prev commands work
37 #####################################################################
38
39 cmd 'workspace next';
40
41 ok(!workspace_exists('next'), 'workspace "next" does not exist');
42
43 cmd "workspace $tmp";
44 cmd 'open';
45
46 ok(workspace_exists($tmp), 'workspace created');
47
48 cmd "workspace $otmp";
49 cmd 'open';
50
51 ok(workspace_exists($tmp), 'workspace tmp still exists');
52 ok(workspace_exists($otmp), 'workspace otmp created');
53
54 is(focused_ws(), $otmp, 'focused workspace is otmp');
55
56 cmd 'workspace prev';
57 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
58
59 cmd 'workspace next';
60 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
61
62
63 #####################################################################
64 # check that wrapping works
65 #####################################################################
66
67 cmd 'workspace next';
68 is(focused_ws(), '1', 'focused workspace is 1 after workspace next');
69
70 cmd 'workspace next';
71 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace next');
72
73 cmd 'workspace next';
74 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
75
76
77 cmd 'workspace prev';
78 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
79
80 cmd 'workspace prev';
81 is(focused_ws(), '1', 'focused workspace is tmp after workspace prev');
82
83 cmd 'workspace prev';
84 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace prev');
85
86
87 #####################################################################
88 # check if we can change to "next" / "prev"
89 #####################################################################
90
91 cmd 'workspace "next"';
92
93 ok(workspace_exists('next'), 'workspace "next" exists');
94 is(focused_ws(), 'next', 'now on workspace next');
95
96 cmd 'workspace "prev"';
97
98 ok(workspace_exists('prev'), 'workspace "prev" exists');
99 is(focused_ws(), 'prev', 'now on workspace prev');
100
101 done_testing;