aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/503-workspace.t
blob: 8a4aab9f136a019015b6da833c40d4f8abcd5202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
#   (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
#   (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
#   (or docs/ipc)
#
# • https://i3wm.org/downloads/modern_perl_a4.pdf
#   (unless you are already familiar with Perl)
#
# Tests whether 'workspace next_on_output' and the like work correctly.
#
use List::Util qw(first);
use i3test i3_config => <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

fake-outputs 1024x768+0+0,1024x768+1024+0
EOT

################################################################################
# Setup workspaces so that they stay open (with an empty container).
################################################################################

sync_with_i3;
$x->root->warp_pointer(0, 0);
sync_with_i3;

is(focused_ws, '1', 'starting on workspace 1');
# ensure workspace 1 stays open
open_window;

cmd 'focus output right';
is(focused_ws, '2', 'workspace 2 on second output');
# ensure workspace 2 stays open
open_window;

cmd 'workspace 6:c';
# ensure workspace 6:c stays open
open_window;

cmd 'focus output right';
is(focused_ws, '1', 'back on workspace 1');

# We don’t use fresh_workspace with named workspaces here since they come last
# when using 'workspace next'.
cmd 'workspace 5';
# ensure workspace 5 stays open
open_window;

# numbered w/ name workspaces must be created in reverse order compared to
# other workspace types (because a new numbered w/ name workspace is prepended
# to the list of similarly numbered workspaces).

cmd 'workspace 6:b';
# ensure workspace 5 stays open
open_window;

cmd 'workspace 6:a';
# ensure workspace 5 stays open
open_window;

################################################################################
# Use workspace next and verify the correct order.
################################################################################

# The current order should be:
# output 1: 1, 5, 6:a, 6:b
# output 2: 2, 6:c
cmd 'workspace 1';
cmd 'workspace next';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
# later in time and mess up our subsequent tests.
sync_with_i3;

is(focused_ws, '2', 'workspace 2 focused');
cmd 'workspace next';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
# later in time and mess up our subsequent tests.
sync_with_i3;

is(focused_ws, '5', 'workspace 5 focused');
cmd 'workspace next';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
# later in time and mess up our subsequent tests.
sync_with_i3;

is(focused_ws, '6:a', 'workspace 6:a focused');
cmd 'workspace next';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
# later in time and mess up our subsequent tests.
sync_with_i3;

is(focused_ws, '6:b', 'workspace 6:b focused');
cmd 'workspace next';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
# later in time and mess up our subsequent tests.
sync_with_i3;

is(focused_ws, '6:c', 'workspace 6:b focused');

################################################################################
# Now try the same with workspace next_on_output.
################################################################################

cmd 'workspace 1';
cmd 'workspace next_on_output';
is(focused_ws, '5', 'workspace 5 focused');
cmd 'workspace next_on_output';
is(focused_ws, '6:a', 'workspace 6:a focused');
cmd 'workspace next_on_output';
is(focused_ws, '6:b', 'workspace 6:b focused');
cmd 'workspace next_on_output';
is(focused_ws, '1', 'workspace 1 focused');

cmd 'workspace prev_on_output';
is(focused_ws, '6:b', 'workspace 6:b focused');
cmd 'workspace prev_on_output';
is(focused_ws, '6:a', 'workspace 6:a focused');
cmd 'workspace prev_on_output';
is(focused_ws, '5', 'workspace 5 focused');
cmd 'workspace prev_on_output';
is(focused_ws, '1', 'workspace 1 focused');

cmd 'workspace 2';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
# later in time and mess up our subsequent tests.
sync_with_i3;

cmd 'workspace prev_on_output';
is(focused_ws, '6:c', 'workspace 6:c focused');

cmd 'workspace prev_on_output';
is(focused_ws, '2', 'workspace 2 focused');

done_testing;