]> git.sur5r.net Git - i3/i3/blob - testcases/t/536-net-wm-desktop_mm.t
tests: use i3_config arg instead of precisely one launch_with_config
[i3/i3] / testcases / t / 536-net-wm-desktop_mm.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://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 for _NET_WM_DESKTOP.
18 # Ticket: #2153
19 use i3test i3_config => <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22
23 workspace "0" output "fake-0"
24 workspace "1" output "fake-0"
25 workspace "2" output "fake-0"
26 workspace "10" output "fake-1"
27 workspace "11" output "fake-1"
28 workspace "12" output "fake-1"
29
30 fake-outputs 1024x768+0+0,1024x768+1024+0
31 EOT
32 use X11::XCB qw(:all);
33
34 sub get_net_wm_desktop {
35     sync_with_i3;
36
37     my ($con) = @_;
38     my $cookie = $x->get_property(
39         0,
40         $con->{id},
41         $x->atom(name => '_NET_WM_DESKTOP')->id,
42         $x->atom(name => 'CARDINAL')->id,
43         0,
44         1
45     );
46
47     my $reply = $x->get_property_reply($cookie->{sequence});
48     return undef if $reply->{length} != 1;
49
50     return unpack("L", $reply->{value});
51 }
52
53 ###############################################################################
54 # _NET_WM_DESKTOP is updated when the window is moved to another workspace
55 # on another output.
56 ###############################################################################
57
58 cmd 'workspace 0';
59 open_window;
60 cmd 'workspace 10';
61 open_window;
62 cmd 'workspace 0';
63 my $con = open_window;
64
65 cmd 'move window to workspace 10';
66
67 is(get_net_wm_desktop($con), 1, '_NET_WM_DESKTOP is updated when moving the window');
68
69 done_testing;