]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/05-ipc.t
Merge branch 'tree' into next
[i3/i3] / testcases / t / 05-ipc.t
index b34ba4f2d4d62d7886ea8bb33e7876704dbb29ae..a910c930b19a87e377e1ffa2c57b05ff4de43231 100644 (file)
@@ -1,51 +1,34 @@
 #!perl
 # vim:ts=4:sw=4:expandtab
 
-use Test::More tests => 4;
-use Test::Deep;
-use X11::XCB qw(:all);
-use Data::Dumper;
-use Time::HiRes qw(sleep);
-use FindBin;
-use lib "$FindBin::Bin/lib";
 use i3test;
+use X11::XCB qw(:all);
 
 BEGIN {
-    use_ok('IO::Socket::UNIX') or BAIL_OUT('Cannot load IO::Socket::UNIX');
     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
 }
 
-X11::XCB::Connection->connect(':0');
-
-my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
-
-isa_ok($sock, 'IO::Socket::UNIX');
+my $x = X11::XCB::Connection->new;
 
+fresh_workspace;
 
 #####################################################################
 # Ensure IPC works by switching workspaces
 #####################################################################
 
-# Switch to the first workspace to get a clean testing environment
-$sock->write(i3test::format_ipc_command("1"));
-
-sleep(0.25);
-
 # Create a window so we can get a focus different from NULL
-my $window = i3test::open_standard_window;
+my $window = open_standard_window($x);
 diag("window->id = " . $window->id);
 
-sleep(0.25);
+sleep 0.25;
 
-my $focus = X11::XCB::Connection->input_focus;
+my $focus = $x->input_focus;
 diag("old focus = $focus");
 
-# Switch to the nineth workspace
-$sock->write(i3test::format_ipc_command("9"));
-
-sleep(0.25);
+# Switch to another workspace
+fresh_workspace;
 
-my $new_focus = X11::XCB::Connection->input_focus;
+my $new_focus = $x->input_focus;
 isnt($focus, $new_focus, "Focus changed");
 
-diag( "Testing i3, Perl $], $^X" );
+done_testing;