]> git.sur5r.net Git - i3/i3/blob - testcases/t/516-move.t
3db8c4f01a005e5bb4da0e175fa51b417b357133
[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 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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_config => <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22
23 fake-outputs 1024x768+0+0,1024x768+1024+0,1024x768+1024+768,1024x768+0+768
24
25 workspace left-top output fake-0
26 workspace right-top output fake-1
27 workspace right-bottom output fake-2
28 workspace left-bottom output fake-3
29 EOT
30
31 # Ensure the pointer is at (0, 0) so that we really start on the first
32 # (the left) workspace.
33 $x->root->warp_pointer(0, 0);
34
35 #####################################################################
36 # Try to move a single window across outputs in each direction
37 #####################################################################
38
39 cmd('workspace left-top');
40 my $alone_window = open_window;
41
42 cmd('move right');
43 is(scalar @{get_ws_content('right-top')}, 1, 'moved individual window to right-top workspace');
44
45 cmd('move down');
46 is(scalar @{get_ws_content('right-bottom')}, 1, 'moved individual window to right-bottom workspace');
47
48 cmd('move left');
49 is(scalar @{get_ws_content('left-bottom')}, 1, 'moved individual window to left-bottom workspace');
50
51 cmd('move up');
52 is(scalar @{get_ws_content('left-top')}, 1, 'moved individual window to left-top workspace');
53
54 $alone_window->unmap;
55 wait_for_unmap;
56
57 #####################################################################
58 # Try to move a window on a workspace with two windows across outputs in each
59 # direction
60 #####################################################################
61
62 # from left-top to right-top
63 cmd('workspace left-top');
64 cmd('split h');
65 my $first_window = open_window;
66 my $social_window = open_window( name => 'CORRECT_WINDOW' );
67 cmd('move right');
68 is(scalar @{get_ws_content('right-top')}, 1, 'moved some window to right-top workspace');
69 my $compare_window = shift @{get_ws_content('right-top')};
70 is($compare_window->{window}, $social_window->id, 'moved correct window to right-top workspace');
71 # unmap the first window so we don't confuse it when we move back here
72 $first_window->unmap;
73 wait_for_unmap;
74
75 # from right-top to right-bottom
76 cmd('split v');
77 open_window;
78 # this window opened above - we need to move down twice
79 cmd('focus up; move down; move down');
80 is(scalar @{get_ws_content('right-bottom')}, 1, 'moved some window to right-bottom workspace');
81 $compare_window = shift @{get_ws_content('right-bottom')};
82 is($compare_window->{name}, $social_window->name, 'moved correct window to right-bottom workspace');
83
84 # from right-bottom to left-bottom
85 cmd('split h');
86 open_window;
87 cmd('focus left; move left');
88 is(scalar @{get_ws_content('left-bottom')}, 1, 'moved some window to left-bottom workspace');
89 $compare_window = shift @{get_ws_content('left-bottom')};
90 is($social_window->name, $compare_window->{name}, 'moved correct window to left-bottom workspace');
91
92 # from left-bottom to left-top
93 cmd('split v');
94 open_window;
95 cmd('focus up; move up');
96 is(scalar @{get_ws_content('left-top')}, 1, 'moved some window to left-bottom workspace');
97 $compare_window = shift @{get_ws_content('left-top')};
98 is($social_window->name, $compare_window->{name}, 'moved correct window to left-bottom workspace');
99
100 #####################################################################
101 # Moving a fullscreen container should change its output.
102 #####################################################################
103
104 kill_all_windows;
105
106 cmd 'workspace left-top';
107 open_window;
108 my $fs_window = open_window;
109 open_window;
110
111 cmd '[id=' . $fs_window->id . '] fullscreen enable, move right';
112 is(scalar @{get_ws_content('right-top')}, 1, 'moved fullscreen window to right-top workspace');
113
114 #####################################################################
115 # Moving a global fullscreen container should not change its output.
116 #####################################################################
117
118 kill_all_windows;
119
120 cmd 'workspace left-top';
121 open_window;
122 open_window;
123 open_window;
124
125 cmd 'fullscreen global, move right, fullscreen disable';
126 is(scalar @{get_ws_content('right-top')}, 0, 'global fullscreen window didn\'t change workspace with move');
127
128 done_testing;