]> git.sur5r.net Git - i3/i3/blob - testcases/t/32-move-workspace.t
Merge branch 'tree' into next
[i3/i3] / testcases / t / 32-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 my $x = X11::XCB::Connection->new;
13 $x->root->warp_pointer(0, 0);
14
15 my $tmp = get_unused_workspace();
16 my $tmp2 = get_unused_workspace();
17 cmd "workspace $tmp";
18
19 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
20
21 my $first = open_empty_con($i3);
22 my $second = open_empty_con($i3);
23 ok(@{get_ws_content($tmp)} == 2, 'two containers on first ws');
24
25 cmd "workspace $tmp2";
26 ok(@{get_ws_content($tmp2)} == 0, 'no containers on second ws yet');
27
28 cmd "workspace $tmp";
29
30 cmd "move workspace $tmp2";
31 ok(@{get_ws_content($tmp)} == 1, 'one container on first ws anymore');
32 ok(@{get_ws_content($tmp2)} == 1, 'one container on second ws');
33 my ($nodes, $focus) = get_ws_content($tmp2);
34
35 is($focus->[0], $second, 'same container on different ws');
36
37 ($nodes, $focus) = get_ws_content($tmp);
38 ok($nodes->[0]->{focused}, 'first container focused on first ws');
39
40 ###################################################################
41 # check if floating cons are moved to new workspaces properly
42 # (that is, if they are floating on the target ws, too)
43 ###################################################################
44
45 $tmp = get_unused_workspace();
46 $tmp2 = get_unused_workspace();
47 cmd "workspace $tmp";
48
49 cmd "open";
50 cmd "floating toggle";
51
52 my $ws = get_ws($tmp);
53 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
54 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');
55
56 cmd "move workspace $tmp2";
57
58 $ws = get_ws($tmp2);
59 is(@{$ws->{nodes}}, 0, 'no nodes on workspace');
60 is(@{$ws->{floating_nodes}}, 1, 'one floating node on workspace');
61
62 done_testing;