2 # vim:ts=4:sw=4:expandtab
4 # Tests focus switching (next/prev)
6 use i3test tests => 14;
10 my $i3 = i3("/tmp/nestedcons");
12 my $tmp = get_unused_workspace();
13 $i3->command("workspace $tmp")->recv;
15 ######################################################################
16 # Open one container, verify that 'next v' and 'next h' do nothing
17 ######################################################################
18 $i3->command('open')->recv;
20 my ($nodes, $focus) = get_ws_content($tmp);
21 my $old_focused = $focus->[0];
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');
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');
31 ######################################################################
32 # Open another container, verify that 'next h' switches
33 ######################################################################
34 my $left = $old_focused;
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];
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];
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)');
51 $i3->command('next h')->recv;
52 ($nodes, $focus) = get_ws_content($tmp);
53 is($focus->[0], $mid, 'middle container focused');
55 $i3->command('next h')->recv;
56 ($nodes, $focus) = get_ws_content($tmp);
57 is($focus->[0], $right, 'right container focused');
59 $i3->command('prev h')->recv;
60 ($nodes, $focus) = get_ws_content($tmp);
61 is($focus->[0], $mid, 'middle container focused');
63 $i3->command('prev h')->recv;
64 ($nodes, $focus) = get_ws_content($tmp);
65 is($focus->[0], $left, 'left container focused');
67 $i3->command('prev h')->recv;
68 ($nodes, $focus) = get_ws_content($tmp);
69 is($focus->[0], $right, 'right container focused');
72 ######################################################################
73 # Test synonyms (horizontal/vertical instead of h/v)
74 ######################################################################
76 $i3->command('prev horizontal')->recv;
77 ($nodes, $focus) = get_ws_content($tmp);
78 is($focus->[0], $mid, 'middle container focused');
80 $i3->command('next horizontal')->recv;
81 ($nodes, $focus) = get_ws_content($tmp);
82 is($focus->[0], $right, 'right container focused');
84 ######################################################################
86 ######################################################################
88 $i3->command(qq|[con_id="$mid"] focus|)->recv;
89 ($nodes, $focus) = get_ws_content($tmp);
90 is($focus->[0], $mid, 'middle container focused');
93 diag( "Testing i3, Perl $], $^X" );