]> git.sur5r.net Git - i3/i3/blob - testcases/t/167-workspace_layout.t
Merge branch 'fix-fullscreen-enternotify'
[i3/i3] / testcases / t / 167-workspace_layout.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Tests the workspace_layout config option.
6 #
7
8 use i3test;
9 use X11::XCB qw(:all);
10 use X11::XCB::Connection;
11
12 my $x = X11::XCB::Connection->new;
13
14 #####################################################################
15 # 1: check that with an empty config, cons are place next to each
16 # other and no split containers are created
17 #####################################################################
18
19 my $config = <<EOT;
20 # i3 config file (v4)
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22 EOT
23
24 my $pid = launch_with_config($config);
25
26 my $tmp = fresh_workspace;
27
28 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
29
30 my $first = open_window($x);
31 my $second = open_window($x);
32
33 sync_with_i3($x);
34
35 is($x->input_focus, $second->id, 'second window focused');
36 ok(@{get_ws_content($tmp)} == 2, 'two containers opened');
37 isnt($content[0]->{layout}, 'stacked', 'layout not stacked');
38 isnt($content[1]->{layout}, 'stacked', 'layout not stacked');
39
40 exit_gracefully($pid);
41
42 #####################################################################
43 # 2: set workspace_layout stacked, check that when opening two cons,
44 # they end up in a stacked con
45 #####################################################################
46
47 $config = <<EOT;
48 # i3 config file (v4)
49 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
50 workspace_layout stacked
51 EOT
52
53 $pid = launch_with_config($config);
54
55 $tmp = fresh_workspace;
56
57 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
58
59 $first = open_window($x);
60 $second = open_window($x);
61
62 sync_with_i3($x);
63
64 is($x->input_focus, $second->id, 'second window focused');
65 my @content = @{get_ws_content($tmp)};
66 ok(@content == 1, 'one con at workspace level');
67 is($content[0]->{layout}, 'stacked', 'layout stacked');
68
69 #####################################################################
70 # 3: focus parent, open two new cons, check that they end up in a stacked
71 # con
72 #####################################################################
73
74 cmd 'focus parent';
75 my $right_top = open_window($x);
76 my $right_bot = open_window($x);
77
78 @content = @{get_ws_content($tmp)};
79 is(@content, 2, 'two cons at workspace level after focus parent');
80 is($content[0]->{layout}, 'stacked', 'layout stacked');
81 is($content[1]->{layout}, 'stacked', 'layout stacked');
82
83 #####################################################################
84 # 4: move one of the cons to the right, check that it will end up in
85 # a stacked con
86 #####################################################################
87
88 cmd 'move right';
89
90 @content = @{get_ws_content($tmp)};
91 is(@content, 3, 'three cons at workspace level after move');
92 is($content[0]->{layout}, 'stacked', 'layout stacked');
93 is($content[1]->{layout}, 'stacked', 'layout stacked');
94 is($content[2]->{layout}, 'stacked', 'layout stacked');
95
96 #####################################################################
97 # 5: move it to the left again, check that the stacked con is deleted
98 #####################################################################
99
100 cmd 'move left';
101
102 @content = @{get_ws_content($tmp)};
103 is(@content, 2, 'two cons at workspace level after moving back');
104 is($content[0]->{layout}, 'stacked', 'layout stacked');
105 is($content[1]->{layout}, 'stacked', 'layout stacked');
106
107 #####################################################################
108 # 6: move it to a different workspace, check that it ends up in a
109 # stacked con
110 #####################################################################
111
112 my $otmp = get_unused_workspace;
113
114 cmd "move workspace $otmp";
115
116 @content = @{get_ws_content($tmp)};
117 is(@content, 2, 'still two cons on this workspace');
118 is($content[0]->{layout}, 'stacked', 'layout stacked');
119 is($content[1]->{layout}, 'stacked', 'layout stacked');
120
121 @content = @{get_ws_content($otmp)};
122 is(@content, 1, 'one con on target workspace');
123 is($content[0]->{layout}, 'stacked', 'layout stacked');
124
125 exit_gracefully($pid);
126
127 done_testing;