]> git.sur5r.net Git - i3/i3/blob - testcases/t/285-sticky.t
Reorder tests to not use the same number (#2947)
[i3/i3] / testcases / t / 285-sticky.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 sticky windows.
18 # Ticket: #1455
19 use i3test;
20
21 my ($ws, $tmp, $focused);
22
23 ###############################################################################
24 # 1: Given a sticky tiling container, when the workspace is switched, then
25 #    nothing happens.
26 ###############################################################################
27 fresh_workspace;
28 open_window(wm_class => 'findme');
29 cmd 'sticky enable';
30 $ws = fresh_workspace;
31
32 is(@{get_ws($ws)->{nodes}}, 0, 'tiling sticky container did not move');
33 is(@{get_ws($ws)->{floating_nodes}}, 0, 'tiling sticky container did not move');
34 cmd '[class="findme"] kill';
35
36 ###############################################################################
37 # 2: Given a sticky floating container, when the workspace is switched, then
38 #    the container moves to the new workspace.
39 ###############################################################################
40 $ws = fresh_workspace;
41 open_floating_window(wm_class => 'findme');
42 $focused = get_focused($ws);
43 cmd 'sticky enable';
44 $ws = fresh_workspace;
45
46 is(@{get_ws($ws)->{floating_nodes}}, 1, 'floating sticky container moved to new workspace');
47 is(get_focused($ws), $focused, 'sticky container has focus');
48 cmd '[class="findme"] kill';
49
50 ###############################################################################
51 # 3: Given two sticky floating containers, when the workspace is switched,
52 #    then both containers move to the new workspace.
53 ###############################################################################
54 fresh_workspace;
55 open_floating_window(wm_class => 'findme');
56 cmd 'sticky enable';
57 open_floating_window(wm_class => 'findme');
58 cmd 'sticky enable';
59 $ws = fresh_workspace;
60
61 is(@{get_ws($ws)->{floating_nodes}}, 2, 'multiple sticky windows can be used at the same time');
62 cmd '[class="findme"] kill';
63
64 ###############################################################################
65 # 4: Given an unfocused sticky floating container and a tiling container on the
66 #    target workspace, when the workspace is switched, then the tiling container
67 #    is focused.
68 ###############################################################################
69 $ws = fresh_workspace;
70 open_window;
71 $focused = get_focused($ws);
72 fresh_workspace;
73 open_floating_window(wm_class => 'findme');
74 cmd 'sticky enable';
75 open_window;
76 cmd 'workspace ' . $ws;
77
78 is(get_focused($ws), $focused, 'the tiling container has focus');
79 cmd '[class="findme"] kill';
80
81 ###############################################################################
82 # 5: Given a focused sticky floating container and a tiling container on the
83 #    target workspace, when the workspace is switched, then the tiling container
84 #    is focused.
85 ###############################################################################
86 $ws = fresh_workspace;
87 open_window;
88 $tmp = fresh_workspace;
89 open_floating_window(wm_class => 'findme');
90 $focused = get_focused($tmp);
91 cmd 'sticky enable';
92 cmd 'workspace ' . $ws;
93
94 is(get_focused($ws), $focused, 'the sticky container has focus');
95 cmd '[class="findme"] kill';
96
97 ###############################################################################
98 # 6: Given a floating container on a non-visible workspace, when the window
99 #    is made sticky, then the window immediately jumps to the currently
100 #    visible workspace.
101 ###############################################################################
102 fresh_workspace;
103 open_floating_window(wm_class => 'findme');
104 cmd 'mark sticky';
105 $ws = fresh_workspace;
106 cmd '[con_mark=sticky] sticky enable';
107
108 is(@{get_ws($ws)->{floating_nodes}}, 1, 'the sticky window jumps to the front');
109 cmd '[class="findme"] kill';
110
111 ###############################################################################
112
113 done_testing;