]> git.sur5r.net Git - i3/i3/blob - testcases/t/73-get-marks.t
Merge branch 'master' into next
[i3/i3] / testcases / t / 73-get-marks.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # checks if the IPC message type get_marks works correctly
5 #
6 use i3test;
7
8 # TODO: this will be available in AnyEvent::I3 soon
9 sub get_marks {
10     my $i3 = i3(get_socket_path());
11     $i3->connect->recv;
12     my $cv = AnyEvent->condvar;
13     my $msg = $i3->message(5);
14     my $t;
15     $msg->cb(sub {
16         my ($_cv) = @_;
17         $cv->send($_cv->recv);
18     });
19     $t = AnyEvent->timer(after => 2, cb => sub {
20         $cv->croak('timeout while waiting for the marks');
21     });
22     return $cv->recv;
23 }
24
25 ##############################################################
26 # 1: check that get_marks returns no marks yet
27 ##############################################################
28
29 my $tmp = fresh_workspace;
30
31 my $marks = get_marks();
32 cmp_deeply($marks, [], 'no marks set so far');
33
34 ##############################################################
35 # 2: check that setting a mark is reflected in the get_marks reply
36 ##############################################################
37
38 cmd 'open';
39 cmd 'mark foo';
40
41 cmp_deeply(get_marks(), [ 'foo' ], 'mark foo set');
42
43 ##############################################################
44 # 3: check that the mark is gone after killing the container
45 ##############################################################
46
47 cmd 'kill';
48
49 cmp_deeply(get_marks(), [ ], 'mark gone');
50
51 ##############################################################
52 # 4: check that duplicate marks are included twice in the get_marks reply
53 ##############################################################
54
55 cmd 'open';
56 cmd 'mark bar';
57
58 cmd 'open';
59 cmd 'mark bar';
60
61 cmp_deeply(get_marks(), [ 'bar', 'bar' ], 'duplicate mark found twice');
62
63 done_testing;