]> git.sur5r.net Git - i3/i3/blob - testcases/t/216-layout-restore-split-swallows.t
tests: replace http:// with https:// where appropriate
[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 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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     "type": "con",
58     "nodes": [
59         {
60             // splitv split container with 2 children
61             "border": "pixel",
62             "floating": "auto_off",
63             "layout": "splitv",
64             "percent": 1,
65             "type": "con",
66             "nodes": [
67                 {
68                     "border": "pixel",
69                     "floating": "auto_off",
70                     "geometry": {
71                        "height": 318,
72                        "width": 566,
73                        "x": 0,
74                        "y": 0
75                     },
76                     "name": "zsh",
77                     "percent": 0.5,
78                     "swallows": [
79                        {
80                          "class": "^URxvt$",
81                          "instance": "^IRC$"
82                        }
83                     ],
84                     "type": "con"
85                 },
86                 {
87                     "border": "pixel",
88                     "floating": "auto_off",
89                     "geometry": {
90                        "height": 1057,
91                        "width": 636,
92                        "x": 0,
93                        "y": 0
94                     },
95                     "name": "Michael Stapelberg",
96                     "percent": 0.5,
97                     "swallows": [
98                        {
99                          "class": "^Pidgin$",
100                          "window_role": "^conversation$"
101                        }
102                     ],
103                     "type": "con"
104                 }
105             ]
106         }
107     ]
108 }
109
110 EOT
111 $fh->flush;
112 my $reply = cmd "append_layout $filename";
113
114 does_i3_live;
115
116 ok($reply->[0]->{success}, 'IPC reply indicates success');
117
118 my @nodes = @{get_ws_content($ws)};
119
120 is_deeply($nodes[0]->{swallows},
121     [
122     {
123         class => '^Pidgin$',
124         window_role => '^buddy_list$',
125     },
126     ],
127     'swallows specification not parsed correctly');
128
129 is_deeply($nodes[1]->{swallows},
130     [],
131     'swallows specification empty on split container');
132
133 my @children = @{$nodes[1]->{nodes}->[0]->{nodes}};
134
135 is_deeply($children[0]->{swallows},
136     [
137     {
138         class => '^URxvt$',
139         instance => '^IRC$',
140     },
141     ],
142     'swallows specification not parsed correctly');
143
144 is_deeply($children[1]->{swallows},
145     [
146     {
147         class => '^Pidgin$',
148         window_role => '^conversation$',
149     },
150     ],
151     'swallows specification not parsed correctly');
152
153 close($fh);
154 done_testing;