]> git.sur5r.net Git - i3/i3/blob - testcases/t/139-ws-numbers.t
add boilerplate to all testcases with documentation references
[i3/i3] / testcases / t / 139-ws-numbers.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Check if numbered workspaces and named workspaces are sorted in the right way
18 # in get_workspaces IPC output (necessary for i3bar etc.).
19 use i3test;
20
21 my $i3 = i3(get_socket_path());
22
23 sub check_order {
24     my ($msg) = @_;
25
26     my @ws = @{$i3->get_workspaces->recv};
27     my @nums = map { $_->{num} } grep { defined($_->{num}) } @ws;
28     my @sorted = sort @nums;
29
30     is_deeply(\@nums, \@sorted, $msg);
31 }
32
33 check_order('workspace order alright before testing');
34
35 #############################################################################
36 # open a window to keep this ws open
37 #############################################################################
38
39 cmd "workspace 93";
40
41 open_window;
42
43 my @ws = @{$i3->get_workspaces->recv};
44 my @f = grep { defined($_->{num}) && $_->{num} == 93 } @ws;
45 is(@f, 1, 'ws 93 found by num');
46 check_order('workspace order alright after opening 93');
47
48 cmd "workspace 92";
49 open_window;
50 check_order('workspace order alright after opening 92');
51
52 cmd "workspace 94";
53 open_window;
54 check_order('workspace order alright after opening 94');
55
56 cmd "workspace 96";
57 open_window;
58 check_order('workspace order alright after opening 96');
59
60 cmd "workspace foo";
61 open_window;
62 check_order('workspace order alright after opening foo');
63
64 cmd "workspace 91";
65 open_window;
66 check_order('workspace order alright after opening 91');
67
68 done_testing;