]> git.sur5r.net Git - i3/i3/blob - testcases/t/39-ws-numbers.t
Merge branch 'userguide-mark'
[i3/i3] / testcases / t / 39-ws-numbers.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Check if numbered workspaces and named workspaces are sorted in the right way
4 # in get_workspaces IPC output (necessary for i3bar etc.).
5 use i3test;
6 use X11::XCB qw(:all);
7
8 BEGIN {
9     use_ok('X11::XCB::Window');
10 }
11
12 my $i3 = i3(get_socket_path());
13 my $x = X11::XCB::Connection->new;
14
15 sub check_order {
16     my ($msg) = @_;
17
18     my @ws = @{$i3->get_workspaces->recv};
19     my @nums = map { $_->{num} } grep { defined($_->{num}) } @ws;
20     my @sorted = sort @nums;
21
22     cmp_deeply(\@nums, \@sorted, $msg);
23 }
24
25 check_order('workspace order alright before testing');
26
27 #############################################################################
28 # open a window to keep this ws open
29 #############################################################################
30
31 cmd "workspace 93";
32
33 open_standard_window($x);
34
35 my @ws = @{$i3->get_workspaces->recv};
36 my @f = grep { defined($_->{num}) && $_->{num} == 93 } @ws;
37 is(@f, 1, 'ws 93 found by num');
38 check_order('workspace order alright after opening 93');
39
40 cmd "workspace 92";
41 open_standard_window($x);
42 check_order('workspace order alright after opening 92');
43
44 cmd "workspace 94";
45 open_standard_window($x);
46 check_order('workspace order alright after opening 94');
47
48 cmd "workspace 96";
49 open_standard_window($x);
50 check_order('workspace order alright after opening 96');
51
52 cmd "workspace foo";
53 open_standard_window($x);
54 check_order('workspace order alright after opening foo');
55
56 cmd "workspace 91";
57 open_standard_window($x);
58 check_order('workspace order alright after opening 91');
59
60 done_testing;