]> git.sur5r.net Git - i3/i3/blob - testcases/t/503-workspace.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 503-workspace.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_on_output' and the like work correctly.
18 #
19 use List::Util qw(first);
20 use i3test i3_autostart => 0;
21
22 my $config = <<EOT;
23 # i3 config file (v4)
24 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
25
26 fake-outputs 1024x768+0+0,1024x768+1024+0
27 EOT
28 my $pid = launch_with_config($config);
29
30 ################################################################################
31 # Setup workspaces so that they stay open (with an empty container).
32 ################################################################################
33
34 sync_with_i3;
35 $x->root->warp_pointer(0, 0);
36 sync_with_i3;
37
38 is(focused_ws, '1', 'starting on workspace 1');
39 # ensure workspace 1 stays open
40 open_window;
41
42 cmd 'focus output right';
43 is(focused_ws, '2', 'workspace 2 on second output');
44 # ensure workspace 2 stays open
45 open_window;
46
47 cmd 'focus output right';
48 is(focused_ws, '1', 'back on workspace 1');
49
50 # We don’t use fresh_workspace with named workspaces here since they come last
51 # when using 'workspace next'.
52 cmd 'workspace 5';
53 # ensure workspace 5 stays open
54 open_window;
55
56 ################################################################################
57 # Use workspace next and verify the correct order.
58 ################################################################################
59
60 # The current order should be:
61 # output 1: 1, 5
62 # output 2: 2
63 cmd 'workspace 1';
64 cmd 'workspace next';
65 # We need to sync after changing focus to a different output to wait for the
66 # EnterNotify to be processed, otherwise it will be processed at some point
67 # later in time and mess up our subsequent tests.
68 sync_with_i3;
69
70 is(focused_ws, '2', 'workspace 2 focused');
71 cmd 'workspace next';
72 # We need to sync after changing focus to a different output to wait for the
73 # EnterNotify to be processed, otherwise it will be processed at some point
74 # later in time and mess up our subsequent tests.
75 sync_with_i3;
76
77 is(focused_ws, '5', 'workspace 5 focused');
78
79 ################################################################################
80 # Now try the same with workspace next_on_output.
81 ################################################################################
82
83 cmd 'workspace 1';
84 cmd 'workspace next_on_output';
85 is(focused_ws, '5', 'workspace 5 focused');
86 cmd 'workspace next_on_output';
87 is(focused_ws, '1', 'workspace 1 focused');
88
89 cmd 'workspace prev_on_output';
90 is(focused_ws, '5', 'workspace 5 focused');
91 cmd 'workspace prev_on_output';
92 is(focused_ws, '1', 'workspace 1 focused');
93
94 cmd 'workspace 2';
95 # We need to sync after changing focus to a different output to wait for the
96 # EnterNotify to be processed, otherwise it will be processed at some point
97 # later in time and mess up our subsequent tests.
98 sync_with_i3;
99
100 cmd 'workspace prev_on_output';
101 is(focused_ws, '2', 'workspace 2 focused');
102
103 exit_gracefully($pid);
104
105 done_testing;