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