]> git.sur5r.net Git - i3/i3/blob - testcases/t/21-next-prev.t
t/21: formatting
[i3/i3] / testcases / t / 21-next-prev.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Tests focus switching (next/prev)
5 #
6 use i3test tests => 14;
7 use X11::XCB qw(:all);
8 use v5.10;
9
10 my $i3 = i3("/tmp/nestedcons");
11
12 my $tmp = get_unused_workspace();
13 $i3->command("workspace $tmp")->recv;
14
15 ######################################################################
16 # Open one container, verify that 'next v' and 'next h' do nothing
17 ######################################################################
18 $i3->command('open')->recv;
19
20 my ($nodes, $focus) = get_ws_content($tmp);
21 my $old_focused = $focus->[0];
22
23 $i3->command('next v')->recv;
24 ($nodes, $focus) = get_ws_content($tmp);
25 is($focus->[0], $old_focused, 'focus did not change with only one con');
26
27 $i3->command('next h')->recv;
28 ($nodes, $focus) = get_ws_content($tmp);
29 is($focus->[0], $old_focused, 'focus did not change with only one con');
30
31 ######################################################################
32 # Open another container, verify that 'next h' switches
33 ######################################################################
34 my $left = $old_focused;
35
36 $i3->command('open')->recv;
37 ($nodes, $focus) = get_ws_content($tmp);
38 isnt($old_focused, $focus->[0], 'new container is focused');
39 my $mid = $focus->[0];
40
41 $i3->command('open')->recv;
42 ($nodes, $focus) = get_ws_content($tmp);
43 isnt($old_focused, $focus->[0], 'new container is focused');
44 my $right = $focus->[0];
45
46 $i3->command('next h')->recv;
47 ($nodes, $focus) = get_ws_content($tmp);
48 isnt($focus->[0], $right, 'focus did change');
49 is($focus->[0], $left, 'left container focused (wrapping)');
50
51 $i3->command('next h')->recv;
52 ($nodes, $focus) = get_ws_content($tmp);
53 is($focus->[0], $mid, 'middle container focused');
54
55 $i3->command('next h')->recv;
56 ($nodes, $focus) = get_ws_content($tmp);
57 is($focus->[0], $right, 'right container focused');
58
59 $i3->command('prev h')->recv;
60 ($nodes, $focus) = get_ws_content($tmp);
61 is($focus->[0], $mid, 'middle container focused');
62
63 $i3->command('prev h')->recv;
64 ($nodes, $focus) = get_ws_content($tmp);
65 is($focus->[0], $left, 'left container focused');
66
67 $i3->command('prev h')->recv;
68 ($nodes, $focus) = get_ws_content($tmp);
69 is($focus->[0], $right, 'right container focused');
70
71
72 ######################################################################
73 # Test synonyms (horizontal/vertical instead of h/v)
74 ######################################################################
75
76 $i3->command('prev horizontal')->recv;
77 ($nodes, $focus) = get_ws_content($tmp);
78 is($focus->[0], $mid, 'middle container focused');
79
80 $i3->command('next horizontal')->recv;
81 ($nodes, $focus) = get_ws_content($tmp);
82 is($focus->[0], $right, 'right container focused');
83
84 ######################################################################
85 # Test focus command
86 ######################################################################
87
88 $i3->command(qq|[con_id="$mid"] focus|)->recv;
89 ($nodes, $focus) = get_ws_content($tmp);
90 is($focus->[0], $mid, 'middle container focused');
91
92
93 diag( "Testing i3, Perl $], $^X" );