]> git.sur5r.net Git - i3/i3/blob - testcases/t/13-urgent.t
Re-implement support for the urgency hint, extend t/13-urgent.t
[i3/i3] / testcases / t / 13-urgent.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test tests => 10;
5 use X11::XCB qw(:all);
6 use Time::HiRes qw(sleep);
7 use List::Util qw(first);
8
9 BEGIN {
10     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
11 }
12
13 my $x = X11::XCB::Connection->new;
14
15 my $i3 = i3("/tmp/nestedcons");
16 my $tmp = get_unused_workspace();
17 $i3->command("workspace $tmp")->recv;
18
19 #####################################################################
20 # Create two windows and put them in stacking mode
21 #####################################################################
22
23 $i3->command('split v')->recv;
24
25 my $top = i3test::open_standard_window($x);
26 my $bottom = i3test::open_standard_window($x);
27
28 my @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
29 is(@urgent, 0, 'no window got the urgent flag');
30
31 #$i3->command('layout stacking')->recv;
32
33 #####################################################################
34 # Add the urgency hint, switch to a different workspace and back again
35 #####################################################################
36 $top->add_hint('urgency');
37 sleep 0.5;
38
39 @content = @{get_ws_content($tmp)};
40 @urgent = grep { $_->{urgent} == 1 } @content;
41 $top_info = first { $_->{window} == $top->id } @content;
42 $bottom_info = first { $_->{window} == $bottom->id } @content;
43
44 is($top_info->{urgent}, 1, 'top window is marked urgent');
45 is($bottom_info->{urgent}, 0, 'bottom window is not marked urgent');
46 is(@urgent, 1, 'exactly one window got the urgent flag');
47
48 $i3->command('[id="' . $top->id . '"] focus')->recv;
49
50 @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
51 is(@urgent, 0, 'no window got the urgent flag after focusing');
52
53 $top->add_hint('urgency');
54 sleep 0.5;
55
56 @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
57 is(@urgent, 0, 'no window got the urgent flag after re-setting urgency hint');
58
59 #####################################################################
60 # Check if the workspace urgency hint gets set/cleared correctly
61 #####################################################################
62 my $ws = get_ws($tmp);
63 is($ws->{urgent}, 0, 'urgent flag not set on workspace');
64
65 my $otmp = get_unused_workspace();
66 $i3->command("workspace $otmp")->recv;
67
68 $top->add_hint('urgency');
69 sleep 0.5;
70
71 $ws = get_ws($tmp);
72 is($ws->{urgent}, 1, 'urgent flag set on workspace');
73
74 $i3->command("workspace $tmp")->recv;
75
76 $ws = get_ws($tmp);
77 is($ws->{urgent}, 0, 'urgent flag not set on workspace after switching');
78
79 diag( "Testing i3, Perl $], $^X" );