]> git.sur5r.net Git - i3/i3/blob - testcases/t/101-focus.t
testcases: drop open_window()s $x parameter, use global one instead
[i3/i3] / testcases / t / 101-focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5
6 my $tmp = fresh_workspace;
7
8 #####################################################################
9 # Create two windows and make sure focus switching works
10 #####################################################################
11
12 # Change mode of the container to "default" for following tests
13 cmd 'layout default';
14 cmd 'split v';
15
16 my $top = open_window;
17 my $mid = open_window;
18 my $bottom = open_window;
19
20 #
21 # Returns the input focus after sending the given command to i3 via IPC
22 # end sleeping for half a second to make sure i3 reacted
23 #
24 sub focus_after {
25     my $msg = shift;
26
27     cmd $msg;
28     sync_with_i3 $x;
29     return $x->input_focus;
30 }
31
32 my $focus = $x->input_focus;
33 is($focus, $bottom->id, "Latest window focused");
34
35 $focus = focus_after('focus up');
36 is($focus, $mid->id, "Middle window focused");
37
38 $focus = focus_after('focus up');
39 is($focus, $top->id, "Top window focused");
40
41 #####################################################################
42 # Test focus wrapping
43 #####################################################################
44
45 $focus = focus_after('focus up');
46 is($focus, $bottom->id, "Bottom window focused (wrapping to the top works)");
47
48 $focus = focus_after('focus down');
49 is($focus, $top->id, "Top window focused (wrapping to the bottom works)");
50
51 ###############################################
52 # Test focus with empty containers and colspan
53 ###############################################
54
55 #my $otmp = get_unused_workspace();
56 #$i3->command("workspace $otmp")->recv;
57 #
58 #$top = i3test::open_standard_window($x);
59 #$bottom = i3test::open_standard_window($x);
60 #sleep 0.25;
61 #
62 #$focus = focus_after("mj");
63 #$focus = focus_after("mh");
64 #$focus = focus_after("k");
65 #is($focus, $bottom->id, "Selecting top window without snapping doesn't work");
66 #
67 #$focus = focus_after("sl");
68 #is($focus, $bottom->id, "Bottom window focused");
69 #
70 #$focus = focus_after("k");
71 #is($focus, $top->id, "Top window focused");
72 #
73 ## Same thing, but left/right instead of top/bottom
74 #
75 #my $o2tmp = get_unused_workspace();
76 #$i3->command("workspace $o2tmp")->recv;
77 #
78 #my $left = i3test::open_standard_window($x);
79 #my $right = i3test::open_standard_window($x);
80 #sleep 0.25;
81 #
82 #$focus = focus_after("ml");
83 #$focus = focus_after("h");
84 #$focus = focus_after("mk");
85 #$focus = focus_after("l");
86 #is($focus, $left->id, "Selecting right window without snapping doesn't work");
87 #
88 #$focus = focus_after("sj");
89 #is($focus, $left->id, "left window focused");
90 #
91 #$focus = focus_after("l");
92 #is($focus, $right->id, "right window focused");
93
94
95 done_testing;