contrib
debian
docs
i3-config-wizard
i3-dump-log
i3-input
i3-msg
i3-nagbar
i3bar
include
libi3
man
parser-specs
src
testcases
lib
t
000-load-deps.t
001-tile.t
002-i3-sync.t
003-ipc.t
004-unmanaged.t
005-floating.t
100-fullscreen.t
101-focus.t
102-dock.t
103-move.t
104-focus-stack.t
105-stacking.t
111-goto.t
112-floating-resize.t
113-urgent.t
114-client-leader.t
115-ipc-workspaces.t
116-nestedcons.t
117-workspace.t
118-openkill.t
119-match.t
120-multiple-cmds.t
121-next-prev.t
122-split.t
124-move.t
126-regress-close.t
127-regress-floating-parent.t
128-open-order.t
129-focus-after-close.t
130-close-empty-split.t
131-stacking-order.t
132-move-workspace.t
133-size-hints.t
134-invalid-command.t
135-floating-focus.t
136-floating-ws-empty.t
137-floating-unmap.t
138-floating-attach.t
139-ws-numbers.t
140-focus-lost.t
141-resize.t
142-regress-move-floating.t
143-regress-floating-restart.t
144-regress-floating-resize.t
145-flattening.t
146-floating-reinsert.t
147-regress-floatingmove.t
148-regress-floatingmovews.t
150-regress-dock-restart.t
151-regress-float-size.t
152-regress-level-up.t
153-floating-originalsize.t
154-regress-multiple-dock.t
155-floating-split-size.t
156-fullscreen-focus.t
158-wm_take_focus.t
159-socketpaths.t
161-regress-borders-restart.t
162-regress-dock-urgent.t
163-wm-state.t
164-kill-win-vs-client.t
165-for_window.t
166-assign.t
167-workspace_layout.t
168-regress-fullscreen-restart.t
169-border-toggle.t
170-force_focus_wrapping.t
171-config-migrate.t
172-start-on-named-ws.t
173-get-marks.t
173-regress-focus-assign.t
174-border-config.t
174-regress-focus-toggle.t
175-startup-notification.t
176-workspace-baf.t
177-bar-config.t
178-regress-workspace-open.t
179-regress-multiple-ws.t
180-fd-leaks.t
181-regress-float-border.t
182-regress-focus-dock.t
183-config-variables.t
184-regress-float-split-resize.t
185-scratchpad.t
186-regress-assign-focus-parent.t
187-commands-parser.t
188-regress-focus-restart.t
189-floating-constraints.t
190-scratchpad-diff-ws.t
191-resize-levels.t
192-layout.t
193-ipc-version.t
194-regress-floating-size.t
195-net-active-window.t
196-randr-output-names.t
197-regression-move-vanish.t
198-regression-scratchpad-crash.t
199-ipc-mode-event.t
200-urgency-timer.t
201-config-parser.t
202-scratchpad-criteria.t
203-regress-assign-and-move.t
204-regress-scratchpad-move.t
205-ipc-windows.t
206-fullscreen-scratchpad.t
207-shmlog.t
208-regress-floating-criteria.t
209-ewmh-net-workarea.t
210-mark-unmark.t
211-regress-urgency-assign.t
212-assign-urgency.t
500-multi-monitor.t
501-scratchpad.t
502-focus-output.t
503-workspace.t
504-move-workspace-to-output.t
505-scratchpad-resolution.t
506-focus-right.t
507-workspace-move-crash.t
509-workspace_layout.t
510-focus-across-outputs.t
511-scratchpad-configure-request.t
512-move-wraps.t
513-move-workspace.t
514-ipc-workspace-multi-monitor.t
515-create-workspace.t
516-move.t
.gitignore
Makefile.PL
Xdummy
complete-run.pl
i3-test.config
new-test
restart-state.golden
tests
yajl-fallback
.gitignore
DEPENDS
LICENSE
Makefile
PACKAGE-MAINTAINER
RELEASE-NOTES-4.2
RELEASE-NOTES-4.3
RELEASE-NOTES-4.4
RELEASE-NOTES-4.5
RELEASE-NOTES-4.5.1
RELEASE-NOTES-4.6
common.mk
generate-command-parser.pl
i3-dmenu-desktop
i3-migrate-config-to-v4
i3-sensible-editor
i3-sensible-pager
i3-sensible-terminal
i3.applications.desktop
i3.config
i3.config.keycodes
i3.xsession.desktop
logo.svg
pseudo-doc.doxygen
The corresponding command is 'rename workspace to <name>'. As a side-effect this fixes the command 'rename workspace 1 to to'. Signed-off-by: Michael Walle <michael@walle.cc>
294 lines
9.8 KiB
Perl
294 lines
9.8 KiB
Perl
#!perl
|
||
# vim:ts=4:sw=4:expandtab
|
||
#
|
||
# Please read the following documents before working on tests:
|
||
# • http://build.i3wm.org/docs/testsuite.html
|
||
# (or docs/testsuite)
|
||
#
|
||
# • http://build.i3wm.org/docs/lib-i3test.html
|
||
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||
#
|
||
# • http://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 whether we can switch to a non-existant workspace
|
||
# (necessary for further tests)
|
||
#
|
||
use List::Util qw(first);
|
||
use i3test;
|
||
|
||
# to ensure that workspace 1 stays open
|
||
cmd 'open';
|
||
|
||
my $tmp = fresh_workspace;
|
||
ok(workspace_exists($tmp), 'workspace created');
|
||
# if the workspace could not be created, we cannot run any other test
|
||
# (every test starts by creating its workspace)
|
||
if (!workspace_exists($tmp)) {
|
||
BAIL_OUT('Cannot create workspace, further tests make no sense');
|
||
}
|
||
|
||
my $otmp = fresh_workspace;
|
||
diag("Other temporary workspace name: $otmp\n");
|
||
|
||
# As the old workspace was empty, it should get
|
||
# cleaned up as we switch away from it
|
||
cmd "workspace $otmp";
|
||
ok(!workspace_exists($tmp), 'old workspace cleaned up');
|
||
|
||
# Switch to the same workspace again to make sure it doesn’t get cleaned up
|
||
cmd "workspace $otmp";
|
||
cmd "workspace $otmp";
|
||
ok(workspace_exists($otmp), 'other workspace still exists');
|
||
|
||
|
||
#####################################################################
|
||
# check if the workspace next / prev commands work
|
||
#####################################################################
|
||
|
||
cmd 'workspace next';
|
||
|
||
ok(!workspace_exists('next'), 'workspace "next" does not exist');
|
||
|
||
cmd "workspace $tmp";
|
||
cmd 'open';
|
||
|
||
ok(workspace_exists($tmp), 'workspace created');
|
||
|
||
cmd "workspace $otmp";
|
||
cmd 'open';
|
||
|
||
ok(workspace_exists($tmp), 'workspace tmp still exists');
|
||
ok(workspace_exists($otmp), 'workspace otmp created');
|
||
|
||
is(focused_ws(), $otmp, 'focused workspace is otmp');
|
||
|
||
cmd 'workspace prev';
|
||
is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
|
||
|
||
cmd 'workspace next';
|
||
is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
|
||
|
||
|
||
#####################################################################
|
||
# check that wrapping works
|
||
#####################################################################
|
||
|
||
cmd 'workspace next';
|
||
is(focused_ws(), '1', 'focused workspace is 1 after workspace next');
|
||
|
||
cmd 'workspace next';
|
||
is(focused_ws(), $tmp, 'focused workspace is tmp after workspace next');
|
||
|
||
cmd 'workspace next';
|
||
is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
|
||
|
||
|
||
cmd 'workspace prev';
|
||
is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
|
||
|
||
cmd 'workspace prev';
|
||
is(focused_ws(), '1', 'focused workspace is tmp after workspace prev');
|
||
|
||
cmd 'workspace prev';
|
||
is(focused_ws(), $otmp, 'focused workspace is otmp after workspace prev');
|
||
|
||
|
||
#####################################################################
|
||
# check if we can change to "next" / "prev"
|
||
#####################################################################
|
||
|
||
cmd 'workspace "next"';
|
||
|
||
ok(workspace_exists('next'), 'workspace "next" exists');
|
||
is(focused_ws(), 'next', 'now on workspace next');
|
||
|
||
cmd 'workspace "prev"';
|
||
|
||
ok(workspace_exists('prev'), 'workspace "prev" exists');
|
||
is(focused_ws(), 'prev', 'now on workspace prev');
|
||
|
||
#####################################################################
|
||
# check that the numbers are assigned/recognized correctly
|
||
#####################################################################
|
||
|
||
cmd "workspace 3: $tmp";
|
||
my $ws = get_ws("3: $tmp");
|
||
ok(defined($ws), "workspace 3: $tmp was created");
|
||
is($ws->{num}, 3, 'workspace number is 3');
|
||
|
||
cmd "workspace 0: $tmp";
|
||
$ws = get_ws("0: $tmp");
|
||
ok(defined($ws), "workspace 0: $tmp was created");
|
||
is($ws->{num}, 0, 'workspace number is 0');
|
||
|
||
cmd "workspace aa: $tmp";
|
||
$ws = get_ws("aa: $tmp");
|
||
ok(defined($ws), "workspace aa: $tmp was created");
|
||
is($ws->{num}, -1, 'workspace number is -1');
|
||
|
||
################################################################################
|
||
# Check that we can go to workspace "4: foo" with the command
|
||
# "workspace number 4".
|
||
################################################################################
|
||
|
||
ok(!workspace_exists('4'), 'workspace 4 does not exist');
|
||
ok(!workspace_exists('4: foo'), 'workspace 4: foo does not exist yet');
|
||
cmd 'workspace 4: foo';
|
||
ok(workspace_exists('4: foo'), 'workspace 4: foo was created');
|
||
cmd 'open';
|
||
|
||
cmd 'workspace 3';
|
||
ok(workspace_exists('4: foo'), 'workspace 4: foo still open');
|
||
cmd 'workspace number 4';
|
||
is(focused_ws(), '4: foo', 'now on workspace 4: foo');
|
||
ok(!workspace_exists('4'), 'workspace 4 still does not exist');
|
||
|
||
################################################################################
|
||
# Check that we "workspace number 5" will create workspace 5 if it does not yet
|
||
# exist.
|
||
################################################################################
|
||
|
||
ok(!workspace_exists('5'), 'workspace 5 does not exist');
|
||
cmd 'workspace number 5';
|
||
ok(workspace_exists('5'), 'workspace 5 was created');
|
||
|
||
################################################################################
|
||
# Check that we can go to workspace "7: foo" with the command
|
||
# "workspace number 7: bar", i.e. the additional workspace name is ignored.
|
||
################################################################################
|
||
|
||
ok(!workspace_exists('7'), 'workspace 7 does not exist');
|
||
ok(!workspace_exists('7: bar'), 'workspace 7: bar does not exist');
|
||
ok(!workspace_exists('7: foo'), 'workspace 7: foo does not exist yet');
|
||
cmd 'workspace 7: foo';
|
||
ok(workspace_exists('7: foo'), 'workspace 7: foo was created');
|
||
cmd 'open';
|
||
|
||
cmd 'workspace 6';
|
||
ok(workspace_exists('7: foo'), 'workspace 7: foo still open');
|
||
cmd 'workspace number 7: bar';
|
||
is(focused_ws(), '7: foo', 'now on workspace 7: foo');
|
||
ok(!workspace_exists('7'), 'workspace 7 still does not exist');
|
||
ok(!workspace_exists('7: bar'), 'workspace 7: bar still does not exist');
|
||
|
||
################################################################################
|
||
# Check that "workspace number 8: foo" will create workspace "8: foo" if it
|
||
# does not yet exist (just like "workspace 8: foo" would).
|
||
################################################################################
|
||
|
||
ok(!workspace_exists('8: foo'), 'workspace 8: foo does not exist');
|
||
cmd 'workspace number 8: foo';
|
||
ok(workspace_exists('8: foo'), 'workspace 8: foo was created');
|
||
|
||
################################################################################
|
||
# Verify that renaming workspaces works.
|
||
################################################################################
|
||
|
||
sub workspace_numbers_sorted {
|
||
my ($name) = @_;
|
||
my $i3 = i3(get_socket_path());
|
||
my $tree = $i3->get_tree->recv;
|
||
|
||
my @outputs = @{$tree->{nodes}};
|
||
my @workspaces;
|
||
for my $output (@outputs) {
|
||
# get the first CT_CON of each output
|
||
my $content = first { $_->{type} == 2 } @{$output->{nodes}};
|
||
@workspaces = (@workspaces, @{$content->{nodes}});
|
||
}
|
||
|
||
my @numbers = grep { $_ != -1 } map { $_->{num} } @workspaces;
|
||
is_deeply(
|
||
[ sort { $a <=> $b } @numbers ],
|
||
\@numbers,
|
||
'workspace numbers sorted');
|
||
}
|
||
|
||
# 1: numbered workspace
|
||
cmd 'workspace 10';
|
||
cmd 'open';
|
||
cmd 'workspace 13';
|
||
cmd 'open';
|
||
|
||
workspace_numbers_sorted();
|
||
|
||
cmd 'workspace 9';
|
||
is(focused_ws(), '9', 'now on workspace 9');
|
||
|
||
ok(!workspace_exists('12'), 'workspace 12 does not exist yet');
|
||
cmd 'rename workspace 9 to 12';
|
||
ok(!workspace_exists('9'), 'workspace 9 does not exist anymore');
|
||
is(focused_ws(), '12', 'now on workspace 12');
|
||
$ws = get_ws('12');
|
||
is($ws->{num}, 12, 'number correctly changed');
|
||
|
||
workspace_numbers_sorted();
|
||
|
||
# 2: numbered + named workspace
|
||
cmd 'workspace 9: foo';
|
||
is(focused_ws(), '9: foo', 'now on workspace 9: foo');
|
||
|
||
ok(!workspace_exists('11: bar'), 'workspace 11: bar does not exist yet');
|
||
cmd 'rename workspace "9: foo" to "11: bar"';
|
||
ok(!workspace_exists('9: foo'), 'workspace 9 does not exist anymore');
|
||
is(focused_ws(), '11: bar', 'now on workspace 10');
|
||
$ws = get_ws('11: bar');
|
||
is($ws->{num}, 11, 'number correctly changed');
|
||
workspace_numbers_sorted();
|
||
# keep that one open, we need it later
|
||
cmd 'open';
|
||
|
||
# 3: named workspace
|
||
cmd 'workspace bleh';
|
||
is(focused_ws(), 'bleh', 'now on workspace bleh');
|
||
|
||
ok(!workspace_exists('qux'), 'workspace qux does not exist yet');
|
||
cmd 'rename workspace bleh to qux';
|
||
ok(!workspace_exists('bleh'), 'workspace 9 does not exist anymore');
|
||
is(focused_ws(), 'qux', 'now on workspace qux');
|
||
$ws = get_ws('qux');
|
||
is($ws->{num}, -1, 'number correctly changed');
|
||
workspace_numbers_sorted();
|
||
|
||
# 4: rename current workspace
|
||
cmd 'workspace 4711';
|
||
is(focused_ws(), '4711', 'now on workspace 4711');
|
||
|
||
ok(!workspace_exists('42'), 'workspace 42 does not exist yet');
|
||
cmd 'rename workspace to 42';
|
||
ok(!workspace_exists('4711'), 'workspace 4711 does not exist anymore');
|
||
is(focused_ws(), '42', 'now on workspace 42');
|
||
$ws = get_ws('42');
|
||
is($ws->{num}, 42, 'number correctly changed');
|
||
workspace_numbers_sorted();
|
||
|
||
# 5: special cases
|
||
cmd 'workspace bla';
|
||
is(focused_ws(), 'bla', 'now on workspace to');
|
||
|
||
ok(!workspace_exists('to'), 'workspace to does not exist yet');
|
||
cmd 'rename workspace bla to to';
|
||
ok(!workspace_exists('bla'), 'workspace bla does not exist anymore');
|
||
is(focused_ws(), 'to', 'now on workspace to');
|
||
cmd 'rename workspace to to bla';
|
||
ok(!workspace_exists('to'), 'workspace to does not exist anymore');
|
||
is(focused_ws(), 'bla', 'now on workspace bla');
|
||
cmd 'rename workspace to to';
|
||
ok(!workspace_exists('bla'), 'workspace bla does not exist anymore');
|
||
is(focused_ws(), 'to', 'now on workspace to');
|
||
|
||
# 6: already existing workspace
|
||
my $result = cmd 'rename workspace qux to 11: bar';
|
||
ok(!$result->[0]->{success}, 'renaming workspace to an already existing one failed');
|
||
|
||
# 7: non-existing old workspace (verify command result)
|
||
$result = cmd 'rename workspace notexistant to bleh';
|
||
ok(!$result->[0]->{success}, 'renaming workspace which does not exist failed');
|
||
|
||
|
||
done_testing;
|