]> git.sur5r.net Git - i3/i3/blob - testcases/t/528-workspace-next-prev-reversed.t
tests: use i3_config arg instead of precisely one launch_with_config
[i3/i3] / testcases / t / 528-workspace-next-prev-reversed.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 whether 'workspace next' works correctly.
18 #
19 use List::Util qw(first);
20 use i3test i3_config => <<EOT;
21 # i3 config file (v4)
22 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
23
24 fake-outputs 1024x768+0+0,1024x768+1024+0
25 EOT
26
27 sub assert_next {
28     my ($expected) = @_;
29
30     cmd 'workspace next';
31     # We need to sync after changing focus to a different output to wait for the
32     # EnterNotify to be processed, otherwise it will be processed at some point
33     # later in time and mess up our subsequent tests.
34     sync_with_i3;
35
36     is(focused_ws, $expected, "workspace $expected focused");
37 }
38
39 sub assert_prev {
40     my ($expected) = @_;
41
42     cmd 'workspace prev';
43     # We need to sync after changing focus to a different output to wait for the
44     # EnterNotify to be processed, otherwise it will be processed at some point
45     # later in time and mess up our subsequent tests.
46     sync_with_i3;
47
48     is(focused_ws, $expected, "workspace $expected focused");
49 }
50
51 sync_with_i3;
52 $x->root->warp_pointer(0, 0);
53 sync_with_i3;
54
55 ################################################################################
56 # Setup workspaces so that they stay open (with an empty container).
57 # open_window ensures, this
58 #
59 #                   numbered       named
60 # output 1 (left) : 1, 2, 3, 6, 7, B, F, C
61 # output 2 (right): 4, 5,          A, D, E
62 #
63 ################################################################################
64
65 cmd 'focus output left';
66 cmd 'workspace A'; open_window;
67 cmd 'workspace D'; open_window;
68 cmd 'workspace 4'; open_window;
69 cmd 'workspace 5'; open_window;
70 cmd 'workspace E'; open_window;
71
72 cmd 'focus output right';
73 cmd 'workspace 1'; open_window;
74 cmd 'workspace 2'; open_window;
75 cmd 'workspace B'; open_window;
76 cmd 'workspace 3'; open_window;
77 cmd 'workspace F'; open_window;
78 cmd 'workspace 6'; open_window;
79 cmd 'workspace C'; open_window;
80 cmd 'workspace 7'; open_window;
81
82 ################################################################################
83 # Use workspace next and verify the correct order.
84 # numbered -> numerical sort
85 # named -> sort by creation time
86 ################################################################################
87 cmd 'workspace 1';
88 is(focused_ws, '1', 'back on workspace 1');
89
90 assert_next('2');
91 assert_next('3');
92 assert_next('4');
93 assert_next('5');
94 assert_next('6');
95 assert_next('7');
96
97 assert_next('B');
98 assert_next('F');
99 assert_next('C');
100 assert_next('A');
101 assert_next('D');
102 assert_next('E');
103 assert_next('1');
104
105 cmd 'workspace 1';
106 is(focused_ws, '1', 'back on workspace 1');
107
108 assert_prev('E');
109 assert_prev('D');
110 assert_prev('A');
111 assert_prev('C');
112 assert_prev('F');
113 assert_prev('B');
114
115 assert_prev('7');
116 assert_prev('6');
117 assert_prev('5');
118 assert_prev('4');
119 assert_prev('3');
120 assert_prev('2');
121 assert_prev('1');
122
123
124 done_testing;