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 # Test that the EWMH specified property _NET_DESKTOP_VIEWPORT is updated
18 # properly on the root window. We interpret this as a list of x/y coordinate
19 # pairs for the upper left corner of the respective outputs of the workspaces
21 use i3test i3_autostart => 0;
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
27 workspace 0 output fake-0
28 workspace 1 output fake-1
30 fake-outputs 1024x768+0+0,1024x768+1024+0
33 my $pid = launch_with_config($config);
35 sub get_desktop_viewport {
36 my $cookie = $x->get_property(
38 $x->get_root_window(),
39 $x->atom(name => '_NET_DESKTOP_VIEWPORT')->id,
40 $x->atom(name => 'CARDINAL')->id,
45 my $reply = $x->get_property_reply($cookie->{sequence});
47 return 0 if $reply->{value_len} == 0;
49 my $len = $reply->{length};
51 return unpack ("L$len", $reply->{value});
54 # initialize the workspaces
58 my @expected_viewport = (0, 0, 1024, 0);
59 my @desktop_viewport = get_desktop_viewport;
61 is_deeply(\@desktop_viewport, \@expected_viewport,
62 '_NET_DESKTOP_VIEWPORT should be an array of x/y coordinate pairs for the upper left corner of the respective outputs of the workspaces');
68 @expected_viewport = (0, 0, 0, 0, 1024, 0);
69 @desktop_viewport = get_desktop_viewport;
71 is_deeply(\@desktop_viewport, \@expected_viewport,
72 'it should be updated when a new workspace appears');
74 cmd 'rename workspace 3 to 2';
76 @expected_viewport = (0, 0, 0, 0, 1024, 0);
77 @desktop_viewport = get_desktop_viewport;
79 is_deeply(\@desktop_viewport, \@expected_viewport,
80 'it should stay up to date when a workspace is renamed');
84 @expected_viewport = (0, 0, 1024, 0);
85 @desktop_viewport = get_desktop_viewport;
87 is_deeply(\@desktop_viewport, \@expected_viewport,
88 'it should be updated when a workspace is emptied');
90 exit_gracefully($pid);