]> git.sur5r.net Git - i3/i3/blob - testcases/t/263-edge-borders.t
Smart option added to hide_edge_borders config param (#2191) (#2191)
[i3/i3] / testcases / t / 263-edge-borders.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 # Tests that the hide_edge_borders smart option works
18 # Ticket: #2188
19
20 use i3test i3_autostart => 0;
21
22 ####################################################################
23 # 1: check that the borders are present on a floating windows
24 #####################################################################
25
26 my $config = <<EOT;
27 # i3 config file (v4)
28 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
29
30 new_window pixel 2
31 new_float pixel 2
32 hide_edge_borders smart
33 EOT
34
35 my $pid = launch_with_config($config);
36
37 my $tmp = fresh_workspace;
38
39 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
40
41 my $floatwindow = open_floating_window;
42
43 my $wscontent = get_ws($tmp);
44
45 my @floating = @{$wscontent->{floating_nodes}};
46 ok(@floating == 1, 'one floating container opened');
47 is($floating[0]->{nodes}[0]->{current_border_width}, 2, 'floating current border width set to 2');
48 is($floatwindow->rect->width, $floating[0]->{rect}->{width} - 2*2, 'floating border width 2');
49
50 exit_gracefully($pid);
51
52 #####################################################################
53 # 2: check that the borders are present on a workspace with two tiled
54 # windows visible
55 #####################################################################
56
57 $config = <<EOT;
58 # i3 config file (v4)
59 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
60
61 new_window pixel 2
62 new_float pixel 2
63 hide_edge_borders smart
64 EOT
65
66 $pid = launch_with_config($config);
67
68 $tmp = fresh_workspace;
69
70 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
71
72 my $tilewindow = open_window;
73 my $tilewindow2 = open_window;
74
75 $wscontent = get_ws($tmp);
76
77 my @tiled = @{$wscontent->{nodes}};
78 ok(@tiled == 2, 'two tiled container opened');
79 is($tiled[0]->{current_border_width}, 2, 'first tiled current border width set to 2');
80 is($tilewindow->rect->width, $tiled[0]->{rect}->{width} - 2*2, 'first tiled border width 2');
81 is($tiled[1]->{current_border_width}, 2, 'second tiled current border width set to 2');
82 is($tilewindow2->rect->width, $tiled[1]->{rect}->{width} - 2*2, 'second tiled border width 2');
83
84 exit_gracefully($pid);
85
86 #####################################################################
87 # 3: check that the borders are hidden on a workspace with one tiled
88 # window visible
89 #####################################################################
90
91 $config = <<EOT;
92 # i3 config file (v4)
93 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
94
95 new_window pixel 2
96 new_float pixel 2
97 hide_edge_borders smart
98 EOT
99
100 $pid = launch_with_config($config);
101
102 $tmp = fresh_workspace;
103
104 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
105
106 $tilewindow = open_window;
107
108 $wscontent = get_ws($tmp);
109
110 @tiled = @{$wscontent->{nodes}};
111 ok(@tiled == 1, 'one tiled container opened');
112 is($tiled[0]->{current_border_width}, 2, 'tiled current border width set to 2');
113 is($tilewindow->rect->width, $tiled[0]->{rect}->{width} - 2*0, 'single tiled border width 0');
114
115 exit_gracefully($pid);
116
117 #####################################################################
118 # 4: check that the borders are present on a workspace with two tiled
119 # windows visible, recursively
120 #####################################################################
121
122 $config = <<EOT;
123 # i3 config file (v4)
124 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
125
126 new_window pixel 2
127 new_float pixel 2
128 hide_edge_borders smart
129 EOT
130
131 $pid = launch_with_config($config);
132
133 $tmp = fresh_workspace;
134
135 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
136
137 $tilewindow = open_window;
138 $tilewindow2 = open_window;
139 ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
140
141 cmd 'layout tabbed';
142 ok(@{get_ws_content($tmp)} == 1, 'layout tabbed -> back to one container');
143
144 cmd 'focus parent';
145 my $tilewindow3 = open_window;
146 ok(@{get_ws_content($tmp)} == 2, 'after split & new window, two containers');
147
148 $wscontent = get_ws($tmp);
149
150 @tiled = @{$wscontent->{nodes}};
151 ok(@tiled == 2, 'two tiled container opened in another container');
152 is($tiled[0]->{current_border_width}, -1, 'first tiled current border width set to -1');
153 is($tilewindow->rect->width, $tiled[0]->{rect}->{width} - 2*2, 'first tiled border width 2');
154 is($tiled[1]->{current_border_width}, 2, 'second tiled current border width set to 2');
155 is($tilewindow2->rect->width, $tiled[1]->{rect}->{width} - 2*2, 'second tiled border width 2');
156
157 exit_gracefully($pid);
158
159 done_testing;