]> git.sur5r.net Git - i3/i3/blob - testcases/t/216-layout-restore-split-swallows.t
Fix incorrect y-offset for text in i3bar
[i3/i3] / testcases / t / 216-layout-restore-split-swallows.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 # Verifies that i3 removes swallows specifications for split containers.
18 # ticket #1149, bug still present in commit 2fea5ef82bd3528ed62681f9ac64f45830f4acdf
19 use i3test;
20 use File::Temp qw(tempfile);
21 use IO::Handle;
22
23 my $ws = fresh_workspace;
24
25 my @content = @{get_ws_content($ws)};
26 is(@content, 0, 'no nodes on the new workspace yet');
27
28 my ($fh, $filename) = tempfile(UNLINK => 1);
29 print $fh <<'EOT';
30 // vim:ts=4:sw=4:et
31 {
32     "border": "pixel",
33     "floating": "auto_off",
34     "geometry": {
35        "height": 777,
36        "width": 199,
37        "x": 0,
38        "y": 0
39     },
40     "name": "Buddy List",
41     "percent": 0.116145833333333,
42     "swallows": [
43        {
44        "class": "^Pidgin$",
45        "window_role": "^buddy_list$"
46        }
47     ],
48     "type": "con"
49 }
50
51 {
52     // splitv split container with 1 children
53     "border": "pixel",
54     "floating": "auto_off",
55     "layout": "splitv",
56     "percent": 0.883854166666667,
57     "swallows": [
58        {}
59     ],
60     "type": "con",
61     "nodes": [
62         {
63             // splitv split container with 2 children
64             "border": "pixel",
65             "floating": "auto_off",
66             "layout": "splitv",
67             "percent": 1,
68             "swallows": [
69                {}
70             ],
71             "type": "con",
72             "nodes": [
73                 {
74                     "border": "pixel",
75                     "floating": "auto_off",
76                     "geometry": {
77                        "height": 318,
78                        "width": 566,
79                        "x": 0,
80                        "y": 0
81                     },
82                     "name": "zsh",
83                     "percent": 0.5,
84                     "swallows": [
85                        {
86                          "class": "^URxvt$",
87                          "instance": "^IRC$"
88                        }
89                     ],
90                     "type": "con"
91                 },
92                 {
93                     "border": "pixel",
94                     "floating": "auto_off",
95                     "geometry": {
96                        "height": 1057,
97                        "width": 636,
98                        "x": 0,
99                        "y": 0
100                     },
101                     "name": "Michael Stapelberg",
102                     "percent": 0.5,
103                     "swallows": [
104                        {
105                          "class": "^Pidgin$",
106                          "window_role": "^conversation$"
107                        }
108                     ],
109                     "type": "con"
110                 }
111             ]
112         }
113     ]
114 }
115
116 EOT
117 $fh->flush;
118 my $reply = cmd "append_layout $filename";
119
120 does_i3_live;
121
122 ok($reply->[0]->{success}, 'IPC reply indicates success');
123
124 my @nodes = @{get_ws_content($ws)};
125
126 is_deeply($nodes[0]->{swallows},
127     [
128     {
129         class => '^Pidgin$',
130         window_role => '^buddy_list$',
131     },
132     ],
133     'swallows specification not parsed correctly');
134
135 is_deeply($nodes[1]->{swallows},
136     [],
137     'swallows specification empty on split container');
138
139 my @children = @{$nodes[1]->{nodes}->[0]->{nodes}};
140
141 is_deeply($children[0]->{swallows},
142     [
143     {
144         class => '^URxvt$',
145         instance => '^IRC$',
146     },
147     ],
148     'swallows specification not parsed correctly');
149
150 is_deeply($children[1]->{swallows},
151     [
152     {
153         class => '^Pidgin$',
154         window_role => '^conversation$',
155     },
156     ],
157     'swallows specification not parsed correctly');
158
159 close($fh);
160 done_testing;