]> git.sur5r.net Git - i3/i3/blob - testcases/t/212-assign-urgency.t
f53eb7ef4cdde70c3a1fea4d886af0f18d6786b4
[i3/i3] / testcases / t / 212-assign-urgency.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 if the urgency hint will be set appropriately when opening a window
18 # assigned to a workspace.
19 #
20 use i3test i3_autostart => 0;
21
22 # Based on the eponymous function in t/166-assign.t
23 sub open_special {
24     my %args = @_;
25     $args{name} //= 'special window';
26
27     # We use dont_map because i3 will not map the window on the current
28     # workspace. Thus, open_window would time out in wait_for_map (2 seconds).
29     my $window = open_window(
30         %args,
31         wm_class => 'special',
32         dont_map => 1,
33     );
34     $window->map;
35     return $window;
36 }
37
38 #####################################################################
39 # start a window assigned to a non-visible workspace and see that the urgency
40 # hint is set.
41 #####################################################################
42
43 my $config = <<EOT;
44 # i3 config file (v4)
45 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
46 assign [class="special"] → targetws
47 EOT
48
49 my $pid = launch_with_config($config);
50
51 cmd 'workspace ordinaryws';
52 my $window = open_special;
53 sync_with_i3;
54
55 ok(get_ws('targetws')->{urgent}, 'target workspace is urgent');
56
57 $window->destroy;
58
59 exit_gracefully($pid);
60
61
62 #####################################################################
63 # start a window assigned to a visible workspace and see that the urgency hint
64 # is not set.
65 #####################################################################
66
67 $config = <<EOT;
68 # i3 config file (v4)
69 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
70 assign [class="special"] → targetws
71 EOT
72
73 $pid = launch_with_config($config);
74
75 cmd 'workspace targetws';
76 $window = open_special;
77 sync_with_i3;
78
79 ok(!get_ws('targetws')->{urgent}, 'visible workspace is not urgent');
80
81 $window->destroy;
82
83 exit_gracefully($pid);
84
85 #####################################################################
86 # start a window assigned to a visible workspace on a different output and see
87 # that the urgency hint is not set.
88 #####################################################################
89
90 $config = <<EOT;
91 # i3 config file (v4)
92 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
93
94 fake-outputs 1024x768+0+0,1024x768+1024+0
95 workspace targetws output fake-0
96 workspace ordinaryws output fake-1
97
98 assign [class="special"] → targetws
99 EOT
100
101 $pid = launch_with_config($config);
102
103 cmd 'workspace ordinaryws';
104 $window = open_special;
105 sync_with_i3;
106
107 ok(!get_ws('targetws')->{urgent}, 'target workspace is not urgent');
108
109 $window->destroy;
110
111 exit_gracefully($pid);
112
113 done_testing;