Make "scratchpad show" return correct info

Fix the issue #3227(https://github.com/i3/i3/issues/3227).

1).Make cmd_scratchpad_show() use the information coming from scratchpad_show().
2).Add a test case 298-scratchpad-show.t.
This commit is contained in:
hwangcc23
2018-04-07 00:00:38 +08:00
parent a92acadfc0
commit 4869becfee
4 changed files with 61 additions and 12 deletions

View File

@ -471,4 +471,50 @@ is(scalar @$nodes, 0, 'no window on current ws anymore');
is($scratch_nodes[0]->{scratchpad_state}, 'changed', 'scratchpad_state changed');
################################################################################
# 15: Verify that 'scratchpad show' returns correct info.
################################################################################
kill_all_windows;
my $result = cmd 'scratchpad show';
is($result->[0]->{success}, 0, 'no scratchpad window and call to scratchpad failed');
open_window;
cmd 'move scratchpad';
$result = cmd 'scratchpad show';
is($result->[0]->{success}, 1, 'call to scratchpad succeeded');
$result = cmd 'scratchpad show';
is($result->[0]->{success}, 1, 'call to scratchpad succeeded');
kill_all_windows;
$result = cmd 'scratchpad show';
is($result->[0]->{success}, 0, 'call to scratchpad failed');
################################################################################
# 16: Verify that 'scratchpad show' with the criteria returns correct info.
################################################################################
open_window(name => "scratch-match");
cmd 'move scratchpad';
$result = cmd '[title="scratch-match"] scratchpad show';
is($result->[0]->{success}, 1, 'call to scratchpad with the criteria succeeded');
$result = cmd '[title="nomatch"] scratchpad show';
is($result->[0]->{success}, 0, 'call to scratchpad with non-matching criteria failed');
################################################################################
# 17: Open a scratchpad window on a workspace, switch to another workspace and
# call 'scratchpad show' again. Verify that it returns correct info.
################################################################################
fresh_workspace;
open_window;
cmd 'move scratchpad';
fresh_workspace;
$result = cmd 'scratchpad show';
is($result->[0]->{success}, 1, 'call to scratchpad in another workspace succeeded');
done_testing;