]> git.sur5r.net Git - i3/i3/blob - testcases/t/120-multiple-cmds.t
Merge branch 'next' into master
[i3/i3] / testcases / t / 120-multiple-cmds.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 # Tests multiple commands (using ';') and multiple operations (using ',')
18 #
19 use i3test;
20
21 my $tmp = fresh_workspace;
22
23 sub multiple_cmds {
24     my ($cmd) = @_;
25
26     cmd 'open';
27     cmd 'open';
28     ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
29
30     cmd $cmd;
31     ok(@{get_ws_content($tmp)} == 0, "both containers killed (cmd = $cmd)");
32 }
33 multiple_cmds('kill;kill');
34 multiple_cmds('kill; kill');
35 multiple_cmds('kill ; kill');
36 multiple_cmds('kill ;kill');
37 multiple_cmds('kill  ;kill');
38 multiple_cmds('kill  ;  kill');
39 multiple_cmds("kill;\tkill");
40 multiple_cmds("kill\t;kill");
41 multiple_cmds("kill\t;\tkill");
42 multiple_cmds("kill\t ;\tkill");
43 multiple_cmds("kill\t ;\t kill");
44 multiple_cmds("kill \t ; \t kill");
45
46 #####################################################################
47 # test if un-quoted strings are handled correctly
48 #####################################################################
49
50 $tmp = fresh_workspace;
51 cmd 'open';
52 my $unused = get_unused_workspace;
53 ok(!($unused ~~ @{get_workspace_names()}), 'workspace does not exist yet');
54 cmd "move workspace $unused; nop parser test";
55 ok(($unused ~~ @{get_workspace_names()}), 'workspace exists after moving');
56
57 #####################################################################
58 # quote the workspace name and use a ; (command separator) in its name
59 #####################################################################
60
61 cmd 'open';
62 $unused = get_unused_workspace;
63 $unused .= ';a';
64 ok(!($unused ~~ @{get_workspace_names()}), 'workspace does not exist yet');
65 cmd qq|move workspace "$unused"; nop parser test|;
66 ok(($unused ~~ @{get_workspace_names()}), 'workspace exists after moving');
67
68 # TODO: need a non-invasive command before implementing a test which uses ','
69
70 ################################################################################
71 # regression test: 10 invalid commands should not crash i3 (10 is the stack
72 # depth)
73 ################################################################################
74
75 cmd 'move gibberish' for (0 .. 10);
76
77 does_i3_live;
78
79 ################################################################################
80 # regression test: an invalid command should come back with an error.
81 ################################################################################
82
83 my $reply = cmd 'bullshit-command-which-we-never-implement meh';
84 is(scalar @$reply, 1, 'got one command reply');
85 ok(!$reply->[0]->{success}, 'reply has success == false');
86
87 done_testing;