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