tests: add inject_randr15 (#2573)
This tool is similar to xtrace in usage in that it intercepts traffic to the X server. The motivating feature for writing the tool is its ability to inject prepared reply messages instead of the server’s reply. In this particular case, we’ll inject a RRGetMonitors reply to test i3’s RandR 1.5 code paths. The added testcase is a noop for now, but with the code that’s lingering in the randr15 branch, i3 does actually detect monitors as per the injected reply: 2016-11-20 21:10:05 - randr.c:__randr_query_outputs:618 - RandR 1.5 available, querying monitors 2016-11-20 21:10:05 - randr.c:__randr_query_outputs:628 - 1 RandR monitors found (timestamp 0) 2016-11-20 21:10:05 - randr.c:__randr_query_outputs:646 - name DP3, x 0, y 0, width 3840 px, height 2160 px, width 520 mm, height 290 mm, primary 1, automatic 1 This is preparation work for issue #1799
This commit is contained in:
committed by
GitHub
parent
aa20c416c3
commit
3e7a07e48d
73
testcases/t/533-randr15.t
Normal file
73
testcases/t/533-randr15.t
Normal file
@ -0,0 +1,73 @@
|
||||
#!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)
|
||||
#
|
||||
# TODO: Description of this file.
|
||||
# Ticket: #999
|
||||
# Bug still in: 4.13-12-g2ff3d9d
|
||||
use File::Temp qw(tempfile);
|
||||
use i3test i3_autostart => 0;
|
||||
|
||||
my $config = <<EOT;
|
||||
# i3 config file (v4)
|
||||
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||
|
||||
EOT
|
||||
|
||||
my ($outfh, $outname) = tempfile('i3-randr15reply-XXXXXX', UNLINK => 1);
|
||||
|
||||
# Prepare a RRGetMonitors reply, see A.2.4 in
|
||||
# https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
|
||||
my $reply = pack('cxSLLLLx[LLL]',
|
||||
1, # reply
|
||||
0, # sequence (will be filled in by inject_randr15)
|
||||
# 56 = length($reply) + length($monitor1)
|
||||
# 32 = minimum X11 reply length
|
||||
(56-32) / 4, # length in words
|
||||
0, # timestamp TODO
|
||||
1, # nmonitors
|
||||
0); # noutputs
|
||||
|
||||
# Manually intern _NET_CURRENT_DESKTOP as $x->atom will not create atoms if
|
||||
# they are not yet interned.
|
||||
my $atom_cookie = $x->intern_atom(0, length("DP3"), "DP3");
|
||||
my $DP3 = $x->intern_atom_reply($atom_cookie->{sequence})->{atom};
|
||||
|
||||
# MONITORINFO is defined in A.1.1 in
|
||||
# https://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
|
||||
my $monitor1 = pack('LccSssSSLL',
|
||||
$DP3, # name (ATOM)
|
||||
1, # primary
|
||||
1, # automatic
|
||||
0, # ncrtcs
|
||||
0, # x
|
||||
0, # y
|
||||
3840, # width in pixels
|
||||
2160, # height in pixels
|
||||
520, # width in millimeters
|
||||
290); # height in millimeters
|
||||
|
||||
print $outfh $reply;
|
||||
print $outfh $monitor1;
|
||||
|
||||
close($outfh);
|
||||
|
||||
my $pid = launch_with_config($config, inject_randr15 => $outname);
|
||||
|
||||
cmd 'nop';
|
||||
|
||||
exit_gracefully($pid);
|
||||
|
||||
done_testing;
|
Reference in New Issue
Block a user