]> git.sur5r.net Git - i3/i3/blob - testcases/t/516-move.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 516-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 # Tests if a simple 'move <direction>' command will move containers across outputs.
18 #
19 use i3test i3_autostart => 0;
20
21 # Ensure the pointer is at (0, 0) so that we really start on the first
22 # (the left) workspace.
23 $x->root->warp_pointer(0, 0);
24
25 my $config = <<EOT;
26 # i3 config file (v4)
27 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
28
29 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
30
31 workspace left-top output fake-0
32 workspace right-top output fake-1
33 workspace right-bottom output fake-2
34 workspace left-bottom output fake-3
35 EOT
36
37 my $pid = launch_with_config($config);
38
39 #####################################################################
40 # Try to move a single window across outputs in each direction
41 #####################################################################
42
43 cmd('workspace left-top');
44 my $alone_window = open_window;
45
46 cmd('move right');
47 is(scalar @{get_ws_content('right-top')}, 1, 'moved individual window to right-top workspace');
48
49 cmd('move down');
50 is(scalar @{get_ws_content('right-bottom')}, 1, 'moved individual window to right-bottom workspace');
51
52 cmd('move left');
53 is(scalar @{get_ws_content('left-bottom')}, 1, 'moved individual window to left-bottom workspace');
54
55 cmd('move up');
56 is(scalar @{get_ws_content('left-top')}, 1, 'moved individual window to left-top workspace');
57
58 $alone_window->unmap;
59 wait_for_unmap;
60
61 #####################################################################
62 # Try to move a window on a workspace with two windows across outputs in each
63 # direction
64 #####################################################################
65
66 # from left-top to right-top
67 cmd('workspace left-top');
68 cmd('split h');
69 my $first_window = open_window;
70 my $social_window = open_window( name => 'CORRECT_WINDOW' );
71 cmd('move right');
72 is(scalar @{get_ws_content('right-top')}, 1, 'moved some window to right-top workspace');
73 my $compare_window = shift @{get_ws_content('right-top')};
74 is($compare_window->{window}, $social_window->id, 'moved correct window to right-top workspace');
75 # unmap the first window so we don't confuse it when we move back here
76 $first_window->unmap;
77 wait_for_unmap;
78
79 # from right-top to right-bottom
80 cmd('split v');
81 open_window;
82 # this window opened above - we need to move down twice
83 cmd('focus up; move down; move down');
84 is(scalar @{get_ws_content('right-bottom')}, 1, 'moved some window to right-bottom workspace');
85 $compare_window = shift @{get_ws_content('right-bottom')};
86 is($compare_window->{name}, $social_window->name, 'moved correct window to right-bottom workspace');
87
88 # from right-bottom to left-bottom
89 cmd('split h');
90 open_window;
91 cmd('focus left; move left');
92 is(scalar @{get_ws_content('left-bottom')}, 1, 'moved some window to left-bottom workspace');
93 $compare_window = shift @{get_ws_content('left-bottom')};
94 is($social_window->name, $compare_window->{name}, 'moved correct window to left-bottom workspace');
95
96 # from left-bottom to left-top
97 cmd('split v');
98 open_window;
99 cmd('focus up; move up');
100 is(scalar @{get_ws_content('left-top')}, 1, 'moved some window to left-bottom workspace');
101 $compare_window = shift @{get_ws_content('left-top')};
102 is($social_window->name, $compare_window->{name}, 'moved correct window to left-bottom workspace');
103
104 exit_gracefully($pid);
105
106 done_testing;