]> git.sur5r.net Git - i3/i3/blob - testcases/t/35-floating-focus.t
tests: clean up/beautify all tests (code style / test style)
[i3/i3] / testcases / t / 35-floating-focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5
6 my $tmp = fresh_workspace;
7
8 #############################################################################
9 # 1: see if focus stays the same when toggling tiling/floating mode
10 #############################################################################
11
12 cmd "open";
13 cmd "open";
14
15 my @content = @{get_ws_content($tmp)};
16 cmp_ok(@content, '==', 2, 'two containers opened');
17 cmp_ok($content[1]->{focused}, '==', 1, 'Second container focused');
18
19 cmd "mode floating";
20 cmd "mode tiling";
21
22 @content = @{get_ws_content($tmp)};
23 cmp_ok($content[1]->{focused}, '==', 1, 'Second container still focused after mode toggle');
24
25 #############################################################################
26 # 2: see if the focus gets reverted correctly when closing floating clients
27 # (first to the next floating client, then to the last focused tiling client)
28 #############################################################################
29
30 $tmp = fresh_workspace;
31
32 cmd "open";
33 cmd "open";
34 cmd "open";
35
36 @content = @{get_ws_content($tmp)};
37 cmp_ok(@content, '==', 3, 'two containers opened');
38 cmp_ok($content[2]->{focused}, '==', 1, 'Last container focused');
39
40 my $last_id = $content[2]->{id};
41 my $second_id = $content[1]->{id};
42 my $first_id = $content[0]->{id};
43 diag("last_id = $last_id, second_id = $second_id, first_id = $first_id");
44
45 cmd qq|[con_id="$second_id"] focus|;
46 @content = @{get_ws_content($tmp)};
47 cmp_ok($content[1]->{focused}, '==', 1, 'Second container focused');
48
49 cmd "mode floating";
50
51 cmd qq|[con_id="$last_id"] focus|;
52 @content = @{get_ws_content($tmp)};
53 cmp_ok($content[1]->{focused}, '==', 1, 'Last container focused');
54
55 cmd "mode floating";
56
57 diag("focused = " . get_focused($tmp));
58
59 cmd "kill";
60
61 diag("focused = " . get_focused($tmp));
62 # TODO: this test result is actually not right. the focus reverts to where the mouse pointer is.
63 cmp_ok(get_focused($tmp), '==', $second_id, 'Focus reverted to second floating container');
64
65 cmd "kill";
66 @content = @{get_ws_content($tmp)};
67 cmp_ok($content[0]->{focused}, '==', 1, 'Focus reverted to tiling container');
68
69 done_testing;