From 061d90f305606ed7c7fcf905110e042c310bfa50 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 24 Dec 2012 19:19:32 +0100 Subject: [PATCH] move scratchpad test to separate file, otherwise it is non-conclusive --- testcases/t/185-scratchpad.t | 33 --------------- testcases/t/202-scratchpad-criteria.t | 58 +++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 testcases/t/202-scratchpad-criteria.t diff --git a/testcases/t/185-scratchpad.t b/testcases/t/185-scratchpad.t index dafe51e0..af881a29 100644 --- a/testcases/t/185-scratchpad.t +++ b/testcases/t/185-scratchpad.t @@ -216,39 +216,6 @@ cmd 'scratchpad show'; isnt(get_focused($tmp), $fresh_id, 'focus changed'); -################################################################################ -# 7: Verify that using scratchpad show with criteria works as expected: -# When matching a scratchpad window which is visible, it should hide it. -# When matching a scratchpad window which is on __i3_scratch, it should show it. -# When matching a non-scratchpad window, it should be a no-op. -################################################################################ - -# Verify that using 'scratchpad show' without any matching windows is a no-op. -$old_focus = get_focused($tmp); - -cmd '[title="nomatch"] scratchpad show'; - -is(get_focused($tmp), $old_focus, 'non-matching criteria have no effect'); - -# Verify that we can use criteria to show a scratchpad window. -cmd '[title="scratch-match"] scratchpad show'; - -my $scratch_focus = get_focused($tmp); -isnt($scratch_focus, $old_focus, 'matching criteria works'); - -cmd '[title="scratch-match"] scratchpad show'; - -isnt(get_focused($tmp), $scratch_focus, 'matching criteria works'); -is(get_focused($tmp), $old_focus, 'focus restored'); - -# Verify that we cannot use criteria to show a non-scratchpad window. -my $tmp2 = fresh_workspace; -my $non_scratch_window = open_window(name => 'non-scratch'); -cmd "workspace $tmp"; -is(get_focused($tmp), $old_focus, 'focus still ok'); -cmd '[title="non-match"] scratchpad show'; -is(get_focused($tmp), $old_focus, 'focus unchanged'); - ################################################################################ # 8: Show it, move it around, hide it. Verify that the position is retained # when showing it again. diff --git a/testcases/t/202-scratchpad-criteria.t b/testcases/t/202-scratchpad-criteria.t new file mode 100644 index 00000000..2603f65a --- /dev/null +++ b/testcases/t/202-scratchpad-criteria.t @@ -0,0 +1,58 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Please read the following documents before working on tests: +# • http://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • http://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • http://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# +# Verifies that using criteria to address scratchpad windows works. +use i3test; + +################################################################################ +# Verify that using scratchpad show with criteria works as expected: +# When matching a scratchpad window which is visible, it should hide it. +# When matching a scratchpad window which is on __i3_scratch, it should show it. +# When matching a non-scratchpad window, it should be a no-op. +################################################################################ + +my $tmp = fresh_workspace; + +my $third_window = open_window(name => 'scratch-match'); +cmd 'move scratchpad'; + +# Verify that using 'scratchpad show' without any matching windows is a no-op. +my $old_focus = get_focused($tmp); + +cmd '[title="nomatch"] scratchpad show'; + +is(get_focused($tmp), $old_focus, 'non-matching criteria have no effect'); + +# Verify that we can use criteria to show a scratchpad window. +cmd '[title="scratch-match"] scratchpad show'; + +my $scratch_focus = get_focused($tmp); +isnt($scratch_focus, $old_focus, 'matching criteria works'); + +cmd '[title="scratch-match"] scratchpad show'; + +isnt(get_focused($tmp), $scratch_focus, 'matching criteria works'); +is(get_focused($tmp), $old_focus, 'focus restored'); + +# Verify that we cannot use criteria to show a non-scratchpad window. +my $tmp2 = fresh_workspace; +my $non_scratch_window = open_window(name => 'non-scratch'); +cmd "workspace $tmp"; +is(get_focused($tmp), $old_focus, 'focus still ok'); +cmd '[title="non-match"] scratchpad show'; +is(get_focused($tmp), $old_focus, 'focus unchanged'); + +done_testing; -- 2.39.5