X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=testcases%2Ft%2F276-ipc-window-move.t;h=708963dfd649997f68d77f6161ee7e839fb299c0;hb=9380a75186f8d2adcf572a3741168f12351faa9b;hp=117d27fbdceb4af2cd1782a4c3696df8d910c3b3;hpb=8cad1c1fa622db78ed47d5377045671816686e79;p=i3%2Fi3 diff --git a/testcases/t/276-ipc-window-move.t b/testcases/t/276-ipc-window-move.t index 117d27fb..708963df 100644 --- a/testcases/t/276-ipc-window-move.t +++ b/testcases/t/276-ipc-window-move.t @@ -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 @@ -19,43 +19,22 @@ # Bug still in: 4.8-7-gf4a8253 use i3test; -my $i3 = i3(get_socket_path()); -$i3->connect()->recv; - -my $cv; -my $t; - -sub reset_test { - $cv = AE::cv; - $t = AE::timer(0.5, 0, sub { $cv->send(0); }); -} - -reset_test; - -$i3->subscribe({ - window => sub { - my ($e) = @_; - if ($e->{change} eq 'move') { - $cv->send($e->{container}); - } - }, - })->recv; - my $dummy_window = open_window; my $window = open_window; -cmd 'move right'; -my $con = $cv->recv; - -ok($con, 'moving a window should emit the window::move event'); -is($con->{window}, $window->{id}, 'the event should contain info about the window'); +sub move_subtest { + my ($cmd) = @_; + my $cv = AnyEvent->condvar; + my @events = events_for( + sub { cmd $cmd }, + 'window'); -reset_test; - -cmd 'move to workspace ws_new'; -$con = $cv->recv; + my @move = grep { $_->{change} eq 'move' } @events; + is(scalar @move, 1, 'Received 1 window::move event'); + is($move[0]->{container}->{window}, $window->{id}, 'window id matches'); +} -ok($con, 'moving a window to a different workspace should emit the window::move event'); -is($con->{window}, $window->{id}, 'the event should contain info about the window'); +subtest 'move left', \&move_subtest, 'move left'; +subtest 'move to workspace', \&move_subtest, 'move to workspace ws_new'; done_testing;