]> git.sur5r.net Git - i3/i3/blob - testcases/t/103-move.t
Fix spelling mistakes
[i3/i3] / testcases / t / 103-move.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Beware that this test uses workspace 9 to perform some tests (it expects
18 # the workspace to be empty).
19 # TODO: skip it by default?
20
21 use i3test tests => 8;
22 use X11::XCB qw(:all);
23 use Time::HiRes qw(sleep);
24
25 BEGIN {
26     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
27 }
28
29 SKIP: {
30     skip "Testcase not yet modified for new move concept", 7;
31
32 my $x = X11::XCB::Connection->new;
33
34 my $i3 = i3;
35
36 # Switch to the ninth workspace
37 $i3->command('9')->recv;
38
39 #####################################################################
40 # Create two windows and make sure focus switching works
41 #####################################################################
42
43 my $top = i3test::open_standard_window($x);
44 sleep(0.25);
45 my $mid = i3test::open_standard_window($x);
46 sleep(0.25);
47 my $bottom = i3test::open_standard_window($x);
48 sleep(0.25);
49
50 diag("top id = " . $top->id);
51 diag("mid id = " . $mid->id);
52 diag("bottom id = " . $bottom->id);
53
54 #
55 # Returns the input focus after sending the given command to i3 via IPC
56 # end sleeping for half a second to make sure i3 reacted
57 #
58 sub focus_after {
59     my $msg = shift;
60
61     $i3->command($msg)->recv;
62     return $x->input_focus;
63 }
64
65 my $focus = $x->input_focus;
66 is($focus, $bottom->id, "Latest window focused");
67
68 $focus = focus_after("ml");
69 is($focus, $bottom->id, "Right window still focused");
70
71 $focus = focus_after("h");
72 is($focus, $mid->id, "Middle window focused");
73
74 #####################################################################
75 # Now move to the top window, move right, then move left again
76 # (e.g., does i3 remember the focus in the last container?)
77 #####################################################################
78
79 $focus = focus_after("k");
80 is($focus, $top->id, "Top window focused");
81
82 $focus = focus_after("l");
83 is($focus, $bottom->id, "Right window focused");
84
85 $focus = focus_after("h");
86 is($focus, $top->id, "Top window focused");
87
88 #####################################################################
89 # Move window cross-workspace
90 #####################################################################
91
92 for my $cmd (qw(m12 t m13 12 13)) {
93     $i3->command($cmd)->recv;
94 }
95 ok(1, "Still living");
96 }