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 # Tests all supported criteria for the "swallows" key.
19 use File::Temp qw(tempfile);
21 use X11::XCB qw(PROP_MODE_REPLACE);
23 sub verify_swallow_criterion {
24 my ($cfgline, $open_window_cb) = @_;
26 my $ws = fresh_workspace;
28 my @content = @{get_ws_content($ws)};
29 is(@content, 0, "no nodes on the new workspace yet ($cfgline)");
31 my ($fh, $filename) = tempfile(UNLINK => 1);
47 cmd "append_layout $filename";
51 @content = @{get_ws_content($ws)};
52 is(@content, 1, "one node on the workspace now ($cfgline)");
54 my $top = $open_window_cb->();
56 @content = @{get_ws_content($ws)};
57 is(@content, 1, "still one node on the workspace now ($cfgline)");
58 my @nodes = @{$content[0]->{nodes}};
59 is($nodes[0]->{window}, $top->id, "top window on top ($cfgline)");
64 verify_swallow_criterion(
65 '"class": "^special_class$"',
66 sub { open_window(wm_class => 'special_class') }
69 # Run the same test again to verify that the window is not being swallowed by
70 # the first container. Each swallow condition should only swallow precisely one
72 verify_swallow_criterion(
73 '"class": "^special_class$"',
74 sub { open_window(wm_class => 'special_class') }
77 verify_swallow_criterion(
78 '"instance": "^special_instance$"',
79 sub { open_window(wm_class => '', instance => 'special_instance') }
82 verify_swallow_criterion(
83 '"title": "^special_title$"',
84 sub { open_window(name => 'special_title') }
87 verify_swallow_criterion(
88 '"window_role": "^special_role$"',
94 my $atomname = $x->atom(name => 'WM_WINDOW_ROLE');
95 my $atomtype = $x->atom(name => 'STRING');
102 length("special_role") + 1,