]> git.sur5r.net Git - i3/i3/blob - testcases/t/503-workspace.t
Merge branch 'next' into master
[i3/i3] / testcases / t / 503-workspace.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests whether 'workspace next_on_output' and the like work correctly.
18 #
19 use List::Util qw(first);
20 use i3test i3_config => <<EOT;
21 # i3 config file (v4)
22 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
23
24 fake-outputs 1024x768+0+0,1024x768+1024+0
25 EOT
26
27 ################################################################################
28 # Setup workspaces so that they stay open (with an empty container).
29 ################################################################################
30
31 sync_with_i3;
32 $x->root->warp_pointer(0, 0);
33 sync_with_i3;
34
35 is(focused_ws, '1', 'starting on workspace 1');
36 # ensure workspace 1 stays open
37 open_window;
38
39 cmd 'focus output right';
40 is(focused_ws, '2', 'workspace 2 on second output');
41 # ensure workspace 2 stays open
42 open_window;
43
44 cmd 'focus output right';
45 is(focused_ws, '1', 'back on workspace 1');
46
47 # We don’t use fresh_workspace with named workspaces here since they come last
48 # when using 'workspace next'.
49 cmd 'workspace 5';
50 # ensure workspace 5 stays open
51 open_window;
52
53 ################################################################################
54 # Use workspace next and verify the correct order.
55 ################################################################################
56
57 # The current order should be:
58 # output 1: 1, 5
59 # output 2: 2
60 cmd 'workspace 1';
61 cmd 'workspace next';
62 # We need to sync after changing focus to a different output to wait for the
63 # EnterNotify to be processed, otherwise it will be processed at some point
64 # later in time and mess up our subsequent tests.
65 sync_with_i3;
66
67 is(focused_ws, '2', 'workspace 2 focused');
68 cmd 'workspace next';
69 # We need to sync after changing focus to a different output to wait for the
70 # EnterNotify to be processed, otherwise it will be processed at some point
71 # later in time and mess up our subsequent tests.
72 sync_with_i3;
73
74 is(focused_ws, '5', 'workspace 5 focused');
75
76 ################################################################################
77 # Now try the same with workspace next_on_output.
78 ################################################################################
79
80 cmd 'workspace 1';
81 cmd 'workspace next_on_output';
82 is(focused_ws, '5', 'workspace 5 focused');
83 cmd 'workspace next_on_output';
84 is(focused_ws, '1', 'workspace 1 focused');
85
86 cmd 'workspace prev_on_output';
87 is(focused_ws, '5', 'workspace 5 focused');
88 cmd 'workspace prev_on_output';
89 is(focused_ws, '1', 'workspace 1 focused');
90
91 cmd 'workspace 2';
92 # We need to sync after changing focus to a different output to wait for the
93 # EnterNotify to be processed, otherwise it will be processed at some point
94 # later in time and mess up our subsequent tests.
95 sync_with_i3;
96
97 cmd 'workspace prev_on_output';
98 is(focused_ws, '2', 'workspace 2 focused');
99
100 done_testing;