aboutsummaryrefslogtreecommitdiff
path: root/testcases/t/532-xresources.t
blob: 1ff48e515044556a911d55e37b811e3255df1fa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!perl
# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
# • https://build.i3wm.org/docs/testsuite.html
#   (or docs/testsuite)
#
# • https://build.i3wm.org/docs/lib-i3test.html
#   (alternatively: perldoc ./testcases/lib/i3test.pm)
#
# • https://build.i3wm.org/docs/ipc.html
#   (or docs/ipc)
#
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
#   (unless you are already familiar with Perl)
#
# Tests for using X resources in the config.
# Ticket: #2130
use i3test i3_autostart => 0;
use X11::XCB qw(PROP_MODE_REPLACE);

sub get_marks {
    return i3(get_socket_path())->get_marks->recv;
}

my $config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1

# This isn't necessarily what X resources are intended for, but it'll do the
# job for the test.
set_from_resource \$mark i3wm.mark none
for_window [class=worksforme] mark \$mark

set_from_resource \$othermark i3wm.doesnotexist none
for_window [class=doesnotworkforme] mark \$othermark

EOT

$x->change_property(
    PROP_MODE_REPLACE,
    $x->get_root_window(),
    $x->atom(name => 'RESOURCE_MANAGER')->id,
    $x->atom(name => 'STRING')->id,
    32,
    length('*mark: works'),
    '*mark: works');
$x->flush;

my $pid = launch_with_config($config);

open_window(wm_class => 'worksforme');
sync_with_i3;
is_deeply(get_marks(), [ 'works' ], 'the resource has loaded correctly');

cmd 'kill';

open_window(wm_class => 'doesnotworkforme');
sync_with_i3;
is_deeply(get_marks(), [ 'none' ], 'the resource fallback was used');

exit_gracefully($pid);

done_testing;