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