]> git.sur5r.net Git - i3/i3/blob - testcases/t/11-goto.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 11-goto.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use File::Temp;
6
7 my $x = X11::XCB::Connection->new;
8
9 my $tmp = fresh_workspace;
10
11 cmd 'split h';
12
13 #####################################################################
14 # Create two windows and make sure focus switching works
15 #####################################################################
16
17 my $top = open_window($x);
18 my $mid = open_window($x);
19 my $bottom = open_window($x);
20
21 #
22 # Returns the input focus after sending the given command to i3 via IPC
23 # and syncing with i3
24 #
25 sub focus_after {
26     my $msg = shift;
27
28     cmd $msg;
29     sync_with_i3($x);
30     return $x->input_focus;
31 }
32
33 $focus = $x->input_focus;
34 is($focus, $bottom->id, "Latest window focused");
35
36 $focus = focus_after('focus left');
37 is($focus, $mid->id, "Middle window focused");
38
39 #####################################################################
40 # Now goto a mark which does not exist
41 #####################################################################
42
43 my $random_mark = mktemp('mark.XXXXXX');
44
45 $focus = focus_after(qq|[con_mark="$random_mark"] focus|);
46 is($focus, $mid->id, "focus unchanged");
47
48 cmd "mark $random_mark";
49
50 $focus = focus_after('focus left');
51 is($focus, $top->id, "Top window focused");
52
53 $focus = focus_after(qq|[con_mark="$random_mark"] focus|);
54 is($focus, $mid->id, "goto worked");
55
56 # check that we can specify multiple criteria
57
58 $focus = focus_after('focus left');
59 is($focus, $top->id, "Top window focused");
60
61 $focus = focus_after(qq|[con_mark="$random_mark" con_mark="$random_mark"] focus|);
62 is($focus, $mid->id, "goto worked");
63
64 #####################################################################
65 # Check whether the focus command will switch to a different
66 # workspace if necessary
67 #####################################################################
68
69 my $tmp2 = fresh_workspace;
70
71 is(focused_ws(), $tmp2, 'tmp2 now focused');
72
73 cmd qq|[con_mark="$random_mark"] focus|;
74
75 is(focused_ws(), $tmp, 'tmp now focused');
76
77 done_testing;