2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Verifies that scratchpad windows show up on the proper output.
18 # ticket #596, bug present until up to commit
19 # 89dded044b4fffe78f9d70778748fabb7ac533e9.
21 use i3test i3_config => <<EOT;
23 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25 fake-outputs 1024x768+0+0,1024x768+1024+0
28 ################################################################################
29 # Open a workspace on the second output, put a window to scratchpad, display
30 # it, verify it’s on the same workspace.
31 ################################################################################
33 sub verify_scratchpad_on_same_ws {
36 is_num_children($ws, 0, 'no nodes on this ws');
38 my $window = open_window;
40 is_num_children($ws, 1, 'one nodes on this ws');
42 cmd 'move scratchpad';
44 is_num_children($ws, 0, 'no nodes on this ws');
46 cmd 'scratchpad show';
47 is_num_children($ws, 0, 'no nodes on this ws');
48 is(scalar @{get_ws($ws)->{floating_nodes}}, 1, 'one floating node on this ws');
51 my $second = fresh_workspace(output => 1);
53 verify_scratchpad_on_same_ws($second);
55 ################################################################################
56 # The same thing, but on the first output.
57 ################################################################################
59 my $first = fresh_workspace(output => 0);
61 verify_scratchpad_on_same_ws($first);
63 ################################################################################
64 # Now open the scratchpad on one output and switch to another.
65 ################################################################################
67 sub verify_scratchpad_switch {
68 my ($first, $second) = @_;
70 cmd "workspace $first";
72 is_num_children($first, 0, 'no nodes on this ws');
74 my $window = open_window;
76 is_num_children($first, 1, 'one nodes on this ws');
78 cmd 'move scratchpad';
80 is_num_children($first, 0, 'no nodes on this ws');
82 cmd "workspace $second";
84 cmd 'scratchpad show';
85 my $ws = get_ws($second);
86 is_num_children($second, 0, 'no nodes on this ws');
87 is(scalar @{$ws->{floating_nodes}}, 1, 'one floating node on this ws');
89 # Verify that the coordinates are within bounds.
90 my $srect = $ws->{floating_nodes}->[0]->{rect};
91 my $rect = $ws->{rect};
92 cmd 'nop before bounds check';
93 cmp_ok($srect->{x}, '>=', $rect->{x}, 'x within bounds');
94 cmp_ok($srect->{y}, '>=', $rect->{y}, 'y within bounds');
95 cmp_ok($srect->{x} + $srect->{width}, '<=', $rect->{x} + $rect->{width},
96 'width within bounds');
97 cmp_ok($srect->{y} + $srect->{height}, '<=', $rect->{y} + $rect->{height},
98 'height within bounds');
101 $first = fresh_workspace(output => 0);
102 $second = fresh_workspace(output => 1);
104 verify_scratchpad_switch($first, $second);
106 $first = fresh_workspace(output => 1);
107 $second = fresh_workspace(output => 0);
109 verify_scratchpad_switch($first, $second);