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_NAMES is updated properly
18 # on the root window. We interpret this as a list of the open workspace names.
22 sub get_desktop_names {
23 # Make sure that i3 pushed its changes to X11 before querying.
26 my $cookie = $x->get_property(
28 $x->get_root_window(),
29 $x->atom(name => '_NET_DESKTOP_NAMES')->id,
30 $x->atom(name => 'UTF8_STRING')->id,
35 my $reply = $x->get_property_reply($cookie->{sequence});
37 return 0 if $reply->{value_len} == 0;
39 # the property is a null-delimited list of utf8 strings ;;
40 return split /\0/, $reply->{value};
45 my @expected_names = ('foo');
46 my @desktop_names = get_desktop_names;
48 is_deeply(\@desktop_names, \@expected_names, '_NET_DESKTOP_NAMES should be an array of the workspace names');
50 # open a new workspace and see that the property is updated correctly
54 @desktop_names = get_desktop_names;
55 @expected_names = ('foo', 'bar');
57 is_deeply(\@desktop_names, \@expected_names, 'it should be updated when a new workspace appears');
59 # rename the workspace and see that the property is updated correctly
60 cmd 'rename workspace bar to baz';
62 @desktop_names = get_desktop_names;
63 @expected_names = ('foo', 'baz');
65 is_deeply(\@desktop_names, \@expected_names, 'it should be updated when a workspace is renamed');
67 # empty a workspace and see that the property is updated correctly
70 @desktop_names = get_desktop_names;
71 @expected_names = ('foo');
73 is_deeply(\@desktop_names, \@expected_names, 'it should be updated when a workspace is emptied');