2 # vim:ts=4:sw=4:expandtab
3 # Beware that this test uses workspace 9 to perform some tests (it expects
4 # the workspace to be empty).
5 # TODO: skip it by default?
7 use i3test tests => 22;
9 use Time::HiRes qw(sleep);
12 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
16 skip "stacking test not yet updated", 21;
18 my $x = X11::XCB::Connection->new;
22 # Switch to the nineth workspace
23 $i3->command('9')->recv;
25 #####################################################################
26 # Create two windows and make sure focus switching works
27 #####################################################################
29 my $top = i3test::open_standard_window($x);
30 my $mid = i3test::open_standard_window($x);
31 my $bottom = i3test::open_standard_window($x);
34 diag("top id = " . $top->id);
35 diag("mid id = " . $mid->id);
36 diag("bottom id = " . $bottom->id);
39 # Returns the input focus after sending the given command to i3 via IPC
40 # end sleeping for half a second to make sure i3 reacted
45 $i3->command($msg)->recv;
46 return $x->input_focus;
49 my $focus = $x->input_focus;
50 is($focus, $bottom->id, "Latest window focused");
52 $focus = focus_after("s");
53 is($focus, $bottom->id, "Last window still focused");
55 $focus = focus_after("k");
56 is($focus, $mid->id, "Middle window focused");
58 $focus = focus_after("k");
59 is($focus, $top->id, "Top window focused");
61 #####################################################################
63 #####################################################################
65 $focus = focus_after("k");
66 is($focus, $bottom->id, "Bottom window focused (wrapping to the top works)");
68 $focus = focus_after("j");
69 is($focus, $top->id, "Top window focused (wrapping to the bottom works)");
71 #####################################################################
72 # Restore of focus after moving windows out/into the stack
73 #####################################################################
75 $focus = focus_after("ml");
76 is($focus, $top->id, "Top window still focused (focus after moving)");
78 $focus = focus_after("h");
79 is($focus, $bottom->id, "Bottom window focused (focus after moving)");
81 my $new = i3test::open_standard_window($x);
84 # By now, we have this layout:
91 $focus = focus_after("l");
92 is($focus, $top->id, "Got top window");
94 $focus = focus_after("mh");
95 is($focus, $top->id, "Moved it into the stack");
97 $focus = focus_after("k");
98 is($focus, $new->id, "Window above is new");
100 $focus = focus_after("k");
101 is($focus, $bottom->id, "Window above is bottom");
103 $focus = focus_after("k");
104 is($focus, $mid->id, "Window above is mid");
106 $focus = focus_after("k");
107 is($focus, $top->id, "At top again");
109 $focus = focus_after("ml");
110 is($focus, $top->id, "Still at top, moved out");
112 $focus = focus_after("h");
113 is($focus, $mid->id, "At mid again");
115 $focus = focus_after("j");
116 is($focus, $bottom->id, "At bottom again");
118 $focus = focus_after("l");
119 is($focus, $top->id, "At top again");
121 $focus = focus_after("mh");
122 is($focus, $top->id, "Still at top, moved into");
124 $focus = focus_after("k");
125 is($focus, $bottom->id, "Window above is bottom");
127 $focus = focus_after("k");
128 is($focus, $mid->id, "Window above is mid");