]> git.sur5r.net Git - i3/i3/blob - testcases/t/532-xresources.t
Introduce support for specifying variables from X resources. (#2286)
[i3/i3] / testcases / t / 532-xresources.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 using X resources in the config.
18 # Ticket: #2130
19 use i3test i3_autostart => 0;
20 use X11::XCB qw(PROP_MODE_REPLACE);
21
22 sub get_marks {
23     return i3(get_socket_path())->get_marks->recv;
24 }
25
26 my $config = <<EOT;
27 # i3 config file (v4)
28 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
29
30 # This isn't necessarily what X resources are intended for, but it'll do the
31 # job for the test.
32 set_from_resource \$mark i3wm.mark none
33 for_window [class=worksforme] mark \$mark
34
35 set_from_resource \$othermark i3wm.doesnotexist none
36 for_window [class=doesnotworkforme] mark \$othermark
37
38 EOT
39
40 $x->change_property(
41     PROP_MODE_REPLACE,
42     $x->get_root_window(),
43     $x->atom(name => 'RESOURCE_MANAGER')->id,
44     $x->atom(name => 'STRING')->id,
45     32,
46     length('*mark: works'),
47     '*mark: works');
48 $x->flush;
49
50 my $pid = launch_with_config($config);
51
52 open_window(wm_class => 'worksforme');
53 sync_with_i3;
54 is_deeply(get_marks(), [ 'works' ], 'the resource has loaded correctly');
55
56 cmd 'kill';
57
58 open_window(wm_class => 'doesnotworkforme');
59 sync_with_i3;
60 is_deeply(get_marks(), [ 'none' ], 'the resource fallback was used');
61
62 exit_gracefully($pid);
63
64 done_testing;