]> git.sur5r.net Git - i3/i3/blob - testcases/t/74-border-config.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 74-border-config.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Tests the new_window and new_float config option.
6 #
7
8 use i3test;
9 use X11::XCB qw(:all);
10 use X11::XCB::Connection;
11
12 my $x = X11::XCB::Connection->new;
13
14 #####################################################################
15 # 1: check that new windows start with 'normal' border unless configured
16 # otherwise
17 #####################################################################
18
19 my $config = <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22 EOT
23
24 my $process = launch_with_config($config);
25
26 my $tmp = fresh_workspace;
27
28 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
29
30 my $first = open_standard_window($x);
31
32 my @content = @{get_ws_content($tmp)};
33 ok(@content == 1, 'one container opened');
34 is($content[0]->{border}, 'normal', 'border normal by default');
35
36 exit_gracefully($process->pid);
37
38 #####################################################################
39 # 2: check that new tiling windows start with '1pixel' border when
40 # configured
41 #####################################################################
42
43 $config = <<EOT;
44 # i3 config file (v4)
45 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
46
47 new_window 1pixel
48 EOT
49
50 $process = launch_with_config($config);
51
52 $tmp = fresh_workspace;
53
54 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
55
56 $first = open_standard_window($x);
57
58 @content = @{get_ws_content($tmp)};
59 ok(@content == 1, 'one container opened');
60 is($content[0]->{border}, '1pixel', 'border normal by default');
61
62 exit_gracefully($process->pid);
63
64 #####################################################################
65 # 3: check that new floating windows start with 'normal' border unless
66 # configured otherwise
67 #####################################################################
68
69 $config = <<EOT;
70 # i3 config file (v4)
71 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
72 EOT
73
74 $process = launch_with_config($config);
75
76 $tmp = fresh_workspace;
77
78 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
79
80 # Create a floating window which is smaller than the minimum enforced size of i3
81 $first = $x->root->create_child(
82     class => WINDOW_CLASS_INPUT_OUTPUT,
83     rect => [ 0, 0, 30, 30],
84     background_color => '#C0C0C0',
85     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
86     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
87 );
88
89 $first->map;
90
91 sleep 0.25;
92
93 my $wscontent = get_ws($tmp);
94 my @floating = @{$wscontent->{floating_nodes}};
95 ok(@floating == 1, 'one floating container opened');
96 my $floatingcon = $floating[0];
97 is($floatingcon->{nodes}->[0]->{border}, 'normal', 'border normal by default');
98
99 exit_gracefully($process->pid);
100
101 #####################################################################
102 # 4: check that new floating windows start with '1pixel' border when
103 # configured
104 #####################################################################
105
106 $config = <<EOT;
107 # i3 config file (v4)
108 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
109
110 new_float 1pixel
111 EOT
112
113 $process = launch_with_config($config);
114
115 $tmp = fresh_workspace;
116
117 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
118
119 # Create a floating window which is smaller than the minimum enforced size of i3
120 $first = $x->root->create_child(
121     class => WINDOW_CLASS_INPUT_OUTPUT,
122     rect => [ 0, 0, 30, 30],
123     background_color => '#C0C0C0',
124     # replace the type with 'utility' as soon as the coercion works again in X11::XCB
125     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
126 );
127
128 $first->map;
129
130 sleep 0.25;
131
132 $wscontent = get_ws($tmp);
133 @floating = @{$wscontent->{floating_nodes}};
134 ok(@floating == 1, 'one floating container opened');
135 $floatingcon = $floating[0];
136 is($floatingcon->{nodes}->[0]->{border}, '1pixel', 'border normal by default');
137
138 exit_gracefully($process->pid);
139
140 done_testing;