]> git.sur5r.net Git - i3/i3/blob - testcases/t/284-ewmh-visible-name.t
tests: replace http:// with https:// where appropriate
[i3/i3] / testcases / t / 284-ewmh-visible-name.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Tests that _NET_WM_VISIBLE_NAME is set correctly.
18 # Ticket: #1872
19 use i3test;
20 use X11::XCB qw(:all);
21
22 my ($con);
23
24 sub get_visible_name {
25     sync_with_i3;
26     my ($con) = @_;
27
28     my $cookie = $x->get_property(
29         0,
30         $con->{id},
31         $x->atom(name => '_NET_WM_VISIBLE_NAME')->id,
32         $x->atom(name => 'UTF8_STRING')->id,
33         0,
34         4096
35     );
36
37     my $reply = $x->get_property_reply($cookie->{sequence});
38     return undef if $reply->{value_len} == 0;
39     return $reply->{value};
40 }
41
42 ###############################################################################
43 # 1: _NET_WM_VISIBLE_NAME is set when the title format of a window is changed.
44 ###############################################################################
45
46 fresh_workspace;
47 $con = open_window(name => 'boring title');
48 is(get_visible_name($con), undef, 'sanity check: initially no visible name is set');
49
50 cmd 'title_format custom';
51 is(get_visible_name($con), 'custom', 'the visible name is updated');
52
53 cmd 'title_format "<s>%title</s>"';
54 is(get_visible_name($con), '<s>boring title</s>', 'markup is returned as is');
55
56 ###############################################################################
57 # 2: _NET_WM_VISIBLE_NAME is removed if not needed.
58 ###############################################################################
59
60 fresh_workspace;
61 $con = open_window(name => 'boring title');
62 cmd 'title_format custom';
63 is(get_visible_name($con), 'custom', 'sanity check: a visible name is set');
64
65 cmd 'title_format %title';
66 is(get_visible_name($con), undef, 'the visible name is removed again');
67
68 ###############################################################################
69
70 done_testing;