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 # Tests for mark/unmark with multiple marks on a single window.
20 use List::Util qw(first);
22 my ($ws, $con, $first, $second);
25 return i3(get_socket_path())->get_marks->recv;
28 sub get_mark_for_window_on_workspace {
31 my $current = first { $_->{window} == $con->{id} } @{get_ws_content($ws)};
32 return $current->{marks};
35 ###############################################################################
36 # Verify that multiple marks can be set on a window.
37 ###############################################################################
39 $ws = fresh_workspace;
44 is_deeply(sort(get_marks()), [ 'A', 'B' ], 'both marks exist');
45 is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B' ], 'both marks are on the same window');
49 ###############################################################################
50 # Verify that toggling a mark can affect only the specified mark.
51 ###############################################################################
53 $ws = fresh_workspace;
57 cmd 'mark --add --toggle B';
58 is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B' ], 'both marks are on the same window');
59 cmd 'mark --add --toggle B';
60 is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A' ], 'only mark B has been removed');
64 ###############################################################################
65 # Verify that unmarking a mark leaves other marks on the same window intact.
66 ###############################################################################
68 $ws = fresh_workspace;
75 is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'C' ], 'only mark B has been removed');
79 ###############################################################################
80 # Verify that matching via mark works on windows with multiple marks.
81 ###############################################################################
83 $ws = fresh_workspace;
89 cmd '[con_mark=B] mark --add C';
90 is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B', 'C' ], 'matching on a mark works with multiple marks');
94 ###############################################################################
95 # Verify that "unmark" can be matched on the focused window.
96 ###############################################################################
98 $ws = fresh_workspace;
106 is_deeply(sort(get_marks()), [ 'A', 'B', 'C', 'D' ], 'all marks exist');
108 cmd '[con_id=__focused__] unmark';
110 is_deeply(sort(get_marks()), [ 'A', 'B' ], 'marks on the unfocused window still exist');
111 is_deeply(get_mark_for_window_on_workspace($ws, $con), [ 'A', 'B' ], 'matching on con_id=__focused__ works for unmark');
115 ###############################################################################