]> git.sur5r.net Git - i3/i3/blob - testcases/t/528-workspace-next-prev.t
Revise workspace next/prev
[i3/i3] / testcases / t / 528-workspace-next-prev.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
35 my $config = <<EOT;
36 # i3 config file (v4)
37 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
38
39 fake-outputs 1024x768+0+0,1024x768+1024+0
40 EOT
41 my $pid = launch_with_config($config);
42
43 ################################################################################
44 # Setup workspaces so that they stay open (with an empty container).
45 # Have only named workspaces in the 1st output and numbered + named workspaces
46 # in the 2nd output.
47 ################################################################################
48
49 sync_with_i3;
50 $x->root->warp_pointer(0, 0);
51 sync_with_i3;
52
53 cmd 'workspace A';
54 # ensure workspace A stays open
55 open_window;
56
57 cmd 'workspace B';
58 # ensure workspace B stays open
59 open_window;
60
61 cmd 'workspace D';
62 # ensure workspace D stays open
63 open_window;
64
65 cmd 'workspace E';
66 # ensure workspace E stays open
67 open_window;
68
69 cmd 'focus output right';
70
71 cmd 'workspace 1';
72 # ensure workspace 1 stays open
73 open_window;
74
75 cmd 'workspace 2';
76 # ensure workspace 2 stays open
77 open_window;
78
79 cmd 'workspace 3';
80 # ensure workspace 3 stays open
81 open_window;
82
83 cmd 'workspace 4';
84 # ensure workspace 4 stays open
85 open_window;
86
87 cmd 'workspace 5';
88 # ensure workspace 5 stays open
89 open_window;
90
91 cmd 'workspace C';
92 # ensure workspace C stays open
93 open_window;
94
95 cmd 'workspace F';
96 # ensure workspace F stays open
97 open_window;
98
99 cmd 'focus output right';
100
101 ################################################################################
102 # Use workspace next and verify the correct order.
103 ################################################################################
104
105 # The current order should be:
106 # output 1: A, B, D, E
107 # output 2: 1, 2, 3, 4, 5, C, F
108
109 cmd 'workspace A';
110 is(focused_ws, 'A', 'back on workspace A');
111
112 assert_next('B');
113 assert_next('D');
114 assert_next('E');
115 assert_next('C');
116 assert_next('F');
117 assert_next('1');
118 assert_next('2');
119 assert_next('3');
120 assert_next('4');
121 assert_next('5');
122 assert_next('A');
123 assert_next('B');
124
125 exit_gracefully($pid);
126
127 done_testing;