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_config => <<EOT;
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25 for_window [class="Special"] mark special_class_mark
27 use X11::XCB qw(PROP_MODE_REPLACE);
29 sub change_window_class {
30 my ($window, $class, $length) = @_;
31 my $atomname = $x->atom(name => 'WM_CLASS');
32 my $atomtype = $x->atom(name => 'STRING');
33 $length ||= length($class) + 1;
46 my $ws = fresh_workspace;
48 my $win = open_window;
50 change_window_class($win, "special\0Special");
52 my $con = @{get_ws_content($ws)}[0];
54 is($con->{window_properties}->{class}, 'Special',
55 'The container class should be updated when a window changes class');
57 is($con->{window_properties}->{instance}, 'special',
58 'The container instance should be updated when a window changes instance');
60 # The mark `special_class_mark` is added in a `for_window` assignment in the
61 # config for testing purposes
62 is_deeply($con->{marks}, [ 'special_class_mark' ],
63 'A `for_window` assignment should run for a match when the window changes class');
65 change_window_class($win, "abcdefghijklmnopqrstuv\0abcd", 24);
67 $con = @{get_ws_content($ws)}[0];
69 is($con->{window_properties}->{class}, 'a',
70 'Non-null-terminated strings should be handled correctly');