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 # Contains various tests that use the cmp_tree subroutine.
22 local $Test::Builder::Level = $Test::Builder::Level + 1;
24 my ($layout, $focus_idx) = @_;
25 my @windows = cmp_tree(
26 msg => 'Sanity check',
27 layout_before => $layout,
28 layout_after => $layout);
29 is($x->input_focus, $windows[$focus_idx]->id, 'Correct window focused') if $focus_idx >= 0;
32 sanity_check('H[ V[ a* V[ b c ] d ] e ]', 0);
33 sanity_check('H[ a b c d* ]', 3);
34 sanity_check('V[a b] V[c d*]', 3);
35 sanity_check('T[a b] S[c*]', 2);
38 msg => 'Simple focus test',
39 layout_before => 'H[a b] V[c* d]',
40 layout_after => 'H[a* b] V[c d]',
42 cmd '[class=a] focus';
46 msg => 'Simple move test',
47 layout_before => 'H[a b] V[c* d]',
48 layout_after => 'H[a b] V[d c*]',
54 msg => 'Move from horizontal to vertical',
55 layout_before => 'H[a b] V[c d*]',
56 layout_after => 'H[b] V[c d a*]',
58 cmd '[class=a] focus';
59 cmd 'move right, move right';
63 msg => 'Move unfocused non-leaf container',
64 layout_before => 'S[a b] V[c d* T[e f g]]',
65 layout_after => 'S[a T[e f g] b] V[c d*]',
67 cmd '[con_mark=T1] move up, move up, move left, move up';
71 msg => 'Simple swap test',
72 layout_before => 'H[a b] V[c d*]',
73 layout_after => 'H[a d*] V[c b]',
75 cmd '[class=b] swap with id ' . $_[0][3]->{id};
79 msg => 'Swap non-leaf containers',
80 layout_before => 'S[a b] V[c d*]',
81 layout_after => 'V[c d*] S[a b]',
83 cmd '[con_mark=S1] swap with mark V1';
87 msg => 'Swap nested non-leaf containers',
88 layout_before => 'S[a b] V[c d* T[e f g]]',
89 layout_after => 'T[e f g] V[c d* S[a b]]',
91 cmd '[con_mark=S1] swap with mark T1';