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