]> git.sur5r.net Git - i3/i3/blob - testcases/t/132-move-workspace.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 132-move-workspace.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Checks if the 'move workspace' command works correctly
5 #
6 use i3test;
7
8 my $i3 = i3(get_socket_path());
9
10 # We move the pointer out of our way to avoid a bug where the focus will
11 # be set to the window under the cursor
12 $x->root->warp_pointer(0, 0);
13
14 my $tmp = get_unused_workspace();
15 my $tmp2 = get_unused_workspace();
16 cmd "workspace $tmp";
17
18 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
19
20 my $first = open_empty_con($i3);
21 my $second = open_empty_con($i3);
22 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
23
24 cmd "workspace $tmp2";
25 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws yet');
26
27 cmd "workspace $tmp";
28
29 cmd "move workspace $tmp2";
30 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws anymore');
31 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
32 my ($nodes, $focus) = get_ws_content($tmp2);
33
34 is($focus->[0], $second, 'same container on different ws');
35
36 ($nodes, $focus) = get_ws_content($tmp);
37 ok($nodes->[0]->{focused}, 'first container focused on first ws');
38
39 ###################################################################
40 # check if 'move workspace next' and 'move workspace prev' work
41 ###################################################################
42
43 # Open two containers on the first workspace, one container on the second
44 # workspace. Because the workspaces are named, they will be sorted by order of
45 # creation.
46 $tmp = get_unused_workspace();
47 $tmp2 = get_unused_workspace();
48 cmd "workspace $tmp";
49 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
50 $first = open_empty_con($i3);
51 $second = open_empty_con($i3);
52 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
53
54 cmd "workspace $tmp2";
55 ok(@{get_ws_content($tmp2)} == 0, 'no containers yet');
56 my $third = open_empty_con($i3);
57 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
58
59 # go back to the first workspace, move one of the containers to the next one
60 cmd "workspace $tmp";
61 cmd 'move workspace next';
62 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws');
63 ok(@{get_ws_content($tmp2)} == 2, 'two containers on second ws');
64
65 # go to the second workspace and move two containers to the first one
66 cmd "workspace $tmp2";
67 cmd 'move workspace prev';
68 cmd 'move workspace prev';
69 ok(@{get_ws_content($tmp)} == 3, 'three containers on first ws');
70 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws');
71
72 ###################################################################
73 # check if floating cons are moved to new workspaces properly
74 # (that is, if they are floating on the target ws, too)
75 ###################################################################
76
77 $tmp = get_unused_workspace();
78 $tmp2 = get_unused_workspace();
79 cmd "workspace $tmp";
80
81 cmd "open";
82 cmd "floating toggle";
83
84 my $ws = get_ws($tmp);
85 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
86 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');
87
88 cmd "move workspace $tmp2";
89
90 $ws = get_ws($tmp2);
91 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
92 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');
93
94 done_testing;