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 changes to WM_CLASS are internally processed by i3 by updating the
18 # cached property and running assignments. This allows the property to be used
19 # in criteria selection
21 # Bug still in: 4.8-73-g6bf7f8e
22 use i3test i3_autostart => 0;
23 use X11::XCB qw(PROP_MODE_REPLACE);
27 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
28 for_window [class="Special"] mark special_class_mark
31 my $pid = launch_with_config($config);
33 sub change_window_class {
34 my ($window, $class, $length) = @_;
35 my $atomname = $x->atom(name => 'WM_CLASS');
36 my $atomtype = $x->atom(name => 'STRING');
37 $length ||= length($class) + 1;
50 my $ws = fresh_workspace;
52 my $win = open_window;
54 change_window_class($win, "special\0Special");
56 my $con = @{get_ws_content($ws)}[0];
58 is($con->{window_properties}->{class}, 'Special',
59 'The container class should be updated when a window changes class');
61 is($con->{window_properties}->{instance}, 'special',
62 'The container instance should be updated when a window changes instance');
64 # The mark `special_class_mark` is added in a `for_window` assignment in the
65 # config for testing purposes
66 is($con->{mark}, 'special_class_mark',
67 'A `for_window` assignment should run for a match when the window changes class');
69 change_window_class($win, "abcdefghijklmnopqrstuv\0abcd", 24);
71 $con = @{get_ws_content($ws)}[0];
73 is($con->{window_properties}->{class}, 'a',
74 'Non-null-terminated strings should be handled correctly');
76 exit_gracefully($pid);