]> git.sur5r.net Git - i3/i3/blob - testcases/t/232-cmd-move-criteria.t
Added testcase for 'window_type' criterion when used as a command.
[i3/i3] / testcases / t / 232-cmd-move-criteria.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 # Test that the `move [direction]` command works with criteria
18 # Bug still in: 4.8-16-g6888a1f
19 use i3test;
20
21 ###############################################################################
22 # Tets moving with 'id' criterion.
23 ###############################################################################
24
25 my $ws = fresh_workspace;
26
27 my $win1 = open_window;
28 my $win2 = open_window;
29 my $win3 = open_window;
30
31 # move win1 from the left to the right
32 cmd '[id="' . $win1->{id} . '"] move right';
33
34 # now they should be switched, with win2 still being focused
35 my $ws_con = get_ws($ws);
36
37 # win2 should be on the left
38 is($ws_con->{nodes}[0]->{window}, $win2->{id}, 'the `move [direction]` command should work with criteria');
39 is($x->input_focus, $win3->{id}, 'it should not disturb focus');
40
41 ###############################################################################
42 # Tets moving with 'window_type' criterion.
43 ###############################################################################
44
45 # test all window types
46 my %window_types = ( 
47     'normal'        => '_NET_WM_WINDOW_TYPE_NORMAL',
48     'dialog'        => '_NET_WM_WINDOW_TYPE_DIALOG',
49     'utility'       => '_NET_WM_WINDOW_TYPE_UTILITY',
50     'toolbar'       => '_NET_WM_WINDOW_TYPE_TOOLBAR',
51     'splash'        => '_NET_WM_WINDOW_TYPE_SPLASH',
52     'menu'          => '_NET_WM_WINDOW_TYPE_MENU',
53     'dropdown_menu' => '_NET_WM_WINDOW_TYPE_DROPDOWN_MENU',
54     'popup_menu'    => '_NET_WM_WINDOW_TYPE_POPUP_MENU',
55     'tooltip'       => '_NET_WM_WINDOW_TYPE_TOOLTIP'
56 );
57
58 while (my ($window_type, $atom) = each %window_types) {
59
60     $ws = fresh_workspace;
61
62     $win1 = open_window(window_type => $x->atom(name => $atom));
63     $win2 = open_window;
64     $win3 = open_window;
65
66     cmd '[window_type="' . $window_type . '"] move right';
67
68     $ws_con = get_ws($ws);
69     is($ws_con->{nodes}[0]->{window}, $win2->{id}, 'the `move [direction]` command should work with window_type = ' . $window_type);
70     is($x->input_focus, $win3->{id}, 'it should not disturb focus');
71
72 }
73
74 ###############################################################################
75
76 done_testing;