2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
5 # Tests if assignments work
8 use X11::XCB qw(PROP_MODE_REPLACE);
10 # TODO: move to X11::XCB
12 my ($id, $class, $instance) = @_;
14 # Add a _NET_WM_STRUT_PARTIAL hint
15 my $atomname = $x->atom(name => 'WM_CLASS');
16 my $atomtype = $x->atom(name => 'STRING');
24 length($class) + length($instance) + 2,
25 "$instance\x00$class\x00"
31 my $wm_class = delete($args{wm_class}) || 'special';
32 $args{name} //= 'special window';
36 before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
40 #####################################################################
41 # start a window and see that it does not get assigned with an empty config
42 #####################################################################
46 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
49 my $pid = launch_with_config($config);
51 my $tmp = fresh_workspace;
53 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
55 my $window = open_special;
57 ok(@{get_ws_content($tmp)} == 1, 'special window got managed to current (random) workspace');
59 exit_gracefully($pid);
63 #####################################################################
64 # start a window and see that it gets assigned to a formerly unused
66 #####################################################################
70 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
71 assign "special" → targetws
74 $pid = launch_with_config($config);
76 $tmp = fresh_workspace;
78 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
79 my $workspaces = get_workspace_names;
80 ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
82 $window = open_special;
84 ok(@{get_ws_content($tmp)} == 0, 'still no containers');
85 ok("targetws" ~~ @{get_workspace_names()}, 'targetws exists');
89 exit_gracefully($pid);
93 #####################################################################
94 # start a window and see that it gets assigned to a workspace which has content
95 # already, next to the existing node.
96 #####################################################################
98 $pid = launch_with_config($config);
100 # initialize the target workspace, then go to a fresh one
101 ok(!("targetws" ~~ @{get_workspace_names()}), 'targetws does not exist yet');
102 cmd 'workspace targetws';
103 cmp_ok(@{get_ws_content('targetws')}, '==', 0, 'no containers on targetws yet');
105 cmp_ok(@{get_ws_content('targetws')}, '==', 1, 'one container on targetws');
106 $tmp = fresh_workspace;
108 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
109 ok("targetws" ~~ @{get_workspace_names()}, 'targetws does not exist yet');
112 # We use sync_with_i3 instead of wait_for_map here because i3 will not actually
113 # map the window -- it will be assigned to a different workspace and will only
114 # be mapped once you switch to that workspace
115 $window = open_special(dont_map => 1);
119 ok(@{get_ws_content($tmp)} == 0, 'still no containers');
120 ok(@{get_ws_content('targetws')} == 2, 'two containers on targetws');
122 exit_gracefully($pid);
124 #####################################################################
125 # start a window and see that it gets assigned to a workspace which has content
126 # already, next to the existing node.
127 #####################################################################
130 # i3 config file (v4)
131 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
135 $pid = launch_with_config($config);
137 $tmp = fresh_workspace;
139 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
140 $workspaces = get_workspace_names;
141 ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
143 $window = open_special;
145 my $content = get_ws($tmp);
146 ok(@{$content->{nodes}} == 0, 'no tiling cons');
147 ok(@{$content->{floating_nodes}} == 1, 'one floating con');
151 exit_gracefully($pid);
155 #####################################################################
156 # make sure that assignments are case-insensitive in the old syntax.
157 #####################################################################
160 # i3 config file (v4)
161 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
165 $pid = launch_with_config($config);
167 $tmp = fresh_workspace;
169 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
170 $workspaces = get_workspace_names;
171 ok(!("targetws" ~~ @{$workspaces}), 'targetws does not exist yet');
173 $window = open_special(wm_class => 'SPEcial');
175 $content = get_ws($tmp);
176 ok(@{$content->{nodes}} == 0, 'no tiling cons');
177 ok(@{$content->{floating_nodes}} == 1, 'one floating con');
181 exit_gracefully($pid);
185 #####################################################################
186 # regression test: dock clients with floating assignments should not crash
187 # (instead, nothing should happen - dock clients can’t float)
189 #####################################################################
192 # i3 config file (v4)
193 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
197 $pid = launch_with_config($config);
199 # TODO: replace this with checking the process hierarchy
200 # XXX: give i3-nagbar some time to start up
203 $tmp = fresh_workspace;
205 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
206 my @docked = get_dock_clients;
207 # We expect i3-nagbar as the first dock client due to using the old assign
209 is(@docked, 1, 'one dock client yet');
211 $window = open_special(
212 window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
215 $content = get_ws($tmp);
216 ok(@{$content->{nodes}} == 0, 'no tiling cons');
217 ok(@{$content->{floating_nodes}} == 0, 'one floating con');
218 @docked = get_dock_clients;
219 is(@docked, 2, 'two dock clients now');
225 exit_gracefully($pid);