This repository has been archived by the owner on Apr 18, 2023. It is now read-only.
/
522-rename-assigned-workspace.t
97 lines (81 loc) · 3.4 KB
/
522-rename-assigned-workspace.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
# (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
# (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
# (or docs/ipc)
#
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
# (unless you are already familiar with Perl)
#
#
# Tests that workspaces are moved to the assigned output if they
# are renamed to an assigned name.
# Ticket: #1473
use i3test i3_config => <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
fake-outputs 1024x768+0+0,1024x768+1024+0
workspace 1 output fake-0
workspace 2 output fake-1
workspace 3:foo output fake-1
workspace baz output fake-1
workspace 5 output left
EOT
my $i3 = i3(get_socket_path());
$i3->connect->recv;
# Returns the name of the output on which this workspace resides
sub get_output_for_workspace {
my $ws_name = shift @_;
foreach (grep { not $_->{name} =~ /^__/ } @{$i3->get_tree->recv->{nodes}}) {
my $output = $_->{name};
foreach (grep { $_->{name} =~ "content" } @{$_->{nodes}}) {
return $output if $_->{nodes}[0]->{name} =~ $ws_name;
}
}
}
##########################################################################
# Renaming the workspace to an unassigned name does not move the workspace
# (regression test)
##########################################################################
cmd 'focus output fake-0';
cmd 'rename workspace to unassigned';
is(get_output_for_workspace('unassigned'), 'fake-0',
'Unassigned workspace should stay on its output when being renamed');
##########################################################################
# Renaming a workspace by number only triggers the assignment
##########################################################################
cmd 'focus output fake-0';
cmd 'rename workspace to 2';
is(get_output_for_workspace('2'), 'fake-1',
'Renaming the workspace to a number should move it to the assigned output');
##########################################################################
# Renaming a workspace by number and name triggers the assignment
##########################################################################
cmd 'focus output fake-0';
cmd 'rename workspace to "2:foo"';
is(get_output_for_workspace('2:foo'), 'fake-1',
'Renaming the workspace to a number and name should move it to the assigned output');
##########################################################################
# Renaming a workspace by name only triggers the assignment
##########################################################################
cmd 'focus output fake-0';
cmd 'rename workspace to baz';
is(get_output_for_workspace('baz'), 'fake-1',
'Renaming the workspace to a number and name should move it to the assigned output');
##########################################################################
# Renaming a workspace so that it is assigned a directional output does
# not move the workspace or crash
##########################################################################
cmd 'focus output fake-0';
cmd 'workspace bar';
cmd 'rename workspace to 5';
is(get_output_for_workspace('5'), 'fake-0',
'Renaming the workspace to a workspace assigned to a directional output should not move the workspace');
done_testing;