]> git.sur5r.net Git - i3/i3/blob - testcases/t/183-config-variables.t
Merge "force_focus_wrapping" option into "focus_wrapping force"
[i3/i3] / testcases / t / 183-config-variables.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 # Checks that variables are parsed correctly by using for_window rules with
18 # variables in it.
19 #
20
21 use i3test i3_autostart => 0;
22
23 # starts i3 with the given config, opens a window, returns its border style
24 sub launch_get_border {
25     my ($config) = @_;
26
27     my $pid = launch_with_config($config);
28
29     my $i3 = i3(get_socket_path(0));
30     my $tmp = fresh_workspace;
31
32     my $window = open_window(name => 'special title');
33
34     my @content = @{get_ws_content($tmp)};
35     cmp_ok(@content, '==', 1, 'one node on this workspace now');
36     my $border = $content[0]->{border};
37
38     exit_gracefully($pid);
39
40     return $border;
41 }
42
43 #####################################################################
44 # test thet windows get the default border
45 #####################################################################
46
47 my $config = <<EOT;
48 # i3 config file (v4)
49 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
50 EOT
51
52 is(launch_get_border($config), 'normal', 'normal border');
53
54 #####################################################################
55 # now use a variable and for_window
56 #####################################################################
57
58 $config = <<'EOT';
59 # i3 config file (v4)
60 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
61
62 set $vartest special title
63 for_window [title="$vartest"] border none
64 EOT
65
66 is(launch_get_border($config), 'none', 'no border');
67
68 #####################################################################
69 # check that whitespaces and tabs are ignored
70 #####################################################################
71
72 $config = <<'EOT';
73 # i3 config file (v4)
74 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
75
76 set               $vartest             special title
77 for_window [title="$vartest"] border none
78 EOT
79
80 is(launch_get_border($config), 'none', 'no border');
81
82 #####################################################################
83 # test that longest matching variable name is substituted
84 #####################################################################
85
86 $config = <<'EOT';
87 # i3 config file (v4)
88 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
89
90 set $var normal title
91 set $vartest special title
92 set $vart mundane title
93 for_window [title="$vartest"] border none
94 EOT
95
96 is(launch_get_border($config), 'none', 'no border');
97
98
99
100 done_testing;
101