aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/256-no-auto-back-and-forth.t
blob: 4242b4307aee3edf7a41e8c10eb7c099e5531b49 (plain)
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
98
#!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)
#
# Test for the --no-auto-back-and-forth flag.
# Ticket: #2028
use i3test;

my ($first, $second, $third, $con);
$first = "1:first";
$second = "2:second";
$third = "3:third";

###############################################################################
# Switching to another workspace when passing --no-auto-back-and-forth works
# as if the flag wasn't set.
###############################################################################

cmd qq|workspace "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is focused');

cmd qq|workspace --no-auto-back-and-forth "$second"|;
ok(get_ws($second)->{focused}, 'second workspace is focused');

cmd qq|workspace --no-auto-back-and-forth number "$third"|;
ok(get_ws($third)->{focused}, 'third workspace is focused');

###############################################################################
# Switching to the focused workspace when passing --no-auto-back-and-forth
# is a no-op.
###############################################################################

cmd qq|workspace "$second"|;
cmd qq|workspace "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is focused');

cmd qq|workspace --no-auto-back-and-forth "$first"|;
ok(get_ws($first)->{focused}, 'first workspace is still focused');

cmd qq|workspace --no-auto-back-and-forth number "$first"|;
ok(get_ws($first)->{focused}, 'first  workspace is still focused');

###############################################################################
# Moving a window to another workspace when passing --no-auto-back-and-forth
# works as if the flag wasn't set.
###############################################################################

cmd qq|workspace "$third"|;
cmd qq|workspace "$second"|;
cmd qq|workspace "$first"|;
$con = open_window;
cmd 'mark mywindow';

cmd qq|move --no-auto-back-and-forth window to workspace "$second"|;
is(@{get_ws($second)->{nodes}}, 1, 'window was moved to second workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;

cmd qq|move --no-auto-back-and-forth window to workspace number "$third"|;
is(@{get_ws($third)->{nodes}}, 1, 'window was moved to third workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;

cmd '[con_mark=mywindow] kill';

###############################################################################
# Moving a window to the same workspace when passing --no-auto-back-and-forth
# is a no-op.
###############################################################################

cmd qq|workspace "$second"|;
cmd qq|workspace "$first"|;
$con = open_window;
cmd 'mark mywindow';

cmd qq|move --no-auto-back-and-forth window to workspace "$first"|;
is(@{get_ws($first)->{nodes}}, 1, 'window is still on first workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;

cmd qq|move --no-auto-back-and-forth window to workspace number "$first"|;
is(@{get_ws($first)->{nodes}}, 1, 'window is still on first workspace');
cmd qq|[con_mark=mywindow] move window to workspace "$first"|;

cmd '[con_mark=mywindow] kill';

###############################################################################

done_testing;