]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/205-ipc-windows.t
Merge pull request #2953 from CyberShadow/focus_wrapping
[i3/i3] / testcases / t / 205-ipc-windows.t
index e3b7196cc322214ecf12dc1b317cdc2a5bb8e32a..ca7db1533493416550d1f984f626f8cc796fc406 100644 (file)
@@ -2,13 +2,13 @@
 # vim:ts=4:sw=4:expandtab
 #
 # Please read the following documents before working on tests:
-# • http://build.i3wm.org/docs/testsuite.html
+# • https://build.i3wm.org/docs/testsuite.html
 #   (or docs/testsuite)
 #
-# • http://build.i3wm.org/docs/lib-i3test.html
+# • https://build.i3wm.org/docs/lib-i3test.html
 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
 #
-# • http://build.i3wm.org/docs/ipc.html
+# • https://build.i3wm.org/docs/ipc.html
 #   (or docs/ipc)
 #
 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
 
 use i3test;
 
+SKIP: {
+
+    skip "AnyEvent::I3 too old (need >= 0.15)", 1 if $AnyEvent::I3::VERSION < 0.15;
+
 my $i3 = i3(get_socket_path());
 $i3->connect()->recv;
 
@@ -26,18 +30,32 @@ $i3->connect()->recv;
 # Events
 
 my $new = AnyEvent->condvar;
+my $focus = AnyEvent->condvar;
 $i3->subscribe({
     window => sub {
         my ($event) = @_;
-        $new->send($event->{change} eq 'new');
+        if ($event->{change} eq 'new') {
+            $new->send($event);
+        } elsif ($event->{change} eq 'focus') {
+            $focus->send($event);
+        }
     }
 })->recv;
 
 open_window;
 
 my $t;
-$t = AnyEvent->timer(after => 0.5, cb => sub { $new->send(0); });
+$t = AnyEvent->timer(
+    after => 0.5,
+    cb => sub {
+        $new->send(0);
+        $focus->send(0);
+    }
+);
+
+is($new->recv->{container}->{focused}, 0, 'Window "new" event received');
+is($focus->recv->{container}->{focused}, 1, 'Window "focus" event received');
 
-ok($new->recv, 'Window "new" event received');
+}
 
 done_testing;