2015-10-19 18:10:20 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2015-10-19 18:10:20 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2015-10-19 18:10:20 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2015-10-19 18:10:20 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
|
|
|
# Tests for mark/unmark with multiple marks on a single window.
|
|
|
|
# Ticket: #2014
|
|
|
|
use i3test;
|
|
|
|
use List::Util qw(first);
|
|
|
|
|
|
|
|
my ($ws, $con, $first, $second);
|
|
|
|
|
|
|
|
sub get_marks {
|
|
|
|
return i3(get_socket_path())->get_marks->recv;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub get_mark_for_window_on_workspace {
|
|
|
|
my ($ws, $con) = @_;
|
|
|
|
|
|
|
|
my $current = first { $_->{window} == $con->{id} } @{get_ws_content($ws)};
|
|
|
|
return $current->{marks};
|
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Verify that multiple marks can be set on a window.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
$con = open_window;
|
2015-10-19 18:31:21 +02:00
|
|
|
cmd 'mark --add A';
|
|
|
|
cmd 'mark --add B';
|
2015-10-19 18:10:20 +02:00
|
|
|
|
|
|
|
is_deeply(sort(get_marks()), [ 'A', 'B' ], 'both marks exist');
|
|
|
|
is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B' ], 'both marks are on the same window');
|
|
|
|
|
|
|
|
cmd 'unmark';
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Verify that toggling a mark can affect only the specified mark.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
$con = open_window;
|
|
|
|
cmd 'mark A';
|
|
|
|
|
2015-10-19 18:31:21 +02:00
|
|
|
cmd 'mark --add --toggle B';
|
2015-10-19 18:10:20 +02:00
|
|
|
is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B' ], 'both marks are on the same window');
|
2015-10-19 18:31:21 +02:00
|
|
|
cmd 'mark --add --toggle B';
|
2015-10-19 18:10:20 +02:00
|
|
|
is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A' ], 'only mark B has been removed');
|
|
|
|
|
|
|
|
cmd 'unmark';
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Verify that unmarking a mark leaves other marks on the same window intact.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
$con = open_window;
|
2015-10-19 18:31:21 +02:00
|
|
|
cmd 'mark --add A';
|
|
|
|
cmd 'mark --add B';
|
|
|
|
cmd 'mark --add C';
|
2015-10-19 18:10:20 +02:00
|
|
|
|
|
|
|
cmd 'unmark B';
|
|
|
|
is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'C' ], 'only mark B has been removed');
|
|
|
|
|
|
|
|
cmd 'unmark';
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Verify that matching via mark works on windows with multiple marks.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
$con = open_window;
|
2015-10-19 18:31:21 +02:00
|
|
|
cmd 'mark --add A';
|
|
|
|
cmd 'mark --add B';
|
2015-10-19 18:10:20 +02:00
|
|
|
open_window;
|
|
|
|
|
2015-10-19 18:31:21 +02:00
|
|
|
cmd '[con_mark=B] mark --add C';
|
2015-10-19 18:10:20 +02:00
|
|
|
is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B', 'C' ], 'matching on a mark works with multiple marks');
|
|
|
|
|
|
|
|
cmd 'unmark';
|
|
|
|
|
2015-10-22 15:38:23 +02:00
|
|
|
###############################################################################
|
|
|
|
# Verify that "unmark" can be matched on the focused window.
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
$con = open_window;
|
|
|
|
cmd 'mark --add A';
|
|
|
|
cmd 'mark --add B';
|
|
|
|
open_window;
|
|
|
|
cmd 'mark --add C';
|
|
|
|
cmd 'mark --add D';
|
|
|
|
|
|
|
|
is_deeply(sort(get_marks()), [ 'A', 'B', 'C', 'D' ], 'all marks exist');
|
|
|
|
|
|
|
|
cmd '[con_id=__focused__] unmark';
|
|
|
|
|
|
|
|
is_deeply(sort(get_marks()), [ 'A', 'B' ], 'marks on the unfocused window still exist');
|
|
|
|
is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B' ], 'matching on con_id=__focused__ works for unmark');
|
|
|
|
|
|
|
|
cmd 'unmark';
|
|
|
|
|
2015-10-19 18:10:20 +02:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
done_testing;
|