]> git.sur5r.net Git - i3/i3/blob - testcases/t/07-move.t
bugfix: don’t clean up workspace when switching to the same workspace
[i3/i3] / testcases / t / 07-move.t
1 #!perl
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?
6
7 use i3test tests => 8;
8 use X11::XCB qw(:all);
9 use Time::HiRes qw(sleep);
10
11 BEGIN {
12     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
13 }
14
15 my $x = X11::XCB::Connection->new;
16
17 my $i3 = i3;
18
19 # Switch to the nineth workspace
20 $i3->command('9')->recv;
21
22 #####################################################################
23 # Create two windows and make sure focus switching works
24 #####################################################################
25
26 my $top = i3test::open_standard_window($x);
27 sleep(0.25);
28 my $mid = i3test::open_standard_window($x);
29 sleep(0.25);
30 my $bottom = i3test::open_standard_window($x);
31 sleep(0.25);
32
33 diag("top id = " . $top->id);
34 diag("mid id = " . $mid->id);
35 diag("bottom id = " . $bottom->id);
36
37 #
38 # Returns the input focus after sending the given command to i3 via IPC
39 # end sleeping for half a second to make sure i3 reacted
40 #
41 sub focus_after {
42     my $msg = shift;
43
44     $i3->command($msg)->recv;
45     return $x->input_focus;
46 }
47
48 $focus = $x->input_focus;
49 is($focus, $bottom->id, "Latest window focused");
50
51 $focus = focus_after("ml");
52 is($focus, $bottom->id, "Right window still focused");
53
54 $focus = focus_after("h");
55 is($focus, $mid->id, "Middle window focused");
56
57 #####################################################################
58 # Now move to the top window, move right, then move left again
59 # (e.g., does i3 remember the focus in the last container?)
60 #####################################################################
61
62 $focus = focus_after("k");
63 is($focus, $top->id, "Top window focused");
64
65 $focus = focus_after("l");
66 is($focus, $bottom->id, "Right window focused");
67
68 $focus = focus_after("h");
69 is($focus, $top->id, "Top window focused");
70
71 #####################################################################
72 # Move window cross-workspace
73 #####################################################################
74
75 for my $cmd (qw(m12 t m13 12 13)) {
76     $i3->command($cmd)->recv;
77 }
78 ok(1, "Still living");