2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Verifies that using criteria to address scratchpad windows works.
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 ################################################################################
27 my $tmp = fresh_workspace;
29 my $third_window = open_window(name => 'scratch-match');
30 cmd 'move scratchpad';
32 # Verify that using 'scratchpad show' without any matching windows is a no-op.
33 my $old_focus = get_focused($tmp);
35 cmd '[title="nomatch"] scratchpad show';
37 is(get_focused($tmp), $old_focus, 'non-matching criteria have no effect');
39 # Verify that we can use criteria to show a scratchpad window.
40 cmd '[title="scratch-match"] scratchpad show';
42 my $scratch_focus = get_focused($tmp);
43 isnt($scratch_focus, $old_focus, 'matching criteria works');
45 cmd '[title="scratch-match"] scratchpad show';
47 isnt(get_focused($tmp), $scratch_focus, 'matching criteria works');
48 is(get_focused($tmp), $old_focus, 'focus restored');
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');
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');