2010-04-16 08:24:29 -04:00
|
|
|
|
#!perl
|
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
#
|
|
|
|
|
# Tests whether we can switch to a non-existant workspace
|
|
|
|
|
# (necessary for further tests)
|
|
|
|
|
#
|
2011-06-10 10:03:59 -04:00
|
|
|
|
use List::Util qw(first);
|
2011-03-09 14:25:17 -05:00
|
|
|
|
use i3test;
|
2010-04-16 08:24:29 -04:00
|
|
|
|
|
2011-07-27 08:35:40 -04:00
|
|
|
|
# to ensure that workspace 1 stays open
|
|
|
|
|
cmd 'open';
|
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
|
my $tmp = fresh_workspace;
|
2010-04-16 08:24:29 -04:00
|
|
|
|
ok(workspace_exists($tmp), 'workspace created');
|
2010-04-16 09:03:27 -04:00
|
|
|
|
# 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');
|
|
|
|
|
}
|
2010-04-16 08:24:29 -04:00
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
|
my $otmp = fresh_workspace;
|
2010-04-16 08:24:29 -04:00
|
|
|
|
diag("Other temporary workspace name: $otmp\n");
|
|
|
|
|
|
|
|
|
|
# As the old workspace was empty, it should get
|
|
|
|
|
# cleaned up as we switch away from it
|
2011-03-09 14:25:17 -05:00
|
|
|
|
cmd "workspace $otmp";
|
2010-04-16 08:24:29 -04:00
|
|
|
|
ok(!workspace_exists($tmp), 'old workspace cleaned up');
|
|
|
|
|
|
2010-05-09 17:20:49 -04:00
|
|
|
|
# Switch to the same workspace again to make sure it doesn’t get cleaned up
|
2011-03-09 14:25:17 -05:00
|
|
|
|
cmd "workspace $otmp";
|
|
|
|
|
cmd "workspace $otmp";
|
2010-05-09 17:20:49 -04:00
|
|
|
|
ok(workspace_exists($otmp), 'other workspace still exists');
|
|
|
|
|
|
2011-06-10 10:03:59 -04:00
|
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
|
# 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');
|
|
|
|
|
|
2011-09-05 16:24:28 -04:00
|
|
|
|
#####################################################################
|
|
|
|
|
# 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";
|
2011-11-21 15:04:00 -05:00
|
|
|
|
$ws = get_ws("0: $tmp");
|
2011-09-05 16:24:28 -04:00
|
|
|
|
ok(defined($ws), "workspace 0: $tmp was created");
|
|
|
|
|
is($ws->{num}, 0, 'workspace number is 0');
|
|
|
|
|
|
|
|
|
|
cmd "workspace aa: $tmp";
|
2011-11-21 17:44:20 -05:00
|
|
|
|
$ws = get_ws("aa: $tmp");
|
2011-09-05 16:24:28 -04:00
|
|
|
|
ok(defined($ws), "workspace aa: $tmp was created");
|
|
|
|
|
is($ws->{num}, -1, 'workspace number is -1');
|
|
|
|
|
|
2012-04-08 13:17:46 -04:00
|
|
|
|
################################################################################
|
|
|
|
|
# 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');
|
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
|
done_testing;
|