aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/128-open-order.t
blob: b0ab321f2c5cf191e337cea999edd9e4240b4455 (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
#!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)
#
# Check if new containers are opened after the currently focused one instead
# of always at the end
use List::Util qw(first);
use i3test;

my $i3 = i3(get_socket_path());

my $tmp = fresh_workspace;

ok(@{get_ws_content($tmp)} == 0, 'no containers yet');

# Open two new container
my $first = open_empty_con($i3);

ok(@{get_ws_content($tmp)} == 1, 'containers opened');

my $second = open_empty_con($i3);

isnt($first, $second, 'different container focused');

##############################################################
# see if new containers open after the currently focused
##############################################################

cmd qq|[con_id="$first"] focus|;
cmd 'open';
my $content = get_ws_content($tmp);
ok(@{$content} == 3, 'three containers opened');

is($content->[0]->{id}, $first, 'first container unmodified');
isnt($content->[1]->{id}, $second, 'second container replaced');
is($content->[2]->{id}, $second, 'third container unmodified');

done_testing;