]> git.sur5r.net Git - i3/i3/blob - testcases/t/272-regress-focus-assign.t
tests: use i3_config arg instead of precisely one launch_with_config
[i3/i3] / testcases / t / 272-regress-focus-assign.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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 # Regression: Checks if focus is stolen when a window is managed which is
18 # assigned to an invisible workspace
19 #
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 assign [class="special"] targetws
24 EOT
25
26 sub open_special {
27     my %args = @_;
28     $args{name} //= 'special window';
29
30     # We use dont_map because i3 will not map the window on the current
31     # workspace. Thus, open_window would time out in wait_for_map (2 seconds).
32     my $window = open_window(
33         %args,
34         wm_class => 'special',
35         dont_map => 1,
36     );
37     $window->map;
38     return $window;
39 }
40
41 #####################################################################
42 # start a window and see that it does not get assigned with an empty config
43 #####################################################################
44
45 my $tmp = fresh_workspace;
46
47 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
48 ok(get_ws($tmp)->{focused}, 'current workspace focused');
49
50 my $window = open_special;
51 sync_with_i3;
52
53 ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
54 ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
55 ok(get_ws($tmp)->{focused}, 'current workspace still focused');
56
57 #####################################################################
58 # the same test, but with a floating window
59 #####################################################################
60
61 $window = open_special(
62     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
63 );
64
65 ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
66 ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
67 ok(get_ws($tmp)->{focused}, 'current workspace still focused');
68
69 $window->destroy;
70
71 done_testing;