]> git.sur5r.net Git - i3/i3/blob - testcases/t/202-scratchpad-criteria.t
Merge branch 'fix-unmap'
[i3/i3] / testcases / t / 202-scratchpad-criteria.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 # Verifies that using criteria to address scratchpad windows works.
18 use i3test;
19
20 ################################################################################
21 # Verify that using scratchpad show with criteria works as expected:
22 # When matching a scratchpad window which is visible, it should hide it.
23 # When matching a scratchpad window which is on __i3_scratch, it should show it.
24 # When matching a non-scratchpad window, it should be a no-op.
25 ################################################################################
26
27 my $tmp = fresh_workspace;
28
29 my $third_window = open_window(name => 'scratch-match');
30 cmd 'move scratchpad';
31
32 # Verify that using 'scratchpad show' without any matching windows is a no-op.
33 my $old_focus = get_focused($tmp);
34
35 cmd '[title="nomatch"] scratchpad show';
36
37 is(get_focused($tmp), $old_focus, 'non-matching criteria have no effect');
38
39 # Verify that we can use criteria to show a scratchpad window.
40 cmd '[title="scratch-match"] scratchpad show';
41
42 my $scratch_focus = get_focused($tmp);
43 isnt($scratch_focus, $old_focus, 'matching criteria works');
44
45 cmd '[title="scratch-match"] scratchpad show';
46
47 isnt(get_focused($tmp), $scratch_focus, 'matching criteria works');
48 is(get_focused($tmp), $old_focus, 'focus restored');
49
50 # Verify that we cannot use criteria to show a non-scratchpad window.
51 my $tmp2 = fresh_workspace;
52 my $non_scratch_window = open_window(name => 'non-scratch');
53 cmd "workspace $tmp";
54 is(get_focused($tmp), $old_focus, 'focus still ok');
55 cmd '[title="non-match"] scratchpad show';
56 is(get_focused($tmp), $old_focus, 'focus unchanged');
57
58 done_testing;